Example #1
0
 public static function channels($type, $store = true, $public_only = false, $detail = true)
 {
     $_objects = $type === 'post_types' ? get_post_types(array(), 'object') : get_taxonomies(array(), 'object');
     if (empty($_objects)) {
         return false;
     }
     $objects_all = $objects = array();
     foreach ($_objects as $object) {
         $label = $detail ? "{$object->label} <code>({$object->name})</code>" : $object->label;
         $objects_all[$object->name] = $label;
         if ($object->public || $object->show_ui) {
             $objects[$object->name] = $label;
         }
     }
     if (!$store) {
         if ($public_only) {
             return $objects;
         } else {
             return $objects_all;
         }
     } else {
         switch ($type) {
             case 'post_types':
                 self::$post_types = $objects;
                 self::$post_types_all = $objects_all;
                 break;
             default:
                 self::$taxonomies = $objects;
                 self::$taxonomies_all = $objects_all;
                 break;
         }
     }
 }