Commit bcb882c
committed
Before and after form hooks order
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:
``` html
<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:
``` html
<div>
<p>
</p>
</div>
```1 parent a03b471 commit bcb882c
1 file changed
+12
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | 324 | | |
337 | 325 | | |
338 | 326 | | |
| |||
347 | 335 | | |
348 | 336 | | |
349 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| |||
0 commit comments