RWMB_Field::get_attributes PHP Method

get_attributes() public static method

Get the attributes for a field
public static get_attributes ( array $field, mixed $value = null ) : array
$field array
$value mixed
return array
	public static function get_attributes( $field, $value = null ) {
		$attributes = wp_parse_args( $field['attributes'], array(
			'disabled' => $field['disabled'],
			'required' => $field['required'],
			'id'       => $field['id'],
			'class'    => '',
			'name'     => $field['field_name'],
		) );

		$attributes['class'] = implode( ' ', array_merge( array( "rwmb-{$field['type']}" ), (array) $attributes['class'] ) );

		return $attributes;
	}

Usage Example

Exemplo n.º 1
0
 /**
  * Get the attributes for a field
  *
  * @param array $field
  * @param mixed $value
  *
  * @return array
  */
 static function get_attributes($field, $value = null)
 {
     $attributes = parent::get_attributes($field, $value);
     $attributes = wp_parse_args($attributes, array('cols' => $field['cols'], 'rows' => $field['rows'], 'maxlength' => $field['maxlength'], 'wrap' => $field['wrap'], 'readonly' => $field['readonly'], 'placeholder' => $field['placeholder']));
     $attributes['class'] .= ' large-text';
     return $attributes;
 }
All Usage Examples Of RWMB_Field::get_attributes