using actions and filters in wordpress to make a plugin your own
TRANSCRIPT
![Page 1: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/1.jpg)
Making a Plugin Your OwnUsing Actions and Filters in WordPress
Brian Hoggbrianhogg.com | @brianhogg
WordCamp Toronto 2015
![Page 2: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/2.jpg)
brianhogg.com
Subtitle
![Page 3: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/3.jpg)
wpontheside.com
Subtitle
![Page 4: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/4.jpg)
![Page 5: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/5.jpg)
Actions and Filters
![Page 6: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/6.jpg)
Actions
do_action( $identifier, [ $arg1, $arg2, ... ] )
add_action( $identifier, $function_name, [ $priority, $arg_count ] )
![Page 7: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/7.jpg)
Actions (Example)do_action( 'the_plugin_action' );
function handle_the_plugin_action() {echo 'The action is happening now!';
}
add_action( 'the_plugin_action', 'handle_the_plugin_action' );
![Page 8: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/8.jpg)
Filters
apply_filters( $identifier, $value, [ $arg1, $arg2, ... ] )
add_filter( $identifier, $function_name, [ $priority, $arg_count ] )
![Page 9: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/9.jpg)
Filters (Example)
echo apply_filters( 'plugin_title', 'Title' );
function change_plugin_title( $title ) {return 'New Title';
}
add_filter( 'plugin_title', 'change_plugin_title' );
![Page 10: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/10.jpg)
Filters (Example)
echo apply_filters( 'plugin_title', 'Title' );
function change_plugin_title( $title ) {return 'New ' . $title;
}
add_filter( 'plugin_title', 'change_plugin_title' );
![Page 11: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/11.jpg)
How do you find what you can change in a plugin?
Search for do_action and apply_filters
![Page 12: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/12.jpg)
The Events Calendar Plugin
•apply_filters•442 occurrences
•do_action•190 occurrences
![Page 13: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/13.jpg)
How to Find The One You Need?▪ Look at the plugin documentation (if any)▪ Look at the code▪ Look at the HTML output and backtrack
![Page 14: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/14.jpg)
DEMO
![Page 15: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/15.jpg)
The Events Calendar▪ Message to verify location▪ Venue -> Location▪ Cost formatting
![Page 16: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/16.jpg)
Can’t find the one you need?▪ (Nicely) ask the developer of the plugin
▪ Direct contact information / website▪ wordpress.org support forums
▪ Look for a paid support or Pro version
▪ Submit a patch
![Page 17: Using Actions and Filters in WordPress to Make a Plugin Your Own](https://reader036.vdocuments.us/reader036/viewer/2022070509/58a4ba121a28ab2d688b5d6d/html5/thumbnails/17.jpg)
Go make plugins your own!