From 9de60f3644196301554b35c2db29909152c6a72d Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 6 Feb 2010 17:27:30 +0000 Subject: [PATCH] Add a separate show_ui flag for post types. see #9674 git-svn-id: http://svn.automattic.com/wordpress/trunk@12993 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit.php | 2 +- wp-admin/menu.php | 4 ++-- wp-admin/post-new.php | 2 +- wp-includes/post.php | 23 +++++++++++++---------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/wp-admin/edit.php b/wp-admin/edit.php index ee0e4f9a1..fe0817671 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -20,7 +20,7 @@ if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['pag unset( $_redirect ); } -if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('_show' => true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' => true ) ) ) ) ) +if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) ) ) $post_type = $_GET['post_type']; else $post_type = 'post'; diff --git a/wp-admin/menu.php b/wp-admin/menu.php index b99503814..b2aef44f0 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -81,10 +81,10 @@ $menu[25] = array( sprintf( __('Comments %s'), " true) ) as $ptype ) { +foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) { $_wp_last_object_menu++; $ptype_obj = get_post_type_object($ptype); - $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), 'edit_' . $ptype_obj->capability_type . 's', "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div'); + $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div'); $submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), 'edit_posts', "edit.php?post_type=$ptype"); /* translators: add new custom post type */ $submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" ); diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index 318dbb22f..9b8950419 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -9,7 +9,7 @@ /** Load WordPress Administration Bootstrap */ require_once('admin.php'); -if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('_show' => true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' => true ) ) ) ) ) +if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) ) ) $post_type = $_GET['post_type']; else $post_type = 'post'; diff --git a/wp-includes/post.php b/wp-includes/post.php index 1e291cea0..a554532dd 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -16,8 +16,8 @@ */ function create_initial_post_types() { register_post_type( 'post', array( 'label' => __('Posts'), - 'publicly_queryable' => true, - 'exclude_from_search' => false, + 'public' => true, + 'show_ui' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', @@ -28,8 +28,8 @@ function create_initial_post_types() { ) ); register_post_type( 'page', array( 'label' => __('Pages'), - 'publicly_queryable' => true, - 'exclude_from_search' => false, + 'public' => true, + 'show_ui' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'page', @@ -40,7 +40,8 @@ function create_initial_post_types() { ) ); register_post_type( 'attachment', array('label' => __('Media'), - 'exclude_from_search' => false, + 'public' => true, + 'show_ui' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', @@ -50,7 +51,7 @@ function create_initial_post_types() { ) ); register_post_type( 'revision', array( 'label' => __('Revisions'), - 'exclude_from_search' => true, + 'public' => false, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', @@ -704,6 +705,7 @@ function get_post_types( $args = array(), $output = 'names' ) { * public - Whether posts of this type should be shown in the admin UI. Defaults to false. * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true if the type is not public, false if the type is public. * publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as. + * show_ui - Whether to generate a default UI for managing this post type. Defaults to true if the type is public, false if the type is not public. * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". * edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). @@ -732,7 +734,7 @@ function register_post_type($post_type, $args = array()) { $wp_post_types = array(); // Args prefixed with an underscore are reserved for internal use. - $defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array() ); + $defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null ); $args = wp_parse_args($args, $defaults); $args = (object) $args; @@ -743,6 +745,10 @@ function register_post_type($post_type, $args = array()) { if ( null === $args->publicly_queryable ) $args->publicly_queryable = $args->public; + // If not set, default to the setting for public. + if ( null === $args->show_ui ) + $args->show_ui = $args->public; + // If not set, default to true if not public, false if public. if ( null === $args->exclude_from_search ) $args->exclude_from_search = !$args->public; @@ -765,9 +771,6 @@ function register_post_type($post_type, $args = array()) { if ( empty($args->delete_cap) ) $args->delete_cap = 'delete_' . $args->capability_type; - if ( !$args->_builtin && $args->public ) - $args->_show = true; - if ( ! empty($args->supports) ) { add_post_type_support($post_type, $args->supports); unset($args->supports);