-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected action/filter execution order #2116
Comments
This is the solution I used to fix the issues with Jetpack: Add a new helper and change template() in helpers.php
Change the template_include filter in filters.php by adding
This makes it possible to execute the get_header and wp_head actions early, but delay the output The tracked actions and filters execute in the same order as in a core theme, and filters set up during get_header is applied to functions used in controllers. The question is does this have undesired side effects? |
I can confirm that OP's expected behavior is accurate as per http://rachievee.com/the-wordpress-hooks-firing-sequence/ |
Submit a feature request or bug report
What is the current behavior?
Some notable actions, filters and events are being executed in the following order:
What is the expected or desired behavior?
The actions and filters being executed in the following order:
Bug report
Plugin authors often expect the execution order to be the same on every theme for these key actions and filters.
One example would be Jetpack setting up a the_content filter during get_header. The result is the filter is not applied to the main content loop for a Sage theme.
We also might use template tags in controllers, so 3. party filters should be set up before collecting the data.
Please provide steps to reproduce, including full log output:
The issue was tracked by logging the execution order via priority 0 hooks on tracked actions.
Please describe your local environment:
WordPress version: 4.9.8
OS: Windows 10
NPM/Node version: 8.11.3
Where did the bug happen? Development or remote servers?
On all sites with incompatible plugins.
Is there a related Discourse thread or were any utilized (please link them)?
This issue can be hard to notice, but is related to the issues with wp_enqueue_scripts that is fixed in the template() function. My suggestion would be to replace that fix with something covering more actions/filters to increased compatibility with more plugins.
The text was updated successfully, but these errors were encountered: