Skip to content
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

Make sure we are in The Loop state #12107

Closed

Conversation

moorscode
Copy link
Contributor

🚧 In discussion, DO NOT MERGE 🚧

As the_content filter should assume we are in the loop, and can call global functions, we need to prepare the environment to act that way.

Because WordPress backend does not use The Loop, we need to restore the set globals to their previous state, instead of doing a wp_reset_postdata.

Summary

This PR can be summarized in the following changelog entry:

  • [non-user-facing] Sets up the post data, to make sure filters can use the environment as if we are in the loop.

Relevant technical choices:

  • Store and restore global variables as wp_reset_postdata will leave the system in a different state than before. This might cause unwanted side-effects.

Test instructions

This PR can be tested by following these steps:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Quality assurance

  • I have tested this code to the best of my abilities
  • I have added unittests to verify the code works as intended

Fixes #11395

As `the_content` filter should assume we are in the loop, and can call global functions, we need to prepare the environment to act that way.

Because WordPress backend does not use The Loop, we need to restore the set globals to their previous state, instead of doing a `wp_reset_postdata`
@omarreiss
Copy link
Contributor

This has been open without action for ~two years. Closing.

@omarreiss omarreiss closed this Jun 16, 2020
@omarreiss omarreiss removed the blocked label Jun 16, 2020
@moorscode moorscode deleted the 11395-setup-post-data-when-using-the-content branch August 7, 2020 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants