コード例 #1
0
ファイル: PostType.php プロジェクト: panvagenas/wp-menu-pages
 public function __construct(AbsCmpFields $component, $name, $args = [])
 {
     parent::__construct($component, $name);
     $postTypes = get_post_types($args, 'objects');
     foreach ($postTypes as $postType) {
         $this->options[$postType->label] = $postType->name;
     }
 }
コード例 #2
0
 public function __construct(AbsCmpFields $component, $name, $postType = 'post', $args = [])
 {
     parent::__construct($component, $name);
     $taxonomies = get_object_taxonomies($postType);
     if (!empty($taxonomies)) {
         unset($args['fields']);
         $terms = get_terms($taxonomies, $args);
         if (!is_wp_error($terms)) {
             foreach ($terms as $term) {
                 $this->options[$term->name] = $term->term_id;
             }
         }
     }
 }