/**
  * Normalize parameters for field
  *
  * @param array $field
  *
  * @return array
  */
 static function normalize_field($field)
 {
     $field = wp_parse_args($field, array('post_type' => 'post', 'field_type' => 'select_advanced', 'parent' => false, 'query_args' => array()));
     /**
      * Set default placeholder
      * - If multiple post types: show 'Select a post'
      * - If single post type: show 'Select a %post_type_name%'
      */
     if (empty($field['placeholder'])) {
         $label = __('Select a post', 'meta-box');
         if (is_string($field['post_type']) && post_type_exists($field['post_type'])) {
             $post_type_object = get_post_type_object($field['post_type']);
             $label = sprintf(__('Select a %s', 'meta-box'), $post_type_object->labels->singular_name);
         }
         $field['placeholder'] = $label;
     }
     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 WCQD_METABOX_Select_Field::normalize_field($field);
             break;
         case 'select_advanced':
         default:
             return WCQD_METABOX_Select_Advanced_Field::normalize_field($field);
     }
 }
 /**
  * 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('js_options' => array()));
     $field['js_options'] = wp_parse_args($field['js_options'], array('allowClear' => true, 'width' => 'resolve', 'placeholder' => $field['placeholder']));
     return $field;
 }
 /**
  * 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 WCQD_METABOX_Select_Field::normalize_field($field);
             break;
         case 'select_advanced':
         default:
             return WCQD_METABOX_Select_Advanced_Field::normalize_field($field);
     }
 }
 /**
  * Walker for displaying select in tree format
  *
  * @param        $meta
  * @param        $field
  * @param        $elements
  * @param int    $parent
  * @param bool   $active
  *
  * @return string
  */
 static function walk_select_tree($meta, $field, $elements, $parent = 0, $active = false)
 {
     if (!isset($elements[$parent])) {
         return '';
     }
     $terms = $elements[$parent];
     $field['options'] = self::get_options($terms);
     $classes = array('rw-taxonomy-tree');
     $classes[] = $active ? 'active' : 'disabled';
     $classes[] = "rwmb-taxonomy-{$parent}";
     $html = '<div class="' . implode(' ', $classes) . '">';
     $html .= WCQD_METABOX_Select_Field::html($meta, $field);
     foreach ($terms as $term) {
         $html .= self::walk_select_tree($meta, $field, $elements, $term->term_id, $active && in_array($term->term_id, $meta));
     }
     $html .= '</div>';
     return $html;
 }