Tuesday, 24 January 2017

Hooks, Line, and Sinker: WordPress’ New WP_Hook Class


The hooks system is a central pillar of WordPress and with the 4.7 release a major overhaul of how it works was merged. The Trac ticket that initially raised an issue with the hooks system was logged over 6 years ago. After a few attempts, the updates finally made it into the 4.7 release and the venerable hooks system was overhauled. In this post I want to go over some of the technical changes and decisions that went into the new WP_Hook class. I’ll also go over some of the more interesting aspects of WordPress core development and look into what it takes to overhaul a major feature in WordPress core. For the purposes of this post I’m going to assume you know what the WordPress hooks system is (i.e. add_filter(), add_action(), apply_filters() and do_action()), and have a general idea of how it works. It would also be a good idea to read over the Make blog post that covers the changes.
What’s Changed?
One of the bigger changes introduced in WordPress 4.7 is that there is a new WP_Hook class. This new class is now used to handle all the internal hooks within WordPress core. It’s kind of a big deal. Pre-4.7, all the hook functions (add_filter() etc.) and logic were
Source: https://managewp.org/articles/14265/hooks-line-and-sinker-wordpress-new-wp-hook-class




source https://williechiu40.wordpress.com/2017/01/24/hooks-line-and-sinker-wordpress-new-wp_hook-class/

No comments:

Post a Comment