Trying Something New
Writing your own WordPress plugins is a lot less complicated than you may think. If you have basic PHP skills then you are more than capable of writing your own plugin. To help explain the process over the next few days I am going to take a plugin I recently wrote for Solve360 (by Norada) and explain the basics of how it was built.
Get a free WPMU DEV plugin, plus free weekly tips and resources for using WordPress.
They explain it best themselves as “A modern CRM with features to manage projects” and after using it for a while I have got to agree with them. My own opinion as a freelance developer/IT consultant standpoint is that you simply will not find a better system. I’m not going to try to sell Solve360 to you today, but I would recommend you try out the free trial. Once you start your free trial you can also test the completed version of this plugin by downloading it here:
- A working WordPress website
- A text editor or IDE (I primarily use ShiftEdit, but use SciTE when I need to edit local files)
- We will need to create a folder in the /wp-content/plugins directory. Usually the “slug” version of your name (changing it to all lower case and replacing spaces with dashes) works great, today I decided that “for WordPress” just was not necessary so I left that off. So we are left with a folder named “solve360″ and it is located in /wp-content/plugins.
- Within your newly created plugin folder you will want to create a PHP file with the same name as the folder, so create a file named solve360.php. Once created open the file in your favorite text editor or IDE.
- If there is any text in the file by default go ahead and clear it out so the file has absolutely nothing in it. All WordPress plugins have to have a header that tells WordPress what it is. While also not “required” in a sense that the plugin won’t work, but still important, you should include some licensing info too. This is my header for Solve360 for WordPress:
<?php /* Plugin Name: Solve360 for WordPress Plugin URI: http://www.garmantech.com/wordpress-plugins/solve360/ Description: Add some lead capturing powers to your WordPress site. Version: 1.1 Author: Garman Technical Services Author URI: http://www.garmantech.com/wordpress-plugins/ License: GPLv2 */ /* Copyright 2012 Garman Technical Services (email : [email protected]) 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 */
You can for the most part tell what each line means in the header, but you can always check out more detailed descriptions in the WordPress Codex. The Codex is going to be your best friend. You can find out how to use almost every WordPress function with examples here, try checking out the do_action() page as an example. As this series continues I will reference back to the Codex regularly which will give you more detail on all the functions I use.
Your homework for today:
- Check around in the Codex, get familiar with how it works.
- Skim through the WordPress PHP Coding Standards. I don’t adhere strictly to these, but when coding you want to keep close to the standards. http://codex.wordpress.org/WordPress_Coding_Standards
Check back soon for part two!