Great plugin! Implemented within minutes and simple for end users to manage.
Client is particularly happy with the reporting features of the plugin.
BFowler for Ad King Pro

Latest Tweets

Ad King Pro has FINALLY has an update! A cleanup really with a few tweaks to a couple of features. More to come! https://t.co/Fekax5oh1Z
Your using Ad King Pro right? Your site is responsive, surely. Implement adverts so their mobile friendly! http://t.co/9ouYGcYRMJ
Invoice King Pro and Ad King Pro both receive some amazing new features that you will want to know about! http://t.co/FBgDllGJan
Follow KingProPlugins on Twitter

Start creating a WordPress plugin

So you use WordPress quite a bit and are starting to get frustrated with all of the plugins at your disposal on the plugin directory that only do half the job your wanting. This brings you to creating your own functionality for the project within the themes function file. But this is starting to get messy and the 10,000 lines of code is getting a bit full on. You think to yourself, “I wish there was a way to manage this better” and your PHP mind immediately thinks, “I’ll create multiple function files and include them in”. Nice thought, its essentially what a plugin is!

Believe it or not, plugins aren’t hard to create. You are only a few lines and some file documentation away from it anyway. And this way, if you build something unique enough, why not release it so the world can benefit from your creation!

With that in mind, I’m going to run you through how to setup a plugin.

Step 1: Create your plugin folder

Create a folder within the plugins folder. Choose a unique name for your folder as this will be the base name for your plugin. “gallery_slider” isn’t unique enough, even if you don’t have a plugin with that name. Choose something along the lines of “yourinitials_gallery_slider” or in my case for King Pro Plugins I would use “gslider_king_pro”.

Step 2: Create your plugins main file

The name of this file should be the same name as the folder is it in. So, following the case above, it would be something like “yourinitials_gallery_slider.php” or in my case it would be “gslider_king_pro.php”.

Step 3: Prepare your plugin file

You now have a blank plugin file ready to house your creation. Firstly, the file needs some header information that will be used by the wordpress system to recognise the plugin. So go ahead and enter the following:

<?php
/*
Plugin Name: Your Gallery Slider
Plugin URI: http://yoururl/to/your/plugin/page/
Description: A short description about your plugin.
Version: #
Author: Your Name
Author URI: http://yourwebsite/
License: GPL2

Copyright 2013 Your Name (email : youremail@yourwebsite)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
?>

If you save the above and refresh your plugins page in your WordPress admin, you should see something resembling the following (minus the “Settings” link | This will be covered in a future post):

Ad King Pro version 1.8.2 in plugins list

Explanation

Though most are self explanatory, for the sake of the “just in case”, let me explain a bit about what you just put into your plugin file.

  • Plugin Name
    This will be the name that will show in the plugin list for your plugin.
  • Plugin URI
    The link added here will go behind the text “Visit Plugin Site”.
  • Description
    Entering a short description here will display on this plugin page. It is suggested to be kept short as if it is too long, it will get cut off.
  • Version
    The version number of the plugin. This is really up to you how you manage this. Start with 0.1, 1, 1.0, 1.0.0, etc. For this example, the version number is irrelevant until the plugin is on the WordPress Plugin Directory when it is used for releasing updates.
    This information displays under the description.
  • Author
    This is the label of the link between the version information and the plugin URI. Technically this can be anything, not just the author name.
  • Author URI
    The link that you want behind the text you place in the Author field.
  • Copyright and legal text
    This is recommended by WordPress to be included in your plugin when submitting to the directory. If your building the plugin for your own personal use, you can safely omit this text from your file if you wish.

 

So now your have your plugin listed in the WordPress admin and you can segment your code that you would normally have in your functions.php file. Go ahead and add that code into the plugin file and you will find that it all still works as expected. Difference is now you have a plugin that you can install into another WordPress install and it will work exactly as you need to without any fuss!

Leave a Reply

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