Bending WordPress to your Will
by
Hugh Lashbrooke
×
Copy
Open
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slide 1
Slide 1 text
Bending WordPress To Your Will
Slide 2
Slide 2 text
Folder Structure Headers Events Plugin Development
Slide 3
Slide 3 text
wp-content/plugins/plugin-slug plugin-slug.php readme.txt Folder Structure
Slide 4
Slide 4 text
Headers /* * Plugin Name: Seriously Simple Podcasting * Version: 1.9.6 * Plugin URI: https://wordpress.org/plugins/seriously-simple-podcasting/ * Description: Podcasting the way it's meant to be. * Author: Hugh Lashbrooke * Author URI: http://www.hughlashbrooke.com/ * Requires at least: 4.0 * Tested up to: 4.2 * * Text Domain: seriously-simple-podcasting * Domain Path: /lang/ */
Slide 5
Slide 5 text
PHP call_user_func() WordPress do_action() apply_filters() Events
Slide 6
Slide 6 text
do_action( ‘hook’ ); add_action( ‘hook’, ‘my_function’ ); Events: Hooks
Slide 7
Slide 7 text
add_action( ‘init’, ‘init_function’ ); function init_function() { ... } Events: Hooks
Slide 8
Slide 8 text
add_action( ‘hook’, ‘my_function’, 10 ); Lower number == higher priority Events: Priorities
Slide 9
Slide 9 text
add_action( ‘hook’, ‘my_function’, 10, 2 ); function my_function ( $foo, $bar ) { ... } Events: Parameters
Slide 10
Slide 10 text
apply_filters( ‘filter’, $foo ); add_filter( ‘filter’, ‘my_function’ ); Filters must always return a value Events: Filters
Slide 11
Slide 11 text
add_filter( ‘body_class’, ‘my_function’ ); function my_function( $classes ) { $classes[] = ‘my-class’; return $classes; } Events: Filters
Slide 12
Slide 12 text
remove_action( ‘hook’, ‘function’ ); remove_filter( ‘filter’, ‘function’ ); Priorities must match original hook/filter Removing Hooks & Filters
Slide 13
Slide 13 text
Bringing it Together
Slide 14
Slide 14 text
Plugin Developer Info: wordpress.org/plugins/developers/ Coding Standards: codex.wordpress.org/WordPress_Coding_Standards Action Reference: codex.wordpress.org/Plugin_API/Action_Reference Plugin Template: github.com/hlashbrooke/WordPress-Plugin-Template Helpful Links
Slide 15
Slide 15 text
https://github.com/hlashbrooke/Post-View-Counter Demo Plugin
Slide 16
Slide 16 text
automattic.com make.wordpress.org hugh.blog @hlashbrooke