Writing a Plugin in WordPress

1. Writing a Plugin in WordPress

WordPress Plugins allow easy modification, customization, and improvement of a WordPress site. Instead of changing the core programming of WordPress, you can just add functionality with WordPress Plugins. Here is a basic definition of a WordPress Plugin:

It is a program, or a set of one or more functions, written in the PHP scripting language, that adds a specific set of features or services to the WordPress site, which may be seamlessly integrated with the site using access points and methods provided by the WordPress Plugin Application Program Interface (API).

The first thing to do

Search various WordPress Plugin repositories and sources to see whether someone has already created a WordPress Plugin that suits your needs.

In creating a WordPress Plugin the first task is to think about what the Plugin will be supposed to do, and decide a unique name for your Plugin. You can check out Plugins and the other repositories it refers to, to verify that your name is unique; you might also do a Google search on your proposed name. Most Plugin developers choose to use names that somehow describe what the Plugin does; for example, a fashion-related Plugin would probably have the word “fashion” in the name. The name may be multiple words.

The next step

Create a PHP file with a name obtained from your chosen Plugin name. For example, if your Plugin is called “Awesome Advertising”, you might call your PHP file awesome-advertising.php. The name should really be unique, guys, since people who install your Plugin will be putting this PHP file into the WordPress Plugins directory in their installation (usually wp-content/plugins/), so no two Plugins they are using can have the same PHP file name.

As another option

You can split your Plugin into multiple files. Your WordPress Plugin should have at least one PHP file; it can also contain JavaScript files, CSS files, image files, language files, etc. If there are multiple files, you should pick a unique name for a directory and a name of your choice (usually the same) for the main PHP file of your Plugin, such as awesome-advertising and awesome-advertising.php, respectively, put all your Plugin’s files into that directory, and tell your Plugin users to install the whole directory under wp-content/plugins/. Note that WordPress installation can be configured for wp-content/plugins/ directory to be moved, so you must use plugin_dir_path() and plugins_url() for absolute paths and URLs.

If you want to host your Plugin on https://wordpress.org/plugins/, you also should create a readme.txt file in a standard format, and include it with your Plugin.

Just note

The WordPress plugin repository takes the “Requires” and “Tested up to” versions from the readme.txt in the stable tag.

You should also create a web page to act like the home page for your WordPress Plugin. This page must describe how to install the Plugin, what it does, what versions of WordPress it is compatible with, what has changed from version to version of your Plugin, and how to use the Plugin.

In our following articles, we’ll tell you about Programming a Plugin.

Hope this one was helpful enough for you, guys!

Share this!

Post Author: Staff

Leave a Reply

Your email address will not be published. Required fields are marked *