Developers often create WordPress plugins in order to modify core functionality or to extend it. WordPress provides a range of different functions that allows plugin developers to hook and execute code at the correct time.
I aim to cover in this tutorial the basics of setting up your WordPress plugin.
Firstly lets start by creating the bare bones of our WordPress plugin, head over to wp-content > plugins and create a folder inside named “mash-general-info”. This will act as our plugin folder and will store all of our plugin files. Now just like a theme needs a index.php file our plugin will need a main file named the same as the plugin folder, so in this case our file will be called “mash-general-info.php”.
This file includes core functionality and information regarding your plugin, WordPress requires this information for both local plugins and plugins you aim to publish on WordPress Codex. We will need to source the following information.
- Plugin Name
- Plugin URI
- Description for the plugin
- A Version Number
- Name of the Author
- Author URI
- A License (We will be using GPL2 which is the standard general public license)
<?php /** * Plugin Name: Mash General Website Information * Plugin URI: http://www.mash-webdesign.co.uk * Description: A plugin that allows clients to dynamically control business information. * Version: 1.0 * Author: Adam Collins * Author URI: http://www.mash-webdesign.co.uk * License: GPL2 */ ?>
Insert the above code into your file and upload to the server, if you now head over to “manage plugins” in the backend of WordPress you should be able to see your new plugin along with the information we added above.
Congratulations are in order!
Congratulations you have just developed your first WordPress plugin! Granted it doesn’t currently do anything, we will be looking into adding functionality in the upcoming tutorials, for now embrace the thrill of success!