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

Refactored meta box data collection. Fixed a bug where meta boxes may not be shown. #5619

Merged
merged 1 commit into from Mar 19, 2018

Conversation

Projects
None yet
2 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Mar 14, 2018

We were checking the locations where we have meta boxes in gutenberg_collect_meta_box_data. But our logic did not take into account that the locations of the meta boxes may be changed by the user.
So if the user moved meta boxes that by default appeared in the normal location to the sidebar and had no default sidebar meta box, sidebar meta boxes would not be visible.
To solve that we would need to copy the mechanism that reads user preferences for meta boxes to check their location from do_meta_boxes. Copying this logic makes gutenberg_collect_meta_box_data more complex and increases the maintainability efforts. It would also be very inefficient as that code would be executed multiple times.
So the computing of the array of locations where we have meta boxes was moved to the_gutenberg_metaboxes function where we invoke do_meta_boxes function. This way we can take advantage of the fact that do_meta_boxes returns the number of meta boxes that were outputted.

How Has This Been Tested?

Verify that there are no regression in the meta boxes, they continue to show, we can still use them and save information.
Check that no meta box that appeared by default in the sidebar exists. E.g: extended settings are is not rendered. Activate one more plugin that render meta boxes in the "normal" location e.g: Open Graph Metabox, Simple CSS, Yoast SEO.
Verify that the meta boxes appear in Gutenberg.
In the classic editor move the meta boxes to the sidebar (darg&drop them).
Go to Gutenberg and verify the meta boxes appear in the sidebar as in the classic editor. In master, the meta boxes the user moved to the sidebar are not rendered.

Screenshots (jpeg or gifs if applicable):

Before only meta boxes that were not moved are rendered. Sidebar meta box area does not appear:
image

After, moved meta boxes are also rendered in the correct place, and we have a sidebar meta box are:
image

@jorgefilipecosta jorgefilipecosta self-assigned this Mar 14, 2018

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Mar 16, 2018

@youknowriad

Nice simplification

Refactored the collect of meta box data. Fixed a bug where meta boxes…
… may not be shown if they were moved to other location by the user.

We were checking the locations where we have meta boxes in gutenberg_collect_meta_box_data. But our logic did not take into account that the locations of the meta boxes may be changed by the user.
So if the user moved meta boxes that by default appeared in the normal location to the sidebar and had no default sidebar meta box, sidebar meta boxes would not be visible.
To solve that we would need to copy the mechanism that reads user preferences for meta boxes to check their location from do_meta_boxes. Copying this logic makes gutenberg_collect_meta_box_data more complex and increases the maintainability efforts. It would also be very inefficient as that code would be executed multiple times.
So the computing of the array of locations where we have meta boxes was moved to the_gutenberg_metaboxes function where we invoke do_meta_boxes function. This way we can take advantage of the fact that do_meta_boxes returns the number of meta boxes that were outputted.

@jorgefilipecosta jorgefilipecosta merged commit 27fc447 into master Mar 19, 2018

2 checks passed

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

@jorgefilipecosta jorgefilipecosta deleted the fix/metaboxes-may-not-be-shown-if-they-were-moved branch Mar 19, 2018

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