A plug-in is a software module that, when connected to the main program, serves to expand or use existing capabilities. For the WordPress platform, you can download the necessary modules on the Internet, or you can create it yourself.
It is necessary
- - a computer;
- - Internet connection;
- - text editor with the ability to save text in UTF-8 encoding.
Instructions
Step 1
Determine what functions the plugin should perform. You also need to choose a unique name for it. You can check for WordPress plugin names using the Google search engine. Often the name of a plugin is directly related to its purpose.
Step 2
Then create the main PHP plugin file. It is desirable that its name be consonant with the name of the add-on module and also be unique. Plugin code can be split into multiple PHP files. It can also include JavaScript, CSS files, images, etc. When splitting your plugin code, you will need to create a directory with the same name as the main PHP file, and then place all files there.
Step 3
Open the main plugin module file and create a standard header so that the WordPress platform can recognize the new plugin. For example: If you go to the administration panel and click on the "Plugins" item, you will see the created plugin in the general list.
Step 4
After the title, fill in the plugin license information. Mostly a GRL or a compatible license is used.
Step 5
A system of hooks is used to interact between the components of the plugin system and the WordPress core. Its essence lies in the fact that the kernel functions, before returning the result, call a chain of additional handlers, if they are currently registered. So, before adding a title to a post, WordPress checks for handlers for the hook named the_title. Add the necessary hooks to the plugin and register them by calling add_filter.
Step 6
To add functionality using plugins, you need to create template tags. To declare a template tag, write a PHP function and document it for plugin users.
Step 7
After the plugin is written, it is advisable to prepare it for internationalization, i.e. implement the ability to translate the displayed text into different languages. To do this, choose a name for the plugin translation space. It should be as unique as the name of the plugin itself. Wrap all lines of text that will be shown to the reader in one of two WordPress gettext functions: _ () or _e (). Create a POT (translation directory) file and distribute it along with the plugin. To load the translation, use the load_plugin_textdomain function.
Step 8
Create a web page describing how to install your plugin, what functions it will perform, and which versions of WordPress it is compatible with.