
A NOVICE GUIDE TO WORDPRESS PLUGIN DEVELOPMENT

WordPress is an overwhelming edition tool, as well as a singular of a many appropriate facilities is a coherence to customize a core functions with plugins. The simplest clarification of a plugin is:
A plugin is a dash of formula which is used to magnify a functionality of WordPress.
And a singular of a nicest things about plugins is which a separator to entrance is intensely low. It takes very small technical knowledge to have your initial plugin!
What Will We Learn In This Tutorial?
Let’s take a demeanour at a pass points of a tutorial.
- Learn pass collection required to set up a plugin growth environment
- Develop a own elementary plugin which will insert an author’s info territory in a finish of any article.
- Look at a small core plugin tools, similar to hooks as well as redeeming comments.
- Share a small good resources for plugin development.
But prior to we get started, let’s usually demeanour at a couple of reasons we competence wish to review this post.
Why rise a plugin?
Skip a Repetitive Tasks
For example, to equivocate a nuisance of inserting a couple of author’s page manually any time whilst edition a post, it would be some-more profitable if this subroutine is embedded in a plug-in which will involuntarily perform a task
Earn Money
Not everybody is a formula junky. There have been a lot of business who would cite to compensate a large volume to a small developer for office office office office building a plugin which will encounter their needs.
Get Back Links
Everyone knows which backlinks have been money of online world. If we have rise a good plugin which creates a small hum in a community, you’ll get copiousness of people joining behind to you.
For Fun!
Coding can be utterly enjoyable, generally when a finish product is a underline which we yourself have regularly wanted. And it doesn’t harm to be giving behind to a village either!
Now, onto a tutorial!
Setting up a Environment
This initial step isn’t essential, yet unequivocally endorsed as it will speed up your growth time immensely!
We’re starting to exercise WordPress on a own computer, so we don’t have to be concerned about uploading files to a webserver each time we shift something. Thankfully, this is flattering easy to do! Xampp can be used for Personal Computer as well as MAMP for Mac.
After this squeeze a duplicate of WordPress as well as exercise it on your brand new localhost server. And we can have have have have use of of of of your a a singular preferred calm editor (I’m regulating Notepad++ since of a good syntax highlighting).
Mozilla Firefox with Firebug appendage commissioned is additionally a necessity. Firebug is an overwhelming apparatus for developers; it allows modifying as well as debugging formula in genuine time.
Resources:
Now let’s disaster with a small code.
Coding The Plugin
We need to select a singular name for a plugin. If it is starting to be expelled to a public, it should not compare any plugin in a WordPress repository. we have selected a name “PBD Author Info” for a tutorial.
The initial step in formulating a plugin is to emanate a printed matter with a plugin name in a wp-content/plugins folder. In a case, it is declared PBD_Author_Info.
Now, we emanate a core record which contains standard plugin header information. The record can be declared anything we wish as prolonged as it is in a plugin’s own directory.
If a record is placed yet delay in to wp-content/plugins printed matter (i.e. You skipped out a printed matter step above!), afterwards it contingency have a singular identity. In a case, let’s have a record called “PBD_Author_Info.php” containing a following code.
1 2 3 4 5 6 7 8 9 |
<?php /* Plugin Name: PBD_Author_Info Plugin URI: http://www.problogdesign.com/tag/wordpress/ Version: 0.1 Description: A Plugin which will supplement an writer info territory at a finish of your posts. Author: Saad Hameed Bassi Author URI: http://www.crispytech.com */ |
Line 1 usually equates to which we’re starting to write a small PHP code. The superfluous formula is included in a mailing in /* */, since it’s a criticism (Not executable code). This is a standard plugin report header. WordPress would be incompetent to commend a plugin yet this info.
Now if we revisit a commissioned plugins page, WordPress is means to commend a plugin.

