WordPress plugin development
WordPress plugin development
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
● Hooks
● PHP Code
● Template Code
3. Plugin header example, always on top with your 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 the function
register_activation_hook(__FILE__, 'do_active');
register_deactivation_hook(__FILE__, 'do_deactive');
function do_active(){
//do something
}
//do something
}
function do_deactive(){
//do something
}
//do something
}
5. Actions and Filters (2 Kinds of WordPress Hooks)
● Action and Filter Reference
http://codex.wordpress.org/Plugin_API/Action_Reference
http://codex.wordpress.org/Plugin_API/Filter_Reference
Example:http://codex.wordpress.org/Plugin_API/Action_Reference
http://codex.wordpress.org/Plugin_API/Filter_Reference
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/

Post a Comment