Ejemplo n.º 1
0
 /**
  * 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);
     }
 }
 /**
  * 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);
     $field['display_type'] = $options['type'];
     $html = '';
     switch ($options['type']) {
         case 'checkbox_list':
             $html = WCQD_METABOX_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 = WCQD_METABOX_Select_Advanced_Field::html($meta, $field);
             break;
         case 'select':
         default:
             $html = WCQD_METABOX_Select_Field::html($meta, $field);
     }
     return $html;
 }
Ejemplo n.º 3
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);
 }