Inheritance: extends RWMB_Field
 /**
  * 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('step' => $field['step'], 'max' => $field['max'], 'min' => $field['min']));
     $attributes['type'] = 'number';
     return $attributes;
 }
Beispiel #2
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['type'] = 'checkbox';
     $attributes['list'] = false;
     return $attributes;
 }
Beispiel #3
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('size' => $field['size'], 'maxlength' => $field['maxlength'], 'pattern' => $field['pattern'], 'placeholder' => $field['placeholder']));
     $attributes['type'] = 'text';
     return $attributes;
 }
Beispiel #4
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = parent::normalize_field($field);
     $field['attributes']['list'] = false;
     $field['attributes']['type'] = 'checkbox';
     return $field;
 }
Beispiel #5
0
 static function get_attributes($field, $value = null)
 {
     $attributes = RWMB_Input_Field::get_attributes($field, $value);
     $attributes['id'] = false;
     $attributes['type'] = 'radio';
     $attributes['value'] = $value;
     return $attributes;
 }
Beispiel #6
0
 /**
  * Get the attributes for a field
  *
  * @param array $field
  * @param mixed $value
  *
  * @return array
  */
 public static function get_attributes($field, $value = null)
 {
     $attributes = RWMB_Input_Field::get_attributes($field, $value);
     $attributes['id'] = false;
     $attributes['type'] = $field['multiple'] ? 'checkbox' : 'radio';
     $attributes['value'] = $value;
     return $attributes;
 }
Beispiel #7
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = parent::normalize_field($field);
     $field = wp_parse_args($field, array('step' => 1, 'min' => 0, 'max' => false));
     $field['attributes'] = wp_parse_args($field['attributes'], array('step' => $field['step'], 'max' => $field['max'], 'min' => $field['min']));
     $field['attributes']['type'] = 'number';
     return $field;
 }
Beispiel #8
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = parent::normalize_field($field);
     $field = wp_parse_args($field, array('size' => 30, 'maxlength' => false, 'pattern' => false, 'placeholder' => ''));
     $field['attributes'] = wp_parse_args($field['attributes'], array('size' => $field['size'], 'maxlength' => $field['maxlength'], 'pattern' => $field['pattern'], 'placeholder' => $field['placeholder']));
     $field['attributes']['type'] = 'text';
     return $field;
 }
Beispiel #9
0
 /**
  * Get the attributes for a field
  *
  * @param array $field
  * @param mixed $value
  *
  * @return array
  */
 static function get_attributes($field, $value = null)
 {
     switch ($field['field_type']) {
         case 'checkbox_list':
         case 'radio_list':
             $attributes = RWMB_Input_Field::get_attributes($field, $value);
             $attributes['class'] = "rwmb-choice";
             $attributes['id'] = false;
             $attributes['type'] = 'radio_list' === $field['field_type'] ? 'radio' : 'checkbox';
             break;
         case 'select_advanced':
             $attributes = RWMB_Select_Advanced_Field::get_attributes($field, $value);
             $attributes['class'] = "rwmb-choice rwmb-select_advanced";
             break;
         case 'select_tree':
             $attributes = RWMB_Select_Field::get_attributes($field, $value);
             $attributes['multiple'] = false;
             break;
         case 'select':
         default:
             $attributes = RWMB_Select_Field::get_attributes($field, $value);
             break;
     }
     $attributes['name'] .= !$field['clone'] && $field['multiple'] ? '[]' : '';
     return $attributes;
 }
Beispiel #10
0
 /**
  * Output the field value
  * Display option name instead of option value
  *
  * @use self::meta()
  *
  * @param  array    $field   Field parameters
  * @param  array    $args    Additional arguments. Rarely used. See specific fields for details
  * @param  int|null $post_id Post ID. null for current post. Optional.
  *
  * @return mixed Field value
  */
 static function the_value($field, $args = array(), $post_id = null)
 {
     $value = parent::get_value($field, $args, $post_id);
     return empty($value) ? '' : $field['options'][$value];
 }
Beispiel #11
0
 /**
  * Get meta value
  *
  * @param int   $post_id
  * @param bool  $saved
  * @param array $field
  *
  * @return mixed
  */
 static function meta($post_id, $saved, $field)
 {
     $meta = parent::meta($post_id, $saved, $field);
     if (is_array($meta)) {
         foreach ($meta as $key => $value) {
             $meta[$key] = $field['timestamp'] && $value ? date(self::translate_format($field), intval($value)) : $value;
         }
     } else {
         $meta = $field['timestamp'] && $meta ? date(self::translate_format($field), intval($meta)) : $meta;
     }
     return $meta;
 }
 /**
  * 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['type'] = 'hidden';
     return $attributes;
 }
Beispiel #13
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = parent::normalize_field($field);
     $field['attributes'] = array('name' => $field['field_name'], 'id' => $field['clone'] ? false : $field['id']);
     return $field;
 }