We can turn on a plugin right away if we like, yet of march it’s not starting to do anything since we haven’t taught it to yet! Let’s repair that.
We have been starting to conclude a duty called author_info which calls a territory land writer info.
1 2 3 |
function author_info() { ?> |
Now we will supplement a small unchanging aged HTML as well as WordPress template tags to set up a writer info section.
1 2 3 4 5 |
<div class="author_info"> <?php if (function_exists('get_avatar')) { echo get_avatar(get_the_author_email(), '65' ); }?> This post was created by <?php the_author_posts_link(); ?>.<br /> <?php the_author_meta('description'); ?> </div> |
The functionality has been characterized regulating WordPress template tags. The 3 template tags we used here are:
get_the_author_email()grabs a writer email from his form page.the_author_posts_link()shows author’s open name with a couple to all a posts published by a author.the_author_meta('description')is used to lift out a author’s bio from his form page.
Lastly, let’s tighten up a function>
1 |
<?php } ?> |
On tip of that, we’re starting to supplement in a small CSS styles to carry out a coming of a HTML. We’ll need to have have have have use of of of of a PHP “echo” authority to discuss it a plugin to write a CSS to a webpage.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php function stylesheet() { echo " <style> .avatar { float:left;background-color: #9A9B9B;padding: 4px;margin: 0 4px 0 0;display: inline; } .author_info { color: #666;background: #DDDDDD;padding: 8px;margin:0 0 6px 0; } </style> "; } |
Now we will conclude a categorical duty called display_author_info. This duty is a a singular which is installed when a plugin record is loaded, as well as we’re starting to bucket a 2 functions we’ve usually created from this one.
1 2 3 4 5 |
function display_author_info() { if (is_single() ) return author_info().stylesheet(); } |
is_single simply conveys to WordPress to govern a duty usually when it is display a singular post. is_single is a singular of a core WordPress redeeming tags, there have been a array of others we can have have have have use of of of of in your plugins.
At a moment, we can exam a outlay of plugin by adding a following formula to a single.php record after a content:
1 |
<?php if (function_exists(display_author_info)) echo display_author_info; ?> |
The on top of formula simply calls a plugin function.
The plugin is roughly ready, yet we could have it some-more user accessible by automatically adding a plugin code for users, so they don’t have to revise their thesis files at all.
WordPress hooks yield a approach of we do this. Hooks yield a approach of revelation WordPress to automatically bucket a plugin at a sure indicate whilst it is office office office office building a rest of a webpage.
There have been dual sorts of Hooks. According to a WordPress Codex:
Actions have been a hooks which a WordPress core launches at specific points during execution, or when specific events occur. Your plugin can mention which a singular or some-more of a PHP functions have been executed at these points, regulating a Action API.
And a clarification of Filters according to WordPress codex is
Filters have been a hooks which WordPress launches to cgange calm of assorted sorts prior to adding it to a database or promulgation it to a browser screen. Your plugin can mention which a singular or some-more of a PHP functions is executed to cgange specific sorts of calm at these times, regulating a Filter API.
We will have have have have use of of of of a filter hook called comments_template to offshoot a comments on a singular post. This filter will safeguard which WordPress launches display_author_info when it is loading comments template as well as append a writer info territory in between a post calm as well as comments.
1 2 |
add_filter('comments_template', 'display_author_info'); ?> |
Our Finished Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<?php /* Plugin Name: PBD_Author_Info Plugin URI: http://www.problogdesign.com/tag/wordpress/ Version: 0.1 Description: A Plugin which will supplement an writer info territory at a finish of your posts. Author: Saad Hameed Bassi Author URI: http://www.crispytech.com */ function author_info() { ?> <div class="author_info"> <?php if (function_exists('get_avatar')) { echo get_avatar(get_the_author_email(), '65' ); }?> This post is created by <?php the_author_posts_link(); ?><br> <?php the_author_meta('description'); ?> </div> <?php } function stylesheet() { echo " <style> .avatar { float:left;background-color: #9A9B9B;padding: 4px;margin: 0 4px 0 0;display: inline; } .author_info { color: #666;background: #DDDDDD;padding: 8px;margin:0 0 6px 0; } </style> "; } function display_author_info() { if (is_single()) return author_info().stylesheet(); } add_filter('comments_template', 'display_author_info'); ?> |
And which is a elementary plugin complete. It doesn’t do a good deal, positively not anything which we couldn’t do simply sufficient in your thesis anyway, yet hopefully we’ve demonstrated a small of a core facilities of plugin growth to you!
Resources for More Complex Plugin Development
Now which you’ve found your feet with plugins, it’s time to begin office office office office building which up knowledge. Here have been a small of a many appropriate recommendations we can give you, in 3 categories.
- Beginner
- Intermediate
- Advanced
Beginner

Writing a plugin – WordPress Codex
This idealisation apparatus for Newbies. The endless WordPress codex describes a growth procession in detail. You might find it a small dry though, as well as alternative resources which work by genuine examples might be some-more useful. The codex will regularly be an utilitarian anxiety whilst you’re coding though, nowhere else has anything similar to a volume of report a codex has on opposite WordPress functions!

Free e-Book: How to Write a WordPress Plugin
Very Useful ebook for WordPress plugin developers. This twelve partial array illustrates a routine from origination of a plugin, right by to compelling it. Well value operative by if we have a time!
Developing Plugins for WordPress (Singapore PHP User Group 2008)
A video display from Lester Chan (one of a many appropriate well known plugin devs around!) on office building a WordPress plugin.
This screencast shows we how to have a unequivocally elementary plugin which will reinstate foo with bar. A beginner’s beam from Mark Jaquith, who is a core developer for WordPress.

A Crash Course in WordPress Plugin Development
A elementary educational explaining a doing a Digg symbol as well as adding a small formatting to posts.
Intermediate
The slides from Matt Martz’ display at WordCamp NY09.You can additionally watch a video here.
This essay instructs on how to set up a widget plugin which queries a since array of blog posts scheduled for a future.

Wordpress Plugin Development Tips And Tricks
A unequivocally accessible essay for WordPress plugin developers about a small utilitarian tips as well as tricks.

Top 10 Most Common Coding Mistakes in WordPress Plugins
Ozh, a unequivocally important wordpress plugin developer writes about how to have your plugin blunder explanation from a many usual errors.
Advanced

How To Design And Style Your WordPress Plugin Admin Panel
An modernized educational on how to character your WordPress plugin settings panel.

Make your WordPress plugin speak AJAX
Some good examples of regulating Ajax in WordPress plugins by Irish WordPress Developer, Donncha O Caoimh.

A unequivocally utilitarian beam on how to exercise shortcodes in plugins.

Create a law WordPress plugin from Scratch
This educational elaborates a growth of a plugin which shows pointless products from an outmost OSCommerce database.

Create a Plugin with a Own Custom Database Table
A educational covering a origination of a plugin which has a own database table. Follow this educational if we wish to sense how to countenance a database list if your plugin is essay entries to it.
Conclusion
The beam on top of should give we a many elementary stairs to office office office office building your own plugin. It unequivocally is which easy to start!
And hopefully with all of a resources we’ve listed, you’ll be means to enhance which in to a most some-more formidable plugin someday! If we know of a good educational or plugin apparatus we’ve left out, share it with us!
See a strange post:
A Novice Guide to WordPress Plugin Development




