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.
- $args = apply_filters( 'cmb2_{$element}_attributes', $args, $type_defaults, $this_field, $this_types );
- if ( !empty( $args ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the cmb2_<element>_attributes callback
- function filter_cmb2_element_attributes( $args, $type_defaults, $this_field, $this_types ) {
- // make filter magic happen here...
- return $args;
- };
- // add the filter
- add_filter( "cmb2_{$element}_attributes", 'filter_cmb2_element_attributes', 10, 4 );
- To remove a hook callback, use the example below.
- // remove the filter
- 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
- $args = apply_filters( "cmb2_{$element}_attributes", $args, $type_defaults, $this->field, $this->types );
- /includes/libraries/metabox/includes/CMB2_Types.php
- return wp_parse_args( apply_filters( "cmb2_{$element}_attributes", $this->field->maybe_set_attributes( $args ), $defaults, $this->field, $this ), $defaults );