Changeset 42343 for trunk/tests/phpunit/tests/customize/nav-menus.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/nav-menus.php
r41887 r42343 26 26 global $wp_customize; 27 27 $this->wp_customize = new WP_Customize_Manager(); 28 $wp_customize = $this->wp_customize;28 $wp_customize = $this->wp_customize; 29 29 } 30 30 … … 46 46 function filter_item_types( $items ) { 47 47 $items[] = array( 48 'title' => 'Custom',49 'type' => 'custom_type',50 'object' => 'custom_object',48 'title' => 'Custom', 49 'type' => 'custom_type', 50 'object' => 'custom_object', 51 51 'type_label' => 'Custom Type', 52 52 ); … … 192 192 193 193 // 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 ); 195 200 196 201 // Expected menu item array. … … 295 300 296 301 // Create posts. 297 $post_ids = array();302 $post_ids = array(); 298 303 $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Search & Test' ) ); 299 304 $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Some Other Title' ) ); 300 305 301 306 // Create terms. 302 $term_ids = array();307 $term_ids = array(); 303 308 $term_ids[] = self::factory()->category->create( array( 'name' => 'Dogs Are Cool' ) ); 304 309 $term_ids[] = self::factory()->category->create( array( 'name' => 'Cats Drool' ) ); … … 306 311 // Test empty results. 307 312 $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 ); 309 319 $this->assertEquals( $expected, $results ); 310 320 … … 321 331 ); 322 332 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 ); 326 341 $this->assertEquals( $expected, $results[0] ); 327 342 } … … 329 344 // Test terms. 330 345 foreach ( $term_ids as $term_id ) { 331 $term = get_term_by( 'id', $term_id, 'category' );346 $term = get_term_by( 'id', $term_id, 'category' ); 332 347 $expected = array( 333 348 'id' => 'term-' . $term_id, … … 339 354 'url' => get_term_link( intval( $term_id ), 'category' ), 340 355 ); 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 ); 343 363 $this->assertEquals( $expected, $results[0] ); 344 364 } 345 365 346 366 // 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 ); 348 373 $this->assertEquals( 1, count( $results ) ); 349 374 $count = $this->filter_count_customize_nav_menu_searched_items; 350 375 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 ); 352 382 $this->assertEquals( $count + 1, $this->filter_count_customize_nav_menu_searched_items ); 353 383 $this->assertInternalType( 'array', $results ); … … 383 413 384 414 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 ); 393 425 } 394 426 return $items; … … 419 451 420 452 $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]' ); 422 454 $this->assertEquals( $expected['type'], $results['type'] ); 423 455 424 456 $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]' ); 426 458 $this->assertEquals( $expected['type'], $results['type'] ); 427 459 } … … 437 469 438 470 $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' ) ); 440 472 $this->assertEquals( $expected, $results ); 441 473 442 474 $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' ) ); 444 476 $this->assertEquals( $expected, $results ); 445 477 } … … 454 486 $menu_id = wp_create_nav_menu( 'Primary' ); 455 487 $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 ); 463 497 do_action( 'customize_register', $this->wp_customize ); 464 498 $this->assertInstanceOf( 'WP_Customize_Nav_Menu_Item_Setting', $this->wp_customize->get_setting( "nav_menu_item[$item_id]" ) ); … … 502 536 503 537 $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 ), 508 562 ); 509 563 510 564 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 ); 512 571 } 513 572 … … 515 574 516 575 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 ); 518 582 519 583 $this->assertEquals( $expected, $menus->available_item_types() ); 520 584 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 ); 522 591 523 592 add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); … … 540 609 541 610 // 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 ); 543 617 $this->assertInstanceOf( 'WP_Post', $r ); 544 618 $this->assertEquals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) ); … … 548 622 $this->assertEquals( 'empty_title', $r->get_error_code() ); 549 623 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 ); 551 631 $this->assertInstanceOf( 'WP_Error', $r ); 552 632 $this->assertEquals( 'status_forbidden', $r->get_error_code() ); 553 633 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 ); 555 640 $this->assertInstanceOf( 'WP_Post', $r ); 556 641 $this->assertEquals( 'Hello World', $r->post_title ); … … 560 645 $this->assertEquals( 'post', $r->post_type ); 561 646 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 ); 563 655 $this->assertInstanceOf( 'WP_Post', $r ); 564 656 $this->assertEquals( 'Hello World', $r->post_title ); … … 696 788 */ 697 789 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' ) ); 701 793 $administrator_user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) ); 702 794 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 ); 733 835 734 836 $value = array( … … 766 868 767 869 // 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 ); 773 877 $this->assertInstanceOf( 'WP_Post', $r ); 774 878 $post_ids[] = $r->ID; 775 879 776 880 // 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 ); 782 888 $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 ); 787 895 $post_ids[] = $r->ID; 788 896 … … 790 898 791 899 // 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 ); 797 907 $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; 803 915 $private_post_id = $r->ID; 804 916 805 917 // 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 ); 811 925 $this->assertInstanceOf( 'WP_Post', $r ); 812 926 wp_trash_post( $r->ID ); 813 $post_ids[] = $r->ID;927 $post_ids[] = $r->ID; 814 928 $trashed_post_id = $r->ID; 815 929 … … 845 959 846 960 // Ensure that unique slugs were assigned. 847 $posts = array_map( 'get_post', $drafted_post_ids );961 $posts = array_map( 'get_post', $drafted_post_ids ); 848 962 $post_names = wp_list_pluck( $posts, 'post_name' ); 849 963 $this->assertEqualSets( $post_names, array_unique( $post_names ) ); … … 857 971 function test_filter_wp_nav_menu_args() { 858 972 do_action( 'customize_register', $this->wp_customize ); 859 $menus = $this->wp_customize->nav_menus;973 $menus = $this->wp_customize->nav_menus; 860 974 $menu_id = wp_create_nav_menu( 'Foo' ); 861 975 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 ); 869 985 $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results ); 870 986 $this->assertTrue( $results['can_partial_refresh'] ); 871 987 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 ); 878 996 $this->assertFalse( $results['can_partial_refresh'] ); 879 997 $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results ); … … 881 999 882 1000 $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 ); 890 1010 $this->assertTrue( $results['can_partial_refresh'] ); 891 1011 $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results ); 892 1012 $this->assertEquals( $nav_menu_term->term_id, $results['customize_preview_nav_menus_args']['menu'] ); 893 1013 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 ); 902 1024 $this->assertTrue( $results['can_partial_refresh'] ); 903 1025 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 ); 912 1036 $this->assertTrue( $results['can_partial_refresh'] ); 913 1037 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 ); 922 1048 $this->assertFalse( $results['can_partial_refresh'] ); 923 1049 } … … 999 1125 1000 1126 $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 ); 1015 1145 1016 1146 $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 ) ); 1018 1148 $this->assertNotEmpty( $partials ); 1019 1149 $partial = array_shift( $partials );
Note: See TracChangeset
for help on using the changeset viewer.