Make WordPress Core

Ticket #34113: 34113.3.diff

File 34113.3.diff, 3.3 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/admin-bar.php

    diff --git src/wp-includes/admin-bar.php src/wp-includes/admin-bar.php
    index 2f7c02a..4c4765d 100644
    function wp_admin_bar_edit_menu( $wp_admin_bar ) { 
    577577                                        'href' => get_permalink( $post->ID )
    578578                                ) );
    579579                        }
     580                } elseif ( 'edit' == $current_screen->base
     581                        && ( $post_type_object = get_post_type_object( $current_screen->post_type ) )
     582                        && ( $post_type_object->public )
     583                        && ( $post_type_object->show_in_admin_bar )
     584                        && ( get_post_type_archive_link( $post_type_object->name ) ) )
     585                {
     586                        $wp_admin_bar->add_node( array(
     587                                'id' => 'archive',
     588                                'title' => $post_type_object->labels->view_items,
     589                                'href' => get_post_type_archive_link( $current_screen->post_type )
     590                        ) );
    580591                } elseif ( 'term' == $current_screen->base
    581592                        && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
    582593                        && ( $tax = get_taxonomy( $tag->taxonomy ) )
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index ced823c..b7e2de2 100644
    function _post_type_meta_capabilities( $capabilities = null ) { 
    12341234 * - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
    12351235 * - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
    12361236 * - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
     1237 * - `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
    12371238 * - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
    12381239 * - `not_found` - Label used when no items are found. Default is 'No posts found' / 'No pages found'.
    12391240 * - `not_found_in_trash` - Label used when no items are in the trash. Default is 'No posts found in Trash' /
    function get_post_type_labels( $post_type_object ) { 
    12821283                'edit_item' => array( __('Edit Post'), __('Edit Page') ),
    12831284                'new_item' => array( __('New Post'), __('New Page') ),
    12841285                'view_item' => array( __('View Post'), __('View Page') ),
     1286                'view_items' => array( __('View Posts'), __('View Pages') ),
    12851287                'search_items' => array( __('Search Posts'), __('Search Pages') ),
    12861288                'not_found' => array( __('No posts found.'), __('No pages found.') ),
    12871289                'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),
  • tests/phpunit/tests/adminbar.php

    diff --git tests/phpunit/tests/adminbar.php tests/phpunit/tests/adminbar.php
    index 12a767d..1a20fb7 100644
    class Tests_AdminBar extends WP_UnitTestCase { 
    380380                $this->assertNull( $node_edit );
    381381        }
    382382
     383        /**
     384         * @ticket 34113
     385         */
     386        public function test_admin_bar_contains_view_archive_link() {
     387                set_current_screen( 'edit-post' );
     388
     389                $wp_admin_bar = $this->get_standard_admin_bar();
     390                $node_view    = $wp_admin_bar->get_node( 'archive' );
     391
     392                set_current_screen( 'front' );
     393
     394                $this->assertNotNull( $node_view );
     395        }
     396
     397        /**
     398         * @ticket 34113
     399         */
     400        public function test_admin_bar_has_no_archives_link_for_post_types_without_archive() {
     401                set_current_screen( 'edit-page' );
     402
     403                $wp_admin_bar = $this->get_standard_admin_bar();
     404                $node_view    = $wp_admin_bar->get_node( 'archive' );
     405
     406                set_current_screen( 'front' );
     407
     408                $this->assertNull( $node_view );
     409        }
    383410}