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

Allow dynamic blocks to create loops #9182

Merged
merged 3 commits into from Aug 21, 2018

Conversation

Projects
None yet
2 participants
@obenland
Member

obenland commented Aug 20, 2018

Fixes #7427, fixes #8035.

Description

Stores and restores the global post object around dynamic block callbacks. This allows dynamic blocks to create new WP_Query instances and set up its post data, without changing the currently edited post.

How has this been tested?

Added a new unit test.
Tested with a custom dynamic block in wp-admin and front-end with the block callback I added in the unit test. I could recreate the scenario described in #7427.

Types of changes

Stores global $post in do_blocks() and resets it after every dynamic block callback.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

obenland added some commits Aug 20, 2018

Allow dynamic blocks to create loops
Stores and restores the global post object around dynamic block callbacks. This allows dynamic blocks to create new `WP_Query` instances and set up its post data, without changing the currently edited post.

See #7427, #8035.

@obenland obenland added this to the 3.7 milestone Aug 20, 2018

@obenland obenland requested review from danielbachhuber, pento and aduth Aug 20, 2018

@obenland obenland merged commit ba5dc99 into master Aug 21, 2018

2 checks passed

codecov/project 50.91% remains the same compared to f631337
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@obenland obenland deleted the origin/add/global-post-backup branch Aug 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment