Skip to content

Commit

Permalink
Merge branch 'jrfnl-feature/new-field-arg-filters' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Jan 18, 2019
2 parents 587d020 + dbfce95 commit f003ed9
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions includes/CMB2_Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,30 @@ public function get_default() {
* @return array Modified field config array.
*/
public function _set_field_defaults( $args ) {
$defaults = $this->get_default_field_args( $args );

/**
* Filter the CMB2 Field defaults.
*
* @since 2.6.0
* @param array $defaults Metabox field config array defaults.
* @param string $id Field id for the current field to allow for selective filtering.
* @param string $type Field type for the current field to allow for selective filtering.
* @param CMB2_Field object $field This field object.
*/
$defaults = apply_filters( 'cmb2_field_defaults', $defaults, $args['id'], $args['type'], $this );

// Set up blank or default values for empty ones.
$args = wp_parse_args( $args, $this->get_default_field_args( $args ) );
$args = wp_parse_args( $args, $defaults );

/**
* Filtering the CMB2 Field arguments once merged with the defaults, but before further processing.
*
* @since 2.6.0
* @param array $args Metabox field config array defaults.
* @param CMB2_Field object $field This field object.
*/
$args = apply_filters( 'cmb2_field_arguments_raw', $args, $this );

/*
* Deprecated usage:
Expand Down Expand Up @@ -1371,7 +1392,14 @@ public function _set_field_defaults( $args ) {
CMB2_JS::add_dependencies( 'jquery-ui-sortable' );
}

return $args;
/**
* Filter the CMB2 Field arguments after processing.
*
* @since 2.6.0
* @param array $args Metabox field config array after processing.
* @param CMB2_Field object $field This field object.
*/
return apply_filters( 'cmb2_field_arguments', $args, $this );
}

/**
Expand Down

0 comments on commit f003ed9

Please sign in to comment.