31491 plugins: can’t always find the one you need to do the job
Help others make a tiny tweak by making plugins extensible.
This is about plugins, but also applicable to themes.
“One that can be modified or extended without changing the plugin code itself.”
Much more popular in WP Plugin Directory!
Tools & Functions
Actions & Filters
– a hook to add functionality at that point
Create a function, and add an action, e.g. to 2014 footer.php
– filter the data that WP works with before its seen by the user
E.g. wanted to add a link to a Twitter user within a tweet widget. Looked for class wrapping the user. Searched the plugin for that class, and found an apply_filters string. Don’t need to edit plugin.
Wrote a simple function to user that filter.
Where should we use these actions & filters?
1) Setting up arrays
2) Before/after HTML output
3) Before/after setup
E.g. instead of just declaring an array, pass it through a filter first.
Can use a filter to override template files, e.g. WooCommerce does this.