WordPress is a powerful platform built to be customized and extended to meet any type of functionality and design.

This article is aimed to beginner and intermediate WordPress developers, to teach them how to customize the platform without breaking any core functionality, such as the update system.


Take from betanews

How customization works?

Do you already know about hooks? Then please skip to the next section.

The platform separates these custom functionality and design into plugins and themes (respectively); which have created multiple free and paid markets around them, in which developers, like us, publish them allowing WordPress users to change and extend their sites with ease.

Customization in WordPress is possible thanks to its hooks; to keep it simple, hooks are like pins placed in the code which are triggered through out the execution of the system to either perform an action (like to call a notification) or to filter and manipulate data (like to read a post content and add html at its end).

In fact, hooks represent everything in WordPress. The platform uses them everywhere and to do everything; these are how plugins operate, they use hooks to add, extend or modify certain functionality that comes by default in the system.

WordPress allows developers to create their own hooks within their plugins and themes so they are also customizable by its users (keeping the platform’s customization philosophy).

Customization is added in a WordPress setup by using the “add_action” or “add_filter” hook functions. As explained in this article (read this before continuing if you don’t know how to code a hook call). 


Taken from SecurEdge

Common Mistakes Made by Beginners

Because of WordPress’ popularity and flexibility, many developers (and even web designers) jump to the platform to start a professional career, which is awesome; but the biggest issue here, is that many of them do it without understanding how the platform operates and how things should be correctly customize.

Many of our customers have reached us and asked us help with customization and maintenance of their existing WordPress sites, and most of the time we end up being shocked of how these were poorly and wrongly customized.

1) Directly modifying 3rd party plugins

The most common and the biggest mistake developers make is to directly modify a 3rd party plugin. This means, that in order to achieve a desired result, these developers wrongly modify directly code inside a 3rd party plugin without using provided hooks.

This causes WordPress’ update system to become useless, because this system always overrides any direct changes made to the plugin if there is a new release available. Forcing the WordPress setup to remain on a certain version, not being able to receive any new update that may provide new features or bug fixes.

In my personal opinion, this is a fatal mistake and I always get very mad when I review setups like this, because it not only shows me that the developers had not clue about how WordPress work, but also shows me the lack of professionalism and lack of respect for their clients (who will end up paying their mistakes later).

Any WordPress developer should be following the next rule:

RULE: Any modification that breaks WordPress’ update system should not be coded.

As mentioned in the section above (How customization works?), WordPress and usually all 3rd party plugins provide hooks for developers to correctly add customization without breaking anything.

Don’t modify 3rd party plugins, use hooks instead!

If developers can’t find a hook needed, they can always look for support from the 3rd party developer or ask the community. Their customer will appreciate it in the long run.

2) Adding hooks in the theme

The second mistake developers make, is to add non-design-related customizations in the theme they are developing. This is a common mistake mostly found on custom themes made to clients.

WordPress allows its users to change the appearance of the site with a click of a button; switching a theme should never break or remove non-design-related functionality.

Developers should never add functionality customization inside a theme.


Taken from Nurse.com

How to customize properly?

As mentioned above, WordPress separates functionality from design with plugins and themes, and that is exactly how customizations should be structured and coded.

If a developer wants to customize or redesign an existing theme, then he or she needs to create a child theme and add the customizations inside.

If a developer wants to customize WordPress or a plugin functionality, then he or she needs to create a custom plugin with the customization hooks inside. Adding a custom plugin will not only allow WordPress or any plugin to be updated, but will also allow the site owner to switch themes without removing functionality.

The following quick steps will help you create a small customization plugin:

Step 1: Create directory

Create the following directory inside you WordPress setup:

[root]/wp-content/plugins/wp-customizations

Step 2: Create php file

Inside the folder above, create a new php file:

[root]/wp-content/plugins/wp-customizations/hooks.php

Step 3: Paste code

Copy and paste the following code snippet inside the file create above (this will make the plugin available).

<?php
/*
Plugin Name: Customizations
Description: Customizations made using WordPress hooks.
Version: 9000
*/
// -----------------------------------------------
// CUSTOM HOOKS HERE
// -----------------------------------------------

Step 4: Activate

Go to plugins section of the WordPress dashboard and activate the customization plugin. Then add any customization hook inside. 🙂


Conclusion

I hope this article helps developers to code in WordPress properly, their customers, users and fella developers will highly appreciate it.

Do you have any comments about this article? Did we missed any other common mistake? Or do you have on suggestion on the matter?
Please share with us your thoughts below: