There’s always a learning curve and margin of discomfort when learning something that you really want to do for the first time. Hopefully, I can simplify and jumpstart the whole process for you with a really easy way to get started building your very own WordPress plugin.
There are only two files needed to start your first plugin, a PHP file and a “readme” text file. Let’s jump right in:
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.
“readme” Text File
=== 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: 4.4 Stable tag: 1.2 Adds 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://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
The readme.txt file fills in the content for the download and instruction pages for your plugin on wordpress.org (once it goes live). Most style is done with * character.
* Whatever — creates a list item
*Whatever* — makes it italic
**Whatever** — makes it bold
Prepare and Test Your Plugin
You’ll of course want to set up the latest WordPress for testing. You may have to do a little research to see what the earliest version of WordPress is that your plugin works on. Once you’ve thoroughly tested the plugin (especially for security issues) and are convinced it’s ready to share with the public…
Add Your Plugin
First, take whatever.php and readme.txt and put them together in a folder /whatever/. Second, compress the folder into a zip file: whatever.zip. Once it’s been uploaded and approved you’ll need to learn how to actually publish and update your plugin. If you’ll want to upload this for people to download straight off of your site, a readme file is not necessary and obviously you can skip the rest as well.
Publishing your plugin to the plugin directory on wordpress.org is a little tricky. It’s not quite as simple as using an upload form (like WordPress themes) or uploading via FTP. I recommend using TortoiseSVN (for Windows) and Versions (for Mac). Once you’ve downloaded and installed it, using the WordPress login of the username you uploaded the plugin under (together, with other info provided for you in an email after your plugin is approved), you can now connect and commit your files.
You’ll commit your plugin files to the /trunk/ folder. Once everything is done, please be patient, it takes time for things to update, propagate, and for the wordpress.org cache to clear. It’s not instantaneous. That’s about it, let me know if you have any questions. Happy learning.