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.

git-svn-id: https://develop.svn.wordpress.org/trunk@38634 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-09-20 20:01:55 +00:00
parent debaea8a7c
commit acb43ecc0b
3 changed files with 41 additions and 0 deletions
+11
View File
@@ -577,6 +577,17 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
'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
&& isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
&& ( $tax = get_taxonomy( $tag->taxonomy ) )