Toolbar: Add a 'View Posts' link to the toolbar when on the post listing screen.

This adds a new link to visit the post type archive if the post type supports it. Also introduces a new `view_items` label to `get_post_type_labels()`.

Props paulwilde, akibjorklund, swissspidy.
Fixes #34113.
Built from https://develop.svn.wordpress.org/trunk@38634


git-svn-id: http://core.svn.wordpress.org/trunk@38577 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-09-20 20:02:28 +00:00
parent 7cbecfa33e
commit 8fe586ad57
3 changed files with 15 additions and 1 deletions

View File

@ -577,6 +577,17 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
'href' => get_permalink( $post->ID ) 'href' => get_permalink( $post->ID )
) ); ) );
} }
} elseif ( 'edit' == $current_screen->base
&& ( $post_type_object = get_post_type_object( $current_screen->post_type ) )
&& ( $post_type_object->public )
&& ( $post_type_object->show_in_admin_bar )
&& ( get_post_type_archive_link( $post_type_object->name ) ) )
{
$wp_admin_bar->add_node( array(
'id' => 'archive',
'title' => $post_type_object->labels->view_items,
'href' => get_post_type_archive_link( $current_screen->post_type )
) );
} elseif ( 'term' == $current_screen->base } elseif ( 'term' == $current_screen->base
&& isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
&& ( $tax = get_taxonomy( $tag->taxonomy ) ) && ( $tax = get_taxonomy( $tag->taxonomy ) )

View File

@ -1234,6 +1234,7 @@ function _post_type_meta_capabilities( $capabilities = null ) {
* - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'. * - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
* - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'. * - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
* - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'. * - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
* - `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
* - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'. * - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
* - `not_found` - Label used when no items are found. Default is 'No posts found' / 'No pages found'. * - `not_found` - Label used when no items are found. Default is 'No posts found' / 'No pages found'.
* - `not_found_in_trash` - Label used when no items are in the trash. Default is 'No posts found in Trash' / * - `not_found_in_trash` - Label used when no items are in the trash. Default is 'No posts found in Trash' /
@ -1267,6 +1268,7 @@ function _post_type_meta_capabilities( $capabilities = null ) {
* @since 4.4.0 Added the `insert_into_item`, `uploaded_to_this_item`, `filter_items_list`, * @since 4.4.0 Added the `insert_into_item`, `uploaded_to_this_item`, `filter_items_list`,
* `items_list_navigation`, and `items_list` labels. * `items_list_navigation`, and `items_list` labels.
* @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
* @since 4.7.0 Added the `view_items` label.
* *
* @access private * @access private
* *
@ -1282,6 +1284,7 @@ function get_post_type_labels( $post_type_object ) {
'edit_item' => array( __('Edit Post'), __('Edit Page') ), 'edit_item' => array( __('Edit Post'), __('Edit Page') ),
'new_item' => array( __('New Post'), __('New Page') ), 'new_item' => array( __('New Post'), __('New Page') ),
'view_item' => array( __('View Post'), __('View Page') ), 'view_item' => array( __('View Post'), __('View Page') ),
'view_items' => array( __('View Posts'), __('View Pages') ),
'search_items' => array( __('Search Posts'), __('Search Pages') ), 'search_items' => array( __('Search Posts'), __('Search Pages') ),
'not_found' => array( __('No posts found.'), __('No pages found.') ), 'not_found' => array( __('No posts found.'), __('No pages found.') ),
'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ), 'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-alpha-38633'; $wp_version = '4.7-alpha-38634';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.