http://www.elegantthemes.com/blog/tips-tricks/how-to-create-a-wordpress-plugin

https://www.airpair.com/wordpress/posts/developing-wordpress-plugin-from-scratch

http://corpocrat.com/2009/12/27/tutorial-how-to-write-a-wordpress-plugin/

1.Plugin Directory Structure:

Your Plugin:
● /wp-content/plugins/my-plugin
Inside “my-plugin”
readme.txt
● screenshot-1.png
● my-plugin.php
Always put it in a directory!
Uses 'dashes' and not 'underscores'

2.my-plugin.php having four parts

● Plugin Header
● Hooks
● PHP Code
● Template Code

3. Plugin header example, always on top withyour own detail

<?php
/*
	Plugin Name: Health Check
	Plugin URI: http://wordpress.org/extend/plugins/health-check/
	Description: Checks the health of your WordPress install
	Author: The Health Check Team
	Version: 0.1-alpha
	Author URI: http://wordpress.org/extend/plugins/health-check/
	Text Domain: health-check
	Domain Path: /lang
 */

4. Activate and deactivate function

register_activation_hook(__FILE__, 'do_active');
register_deactivation_hook(__FILE__, 'do_deactive');

function do_active(){
//do something
}

function do_deactive(){
//do something
}

5. Actions and Filters (2 Kinds of WordPress Hooks)

<?php add_filter( $tag, $function_to_add, $priority, $accepted_args ); ?>

<?php add_action( $tag, $function_to_add, $priority, $accepted_args ); ?>

● Action and Filter Reference
http://codex.wordpress.org/Plugin_API/Action_Reference
http://codex.wordpress.org/Plugin_API/Filter_Reference

Advertisements