static function custom_post_types()
 {
     foreach (Kanban_Post_Types::$post_types as $post_type_slug => $post_type_data) {
         $post_type_label = ucfirst($post_type_slug);
         $labels = array('name' => str_replace('_', ' ', sprintf('%ss', $post_type_label)), 'singular_name' => str_replace('_', ' ', $post_type_label), 'menu_name' => str_replace('_', ' ', sprintf('%ss', $post_type_label)), 'name_admin_bar' => str_replace('_', ' ', $post_type_label), 'parent_item_colon' => str_replace('_', ' ', sprintf('Parent %s:', $post_type_label)), 'all_items' => str_replace('_', ' ', sprintf('All %ss', $post_type_label)), 'add_new_item' => str_replace('_', ' ', sprintf('Add New %s', $post_type_label)), 'add_new' => 'Add New', 'new_item' => str_replace('_', ' ', sprintf('New %s', $post_type_label)), 'edit_item' => str_replace('_', ' ', sprintf('Edit %s', $post_type_label)), 'update_item' => str_replace('_', ' ', sprintf('Update %s', $post_type_label)), 'view_item' => str_replace('_', ' ', sprintf('View %s', $post_type_label)), 'search_items' => str_replace('_', ' ', sprintf('Search %s', $post_type_label)), 'not_found' => 'Not found', 'not_found_in_trash' => 'Not found in Trash');
         $rewrite = array('slug' => NULL, 'with_front' => true, 'pages' => true, 'feeds' => true);
         $args = array('label' => $post_type_label, 'labels' => $labels, 'supports' => array('title', 'editor', 'custom-fields'), 'hierarchical' => true, 'public' => false, 'show_ui' => false, 'show_in_menu' => false, 'menu_position' => 5, 'show_in_admin_bar' => false, 'show_in_nav_menus' => false, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => false, 'rewrite' => false, 'capability_type' => 'page');
         register_post_type(Kanban_Post_Types::format_post_type($post_type_slug), $args);
         // register taxonomies associated with each post type
         foreach ($post_type_data['taxonomies'] as $taxonomy_slug => $values) {
             $taxonomy_key = Kanban_Utils::format_key($post_type_slug, $taxonomy_slug);
             $taxonomy_label = ucwords(sprintf('%s %s', $post_type_slug, $taxonomy_slug));
             $labels = array('name' => $taxonomy_label, 'singular_name' => $taxonomy_label, 'menu_name' => $taxonomy_label, 'all_items' => sprintf('All %ss', $taxonomy_label), 'parent_item' => sprintf('Parent %s', $taxonomy_label), 'parent_item_colon' => sprintf('Parent %s:', $taxonomy_label), 'new_item_name' => sprintf('New %s Name', $taxonomy_label), 'add_new_item' => sprintf('Add New %s', $taxonomy_label), 'edit_item' => sprintf('Edit %s', $taxonomy_label), 'update_item' => sprintf('Update %s', $taxonomy_label), 'view_item' => sprintf('View %s', $taxonomy_label), 'separate_items_with_commas' => sprintf('Separate %ss with commas', $taxonomy_label), 'add_or_remove_items' => sprintf('Add or remove %ss', $taxonomy_label), 'choose_from_most_used' => 'Choose from the most used', 'popular_items' => sprintf('Popular %ss', $taxonomy_label), 'search_items' => sprintf('Search %ss', $taxonomy_label), 'not_found' => 'Not Found');
             $rewrite = array('slug' => sprintf('%s/%s/%s', Kanban::$slug, Kanban_Utils::make_word_plural($post_type_slug), Kanban_Utils::make_word_plural($taxonomy_slug)), 'with_front' => true, 'hierarchical' => false);
             $args = array('labels' => $labels, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => false, 'show_tagcloud' => false, 'rewrite' => false);
             register_taxonomy($taxonomy_key, Kanban_Post_Types::format_post_type($post_type_slug), $args);
         }
         // taxonomies
     }
     // post_types
 }
Ejemplo n.º 2
0
 static function admin_menu()
 {
     // Base 64 encoded SVG image.
     $icon_svg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAPCAYAAAAGRPQsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0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ban::get_instance()->settings->pretty_name, 'manage_options', Kanban::get_instance()->settings->basename, null, $icon_svg);
     // redeclare same page to change name to settings
     // @link https://codex.wordpress.org/Function_Reference/add_submenu_page#Inside_menu_created_with_add_menu_page.28.29
     add_submenu_page(Kanban::get_instance()->settings->basename, 'Welcome', 'Welcome', 'manage_options', Kanban::get_instance()->settings->basename, array(__CLASS__, 'welcome_page'));
     // don't show settings page if user doesn't have permission to manage plugins
     if (current_user_can('manage_options')) {
         foreach (Kanban_Post_Types::$post_types as $post_type_slug => $post_type_data) {
             $post_type_label = ucfirst($post_type_slug);
             if (defined('KANBAN_DEBUG') && KANBAN_DEBUG === TRUE) {
                 add_submenu_page(Kanban::get_instance()->settings->basename, sprintf('All %s', str_replace('_', ' ', Kanban_Utils::make_word_plural($post_type_label))), sprintf('All %s', str_replace('_', ' ', Kanban_Utils::make_word_plural($post_type_label))), 'manage_options', sprintf('edit.php?post_type=%s', Kanban_Post_Types::format_post_type($post_type_slug)));
             }
             // DEBUG
             foreach ($post_type_data['taxonomies'] as $taxonomy_slug => $values) {
                 $taxonomy_key = Kanban_Utils::format_key($post_type_slug, $taxonomy_slug);
                 $taxonomy_label = ucwords(sprintf('%s %s', $post_type_slug, Kanban_Utils::make_word_plural($taxonomy_slug)));
                 add_submenu_page(Kanban::get_instance()->settings->basename, $taxonomy_label, $taxonomy_label, 'manage_options', sprintf('edit-tags.php?taxonomy=%s&post_type=%s', $taxonomy_key, Kanban_Post_Types::format_post_type($post_type_slug)));
             }
             // taxonomies
         }
         // post_types
     }
     // activate_plugins
     // don't show settings page if user doesn't have permission to manage plugins
     if (current_user_can('manage_options')) {
         // @link https://codex.wordpress.org/Function_Reference/add_submenu_page#Inside_menu_created_with_add_menu_page.28.29
         add_submenu_page(Kanban::get_instance()->settings->basename, 'Settings', 'Settings', 'manage_options', sprintf('admin.php?page=%s', Kanban::get_instance()->settings->basename), array(__CLASS__, 'plugin_page'));
     }
 }