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

Don't intercept rendering of removed meta boxes #3856

Merged
merged 3 commits into from
Dec 10, 2017
Merged

Don't intercept rendering of removed meta boxes #3856

merged 3 commits into from
Dec 10, 2017

Conversation

jeremyfelt
Copy link
Member

Description

When a metabox is removed with remove_metabox(), the meta box array is updated as:

$wp_meta_boxes[$page][$context][$priority][$id] = false;

When gutenberg_intercept_meta_box_render() loops through each of these contexts, priorities, and boxes, it partially rebuilds the previously removed metabox.

Code like do_meta_boxes() then loops through the data and can generate a notice when $box is no longer falsey or $box['title'] is not available.

We can avoid this by skipping the rebuild of any metaboxes that do not have a $box array available.

Introduced in #3554.

How Has This Been Tested?

Remove previously registered metaboxes with remove_metabox() and loading an editor page.

Types of changes

Bug fix

Checklist:

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

When a metabox is removed with `remove_metabox()`, the meta box
array is updated as:

`$wp_meta_boxes[$page][$context][$priority][$id] = false;`

When `gutenberg_intercept_meta_box_render()` loops through each of
these contexts, priorities, and boxes, it rebuilds the previously
removed metabox with partial information.

Code like `do_meta_boxes()` then loops through and can generate
a notice when `$box` is no longer falsy and `$box['title']` is not
available.

Introduced in #3554.
@jeremyfelt jeremyfelt added [Feature] Meta Boxes A draggable box shown on the post editing screen [Type] Bug An existing feature does not function as intended labels Dec 7, 2017
@BE-Webdesign
Copy link
Contributor

Looks good, is there potential to add a unit test case? I didn't check the values, I just checked that remove_metabox() won't trigger any PHP notices.

@jeremyfelt
Copy link
Member Author

Thanks @BE-Webdesign. I added a test that asserts the meta box key should remain false. I think that should be enough here.

Copy link
Contributor

@BE-Webdesign BE-Webdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Meta Boxes A draggable box shown on the post editing screen [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants