This document provides an introduction to plugin development in WordPress from Josh Pollock of CalderaLabs. It discusses what plugins are, why developers should create them, how to structure them, and best practices for the plugin API. Key topics covered include using hooks and filters, plugin organization, and prioritizing security, reuse, and good coding standards.
2. @Josh412
CalderaLabs.org
Hi I'm Josh
Lead Developer: CalderaWP
I make WordPress plugins
I teach about WordPress
I wrote a book about the WordPress REST API
I am core contributor to WordPress
I am a member of The WPCrowd
9. @Josh412
How To Make A Plugin
Step 1: Add a new directory to the plugins directory
(optional).
Step 2: Add a file in that directory or the plugins
directory with a valid plugin header.
Step 3: Write code (optional).
13. @Josh412
Plugins vs Themes: Best Practices
Themes should be use to present a unique design
Everything else should be in a plugin.
14. @Josh412
Should This Code Go In functions.php ?
Is the answer to any of these questions no:
Do I ever want to reuse this code apart from this
theme?
Will I miss this code when I switch themes?
Switch for troubleshooting.
Switch for new look.
Can I use this code for other purposes?
17. @Josh412
Main File: The File With A Plugin Header
Plugin Header
License/ Copyright/ Contact Info
Check Dependencies & Requirements
Load Plugin
Start Plugin
35. @Josh412
Using Filters: Add To Content
add_filter( 'the_content', 'slug_callback' );
function slug_callback( $content ){
return $content . '<p class="cta">Hey Sign Up for My
Thing!</p>';
}
36. @Josh412
Using Filters: Add To Content
add_filter( 'the_content', function( $content ){
return $content . '<p class="cta">Hey Sign Up for
My Thing!</p>';
});