| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bootstraps the CMB2 process |
| 4 |
* |
| 5 |
* @category WordPress_Plugin |
| 6 |
* @package CMB2 |
| 7 |
* @author CMB2 |
| 8 |
* @license GPL-2.0+ |
| 9 |
* @link https://cmb2.io |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Function to encapsulate the CMB2 bootstrap process. |
| 14 |
* |
| 15 |
* @since 2.2.0 |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
function cmb2_bootstrap() { |
| 19 |
|
| 20 |
if ( is_admin() ) { |
| 21 |
/** |
| 22 |
* Fires on the admin side when CMB2 is included/loaded. |
| 23 |
* |
| 24 |
* In most cases, this should be used to add metaboxes. See example-functions.php |
| 25 |
*/ |
| 26 |
do_action( 'cmb2_admin_init' ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Fires when CMB2 is included/loaded |
| 31 |
* |
| 32 |
* Can be used to add metaboxes if needed on the front-end or WP-API (or the front and backend). |
| 33 |
*/ |
| 34 |
do_action( 'cmb2_init' ); |
| 35 |
|
| 36 |
/** |
| 37 |
* For back-compat. Does the dirty-work of instantiating all the |
| 38 |
* CMB2 instances for the cmb2_meta_boxes filter |
| 39 |
* |
| 40 |
* @since 2.0.2 |
| 41 |
*/ |
| 42 |
$cmb_config_arrays = apply_filters( 'cmb2_meta_boxes', array() ); |
| 43 |
foreach ( (array) $cmb_config_arrays as $cmb_config ) { |
| 44 |
new CMB2( $cmb_config ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Fires after all CMB2 instances are created |
| 49 |
*/ |
| 50 |
do_action( 'cmb2_init_before_hookup' ); |
| 51 |
|
| 52 |
/** |
| 53 |
* Get all created metaboxes, and instantiate CMB2_Hookup |
| 54 |
* on metaboxes which require it. |
| 55 |
* |
| 56 |
* @since 2.0.2 |
| 57 |
*/ |
| 58 |
foreach ( CMB2_Boxes::get_all() as $cmb ) { |
| 59 |
|
| 60 |
/** |
| 61 |
* Initiates the box "hookup" into WordPress. |
| 62 |
* |
| 63 |
* Unless the 'hookup' box property is `false`, the box will be hooked in as |
| 64 |
* a post/user/comment/option/term box. |
| 65 |
* |
| 66 |
* And if the 'show_in_rest' box property is set, the box will be hooked |
| 67 |
* into the CMB2 REST API. |
| 68 |
* |
| 69 |
* The dynamic portion of the hook name, $cmb->cmb_id, is the box id. |
| 70 |
* |
| 71 |
* @since 2.2.6 |
| 72 |
* |
| 73 |
* @param array $cmb The CMB2 object to hookup. |
| 74 |
*/ |
| 75 |
do_action( "cmb2_init_hookup_{$cmb->cmb_id}", $cmb ); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Fires after CMB2 initiation process has been completed |
| 80 |
*/ |
| 81 |
do_action( 'cmb2_after_init' ); |
| 82 |
} |
| 83 |
|
| 84 |
/* End. That's it, folks! */ |
| 85 |
|