<object_class>_inherit_<method>

Allows overloading the object (CMB2 or CMB2_Field) with additional capabilities by registering hook callbacks.

Description

apply_filters( '<object_class>_inherit_<method>', (array) $args ); 

The first dynamic portion(s) of the hook name refer to the object class, either cmb2 or cmb2_field.

The second dynamic portion(s) of the hook name refer is the non-existent method being called on the object. To avoid possible future methods encroaching on your hooks, use a unique method (aka, $cmb->prefix_my_method()).

When registering your callback, you will need to ensure that you register the correct number of $accepted_args,, accounting for this object instance being the first argument.

Parameters (1)

0. $args (array)
The arguments to be passed to the hook. The first argument will always be this object instance.

Usage

To run the hook, copy the example below.
  1. $args = apply_filters( '{$object_class}_inherit_{$method}', $args ); 
  2.  
  3. if ( !empty( $args ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the <object_class>_inherit_<method> callback 
  2. function filter_object_class_inherit_method( $args ) { 
  3. // make filter magic happen here... 
  4. return $args
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "{$object_class}_inherit_{$method}", 'filter_object_class_inherit_method', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "{$object_class}_inherit_{$method}", 'filter_object_class_inherit_method', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/CMB2_Base.php  
  1. return apply_filters_ref_array( "{$object_class}_inherit_{$method}", $args );