/** * Normalize parameters for field * * @param array $field * * @return array */ static function normalize($field) { $field = parent::normalize($field); $field = wp_parse_args($field, array('prefix' => '', 'suffix' => '', 'js_options' => array())); $field['js_options'] = wp_parse_args($field['js_options'], array('range' => 'min')); return $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('cols' => $field['cols'], 'rows' => $field['rows'], 'maxlength' => $field['maxlength'], 'wrap' => $field['wrap'], 'readonly' => $field['readonly'], 'placeholder' => $field['placeholder'])); $attributes['class'] .= ' large-text'; return $attributes; }
/** * Normalize parameters for field * * @param array $field * @return array */ static function normalize($field) { $field = parent::normalize($field); $field = wp_parse_args($field, array('raw' => false, 'options' => array())); $field['options'] = wp_parse_args($field['options'], array('editor_class' => 'mashsb-rwmb-wysiwyg', 'dfw' => true)); // Keep the filter to be compatible with previous versions $field['options'] = apply_filters('rwmb_wysiwyg_settings', $field['options']); return $field; }
/** * Normalize parameters for field * * @param array $field * * @return array */ static function normalize($field) { $field = parent::normalize($field); $field['multiple'] = true; $field['field_name'] = $field['id']; if (!$field['clone']) { $field['field_name'] .= '[]'; } return $field; }
/** * @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']; $meta = $this->meta; $field = $this->field; $field_class = MASHSB_RW_Meta_Box::get_class_name($field); $attributes = call_user_func(array($field_class, 'get_attributes'), $field, $object->{$id}); $output .= sprintf('<li><label><input %s %s>%s</label>', MASHSB_RWMB_Field::render_attributes($attributes), checked(in_array($object->{$id}, $meta), 1, false), $object->{$label}); }
function display_level($options, $parent_id = 0, $active = false) { $id = $this->db_fields['id']; $field = $this->field; $meta = $this->meta; $walker = new MASHSB_RWMB_Select_Walker($this->db_fields, $this->field, $this->meta); $field_class = MASHSB_RW_Meta_Box::get_class_name($field); $attributes = call_user_func(array($field_class, 'get_attributes'), $field, $meta); $children = $options[$parent_id]; $output = sprintf('<div class="mashsb-rwmb-select-tree %s" data-parent-id="%s"><select %s>', $active ? '' : 'hidden', $parent_id, MASHSB_RWMB_Field::render_attributes($attributes)); $output .= isset($field['placeholder']) ? "<option value=''>{$field['placeholder']}</option>" : '<option></option>'; $output .= $walker->walk($children, -1); $output .= '</select>'; foreach ($children as $c) { if (isset($options[$c->{$id}])) { $output .= $this->display_level($options, $c->{$id}, in_array($c->{$id}, $meta) && $active); } } $output .= '</div>'; return $output; }
/** * Save meta value * * @param $new * @param $old * @param $post_id * @param $field */ static function save($new, $old, $post_id, $field) { delete_post_meta($post_id, $field['id']); parent::save($new, array(), $post_id, $field); }
/** * Normalize parameters for field * * @param array $field * @return array */ public static function normalize($field) { $field = parent::normalize($field); $field = wp_parse_args($field, array('flatten' => true, 'options' => array())); return $field; }
/** * Normalize parameters for field * * @param array $field * * @return array */ static function normalize($field) { $field = parent::normalize($field); $field = wp_parse_args($field, array('size' => 30, 'placeholder' => '')); return $field; }
/** * Normalize parameters for field * * @param array $field * * @return array */ static function normalize($field) { $field = parent::normalize($field); $field = wp_parse_args($field, array('std' => array(), 'force_delete' => false, 'max_file_uploads' => 0, 'mime_type' => '')); $field['multiple'] = true; return $field; }
/** * Normalize parameters for field * * @param array $field * @return array */ static function normalize($field) { $field = parent::normalize($field); $field['field_name'] .= $field['multiple'] ? '[]' : ''; return $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('list' => $field['datalist'] ? $field['datalist']['id'] : false, 'readonly' => $field['readonly'], 'value' => $value, 'placeholder' => $field['placeholder'])); return $attributes; }
/** * 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['class'] .= ' button hide-if-no-js'; return $attributes; }