cmb2_<element>_attributes

Filter attributes for a field type.

Description

apply_filters( 'cmb2_<element>_attributes', (array) $args, (array) $type_defaults, (array) $this_field, (object) $this_types ); 

The dynamic portion(s) of the hook name refer to the field type.

Parameters (4)

0. $args (array)
The array of attribute arguments.
1. $type_defaults (array)
The array of default values.
2. $this_field (array)
The CMB2_Field object.
3. $this_types (object)
This CMB2_Types object.

Usage

To run the hook, copy the example below.
  1. $args = apply_filters( 'cmb2_{$element}_attributes', $args, $type_defaults, $this_field, $this_types ); 
  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 cmb2_<element>_attributes callback 
  2. function filter_cmb2_element_attributes( $args, $type_defaults, $this_field, $this_types ) { 
  3. // make filter magic happen here... 
  4. return $args
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "cmb2_{$element}_attributes", 'filter_cmb2_element_attributes', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "cmb2_{$element}_attributes", 'filter_cmb2_element_attributes', 10, 4 ); 

Defined (2)

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

/vendor/wordimpress/maps-builder-core/includes/libraries/metabox/includes/types/CMB2_Type_Base.php  
  1. $args = apply_filters( "cmb2_{$element}_attributes", $args, $type_defaults, $this->field, $this->types ); 
/includes/libraries/metabox/includes/CMB2_Types.php  
  1. return wp_parse_args( apply_filters( "cmb2_{$element}_attributes", $this->field->maybe_set_attributes( $args ), $defaults, $this->field, $this ), $defaults );