RWMB_Field::filter PHP Method

filter() public static method

Filters: - rwmb_{$name} - rwmb_{$field['type']}_{$name} - rwmb_{$field['id']}_{$name}
public static filter ( ) : mixed
return mixed
	public static function filter() {
		$args = func_get_args();

		// 3 first params must be: filter name, value, field. Other params will be used for filters.
		$name  = array_shift( $args );
		$value = array_shift( $args );
		$field = array_shift( $args );

		// List of filters
		$filters = array(
			'rwmb_' . $name,
			'rwmb_' . $field['type'] . '_' . $name,
		);
		if ( isset( $field['id'] ) ) {
			$filters[] = 'rwmb_' . $field['id'] . '_' . $name;
		}

		// Filter params: value, field, other params. Note: value is changed after each run.
		array_unshift( $args, $field );
		foreach ( $filters as $filter ) {
			$filter_args = $args;
			array_unshift( $filter_args, $value );
			$value = apply_filters_ref_array( $filter, $filter_args );
		}

		return $value;
	}

Usage Example

Exemplo n.º 1
0
 /**
  * @see Walker::start_el()
  *
  * @param string $output            Passed by reference. Used to append additional content.
  * @param object $object            Item data object.
  * @param int    $depth             Depth of item.
  * @param int    $current_object_id Item ID.
  * @param array  $args
  */
 public function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
 {
     $label = $this->db_fields['label'];
     $id = $this->db_fields['id'];
     $attributes = RWMB_Field::call('get_attributes', $this->field, $object->{$id});
     $output .= sprintf('<li><label><input %s %s>%s</label>', RWMB_Field::render_attributes($attributes), checked(in_array($object->{$id}, $this->meta), 1, false), RWMB_Field::filter('choice_label', $object->{$label}, $this->field, $object));
 }
All Usage Examples Of RWMB_Field::filter