There’s always a learning curve and margin of discomfort when learning something that you really want to do for the first time. So, hopefully I can simplify and jump start the whole process for you with a really easy, super simple way to get started building your very own WordPress plugin.
There are only 2 files needed to start your first plugin, a PHP file and a “readme” text file. Let’s jump right in:
PHP File
whatever.php
<?php
/*
Plugin Name: Whatever
Version: 1.0
Plugin URI: http://www.website.com/whatever-plugin/
Description: Adds blah blah blah functionality to blah blah blah.
Author: John Doe
Author URI: http://www.website.com/This code is completely free and open source.
*/function whatever() {
echo "<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>";
}add_action('wp_head','whatever',1,1);
?>
What this happens to be doing is inserting jQuery into the <head> ... </head> section of WordPress. You can of course switch out the echo to whatever you’d like and the part that is specifying that it should be inserted into the header is: wp_head which is a WordPress hook. So, depending on where you want to insert code for your plugin, see the WordPress hook master lists.
“readme” Text File
readme.txt
=== Plugin Name ===Contributors: yourwordpressusername
Donate link: https://www.paypal.com/your-button-link
Tags: add, code, function, seo, whatever
Requires at least: 1.2
Tested up to: 3.0
Stable tag: 1.2Adds blah blah blah functionality to blah blah blah.
== Description ==
Adds blah blah blah functionality to blah blah blah.
== Installation ==
**Automatic**
* From your WordPress Admin, navigate to: **Plugins** > **Add New**
* Search for: **Plugin Name**
* Install it
* Activate it**Manual**
* Unzip
* Upload to plugins folder
* Activate== Frequently Asked Questions ==
**Does something blah blah blah?**
No. You can blah blah blah.**Does something blah blah blah?**
No. You can blah blah blah.== Screenshots ==
`http://www.website.com/images/screenshot.png`
== Changelog ==
- 1.1 something changed
- 1.2 something changed again
== Upgrade Notice ==
1.2 needs something to something or another
This file creates the download/instruction pages for your plugin on wordpress.org. Most style is done with *.
* Whatever – creates a list item
*Whatever* – makes it italic
**Whatever** – makes it bold
See full documentation on the WordPress example readme file. You can validate your file here.
Prepare and Test Your Plugin
You’ll of course want to setup the latest WordPress for testing. You may have to do a little research/testing to see the earliest version of WordPress your plugin works on. Once you’ve thoroughly tested the plugin and are convinced it’s ready to share…
Add Your Plugin
http://wordpress.org/extend/plugins/add/ – Once it’s been approved you’ll need to learn how to actually upload your files for people to download. First take whatever.php and readme.txt and put them together in a folder /whatever/ then zip the folder as whatever.zip. You’ll want to upload this for people to download off your site (for this purpose you really don’t need the readme file, which is for use on wordpress.org).
Now adding your plugin to the plugin directory on wordpress.org is a little tricky, it’s not quite as simple as using an upload form or uploading via FTP. I recommend using this program: TortoiseSVN. Once you’ve downloaded and installed it, locate your /whatever/ folder and right-click on it, you’ll see TortoiseSVN in the options list, go to it and click “Create repository here”. Then, using the special login info provided from WordPress once your plugin was approved, you can now connect and upload and later update your plugin files.
You’ll upload from /trunk/ to /trunk/ by right-clicking on files and choosing “SVN Commit”. Please be patient, it takes time for things to update, appear or propagate, it’s not instantaneous. That’s about it, let me know if you have any questions. Happy learning.
Thanks, Bryan










