Inheritance: extends RWMB_Select_Field
示例#1
0
 /**
  * Enqueue scripts and styles
  */
 public static function admin_enqueue_scripts()
 {
     RWMB_Input_List_Field::admin_enqueue_scripts();
     RWMB_Select_Field::admin_enqueue_scripts();
     RWMB_Select_Tree_Field::admin_enqueue_scripts();
     RWMB_Select_Advanced_Field::admin_enqueue_scripts();
 }
示例#2
0
 /**
  * Get meta value
  * If field is cloneable, value is saved as a single entry in DB
  * Otherwise value is saved as multiple entries (for backward compatibility)
  *
  * @see "save" method for better understanding
  *
  * @param $post_id
  * @param $saved
  * @param $field
  *
  * @return array
  */
 static function meta($post_id, $saved, $field)
 {
     if (isset($field['parent']) && $field['parent']) {
         $post = get_post($post_id);
         return $post->post_parent;
     }
     return parent::meta($post_id, $saved, $field);
 }
示例#3
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $pt_obj = get_post_type_object($field['post_type']);
     $field = wp_parse_args($field, array('post_type' => 'post', 'field_type' => 'select_advanced', 'default' => sprintf(__('Select a %s', 'rwmb'), $pt_obj->labels->singular_name), 'parent' => false, 'query_args' => array()));
     if ($field['parent']) {
         $field['multiple'] = false;
         $field['field_name'] = 'parent_id';
     }
     $field['query_args'] = wp_parse_args($field['query_args'], array('post_type' => $field['post_type'], 'post_status' => 'publish', 'posts_per_page' => '-1'));
     return RWMB_Select_Advanced_Field::normalize_field($field);
 }
示例#4
0
文件: user.php 项目: riopse/meta-box
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = wp_parse_args($field, array('field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
     $field['std'] = empty($field['std']) ? __('Select an user', 'meta-box') : $field['std'];
     $field['query_args'] = wp_parse_args($field['query_args'], array('orderby' => 'display_name', 'order' => 'asc', 'role' => '', 'fields' => 'all'));
     switch ($field['field_type']) {
         case 'select':
             return RWMB_Select_Field::normalize_field($field);
             break;
         case 'select_advanced':
         default:
             return RWMB_Select_Advanced_Field::normalize_field($field);
     }
 }
示例#5
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $default_post_type = __('用户', 'rwmb');
     $field = wp_parse_args($field, array('field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
     $field['std'] = empty($field['std']) ? sprintf(__('已选择 %s', 'rwmb'), $default_post_type) : $field['std'];
     $field['query_args'] = wp_parse_args($field['query_args'], array('orderby' => 'display_name', 'order' => 'asc', 'role' => '', 'fields' => 'all'));
     switch ($field['field_type']) {
         case 'select':
             return RWMB_Select_Field::normalize_field($field);
             break;
         case 'select_advanced':
         default:
             return RWMB_Select_Advanced_Field::normalize_field($field);
     }
 }
示例#6
0
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $default_post_type = __('Post', 'meta-box');
     $field = wp_parse_args($field, array('field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
     $field['std'] = empty($field['std']) ? sprintf(__('Select a %s', 'meta-box'), $default_post_type) : $field['std'];
     if ($field['parent']) {
         $field['multiple'] = false;
         $field['field_name'] = 'parent_id';
     }
     switch ($field['field_type']) {
         case 'select':
             return RWMB_Select_Field::normalize_field($field);
             break;
         case 'select_advanced':
         default:
             return RWMB_Select_Advanced_Field::normalize_field($field);
     }
 }
示例#7
0
文件: post.php 项目: crazyyy/octagram
 /**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $default_post_type = __('Post', 'rwmb');
     if (is_string($field['post_type'])) {
         $post_type_object = get_post_type_object($field['post_type']);
         $default_post_type = $post_type_object->labels->singular_name;
     }
     $field = wp_parse_args($field, array('post_type' => 'post', 'field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
     $field['std'] = empty($field['std']) ? sprintf(__('Select a %s', 'rwmb'), $default_post_type) : $field['std'];
     if ($field['parent']) {
         $field['multiple'] = false;
         $field['field_name'] = 'parent_id';
     }
     $field['query_args'] = wp_parse_args($field['query_args'], array('post_type' => $field['post_type'], 'post_status' => 'publish', 'posts_per_page' => -1));
     switch ($field['field_type']) {
         case 'select':
             return RWMB_Select_Field::normalize_field($field);
             break;
         case 'select_advanced':
         default:
             return RWMB_Select_Advanced_Field::normalize_field($field);
     }
 }
示例#8
0
 /**
  * Get field HTML
  *
  * @param $field
  * @param $meta
  *
  * @return string
  */
 static function html($meta, $field)
 {
     $options = $field['options'];
     $terms = get_terms($options['taxonomy'], $options['args']);
     $field['options'] = self::get_options($terms);
     $html = '';
     switch ($options['type']) {
         case 'checkbox_list':
             $html = RWMB_Checkbox_List_Field::html($meta, $field);
             break;
         case 'checkbox_tree':
             $elements = self::process_terms($terms);
             $html .= self::walk_checkbox_tree($meta, $field, $elements, $options['parent'], true);
             break;
         case 'select_tree':
             $elements = self::process_terms($terms);
             $html .= self::walk_select_tree($meta, $field, $elements, $options['parent'], true);
             break;
         case 'select_advanced':
             $html = RWMB_Select_Advanced_Field::html($meta, $field);
             break;
         case 'select':
         default:
             $html = RWMB_Select_Field::html($meta, $field);
     }
     return $html;
 }
示例#9
0
 /**
  * Enqueue scripts and styles
  *
  * @return void
  */
 static function admin_enqueue_scripts()
 {
     wp_enqueue_style('rwmb-object-choice', RWMB_CSS_URL . 'object-choice.css', array(), RWMB_VER);
     wp_enqueue_script('rwmb-object-choice', RWMB_JS_URL . 'object-choice.js', array(), RWMB_VER, true);
     RWMB_Select_Field::admin_enqueue_scripts();
     RWMB_Select_Advanced_Field::admin_enqueue_scripts();
 }