Ejemplo n.º 1
0
 /**
  * @param $type
  * @param $name
  * @param $default_fields
  *
  * @return array
  */
 public function groups_get($type, $name, $default_fields = null)
 {
     if ('post_type' == $type && 'attachment' == $name) {
         $type = 'media';
         $name = 'media';
     }
     do_action('pods_meta_groups', $type, $name);
     $pod = array();
     $fields = array();
     $object = self::$post_types;
     if ('taxonomy' == $type) {
         $object = self::$taxonomies;
     } elseif ('media' == $type) {
         $object = self::$media;
     } elseif ('user' == $type) {
         $object = self::$user;
     } elseif ('comment' == $type) {
         $object = self::$comment;
     } elseif ('pod' == $type) {
         $object = self::$advanced_content_types;
     }
     if (!empty($object) && is_array($object) && isset($object[$name])) {
         $fields = $object[$name]['fields'];
     } else {
         if (empty(self::$current_pod_data) || !is_object(self::$current_pod_data) || self::$current_pod_data['name'] != $name) {
             self::$current_pod_data = pods_api()->load_pod(array('name' => $name), false);
         }
         $pod = self::$current_pod_data;
         if (!empty($pod)) {
             $fields = $pod['fields'];
         }
     }
     if (null !== $default_fields) {
         $fields = $default_fields;
     }
     $defaults = array('name' => 'post', 'object' => 'post', 'type' => 'post_type');
     $pod = array_merge($defaults, (array) $pod);
     if (empty($pod['name'])) {
         $pod['name'] = $pod['object'];
     } elseif (empty($pod['object'])) {
         $pod['object'] = $pod['name'];
     }
     if ($pod['type'] != $type) {
         return array();
     }
     $groups = array(array('pod' => $pod, 'label' => apply_filters('pods_meta_default_box_title', __('More Fields', 'pods'), $pod, $fields, $type, $name), 'fields' => $fields, 'context' => 'normal', 'priority' => 'default'));
     if (isset(self::$groups[$type]) && isset(self::$groups[$type][$name])) {
         $groups = self::$groups[$type][$name];
     }
     return $groups;
 }