protected function _get_post_types() { $return = array(); $post_types = \Morepress\Post_Type::find($this->_params['args'], 'object'); foreach ($post_types as $name => $post_type) { $return[$name] = $post_type->labels->name; } return $return; }
public function __construct($manager, $id, $args = array()) { parent::__construct($manager, $id, $args); $this->choices = array(); $post_types = \Morepress\Post_Type::find(array(), 'object'); foreach ($post_types as $key => $item) { $this->choices[$key] = $item->labels->name; } }
public function callback($params) { global $_nav_menu_placeholder, $nav_menu_selected_id; $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1; /* get custom post types with archive support */ $args = array('show_in_nav_menus' => true, 'has_archive' => true); $post_types = Post_Type::find($args, 'object'); /* hydrate the necessary object properties for the walker */ foreach ($post_types as &$post_type) { $post_type->classes = array(); $post_type->type = $post_type->name; $post_type->object_id = $post_type->name; $post_type->title = $post_type->labels->name . ' ' . __('Archive', 'default'); $post_type->object = 'cpt-archive'; $post_type->menu_item_parent = null; $post_type->url = null; $post_type->xfn = null; $post_type->db_id = null; $post_type->target = null; $post_type->attr_title = null; } $walker = new \Walker_Nav_Menu_Checklist(array()); ?> <div id="cpt-archive" class="posttypediv"> <div id="tabs-panel-cpt-archive" class="tabs-panel tabs-panel-active"> <ul id="ctp-archive-checklist" class="categorychecklist form-no-clear"> <?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $post_types), 0, (object) array('walker' => $walker)); ?> </ul> </div> </div> <p class="button-controls"> <span class="add-to-menu"> <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?> " name="add-ctp-archive-menu-item" id="submit-cpt-archive" /> <span class="spinner"></span> </span> </p> <?php }