mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues. This change includes three notable additions: - Multiline function calls must now put each parameter on a new line. - Auto-formatting files is now part of the `grunt precommit` script. - Auto-fixable coding standards issues will now cause Travis failures. Fixes #44600. git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -42,40 +42,51 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
function test_check_capabilities() {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize, 'blogname', array(
|
||||
$this->wp_customize,
|
||||
'blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname' ),
|
||||
)
|
||||
);
|
||||
$this->assertTrue( $control->check_capabilities() );
|
||||
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize, 'blogname', array(
|
||||
$this->wp_customize,
|
||||
'blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname', 'non_existing' ),
|
||||
)
|
||||
);
|
||||
$this->assertFalse( $control->check_capabilities() );
|
||||
|
||||
$this->wp_customize->add_setting(
|
||||
'top_secret_message', array(
|
||||
'top_secret_message',
|
||||
array(
|
||||
'capability' => 'top_secret_clearance',
|
||||
)
|
||||
);
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize, 'blogname', array(
|
||||
$this->wp_customize,
|
||||
'blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname', 'top_secret_clearance' ),
|
||||
)
|
||||
);
|
||||
$this->assertFalse( $control->check_capabilities() );
|
||||
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize, 'no_setting', array(
|
||||
$this->wp_customize,
|
||||
'no_setting',
|
||||
array(
|
||||
'settings' => array(),
|
||||
)
|
||||
);
|
||||
$this->assertTrue( $control->check_capabilities() );
|
||||
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize, 'no_setting', array(
|
||||
$this->wp_customize,
|
||||
'no_setting',
|
||||
array(
|
||||
'settings' => array(),
|
||||
'capability' => 'top_secret_clearance',
|
||||
)
|
||||
@@ -83,7 +94,9 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
|
||||
$this->assertFalse( $control->check_capabilities() );
|
||||
|
||||
$control = new WP_Customize_Control(
|
||||
$this->wp_customize, 'no_setting', array(
|
||||
$this->wp_customize,
|
||||
'no_setting',
|
||||
array(
|
||||
'settings' => array(),
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
|
||||
@@ -169,7 +169,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
|
||||
// Make sure that wp_update_custom_css_post() works as expected for updates.
|
||||
$r = wp_update_custom_css_post(
|
||||
'body { color:red; }', array(
|
||||
'body { color:red; }',
|
||||
array(
|
||||
'stylesheet' => $this->setting->stylesheet,
|
||||
'preprocessed' => "body\n\tcolor:red;",
|
||||
)
|
||||
@@ -185,7 +186,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
|
||||
// Make sure that wp_update_custom_css_post() works as expected for insertion.
|
||||
$r = wp_update_custom_css_post(
|
||||
'body { background:black; }', array(
|
||||
'body { background:black; }',
|
||||
array(
|
||||
'stylesheet' => 'other',
|
||||
)
|
||||
);
|
||||
@@ -214,7 +216,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
$updated_css = 'body { background: red; }';
|
||||
|
||||
$post = wp_update_custom_css_post(
|
||||
$inserted_css, array(
|
||||
$inserted_css,
|
||||
array(
|
||||
'stylesheet' => 'testtheme',
|
||||
)
|
||||
);
|
||||
@@ -225,7 +228,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
|
||||
$this->assertSame( $inserted_css, $revisions[0]->post_content );
|
||||
|
||||
wp_update_custom_css_post(
|
||||
$updated_css, array(
|
||||
$updated_css,
|
||||
array(
|
||||
'stylesheet' => 'testtheme',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -550,7 +550,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
add_theme_support( 'custom-background' );
|
||||
|
||||
$existing_canola_attachment_id = self::factory()->attachment->create_object(
|
||||
$this->test_file, 0, array(
|
||||
$this->test_file,
|
||||
0,
|
||||
array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
'post_type' => 'attachment',
|
||||
'post_name' => 'canola',
|
||||
@@ -985,12 +987,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
// Test saving with invalid settings, ensuring transaction blocked.
|
||||
$previous_saved_data = $saved_data;
|
||||
$manager->add_setting(
|
||||
'foo_unauthorized', array(
|
||||
'foo_unauthorized',
|
||||
array(
|
||||
'capability' => 'do_not_allow',
|
||||
)
|
||||
);
|
||||
$manager->add_setting(
|
||||
'baz_illegal', array(
|
||||
'baz_illegal',
|
||||
array(
|
||||
'validate_callback' => array( $this, 'return_illegal_error' ),
|
||||
)
|
||||
);
|
||||
@@ -1098,7 +1102,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
|
||||
do_action( 'customize_register', $wp_customize );
|
||||
$manager->add_setting(
|
||||
'scratchpad', array(
|
||||
'scratchpad',
|
||||
array(
|
||||
'type' => 'option',
|
||||
'capability' => 'exist',
|
||||
)
|
||||
@@ -1382,18 +1387,21 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
);
|
||||
do_action( 'customize_register', $manager );
|
||||
$manager->add_setting(
|
||||
'blogfounded', array(
|
||||
'blogfounded',
|
||||
array(
|
||||
'type' => 'option',
|
||||
)
|
||||
);
|
||||
$manager->add_setting(
|
||||
'blogterminated', array(
|
||||
'blogterminated',
|
||||
array(
|
||||
'type' => 'option',
|
||||
'capability' => 'do_not_allow',
|
||||
)
|
||||
);
|
||||
$manager->add_setting(
|
||||
'scratchpad', array(
|
||||
'scratchpad',
|
||||
array(
|
||||
'type' => 'option',
|
||||
'capability' => 'exist',
|
||||
)
|
||||
@@ -1898,7 +1906,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
*/
|
||||
function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'scratchpad', array(
|
||||
'scratchpad',
|
||||
array(
|
||||
'type' => 'option',
|
||||
'capability' => 'exist',
|
||||
'sanitize_callback' => array( $this, 'filter_sanitize_scratchpad' ),
|
||||
@@ -2194,7 +2203,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$default_value = 'foo_default';
|
||||
$setting = $this->manager->add_setting(
|
||||
'foo', array(
|
||||
'foo',
|
||||
array(
|
||||
'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
|
||||
'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
|
||||
)
|
||||
@@ -2262,7 +2272,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$default_value = '0';
|
||||
$setting = $this->manager->add_setting(
|
||||
'numeric', array(
|
||||
'numeric',
|
||||
array(
|
||||
'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
|
||||
'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
|
||||
)
|
||||
@@ -2308,7 +2319,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
function test_validate_setting_values() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$setting = $this->manager->add_setting(
|
||||
'foo', array(
|
||||
'foo',
|
||||
array(
|
||||
'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
|
||||
'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
|
||||
)
|
||||
@@ -2433,7 +2445,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
function test_validate_setting_values_validation_sanitization_order() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$setting = $this->manager->add_setting(
|
||||
'numeric', array(
|
||||
'numeric',
|
||||
array(
|
||||
'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
|
||||
'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
|
||||
)
|
||||
@@ -2477,7 +2490,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
function test_set_post_value() {
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$this->manager->add_setting(
|
||||
'foo', array(
|
||||
'foo',
|
||||
array(
|
||||
'sanitize_callback' => array( $this, 'sanitize_foo_for_test_set_post_value' ),
|
||||
)
|
||||
);
|
||||
@@ -2970,7 +2984,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$section_id = 'foo-section';
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$manager->add_section(
|
||||
$section_id, array(
|
||||
$section_id,
|
||||
array(
|
||||
'title' => 'Section',
|
||||
'priority' => 1,
|
||||
)
|
||||
@@ -2983,7 +2998,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$added_control_ids[] = $id;
|
||||
$manager->add_setting( $id );
|
||||
$control = new WP_Customize_Control(
|
||||
$manager, $id, array(
|
||||
$manager,
|
||||
$id,
|
||||
array(
|
||||
'section' => $section_id,
|
||||
'priority' => 1,
|
||||
'setting' => $id,
|
||||
@@ -3007,7 +3024,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
|
||||
$section_id = 'foo-section';
|
||||
$result_section = $manager->add_section(
|
||||
$section_id, array(
|
||||
$section_id,
|
||||
array(
|
||||
'title' => 'Section',
|
||||
'priority' => 1,
|
||||
)
|
||||
@@ -3017,7 +3035,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertEquals( $section_id, $result_section->id );
|
||||
|
||||
$section = new WP_Customize_Section(
|
||||
$manager, $section_id, array(
|
||||
$manager,
|
||||
$section_id,
|
||||
array(
|
||||
'title' => 'Section 2',
|
||||
'priority' => 2,
|
||||
)
|
||||
@@ -3109,7 +3129,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
|
||||
$panel_id = 'foo-panel';
|
||||
$result_panel = $manager->add_panel(
|
||||
$panel_id, array(
|
||||
$panel_id,
|
||||
array(
|
||||
'title' => 'Test Panel',
|
||||
'priority' => 2,
|
||||
)
|
||||
@@ -3119,7 +3140,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertEquals( $panel_id, $result_panel->id );
|
||||
|
||||
$panel = new WP_Customize_Panel(
|
||||
$manager, $panel_id, array(
|
||||
$manager,
|
||||
$panel_id,
|
||||
array(
|
||||
'title' => 'Test Panel 2',
|
||||
)
|
||||
);
|
||||
@@ -3138,7 +3161,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$section_id = 'foo-section';
|
||||
wp_set_current_user( self::$admin_user_id );
|
||||
$manager->add_section(
|
||||
$section_id, array(
|
||||
$section_id,
|
||||
array(
|
||||
'title' => 'Section',
|
||||
'priority' => 1,
|
||||
)
|
||||
@@ -3148,7 +3172,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$manager->add_setting( $control_id );
|
||||
|
||||
$result_control = $manager->add_control(
|
||||
$control_id, array(
|
||||
$control_id,
|
||||
array(
|
||||
'section' => $section_id,
|
||||
'priority' => 1,
|
||||
'setting' => $control_id,
|
||||
@@ -3158,7 +3183,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertEquals( $control_id, $result_control->id );
|
||||
|
||||
$control = new WP_Customize_Control(
|
||||
$manager, $control_id, array(
|
||||
$manager,
|
||||
$control_id,
|
||||
array(
|
||||
'section' => $section_id,
|
||||
'priority' => 1,
|
||||
'setting' => $control_id,
|
||||
@@ -3253,7 +3280,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
foreach ( $controls as $control_id => $priority ) {
|
||||
$this->manager->add_setting( $control_id );
|
||||
$this->manager->add_control(
|
||||
$control_id, array(
|
||||
$control_id,
|
||||
array(
|
||||
'priority' => $priority,
|
||||
'section' => 'foosection',
|
||||
)
|
||||
@@ -3282,7 +3310,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
|
||||
foreach ( $sections as $section_id => $priority ) {
|
||||
$this->manager->add_section(
|
||||
$section_id, array(
|
||||
$section_id,
|
||||
array(
|
||||
'priority' => $priority,
|
||||
)
|
||||
);
|
||||
@@ -3310,7 +3339,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
|
||||
foreach ( $panels as $panel_id => $priority ) {
|
||||
$this->manager->add_panel(
|
||||
$panel_id, array(
|
||||
$panel_id,
|
||||
array(
|
||||
'priority' => $priority,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -154,7 +154,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$menu_id = wp_create_nav_menu( 'Menu' );
|
||||
$item_title = 'Greetings';
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -179,7 +181,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
$other_menu_id = wp_create_nav_menu( 'Menu2' );
|
||||
wp_update_nav_menu_item(
|
||||
$other_menu_id, $item_id, array(
|
||||
$other_menu_id,
|
||||
$item_id,
|
||||
array(
|
||||
'menu-item-title' => 'Hola',
|
||||
)
|
||||
);
|
||||
@@ -201,7 +205,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Menu' );
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -231,7 +237,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$menu_id = wp_create_nav_menu( 'Menu' );
|
||||
$item_title = 'Greetings';
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'taxonomy',
|
||||
'menu-item-object' => 'category',
|
||||
'menu-item-object-id' => $tax_id,
|
||||
@@ -266,7 +274,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
$menu_id = wp_create_nav_menu( 'Menu' );
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'custom_type',
|
||||
'menu-item-object' => 'custom_object',
|
||||
'menu-item-title' => 'Cool beans',
|
||||
@@ -310,7 +320,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -343,7 +355,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
|
||||
$item_title = 'Greetings';
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$primary_menu_id, 0, array(
|
||||
$primary_menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $first_post_id,
|
||||
@@ -394,7 +408,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$item_ids = array();
|
||||
for ( $i = 0; $i < 5; $i += 1 ) {
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -451,7 +467,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$item_ids = array();
|
||||
for ( $i = 0; $i < 5; $i += 1 ) {
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -573,7 +591,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
$nav_menu_item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, wp_slash(
|
||||
$menu_id,
|
||||
0,
|
||||
wp_slash(
|
||||
array(
|
||||
'menu-item-object-id' => $unsanitized['object_id'],
|
||||
'menu-item-object' => $unsanitized['object'],
|
||||
@@ -625,7 +645,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$secondary_menu_id = wp_create_nav_menu( 'Secondary' );
|
||||
$item_title = 'Greetings';
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$primary_menu_id, 0, array(
|
||||
$primary_menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $first_post_id,
|
||||
@@ -690,7 +712,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$item_ids = array();
|
||||
for ( $i = 0; $i < 5; $i += 1 ) {
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -761,7 +785,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
$item_ids = array();
|
||||
for ( $i = 0; $i < 5; $i += 1 ) {
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -806,7 +832,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
function test_invalid_nav_menu_item() {
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
register_post_type(
|
||||
'poem', array(
|
||||
'poem',
|
||||
array(
|
||||
'public' => true,
|
||||
)
|
||||
);
|
||||
@@ -819,7 +846,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
);
|
||||
$post = get_post( $post_id );
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'poem',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -920,7 +949,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
function test_value_as_wp_post_nav_menu_item_term_urls() {
|
||||
$term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
|
||||
register_post_type(
|
||||
'press_release', array(
|
||||
'press_release',
|
||||
array(
|
||||
'has_archive' => true,
|
||||
)
|
||||
);
|
||||
@@ -932,7 +962,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'nav_menu_item[-1]'
|
||||
);
|
||||
$this->wp_customize->set_post_value(
|
||||
$setting->id, array(
|
||||
$setting->id,
|
||||
array(
|
||||
'type' => 'taxonomy',
|
||||
'object' => 'category',
|
||||
'object_id' => $term_id,
|
||||
@@ -950,7 +981,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'nav_menu_item[-2]'
|
||||
);
|
||||
$this->wp_customize->set_post_value(
|
||||
$setting->id, array(
|
||||
$setting->id,
|
||||
array(
|
||||
'type' => 'post_type',
|
||||
'object' => 'press_release',
|
||||
'object_id' => $post_id,
|
||||
@@ -968,7 +1000,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'nav_menu_item[-3]'
|
||||
);
|
||||
$this->wp_customize->set_post_value(
|
||||
$setting->id, array(
|
||||
$setting->id,
|
||||
array(
|
||||
'type' => 'post_type_archive',
|
||||
'object' => 'press_release',
|
||||
'title' => 'PR',
|
||||
@@ -989,7 +1022,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
function test_get_original_title() {
|
||||
$menu_id = wp_create_nav_menu( 'Menu' );
|
||||
register_post_type(
|
||||
'press_release', array(
|
||||
'press_release',
|
||||
array(
|
||||
'has_archive' => true,
|
||||
'labels' => array(
|
||||
'name' => 'PRs',
|
||||
@@ -1015,7 +1049,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
// Post: existing nav menu item.
|
||||
$nav_menu_item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-object-id' => $post_id,
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'press_release',
|
||||
@@ -1044,7 +1080,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'nav_menu_item[-1]'
|
||||
);
|
||||
$this->wp_customize->set_post_value(
|
||||
$setting->id, array(
|
||||
$setting->id,
|
||||
array(
|
||||
'object_id' => $post_id,
|
||||
'type' => 'post_type',
|
||||
'object' => 'press_release',
|
||||
@@ -1066,7 +1103,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
// Term: existing nav menu item.
|
||||
$nav_menu_item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-object-id' => $term_id,
|
||||
'menu-item-type' => 'taxonomy',
|
||||
'menu-item-object' => 'category',
|
||||
@@ -1095,7 +1134,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'nav_menu_item[-2]'
|
||||
);
|
||||
$this->wp_customize->set_post_value(
|
||||
$setting->id, array(
|
||||
$setting->id,
|
||||
array(
|
||||
'object_id' => $term_id,
|
||||
'type' => 'taxonomy',
|
||||
'object' => 'category',
|
||||
@@ -1117,7 +1157,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
|
||||
// Post Type Archive: existing nav menu item.
|
||||
$nav_menu_item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type_archive',
|
||||
'menu-item-object' => 'press_release',
|
||||
'menu-item-title' => '',
|
||||
@@ -1145,7 +1187,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
|
||||
'nav_menu_item[-3]'
|
||||
);
|
||||
$this->wp_customize->set_post_value(
|
||||
$setting->id, array(
|
||||
$setting->id,
|
||||
array(
|
||||
'type' => 'post_type_archive',
|
||||
'object' => 'press_release',
|
||||
'title' => '',
|
||||
|
||||
@@ -135,7 +135,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
$parent_menu_id = wp_create_nav_menu( wp_slash( "Parent $menu_name" ) );
|
||||
$description = 'Hello my world \\o/.';
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
0, wp_slash(
|
||||
0,
|
||||
wp_slash(
|
||||
array(
|
||||
'menu-name' => $menu_name,
|
||||
'parent' => $parent_menu_id,
|
||||
@@ -171,7 +172,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
0, wp_slash(
|
||||
0,
|
||||
wp_slash(
|
||||
array(
|
||||
'menu-name' => 'Name 1 \\o/',
|
||||
'description' => 'Description 1 \\o/',
|
||||
@@ -282,7 +284,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
0, wp_slash(
|
||||
0,
|
||||
wp_slash(
|
||||
array(
|
||||
'menu-name' => 'Name 1 \\o/',
|
||||
'description' => 'Description 1 \\o/',
|
||||
@@ -351,7 +354,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
|
||||
$menu_id = wp_update_nav_menu_object(
|
||||
0, wp_slash(
|
||||
0,
|
||||
wp_slash(
|
||||
array(
|
||||
'menu-name' => 'Name 1 \\o/',
|
||||
'description' => 'Description 1 \\o/',
|
||||
|
||||
@@ -426,7 +426,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
|
||||
if ( 'cat' === $args['s'] ) {
|
||||
array_unshift(
|
||||
$items, array(
|
||||
$items,
|
||||
array(
|
||||
'id' => 'home',
|
||||
'title' => 'COOL CAT!',
|
||||
'type' => 'custom',
|
||||
@@ -499,7 +500,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
$menu_id = wp_create_nav_menu( 'Primary' );
|
||||
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
|
||||
$item_id = wp_update_nav_menu_item(
|
||||
$menu_id, 0, array(
|
||||
$menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'post_type',
|
||||
'menu-item-object' => 'post',
|
||||
'menu-item-object-id' => $post_id,
|
||||
@@ -1138,7 +1141,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
|
||||
$menu = wp_create_nav_menu( 'Foo' );
|
||||
wp_update_nav_menu_item(
|
||||
$menu, 0, array(
|
||||
$menu,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'custom',
|
||||
'menu-item-title' => 'WordPress.org',
|
||||
'menu-item-url' => 'https://wordpress.org',
|
||||
|
||||
@@ -81,7 +81,9 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
|
||||
$this->assertTrue( $panel->active() );
|
||||
|
||||
$panel = new WP_Customize_Panel(
|
||||
$this->manager, 'foo', array(
|
||||
$this->manager,
|
||||
'foo',
|
||||
array(
|
||||
'active_callback' => '__return_false',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -116,7 +116,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
$this->assertContains( 'Lorem Ipsum', $partial->render() );
|
||||
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, $partial_id, array(
|
||||
$this->selective_refresh,
|
||||
$partial_id,
|
||||
array(
|
||||
'settings' => 'blogdescription',
|
||||
)
|
||||
);
|
||||
@@ -221,7 +223,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_render_with_bad_callback_should_give_preference_to_return_value() {
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'foo', array(
|
||||
$this->selective_refresh,
|
||||
'foo',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_echo_and_return' ),
|
||||
)
|
||||
);
|
||||
@@ -236,7 +240,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_render_echo_callback() {
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'foo', array(
|
||||
$this->selective_refresh,
|
||||
'foo',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_echo' ),
|
||||
)
|
||||
);
|
||||
@@ -257,7 +263,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_render_return_callback() {
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'foo', array(
|
||||
$this->selective_refresh,
|
||||
'foo',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_return' ),
|
||||
)
|
||||
);
|
||||
@@ -319,40 +327,51 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'blogname', array(
|
||||
$this->selective_refresh,
|
||||
'blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname' ),
|
||||
)
|
||||
);
|
||||
$this->assertTrue( $partial->check_capabilities() );
|
||||
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'blogname', array(
|
||||
$this->selective_refresh,
|
||||
'blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname', 'non_existing' ),
|
||||
)
|
||||
);
|
||||
$this->assertFalse( $partial->check_capabilities() );
|
||||
|
||||
$this->wp_customize->add_setting(
|
||||
'top_secret_message', array(
|
||||
'top_secret_message',
|
||||
array(
|
||||
'capability' => 'top_secret_clearance',
|
||||
)
|
||||
);
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'blogname', array(
|
||||
$this->selective_refresh,
|
||||
'blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname', 'top_secret_clearance' ),
|
||||
)
|
||||
);
|
||||
$this->assertFalse( $partial->check_capabilities() );
|
||||
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'no_setting', array(
|
||||
$this->selective_refresh,
|
||||
'no_setting',
|
||||
array(
|
||||
'settings' => array(),
|
||||
)
|
||||
);
|
||||
$this->assertTrue( $partial->check_capabilities() );
|
||||
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'no_setting', array(
|
||||
$this->selective_refresh,
|
||||
'no_setting',
|
||||
array(
|
||||
'settings' => array(),
|
||||
'capability' => 'top_secret_clearance',
|
||||
)
|
||||
@@ -360,7 +379,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
$this->assertFalse( $partial->check_capabilities() );
|
||||
|
||||
$partial = new WP_Customize_Partial(
|
||||
$this->selective_refresh, 'no_setting', array(
|
||||
$this->selective_refresh,
|
||||
'no_setting',
|
||||
array(
|
||||
'settings' => array(),
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
|
||||
@@ -90,7 +90,9 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
|
||||
$this->assertTrue( $section->active() );
|
||||
|
||||
$section = new WP_Customize_Section(
|
||||
$this->manager, 'foo', array(
|
||||
$this->manager,
|
||||
'foo',
|
||||
array(
|
||||
'active_callback' => '__return_false',
|
||||
)
|
||||
);
|
||||
|
||||
@@ -217,7 +217,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$this->wp_customize->add_setting(
|
||||
'secret_message', array(
|
||||
'secret_message',
|
||||
array(
|
||||
'capability' => 'top_secret_clearance',
|
||||
)
|
||||
);
|
||||
@@ -309,7 +310,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
|
||||
$this->wp_customize->selective_refresh->add_partial(
|
||||
'test_blogname', array(
|
||||
'test_blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname' ),
|
||||
'render_callback' => array( $this, 'render_callback_blogname' ),
|
||||
)
|
||||
@@ -462,13 +464,15 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
|
||||
$this->setup_valid_render_partials_request_environment();
|
||||
|
||||
$this->wp_customize->selective_refresh->add_partial(
|
||||
'test_blogname', array(
|
||||
'test_blogname',
|
||||
array(
|
||||
'settings' => array( 'blogname' ),
|
||||
'render_callback' => array( $this, 'render_callback_blogname' ),
|
||||
)
|
||||
);
|
||||
$this->wp_customize->selective_refresh->add_partial(
|
||||
'test_blogdescription', array(
|
||||
'test_blogdescription',
|
||||
array(
|
||||
'settings' => array( 'blogdescription' ),
|
||||
'render_callback' => array( $this, 'render_callback_blogdescription' ),
|
||||
)
|
||||
|
||||
@@ -143,17 +143,20 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$user->remove_cap( 'top_secret_clearance' );
|
||||
$this->wp_customize->add_setting(
|
||||
'top_secret_message', array(
|
||||
'top_secret_message',
|
||||
array(
|
||||
'capability' => 'top_secret_clearance', // The administrator role lacks this.
|
||||
)
|
||||
);
|
||||
$this->selective_refresh->add_partial(
|
||||
'blogname', array(
|
||||
'blogname',
|
||||
array(
|
||||
'selector' => '#site-title',
|
||||
)
|
||||
);
|
||||
$this->selective_refresh->add_partial(
|
||||
'top_secret_message', array(
|
||||
'top_secret_message',
|
||||
array(
|
||||
'settings' => array( 'top_secret_message' ),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -444,7 +444,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
// Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter.
|
||||
$setting_id = 'custom_without_previewing_value_filter';
|
||||
$setting = $this->manager->add_setting(
|
||||
$setting_id, array(
|
||||
$setting_id,
|
||||
array(
|
||||
'type' => 'custom_preview_test',
|
||||
'default' => 123,
|
||||
'sanitize_callback' => array( $this->manager->nav_menus, 'intval_base10' ),
|
||||
@@ -599,7 +600,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
|
||||
$name = 'autoloaded1';
|
||||
$setting = new WP_Customize_Setting(
|
||||
$this->manager, $name, array(
|
||||
$this->manager,
|
||||
$name,
|
||||
array(
|
||||
'type' => 'option',
|
||||
)
|
||||
);
|
||||
@@ -612,7 +615,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
|
||||
$name = 'autoloaded2';
|
||||
$setting = new WP_Customize_Setting(
|
||||
$this->manager, $name, array(
|
||||
$this->manager,
|
||||
$name,
|
||||
array(
|
||||
'type' => 'option',
|
||||
'autoload' => true,
|
||||
)
|
||||
@@ -626,7 +631,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
|
||||
$name = 'not-autoloaded1';
|
||||
$setting = new WP_Customize_Setting(
|
||||
$this->manager, $name, array(
|
||||
$this->manager,
|
||||
$name,
|
||||
array(
|
||||
'type' => 'option',
|
||||
'autoload' => false,
|
||||
)
|
||||
@@ -640,12 +647,16 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
|
||||
$id_base = 'multi-not-autoloaded';
|
||||
$setting1 = new WP_Customize_Setting(
|
||||
$this->manager, $id_base . '[foo]', array(
|
||||
$this->manager,
|
||||
$id_base . '[foo]',
|
||||
array(
|
||||
'type' => 'option',
|
||||
)
|
||||
);
|
||||
$setting2 = new WP_Customize_Setting(
|
||||
$this->manager, $id_base . '[bar]', array(
|
||||
$this->manager,
|
||||
$id_base . '[bar]',
|
||||
array(
|
||||
'type' => 'option',
|
||||
'autoload' => false,
|
||||
)
|
||||
@@ -695,7 +706,9 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_validate() {
|
||||
$setting = new WP_Customize_Setting(
|
||||
$this->manager, 'name', array(
|
||||
$this->manager,
|
||||
'name',
|
||||
array(
|
||||
'type' => 'key',
|
||||
'validate_callback' => array( $this, 'filter_validate_for_test_validate' ),
|
||||
)
|
||||
@@ -735,7 +748,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
|
||||
|
||||
$initial_value = 456;
|
||||
set_theme_mod(
|
||||
'nav_menu_locations', array(
|
||||
'nav_menu_locations',
|
||||
array(
|
||||
'primary' => $initial_value,
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user