Semalt: WordPress Plugin Development Tips

Plugins are codes that can be installed in the WordPress and have the ability to extend and expand the functionality of a site. It allows for this functioning without the necessity of hacking the core code. It allows the addition of features that can integrate Facebook Open Graph and Hotmail tags.

Frank Abagnale, a top expert from Semalt, focuses here on a compelling practice in this regard.

Creation of a Plugin

The first step is to create a new folder in the WordPress at this link "wp-content/plugins/" followed by creating a folder in it and name it "my-facebook-tags". The name of the plugin's folder is also known as plugin's slug which should be unique and can be obtained by searching on Google.

The next step is creating a folder in the Facebook folder and naming it "my-facebook-tags.p"p". the following code should then be pasted inside the plugin's main file.

After the creation of the plugin, it is necessary to create a hook in a theme namely "wp_head()". There are two types of hooks namely actions and filters. The difference between actions and filters is that actions operate when a hook has been detected by the WordPress whereas filters modify bits of data. To complete the plugin, it is necessary to add the facebook meta tags using the hook wp_head using the following code

It is necessary to pick the right hook for use in a plot.


As earlier mentioned, filters are used to modify bits. It is, therefore, possible to change an error message that occurs when a wrong password has been entered. For instance, when a wrong password has been entered for, the error message can be removed by entering the filtered data. For example in the following case;

The filter is "login_errors". The error message is removed by entering the filtered data.

Scripts and Styles can be added by enqueueing. An example is the addition of a Google font which is a form of a stylesheet. It is illustrated below;

Assets can be loaded and stored in the plugin using enqueueing as shown below.

Creation of a page for plugin settings

There are several ways of creating a page but the most recommended one is the object-oriented approach. The first step is to create a menu where settings user interface can be placed. The "add_menu_page()" is most suitable for creating the superior menu due to the following reasons: page title, menu title, capability, menu slug, function, icon, and position. The settings should then be registered. For example, if we want to register settings for an accountant we follow the following procedure.

The next step is to create a form that will be responsible for displaying the user interface. This code shown below should be pasted inside the "my_plugin_settings_page()" field.

The following precautions should be taken

The "settings_fields()" should be used and the first parameter added as the option group. And the names used in the parameters should be used in the option names field. The "get_option()" function should be used to grab the value of a field and placed as the first parameter in the option name field. The settings form created should look like the figure shown below.

Although it is not necessary to enable translations, it can be useful at times. Translations are enabled using the following procedure. The following should be used to wrap text every time there are instances of outputting "__() function" or the "_e() function".