Bending WordPress to Your Will (October 2018)
by
Hugh Lashbrooke
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Bending WordPress To Your Will
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
Folder Structure Headers Events Plugin Development
Slide 4
Slide 4 text
wp-content/plugins/plugin-slug > plugin-slug.php > readme.txt Folder Structure
Slide 5
Slide 5 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: https://hugh.blog/ * Requires at least: 4.6 * Tested up to: 4.9.8 * * Text Domain: seriously-simple-podcasting */
Slide 6
Slide 6 text
PHP call_user_func() WordPress do_action() apply_filters() Events
Slide 7
Slide 7 text
do_action( ‘hook’ ); add_action( ‘hook’, ‘my_function’ ); Events: Hooks
Slide 8
Slide 8 text
Events: Hooks - Example
Slide 9
Slide 9 text
add_action( ‘div_content’, ‘my_content’ ); function my_content() { echo “
Hello world!
”; } Events: Hooks - Example
Slide 10
Slide 10 text
Hello world!
Events: Hooks - Example
Slide 11
Slide 11 text
add_action( ‘hook’, ‘my_function’, 10 ); Lower number == higher priority Events: Priorities
Slide 12
Slide 12 text
add_action( ‘hook’, ‘my_function’, 10, 2 ); function my_function ( $foo, $bar ) { ... } Events: Parameters
Slide 13
Slide 13 text
apply_filters( ‘filter’, $foo ); add_filter( ‘filter’, ‘my_function’ ); Filters must always return a value Events: Filters
Slide 14
Slide 14 text
$v = apply_filters( 'body_class', $classes ); Events: Filters - Example
Slide 15
Slide 15 text
add_filter( ‘body_class’, ‘add_my_class’ ); function add_my_class( $classes ) { $classes[] = ‘my-class’; return $classes; } Events: Filters - Example
Slide 16
Slide 16 text
remove_action( ‘hook’, ‘function’ ); remove_filter( ‘filter’, ‘function’ ); Priorities must match original hook/filter Removing Hooks & Filters
Slide 17
Slide 17 text
Bringing it Together
Slide 18
Slide 18 text
Varying Vagrant Vagrants: varyingvagrantvagrants.org Plugin Developer Info: wordpress.org/plugins/developers Coding Standards: make.wordpress.org/core/handbook/best-practices/coding-standards Plugin Template: github.com/hlashbrooke/WordPress-Plugin-Template
Slide 19
Slide 19 text
hugh.blog @hlashbrooke automattic.com make.wordpress.org