Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r41887 r42343  
    2626                global $wp_customize;
    2727                $this->wp_customize = new WP_Customize_Manager();
    28                 $wp_customize = $this->wp_customize;
     28                $wp_customize       = $this->wp_customize;
    2929        }
    3030
    … …  
    4646        function filter_item_types( $items ) {
    4747                $items[] = array(
    48                         'title' => 'Custom',
    49                         'type' => 'custom_type',
    50                         'object' => 'custom_object',
     48                        'title'      => 'Custom',
     49                        'type'       => 'custom_type',
     50                        'object'     => 'custom_object',
    5151                        'type_label' => 'Custom Type',
    5252                );
    … …  
    192192
    193193                // Create page.
    194                 $page_id = self::factory()->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
     194                $page_id = self::factory()->post->create(
     195                        array(
     196                                'post_title' => 'Page Title',
     197                                'post_type'  => 'page',
     198                        )
     199                );
    195200
    196201                // Expected menu item array.
    … …  
    295300
    296301                // Create posts.
    297                 $post_ids = array();
     302                $post_ids   = array();
    298303                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Search & Test' ) );
    299304                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Some Other Title' ) );
    300305
    301306                // Create terms.
    302                 $term_ids = array();
     307                $term_ids   = array();
    303308                $term_ids[] = self::factory()->category->create( array( 'name' => 'Dogs Are Cool' ) );
    304309                $term_ids[] = self::factory()->category->create( array( 'name' => 'Cats Drool' ) );
    … …  
    306311                // Test empty results.
    307312                $expected = array();
    308                 $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => 'This Does NOT Exist' ) );
     313                $results  = $menus->search_available_items_query(
     314                        array(
     315                                'pagenum' => 1,
     316                                's'       => 'This Does NOT Exist',
     317                        )
     318                );
    309319                $this->assertEquals( $expected, $results );
    310320
    … …  
    321331                        );
    322332                        wp_set_object_terms( $post_id, $term_ids, 'category' );
    323                         $search = $post_id === $post_ids[0] ? 'test & search' : 'other title';
    324                         $s = sanitize_text_field( wp_unslash( $search ) );
    325                         $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) );
     333                        $search  = $post_id === $post_ids[0] ? 'test & search' : 'other title';
     334                        $s       = sanitize_text_field( wp_unslash( $search ) );
     335                        $results = $menus->search_available_items_query(
     336                                array(
     337                                        'pagenum' => 1,
     338                                        's'       => $s,
     339                                )
     340                        );
    326341                        $this->assertEquals( $expected, $results[0] );
    327342                }
    … …  
    329344                // Test terms.
    330345                foreach ( $term_ids as $term_id ) {
    331                         $term = get_term_by( 'id', $term_id, 'category' );
     346                        $term     = get_term_by( 'id', $term_id, 'category' );
    332347                        $expected = array(
    333348                                'id'         => 'term-' . $term_id,
    … …  
    339354                                'url'        => get_term_link( intval( $term_id ), 'category' ),
    340355                        );
    341                         $s = sanitize_text_field( wp_unslash( $term->name ) );
    342                         $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) );
     356                        $s        = sanitize_text_field( wp_unslash( $term->name ) );
     357                        $results  = $menus->search_available_items_query(
     358                                array(
     359                                        'pagenum' => 1,
     360                                        's'       => $s,
     361                                )
     362                        );
    343363                        $this->assertEquals( $expected, $results[0] );
    344364                }
    345365
    346366                // Test filtered results.
    347                 $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => 'cat' ) );
     367                $results = $menus->search_available_items_query(
     368                        array(
     369                                'pagenum' => 1,
     370                                's'       => 'cat',
     371                        )
     372                );
    348373                $this->assertEquals( 1, count( $results ) );
    349374                $count = $this->filter_count_customize_nav_menu_searched_items;
    350375                add_filter( 'customize_nav_menu_searched_items', array( $this, 'filter_search' ), 10, 2 );
    351                 $results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => 'cat' ) );
     376                $results = $menus->search_available_items_query(
     377                        array(
     378                                'pagenum' => 1,
     379                                's'       => 'cat',
     380                        )
     381                );
    352382                $this->assertEquals( $count + 1, $this->filter_count_customize_nav_menu_searched_items );
    353383                $this->assertInternalType( 'array', $results );
    … …  
    383413
    384414                if ( 'cat' === $args['s'] ) {
    385                         array_unshift( $items, array(
    386                                 'id'         => 'home',
    387                                 'title'      => 'COOL CAT!',
    388                                 'type'       => 'custom',
    389                                 'type_label' => __( 'Custom Link' ),
    390                                 'object'     => '',
    391                                 'url'        => home_url( '/cool-cat' ),
    392                         ) );
     415                        array_unshift(
     416                                $items, array(
     417                                        'id'         => 'home',
     418                                        'title'      => 'COOL CAT!',
     419                                        'type'       => 'custom',
     420                                        'type_label' => __( 'Custom Link' ),
     421                                        'object'     => '',
     422                                        'url'        => home_url( '/cool-cat' ),
     423                                )
     424                        );
    393425                }
    394426                return $items;
    … …  
    419451
    420452                $expected = array( 'type' => 'nav_menu_item' );
    421                 $results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu_item[123]' );
     453                $results  = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu_item[123]' );
    422454                $this->assertEquals( $expected['type'], $results['type'] );
    423455
    424456                $expected = array( 'type' => 'nav_menu' );
    425                 $results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu[123]' );
     457                $results  = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu[123]' );
    426458                $this->assertEquals( $expected['type'], $results['type'] );
    427459        }
    … …  
    437469
    438470                $expected = 'WP_Customize_Nav_Menu_Item_Setting';
    439                 $results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu_item[123]', array( 'type' => 'nav_menu_item' ) );
     471                $results  = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu_item[123]', array( 'type' => 'nav_menu_item' ) );
    440472                $this->assertEquals( $expected, $results );
    441473
    442474                $expected = 'WP_Customize_Nav_Menu_Setting';
    443                 $results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu[123]', array( 'type' => 'nav_menu' ) );
     475                $results  = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu[123]', array( 'type' => 'nav_menu' ) );
    444476                $this->assertEquals( $expected, $results );
    445477        }
    … …  
    454486                $menu_id = wp_create_nav_menu( 'Primary' );
    455487                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    456                 $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    457                         'menu-item-type'      => 'post_type',
    458                         'menu-item-object'    => 'post',
    459                         'menu-item-object-id' => $post_id,
    460                         'menu-item-title'     => 'Hello World',
    461                         'menu-item-status'    => 'publish',
    462                 ) );
     488                $item_id = wp_update_nav_menu_item(
     489                        $menu_id, 0, array(
     490                                'menu-item-type'      => 'post_type',
     491                                'menu-item-object'    => 'post',
     492                                'menu-item-object-id' => $post_id,
     493                                'menu-item-title'     => 'Hello World',
     494                                'menu-item-status'    => 'publish',
     495                        )
     496                );
    463497                do_action( 'customize_register', $this->wp_customize );
    464498                $this->assertInstanceOf( 'WP_Customize_Nav_Menu_Item_Setting', $this->wp_customize->get_setting( "nav_menu_item[$item_id]" ) );
    … …  
    502536
    503537                $expected = array(
    504                         array( 'title' => 'Posts', 'type' => 'post_type', 'object' => 'post', 'type_label' => __( 'Post' ) ),
    505                         array( 'title' => 'Pages', 'type' => 'post_type', 'object' => 'page', 'type_label' => __( 'Page' ) ),
    506                         array( 'title' => 'Categories', 'type' => 'taxonomy', 'object' => 'category', 'type_label' => __( 'Category' ) ),
    507                         array( 'title' => 'Tags', 'type' => 'taxonomy', 'object' => 'post_tag', 'type_label' => __( 'Tag' ) ),
     538                        array(
     539                                'title'      => 'Posts',
     540                                'type'       => 'post_type',
     541                                'object'     => 'post',
     542                                'type_label' => __( 'Post' ),
     543                        ),
     544                        array(
     545                                'title'      => 'Pages',
     546                                'type'       => 'post_type',
     547                                'object'     => 'page',
     548                                'type_label' => __( 'Page' ),
     549                        ),
     550                        array(
     551                                'title'      => 'Categories',
     552                                'type'       => 'taxonomy',
     553                                'object'     => 'category',
     554                                'type_label' => __( 'Category' ),
     555                        ),
     556                        array(
     557                                'title'      => 'Tags',
     558                                'type'       => 'taxonomy',
     559                                'object'     => 'post_tag',
     560                                'type_label' => __( 'Tag' ),
     561                        ),
    508562                );
    509563
    510564                if ( current_theme_supports( 'post-formats' ) ) {
    511                         $expected[] = array( 'title' => 'Format', 'type' => 'taxonomy', 'object' => 'post_format', 'type_label' => __( 'Format' ) );
     565                        $expected[] = array(
     566                                'title'      => 'Format',
     567                                'type'       => 'taxonomy',
     568                                'object'     => 'post_format',
     569                                'type_label' => __( 'Format' ),
     570                        );
    512571                }
    513572
    … …  
    515574
    516575                register_taxonomy( 'wptests_tax', array( 'post' ), array( 'labels' => array( 'name' => 'Foo' ) ) );
    517                 $expected[] = array( 'title' => 'Foo', 'type' => 'taxonomy', 'object' => 'wptests_tax', 'type_label' => 'Foo' );
     576                $expected[] = array(
     577                        'title'      => 'Foo',
     578                        'type'       => 'taxonomy',
     579                        'object'     => 'wptests_tax',
     580                        'type_label' => 'Foo',
     581                );
    518582
    519583                $this->assertEquals( $expected, $menus->available_item_types() );
    520584
    521                 $expected[] = array( 'title' => 'Custom', 'type' => 'custom_type', 'object' => 'custom_object', 'type_label' => 'Custom Type' );
     585                $expected[] = array(
     586                        'title'      => 'Custom',
     587                        'type'       => 'custom_type',
     588                        'object'     => 'custom_object',
     589                        'type_label' => 'Custom Type',
     590                );
    522591
    523592                add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
    … …  
    540609
    541610                // Non-existent post types allowed as of #39610.
    542                 $r = $menus->insert_auto_draft_post( array( 'post_title' => 'Non-existent', 'post_type' => 'nonexistent' ) );
     611                $r = $menus->insert_auto_draft_post(
     612                        array(
     613                                'post_title' => 'Non-existent',
     614                                'post_type'  => 'nonexistent',
     615                        )
     616                );
    543617                $this->assertInstanceOf( 'WP_Post', $r );
    544618                $this->assertEquals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
    … …  
    548622                $this->assertEquals( 'empty_title', $r->get_error_code() );
    549623
    550                 $r = $menus->insert_auto_draft_post( array( 'post_status' => 'publish', 'post_title' => 'Bad', 'post_type' => 'post' ) );
     624                $r = $menus->insert_auto_draft_post(
     625                        array(
     626                                'post_status' => 'publish',
     627                                'post_title'  => 'Bad',
     628                                'post_type'   => 'post',
     629                        )
     630                );
    551631                $this->assertInstanceOf( 'WP_Error', $r );
    552632                $this->assertEquals( 'status_forbidden', $r->get_error_code() );
    553633
    554                 $r = $menus->insert_auto_draft_post( array( 'post_title' => 'Hello World', 'post_type' => 'post' ) );
     634                $r = $menus->insert_auto_draft_post(
     635                        array(
     636                                'post_title' => 'Hello World',
     637                                'post_type'  => 'post',
     638                        )
     639                );
    555640                $this->assertInstanceOf( 'WP_Post', $r );
    556641                $this->assertEquals( 'Hello World', $r->post_title );
    … …  
    560645                $this->assertEquals( 'post', $r->post_type );
    561646
    562                 $r = $menus->insert_auto_draft_post( array( 'post_title' => 'Hello World', 'post_type' => 'post', 'post_name' => 'greetings-world', 'post_content' => 'Hi World' ) );
     647                $r = $menus->insert_auto_draft_post(
     648                        array(
     649                                'post_title'   => 'Hello World',
     650                                'post_type'    => 'post',
     651                                'post_name'    => 'greetings-world',
     652                                'post_content' => 'Hi World',
     653                        )
     654                );
    563655                $this->assertInstanceOf( 'WP_Post', $r );
    564656                $this->assertEquals( 'Hello World', $r->post_title );
    … …  
    696788         */
    697789        function test_sanitize_nav_menus_created_posts() {
    698                 $menus = new WP_Customize_Nav_Menus( $this->wp_customize );
    699                 $contributor_user_id = $this->factory()->user->create( array( 'role' => 'contributor' ) );
    700                 $author_user_id = $this->factory()->user->create( array( 'role' => 'author' ) );
     790                $menus                 = new WP_Customize_Nav_Menus( $this->wp_customize );
     791                $contributor_user_id   = $this->factory()->user->create( array( 'role' => 'contributor' ) );
     792                $author_user_id        = $this->factory()->user->create( array( 'role' => 'author' ) );
    701793                $administrator_user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) );
    702794
    703                 $contributor_post_id = $this->factory()->post->create( array(
    704                         'post_status' => 'auto-draft',
    705                         'post_title' => 'Contributor Post',
    706                         'post_type' => 'post',
    707                         'post_author' => $contributor_user_id,
    708                 ) );
    709                 $author_post_id = $this->factory()->post->create( array(
    710                         'post_status' => 'auto-draft',
    711                         'post_title' => 'Author Post',
    712                         'post_type' => 'post',
    713                         'post_author' => $author_user_id,
    714                 ) );
    715                 $administrator_post_id = $this->factory()->post->create( array(
    716                         'post_status' => 'auto-draft',
    717                         'post_title' => 'Admin Post',
    718                         'post_type' => 'post',
    719                         'post_author' => $administrator_user_id,
    720                 ) );
    721 
    722                 $draft_post_id = $this->factory()->post->create( array(
    723                         'post_status' => 'draft',
    724                         'post_title' => 'Draft',
    725                         'post_author' => $administrator_user_id,
    726                 ) );
    727 
    728                 $private_post_id = $this->factory()->post->create( array(
    729                         'post_status' => 'private',
    730                         'post_title' => 'Private',
    731                         'post_author' => $administrator_user_id,
    732                 ) );
     795                $contributor_post_id   = $this->factory()->post->create(
     796                        array(
     797                                'post_status' => 'auto-draft',
     798                                'post_title'  => 'Contributor Post',
     799                                'post_type'   => 'post',
     800                                'post_author' => $contributor_user_id,
     801                        )
     802                );
     803                $author_post_id        = $this->factory()->post->create(
     804                        array(
     805                                'post_status' => 'auto-draft',
     806                                'post_title'  => 'Author Post',
     807                                'post_type'   => 'post',
     808                                'post_author' => $author_user_id,
     809                        )
     810                );
     811                $administrator_post_id = $this->factory()->post->create(
     812                        array(
     813                                'post_status' => 'auto-draft',
     814                                'post_title'  => 'Admin Post',
     815                                'post_type'   => 'post',
     816                                'post_author' => $administrator_user_id,
     817                        )
     818                );
     819
     820                $draft_post_id = $this->factory()->post->create(
     821                        array(
     822                                'post_status' => 'draft',
     823                                'post_title'  => 'Draft',
     824                                'post_author' => $administrator_user_id,
     825                        )
     826                );
     827
     828                $private_post_id = $this->factory()->post->create(
     829                        array(
     830                                'post_status' => 'private',
     831                                'post_title'  => 'Private',
     832                                'post_author' => $administrator_user_id,
     833                        )
     834                );
    733835
    734836                $value = array(
    … …  
    766868
    767869                // Auto-draft.
    768                 $r = $menus->insert_auto_draft_post( array(
    769                         'post_title' => 'Auto Draft',
    770                         'post_type' => 'post',
    771                         'post_name' => 'auto-draft-1',
    772                 ) );
     870                $r = $menus->insert_auto_draft_post(
     871                        array(
     872                                'post_title' => 'Auto Draft',
     873                                'post_type'  => 'post',
     874                                'post_name'  => 'auto-draft-1',
     875                        )
     876                );
    773877                $this->assertInstanceOf( 'WP_Post', $r );
    774878                $post_ids[] = $r->ID;
    775879
    776880                // Draft.
    777                 $r = $menus->insert_auto_draft_post( array(
    778                         'post_title' => 'Draft',
    779                         'post_type' => 'post',
    780                         'post_name' => 'auto-draft-2',
    781                 ) );
     881                $r = $menus->insert_auto_draft_post(
     882                        array(
     883                                'post_title' => 'Draft',
     884                                'post_type'  => 'post',
     885                                'post_name'  => 'auto-draft-2',
     886                        )
     887                );
    782888                $this->assertInstanceOf( 'WP_Post', $r );
    783                 wp_update_post( array(
    784                         'ID' => $r->ID,
    785                         'post_status' => 'draft',
    786                 ) );
     889                wp_update_post(
     890                        array(
     891                                'ID'          => $r->ID,
     892                                'post_status' => 'draft',
     893                        )
     894                );
    787895                $post_ids[] = $r->ID;
    788896
    … …  
    790898
    791899                // Private (this will exclude it from being considered a stub).
    792                 $r = $menus->insert_auto_draft_post( array(
    793                         'post_title' => 'Private',
    794                         'post_type' => 'post',
    795                         'post_name' => 'auto-draft-3',
    796                 ) );
     900                $r = $menus->insert_auto_draft_post(
     901                        array(
     902                                'post_title' => 'Private',
     903                                'post_type'  => 'post',
     904                                'post_name'  => 'auto-draft-3',
     905                        )
     906                );
    797907                $this->assertInstanceOf( 'WP_Post', $r );
    798                 wp_update_post( array(
    799                         'ID' => $r->ID,
    800                         'post_status' => 'private',
    801                 ) );
    802                 $post_ids[] = $r->ID;
     908                wp_update_post(
     909                        array(
     910                                'ID'          => $r->ID,
     911                                'post_status' => 'private',
     912                        )
     913                );
     914                $post_ids[]      = $r->ID;
    803915                $private_post_id = $r->ID;
    804916
    805917                // Trashed (this will exclude it from being considered a stub).
    806                 $r = $menus->insert_auto_draft_post( array(
    807                         'post_title' => 'Trash',
    808                         'post_type' => 'post',
    809                         'post_name' => 'auto-draft-4',
    810                 ) );
     918                $r = $menus->insert_auto_draft_post(
     919                        array(
     920                                'post_title' => 'Trash',
     921                                'post_type'  => 'post',
     922                                'post_name'  => 'auto-draft-4',
     923                        )
     924                );
    811925                $this->assertInstanceOf( 'WP_Post', $r );
    812926                wp_trash_post( $r->ID );
    813                 $post_ids[] = $r->ID;
     927                $post_ids[]      = $r->ID;
    814928                $trashed_post_id = $r->ID;
    815929
    … …  
    845959
    846960                // Ensure that unique slugs were assigned.
    847                 $posts = array_map( 'get_post', $drafted_post_ids );
     961                $posts      = array_map( 'get_post', $drafted_post_ids );
    848962                $post_names = wp_list_pluck( $posts, 'post_name' );
    849963                $this->assertEqualSets( $post_names, array_unique( $post_names ) );
    … …  
    857971        function test_filter_wp_nav_menu_args() {
    858972                do_action( 'customize_register', $this->wp_customize );
    859                 $menus = $this->wp_customize->nav_menus;
     973                $menus   = $this->wp_customize->nav_menus;
    860974                $menu_id = wp_create_nav_menu( 'Foo' );
    861975
    862                 $results = $menus->filter_wp_nav_menu_args( array(
    863                         'echo'            => true,
    864                         'fallback_cb'     => 'wp_page_menu',
    865                         'walker'          => '',
    866                         'menu'            => $menu_id,
    867                         'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    868                 ) );
     976                $results = $menus->filter_wp_nav_menu_args(
     977                        array(
     978                                'echo'        => true,
     979                                'fallback_cb' => 'wp_page_menu',
     980                                'walker'      => '',
     981                                'menu'        => $menu_id,
     982                                'items_wrap'  => '<ul id="%1$s" class="%2$s">%3$s</ul>',
     983                        )
     984                );
    869985                $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results );
    870986                $this->assertTrue( $results['can_partial_refresh'] );
    871987
    872                 $results = $menus->filter_wp_nav_menu_args( array(
    873                         'echo'            => false,
    874                         'fallback_cb'     => 'wp_page_menu',
    875                         'walker'          => new Walker_Nav_Menu(),
    876                         'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    877                 ) );
     988                $results = $menus->filter_wp_nav_menu_args(
     989                        array(
     990                                'echo'        => false,
     991                                'fallback_cb' => 'wp_page_menu',
     992                                'walker'      => new Walker_Nav_Menu(),
     993                                'items_wrap'  => '<ul id="%1$s" class="%2$s">%3$s</ul>',
     994                        )
     995                );
    878996                $this->assertFalse( $results['can_partial_refresh'] );
    879997                $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results );
    … …  
    881999
    8821000                $nav_menu_term = get_term( wp_create_nav_menu( 'Bar' ) );
    883                 $results = $menus->filter_wp_nav_menu_args( array(
    884                         'echo'            => true,
    885                         'fallback_cb'     => 'wp_page_menu',
    886                         'walker'          => '',
    887                         'menu'            => $nav_menu_term,
    888                         'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    889                 ) );
     1001                $results       = $menus->filter_wp_nav_menu_args(
     1002                        array(
     1003                                'echo'        => true,
     1004                                'fallback_cb' => 'wp_page_menu',
     1005                                'walker'      => '',
     1006                                'menu'        => $nav_menu_term,
     1007                                'items_wrap'  => '<ul id="%1$s" class="%2$s">%3$s</ul>',
     1008                        )
     1009                );
    8901010                $this->assertTrue( $results['can_partial_refresh'] );
    8911011                $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results );
    8921012                $this->assertEquals( $nav_menu_term->term_id, $results['customize_preview_nav_menus_args']['menu'] );
    8931013
    894                 $results = $menus->filter_wp_nav_menu_args( array(
    895                         'echo'            => true,
    896                         'fallback_cb'     => 'wp_page_menu',
    897                         'walker'          => '',
    898                         'menu'            => $menu_id,
    899                         'container'       => 'div',
    900                         'items_wrap'      => '%3$s',
    901                 ) );
     1014                $results = $menus->filter_wp_nav_menu_args(
     1015                        array(
     1016                                'echo'        => true,
     1017                                'fallback_cb' => 'wp_page_menu',
     1018                                'walker'      => '',
     1019                                'menu'        => $menu_id,
     1020                                'container'   => 'div',
     1021                                'items_wrap'  => '%3$s',
     1022                        )
     1023                );
    9021024                $this->assertTrue( $results['can_partial_refresh'] );
    9031025
    904                 $results = $menus->filter_wp_nav_menu_args( array(
    905                         'echo'            => true,
    906                         'fallback_cb'     => 'wp_page_menu',
    907                         'walker'          => '',
    908                         'menu'            => $menu_id,
    909                         'container'       => false,
    910                         'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    911                 ) );
     1026                $results = $menus->filter_wp_nav_menu_args(
     1027                        array(
     1028                                'echo'        => true,
     1029                                'fallback_cb' => 'wp_page_menu',
     1030                                'walker'      => '',
     1031                                'menu'        => $menu_id,
     1032                                'container'   => false,
     1033                                'items_wrap'  => '<ul id="%1$s" class="%2$s">%3$s</ul>',
     1034                        )
     1035                );
    9121036                $this->assertTrue( $results['can_partial_refresh'] );
    9131037
    914                 $results = $menus->filter_wp_nav_menu_args( array(
    915                         'echo'            => true,
    916                         'fallback_cb'     => 'wp_page_menu',
    917                         'walker'          => '',
    918                         'menu'            => $menu_id,
    919                         'container'       => false,
    920                         'items_wrap'      => '%3$s',
    921                 ) );
     1038                $results = $menus->filter_wp_nav_menu_args(
     1039                        array(
     1040                                'echo'        => true,
     1041                                'fallback_cb' => 'wp_page_menu',
     1042                                'walker'      => '',
     1043                                'menu'        => $menu_id,
     1044                                'container'   => false,
     1045                                'items_wrap'  => '%3$s',
     1046                        )
     1047                );
    9221048                $this->assertFalse( $results['can_partial_refresh'] );
    9231049        }
    … …  
    9991125
    10001126                $menu = wp_create_nav_menu( 'Foo' );
    1001                 wp_update_nav_menu_item( $menu, 0, array(
    1002                         'menu-item-type' => 'custom',
    1003                         'menu-item-title' => 'WordPress.org',
    1004                         'menu-item-url' => 'https://wordpress.org',
    1005                         'menu-item-status' => 'publish',
    1006                 ) );
    1007 
    1008                 $nav_menu_args = $this->wp_customize->nav_menus->filter_wp_nav_menu_args( array(
    1009                         'echo'        => true,
    1010                         'menu'        => $menu,
    1011                         'fallback_cb' => 'wp_page_menu',
    1012                         'walker'      => '',
    1013                         'items_wrap'  => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    1014                 ) );
     1127                wp_update_nav_menu_item(
     1128                        $menu, 0, array(
     1129                                'menu-item-type'   => 'custom',
     1130                                'menu-item-title'  => 'WordPress.org',
     1131                                'menu-item-url'    => 'https://wordpress.org',
     1132                                'menu-item-status' => 'publish',
     1133                        )
     1134                );
     1135
     1136                $nav_menu_args = $this->wp_customize->nav_menus->filter_wp_nav_menu_args(
     1137                        array(
     1138                                'echo'        => true,
     1139                                'menu'        => $menu,
     1140                                'fallback_cb' => 'wp_page_menu',
     1141                                'walker'      => '',
     1142                                'items_wrap'  => '<ul id="%1$s" class="%2$s">%3$s</ul>',
     1143                        )
     1144                );
    10151145
    10161146                $partial_id = sprintf( 'nav_menu_instance[%s]', $nav_menu_args['customize_preview_nav_menus_args']['args_hmac'] );
    1017                 $partials = $this->wp_customize->selective_refresh->add_dynamic_partials( array( $partial_id ) );
     1147                $partials   = $this->wp_customize->selective_refresh->add_dynamic_partials( array( $partial_id ) );
    10181148                $this->assertNotEmpty( $partials );
    10191149                $partial = array_shift( $partials );
Note: See TracChangeset for help on using the changeset viewer.