Start a hosting plan from $3.92/mo and get a free year on Tuts+ (normally $180)
This is the second part of step-by-step tutorial on plugin development. As you may remember, in previous part we have discussed the concept of the plugin and defined the plan of development process. I you have not read the first part of tutorial, I recommending reading that article prior to moving forward with this tutorial.
In this part, we are going to prepare our workspace to make it as easy as easy as possible to continue working on our plugin.
We’ll define what we need for work and create the structure of the plugin according to its functionality. In the end you will see your plugin activated in Dashboard. So, let’s start.
The first thing we require for plugin development is, of course, a WordPress installation. For this tutorial, I use clear fresh installation of WordPress 3.8.1 which is the latest version at the moment of tutorial writing.
So, for plugin development you need two things:
- Latest WordPress installation
- Favorite code editor
It is important to pay enough attention to plugin name. The plugin name should describe what plugin does and it must be unique. Since our plugin is based on the Owl Carousel, let's name it Owl Carousel for WordPress. To give plugin name uniqueness we will also be adding a prefix to our functions: WPT.
In some ways, this leads up to having the WPT Owl Carousel for WordPress. As we develop the WordPress plugin, there is no need to say ‘for WordPress’. So, at last, the plugin name is WPT Owl Carousel which is unique and descriptive at the same time.
Much simpler, right?
The next step is to give plugin file the right name. It must be derived from the plugin name. In our case, it is
wpt-owl-carousel. As our plugin will include several files, we have to create plugin folder and place all plugin files under it.
To do this, navigate to the WordPress plugins folder which is
/wp-content/plugins/. Here create folder
wpt-owl-carousel. This will be the folder of our plugin.
In the plugin folder, create file
wpt-owl-carousel.php – this is the main file of the plugin. WordPress will look into this file for the plugin information. This information must be stored in plugin header.
To add this information copy paste the following code into your
wpt-owl-carousel.php at the very beginning of the file.
<?php /** * Plugin Name: WPT Owl Carousel * Plugin URI: * Description: Add Owl Carousel to your posts and pages. * Version: 0.1 * Author: oksamyta * Author URI: * License: GPL2 */ ?>
Each line of this code is quite self-explanatory but let’s make sure everything is clear.
Plugin Name– user-friendly plugin name which will be shown in the list of plugins on WordPress plugins page.
Plugin URI– link to plugin homepage. Leave blank if your plugin doesn’t have a page on the web
Description– short description of plugin functionality. It is aso shown on plugins page.
Version– plugin version in format like 1.0
Author– plugin author name
Author URI– link to plugin author page or website
License– A ‘slug' of license under which plugin is distributed.
wpt-owl-carousel.php and navigate to the WodPress plugins page. There, you should see WPT Owl Carousel in the plugins list. Activate it and we are ready for the next part of this series.
You can download source code from GitHub.
In this part of step-by-step series about plugin development, we have prepared workspace for plugin development and we have created the simplest plugin and activated it in the dashboard.
Now we are ready for the next part of the series which will be about Settings page.