The document provides an overview of how to write WordPress plugins, including plugin structure and basics, using shortcodes and hooks, and resources for plugin developers. It explains that plugins can augment or replace WordPress core functionality and live in specific directories, and demonstrates creating a shortcode and using the hooks API to modify content. The document recommends resources for learning plugin development and gives advice for troubleshooting and understanding WordPress data.
The Ultimate Guide to Choosing WordPress Pros and Cons
Write Your First WordPress Plugin
1. Writing Your First WordPress Plugin or, What I wish someone had told me because it would have prevented me from banging my head on the desk a lot Boone Gorges @boonebgorges [email_address] http://teleogistic.net
9. Let WP know you exist <?php /* Plugin Name: Boone’s Plugin Plugin URI: http://teleogistic.net Description: This plugin will blow your mind Author: boonebgorges Version: 1.0 Author URI: http://teleogistic.net */ wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Writing_a_Plugin#File_Headers
16. Actions are hooks In the core: do_action( 'loop_start' ); In your plugin: add_action( 'loop_start', 'my_code' );
17. Example: A hello message function well_hello_there() { global $user_identity; if ( is_user_logged_in() ) echo "Welcome, " . $user_identity; else echo "Welcome, anonymous lurker!"; } add_action( 'loop_start', 'well_hello_there' ); wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Plugin_API/Action_Reference
18. Filters are hooks… with benefits In the core: $content = apply_filters('the_content', $content); In your plugin: add_filter( 'the_content', 'my_code' );
19. Example: Makin' it 1337 function make_it_leet( $content ) { $leet_content = str_replace( 'e', '3', $content ); return $leet_content; } add_filter( 'the_content', 'make_it_leet' ); wp-content/plugins/boones-plugin/boones-plugin.php See http://codex.wordpress.org/Plugin_API/Filter_Reference
21. Resources on the web The WordPress Codex, especially: - http://codex.wordpress.org/Shortcode_API - http://codex.wordpress.org/Widgets_API - http://codex.wordpress.org/Plugin_API The WordPress PHP Cross-Reference - http://xref.yoast.com The WordPress plugin repository: - http://wordpress.org/extend/plugins to download - http://wordpress.org/extend/plugins/about to add your own plugin PHP resources - W3Schools – http://www.w3schools.com/PHP/ - php.net – http://www.php.net/manual/en
22. Resources on your computer A good text editor, ideally one with - the ability to save over FTP - good search-and-replace - code highlighting - see http://lifehacker.com/385929/best-text-editors for suggestions A local development environment - AMP: Apache, MySQL, PHP - Windows: XAMPP; Mac: MAMP - Use SVN to get the most recent copies of WordPress
23. Words of advice The White Screen Of Death - Usually means you have a syntax error (check your punctuation!) - No duplicate function names, except for functions in pluggable.php - Use if ( function_exists( 'my_function' ) ) Get to know your data - Learn about globals: $wp, $post, $comment - var_dump( $wp ); - print "<pre>"; print_r( $wp ); print "</pre>"; - die(); Pick apart existing plugins Ask for help: http://wordpress.org/support