Skip to content

Conversation

@rubengc
Copy link
Contributor

@rubengc rubengc commented Apr 13, 2017

This is a backwards-compatibility break. If your theme or plugin is using some of next action hooks and your are connecting the output between them then take a look a this explanation

Hooks have been called in this order (until this PR):
cmb2_before_form
cmb2_before_{$object_type}_form_{$cmb_id}
cmb2_after_form
cmb2_after_{$object_type}_form_{$cmb_id}

And now they are called at this order:
cmb2_before_form
cmb2_before_{$object_type}_form_{$cmb_id}
cmb2_after_{$object_type}_form_{$cmb_id}
cmb2_after_form

Why? Because this means call this hooks is really dangerous because you could break your html if you expect a relative order, for example, if two plugins using this hooks to print something, the most common workflow is use same relative callbacks (cmb2_before_form and cmb2_after_form) or (cmb2_before_{$object_type}_form_{$cmb_id} and cmb2_after_{$object_type}_form_{$cmb_id})

A visual example with two plugins (Plugin 1 and Plugin 2):
Current order:
cmb2_before_form Plugin 1 opens a div
cmb2_before_{$object_type}_form_{$cmb_id} Plugin 2 prints a p
cmb2_after_form Plugin 1 closes the div
cmb2_after_{$object_type}_form_{$cmb_id} Plugin 2 closes the p

Result:

<div>
<p>
</div>
</p>

New order:
cmb2_before_form Plugin 1 opens a div
cmb2_before_{$object_type}_form_{$cmb_id} Plugin 2 prints a p
cmb2_after_{$object_type}_form_{$cmb_id} Plugin 2 closes the p
cmb2_after_form Plugin 1 closes the div

Result:

<div>
<p>
</p>
</div>

@rubengc
Copy link
Contributor Author

rubengc commented May 31, 2017

About this PR, I just did a plugin for cmb2 to add tabs that uses this hooks to output div open/close tags

https://github.com/rubengc/cmb2-tabs

@jtsternberg jtsternberg merged commit 7a15bd1 into CMB2:trunk Jun 1, 2017
@jtsternberg
Copy link
Member

Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants