Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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/manager.php

    r41839 r42343  
    4848    public static function wpSetUpBeforeClass( $factory ) {
    4949        self::$subscriber_user_id = $factory->user->create( array( 'role' => 'subscriber' ) );
    50         self::$admin_user_id = $factory->user->create( array( 'role' => 'administrator' ) );
     50        self::$admin_user_id      = $factory->user->create( array( 'role' => 'administrator' ) );
    5151    }
    5252
     
    5757        parent::setUp();
    5858        require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
    59         $this->manager = $this->instantiate();
     59        $this->manager   = $this->instantiate();
    6060        $this->undefined = new stdClass();
    6161
    62         $orig_file = DIR_TESTDATA . '/images/canola.jpg';
     62        $orig_file       = DIR_TESTDATA . '/images/canola.jpg';
    6363        $this->test_file = '/tmp/canola.jpg';
    6464        copy( $orig_file, $this->test_file );
    65         $orig_file2 = DIR_TESTDATA . '/images/waffles.jpg';
     65        $orig_file2       = DIR_TESTDATA . '/images/waffles.jpg';
    6666        $this->test_file2 = '/tmp/waffles.jpg';
    6767        copy( $orig_file2, $this->test_file2 );
     
    110110     */
    111111    function test_constructor() {
    112         $uuid = wp_generate_uuid4();
    113         $theme = 'twentyfifteen';
     112        $uuid              = wp_generate_uuid4();
     113        $theme             = 'twentyfifteen';
    114114        $messenger_channel = 'preview-123';
    115         $wp_customize = new WP_Customize_Manager( array(
    116             'changeset_uuid' => $uuid,
    117             'theme' => $theme,
    118             'messenger_channel' => $messenger_channel,
    119         ) );
     115        $wp_customize      = new WP_Customize_Manager(
     116            array(
     117                'changeset_uuid'    => $uuid,
     118                'theme'             => $theme,
     119                'messenger_channel' => $messenger_channel,
     120            )
     121        );
    120122        $this->assertEquals( $uuid, $wp_customize->changeset_uuid() );
    121123        $this->assertEquals( $theme, $wp_customize->get_stylesheet() );
     
    124126        $this->assertTrue( $wp_customize->branching() );
    125127
    126         $wp_customize = new WP_Customize_Manager( array(
    127             'changeset_uuid' => null,
    128         ) );
     128        $wp_customize = new WP_Customize_Manager(
     129            array(
     130                'changeset_uuid' => null,
     131            )
     132        );
    129133        $this->assertTrue( wp_is_uuid( $wp_customize->changeset_uuid(), 4 ) );
    130134
    131         $theme = 'twentyfourteen';
    132         $messenger_channel = 'preview-456';
    133         $_REQUEST['theme'] = $theme;
     135        $theme                                   = 'twentyfourteen';
     136        $messenger_channel                       = 'preview-456';
     137        $_REQUEST['theme']                       = $theme;
    134138        $_REQUEST['customize_messenger_channel'] = $messenger_channel;
    135         $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
     139        $wp_customize                            = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    136140        $this->assertEquals( $theme, $wp_customize->get_stylesheet() );
    137141        $this->assertEquals( $messenger_channel, $wp_customize->get_messenger_channel() );
    138142
    139         $theme = 'twentyfourteen';
     143        $theme                       = 'twentyfourteen';
    140144        $_REQUEST['customize_theme'] = $theme;
    141         $wp_customize = new WP_Customize_Manager();
     145        $wp_customize                = new WP_Customize_Manager();
    142146        $this->assertEquals( $theme, $wp_customize->get_stylesheet() );
    143147        $this->assertTrue( wp_is_uuid( $wp_customize->changeset_uuid(), 4 ) );
     
    162166
    163167        $uuid1 = wp_generate_uuid4();
    164         $this->factory()->post->create( array(
    165             'post_type' => 'customize_changeset',
    166             'post_name' => $uuid1,
    167             'post_status' => 'draft',
    168             'post_content' => wp_json_encode( $data ),
    169             'post_author' => get_current_user_id(),
    170             'post_date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '-2 days' ) ),
    171         ) );
     168        $this->factory()->post->create(
     169            array(
     170                'post_type'     => 'customize_changeset',
     171                'post_name'     => $uuid1,
     172                'post_status'   => 'draft',
     173                'post_content'  => wp_json_encode( $data ),
     174                'post_author'   => get_current_user_id(),
     175                'post_date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '-2 days' ) ),
     176            )
     177        );
    172178
    173179        /*
     
    175181         * as in non-branching mode there should only be one pending changeset at a time.
    176182         */
    177         $uuid2 = wp_generate_uuid4();
    178         $post_id = $this->factory()->post->create( array(
    179             'post_type' => 'customize_changeset',
    180             'post_name' => $uuid2,
    181             'post_status' => 'draft',
    182             'post_content' => wp_json_encode( $data ),
    183             'post_author' => $other_admin_user_id,
    184             'post_date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '-1 day' ) ),
    185         ) );
    186 
    187         $wp_customize = new WP_Customize_Manager( array(
    188             'changeset_uuid' => false, // Cause UUID to be deferred.
    189             'branching' => false, // To cause drafted changeset to be autoloaded.
    190         ) );
     183        $uuid2   = wp_generate_uuid4();
     184        $post_id = $this->factory()->post->create(
     185            array(
     186                'post_type'     => 'customize_changeset',
     187                'post_name'     => $uuid2,
     188                'post_status'   => 'draft',
     189                'post_content'  => wp_json_encode( $data ),
     190                'post_author'   => $other_admin_user_id,
     191                'post_date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '-1 day' ) ),
     192            )
     193        );
     194
     195        $wp_customize = new WP_Customize_Manager(
     196            array(
     197                'changeset_uuid' => false, // Cause UUID to be deferred.
     198                'branching'      => false, // To cause drafted changeset to be autoloaded.
     199            )
     200        );
    191201        $this->assertEquals( $uuid2, $wp_customize->changeset_uuid() );
    192202        $this->assertEquals( $post_id, $wp_customize->changeset_post_id() );
    193203
    194         $wp_customize = new WP_Customize_Manager( array(
    195             'changeset_uuid' => false, // Cause UUID to be deferred.
    196             'branching' => true, // To cause no drafted changeset to be autoloaded.
    197         ) );
     204        $wp_customize = new WP_Customize_Manager(
     205            array(
     206                'changeset_uuid' => false, // Cause UUID to be deferred.
     207                'branching'      => true, // To cause no drafted changeset to be autoloaded.
     208            )
     209        );
    198210        $this->assertNotContains( $wp_customize->changeset_uuid(), array( $uuid1, $uuid2 ) );
    199211        $this->assertEmpty( $wp_customize->changeset_post_id() );
     
    201213        // Make sure existing changeset is not autoloaded in the case of previewing a theme switch.
    202214        switch_theme( 'twentyseventeen' );
    203         $wp_customize = new WP_Customize_Manager( array(
    204             'changeset_uuid' => false, // Cause UUID to be deferred.
    205             'branching' => false,
    206             'theme' => 'twentyfifteen',
    207         ) );
     215        $wp_customize = new WP_Customize_Manager(
     216            array(
     217                'changeset_uuid' => false, // Cause UUID to be deferred.
     218                'branching'      => false,
     219                'theme'          => 'twentyfifteen',
     220            )
     221        );
    208222        $this->assertEmpty( $wp_customize->changeset_post_id() );
    209223    }
     
    220234
    221235        // Unauthorized.
    222         $exception = null;
     236        $exception    = null;
    223237        $wp_customize = new WP_Customize_Manager();
    224238        wp_set_current_user( self::$subscriber_user_id );
     
    289303
    290304        wp_set_current_user( 0 );
    291         $exception = null;
     305        $exception    = null;
    292306        $wp_customize = new WP_Customize_Manager();
    293307        wp_set_current_user( self::$subscriber_user_id );
     
    372386     */
    373387    function test_changeset_uuid() {
    374         $uuid = wp_generate_uuid4();
     388        $uuid         = wp_generate_uuid4();
    375389        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    376390        $this->assertEquals( $uuid, $wp_customize->changeset_uuid() );
     
    388402        wp_set_current_user( self::$admin_user_id );
    389403        $wp_customize = new WP_Customize_Manager();
    390         $title = 'Hello World';
     404        $title        = 'Hello World';
    391405        $wp_customize->set_post_value( 'blogname', $title );
    392406        $this->assertNotEquals( $title, get_option( 'blogname' ) );
     
    404418     */
    405419    function test_find_changeset_post_id() {
    406         $uuid = wp_generate_uuid4();
    407         $post_id = $this->factory()->post->create( array(
    408             'post_name' => $uuid,
    409             'post_type' => 'customize_changeset',
    410             'post_status' => 'auto-draft',
    411             'post_content' => '{}',
    412         ) );
     420        $uuid    = wp_generate_uuid4();
     421        $post_id = $this->factory()->post->create(
     422            array(
     423                'post_name'    => $uuid,
     424                'post_type'    => 'customize_changeset',
     425                'post_status'  => 'auto-draft',
     426                'post_content' => '{}',
     427            )
     428        );
    413429
    414430        $wp_customize = new WP_Customize_Manager();
     
    427443     */
    428444    function test_changeset_post_id() {
    429         $uuid = wp_generate_uuid4();
     445        $uuid         = wp_generate_uuid4();
    430446        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    431447        $this->assertNull( $wp_customize->changeset_post_id() );
    432448
    433         $uuid = wp_generate_uuid4();
     449        $uuid         = wp_generate_uuid4();
    434450        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    435         $post_id = $this->factory()->post->create( array(
    436             'post_name' => $uuid,
    437             'post_type' => 'customize_changeset',
    438             'post_status' => 'auto-draft',
    439             'post_content' => '{}',
    440         ) );
     451        $post_id      = $this->factory()->post->create(
     452            array(
     453                'post_name'    => $uuid,
     454                'post_type'    => 'customize_changeset',
     455                'post_status'  => 'auto-draft',
     456                'post_content' => '{}',
     457            )
     458        );
    441459        $this->assertEquals( $post_id, $wp_customize->changeset_post_id() );
    442460    }
     
    450468    function test_changeset_data() {
    451469        wp_set_current_user( self::$admin_user_id );
    452         $uuid = wp_generate_uuid4();
     470        $uuid         = wp_generate_uuid4();
    453471        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    454472        $this->assertEquals( array(), $wp_customize->changeset_data() );
     
    456474        $uuid = wp_generate_uuid4();
    457475        $data = array(
    458             'blogname' => array( 'value' => 'Hello World' ),
     476            'blogname'        => array( 'value' => 'Hello World' ),
    459477            'blogdescription' => array( 'value' => 'Greet the world' ),
    460478        );
    461         $this->factory()->post->create( array(
    462             'post_name' => $uuid,
    463             'post_type' => 'customize_changeset',
    464             'post_status' => 'draft',
    465             'post_content' => wp_json_encode( $data ),
    466         ) );
     479        $this->factory()->post->create(
     480            array(
     481                'post_name'    => $uuid,
     482                'post_type'    => 'customize_changeset',
     483                'post_status'  => 'draft',
     484                'post_content' => wp_json_encode( $data ),
     485            )
     486        );
    467487        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    468488        $this->assertEquals( $data, $wp_customize->changeset_data() );
     
    471491        $wp_customize->set_post_value( 'blogname', 'Hola Mundo' );
    472492        $wp_customize->register_controls(); // That is, settings, so blogname setting is registered.
    473         $r = $wp_customize->save_changeset_post( array(
    474             'autosave' => true,
    475         ) );
     493        $r = $wp_customize->save_changeset_post(
     494            array(
     495                'autosave' => true,
     496            )
     497        );
    476498        $this->assertNotInstanceOf( 'WP_Error', $r );
    477499
    478500        // No change to data if not requesting autosave.
    479         $wp_customize = new WP_Customize_Manager( array(
    480             'changeset_uuid' => $uuid,
    481             'autosaved' => false,
    482         ) );
     501        $wp_customize = new WP_Customize_Manager(
     502            array(
     503                'changeset_uuid' => $uuid,
     504                'autosaved'      => false,
     505            )
     506        );
    483507        $wp_customize->register_controls(); // That is, settings.
    484508        $this->assertFalse( $wp_customize->autosaved() );
     
    486510
    487511        // No change to data if not requesting autosave.
    488         $wp_customize = new WP_Customize_Manager( array(
    489             'changeset_uuid' => $uuid,
    490             'autosaved' => true,
    491         ) );
     512        $wp_customize = new WP_Customize_Manager(
     513            array(
     514                'changeset_uuid' => $uuid,
     515                'autosaved'      => true,
     516            )
     517        );
    492518        $this->assertTrue( $wp_customize->autosaved() );
    493519        $this->assertNotEquals( $data, $wp_customize->changeset_data() );
     
    514540        add_theme_support( 'custom-background' );
    515541
    516         $existing_canola_attachment_id = self::factory()->attachment->create_object( $this->test_file, 0, array(
    517             'post_mime_type' => 'image/jpeg',
    518             'post_type' => 'attachment',
    519             'post_name' => 'canola',
    520         ) );
    521         $existing_published_home_page_id = $this->factory()->post->create( array(
    522             'post_name' => 'home',
    523             'post_type' => 'page',
    524             'post_status' => 'publish'
    525         ) );
    526         $existing_auto_draft_about_page_id = $this->factory()->post->create( array(
    527             'post_name' => 'about',
    528             'post_type' => 'page',
    529             'post_status' => 'auto-draft'
    530         ) );
     542        $existing_canola_attachment_id     = self::factory()->attachment->create_object(
     543            $this->test_file, 0, array(
     544                'post_mime_type' => 'image/jpeg',
     545                'post_type'      => 'attachment',
     546                'post_name'      => 'canola',
     547            )
     548        );
     549        $existing_published_home_page_id   = $this->factory()->post->create(
     550            array(
     551                'post_name'   => 'home',
     552                'post_type'   => 'page',
     553                'post_status' => 'publish',
     554            )
     555        );
     556        $existing_auto_draft_about_page_id = $this->factory()->post->create(
     557            array(
     558                'post_name'   => 'about',
     559                'post_type'   => 'page',
     560                'post_status' => 'auto-draft',
     561            )
     562        );
    531563
    532564        global $wp_customize;
    533         $wp_customize = new WP_Customize_Manager();
     565        $wp_customize           = new WP_Customize_Manager();
    534566        $starter_content_config = array(
    535             'widgets' => array(
     567            'widgets'     => array(
    536568                'sidebar-1' => array(
    537569                    'text_business_info',
    538                     'meta_custom' => array( 'meta', array(
    539                         'title' => 'Pre-hydrated meta widget.',
    540                     ) ),
     570                    'meta_custom' => array(
     571                        'meta',
     572                        array(
     573                            'title' => 'Pre-hydrated meta widget.',
     574                        ),
     575                    ),
    541576                ),
    542577            ),
    543             'nav_menus' => array(
     578            'nav_menus'   => array(
    544579                'top' => array(
    545580                    'name'  => 'Menu Name',
     
    552587                        'link_custom' => array(
    553588                            'title' => 'Custom',
    554                             'url' => 'https://custom.example.com/',
     589                            'url'   => 'https://custom.example.com/',
    555590                        ),
    556591                    ),
    557592                ),
    558593            ),
    559             'posts' => array(
     594            'posts'       => array(
    560595                'home',
    561                 'about' => array(
     596                'about'       => array(
    562597                    'template' => 'sample-page-template.php',
    563598                ),
    564599                'blog',
    565                 'custom' => array(
    566                     'post_type' => 'post',
     600                'custom'      => array(
     601                    'post_type'  => 'post',
    567602                    'post_title' => 'Custom',
    568                     'thumbnail' => '{{waffles}}',
     603                    'thumbnail'  => '{{waffles}}',
    569604                ),
    570605                'unknown_cpt' => array(
    571                     'post_type' => 'unknown_cpt',
     606                    'post_type'  => 'unknown_cpt',
    572607                    'post_title' => 'Unknown CPT',
    573608                ),
     
    575610            'attachments' => array(
    576611                'waffles' => array(
    577                     'post_title' => 'Waffles',
     612                    'post_title'   => 'Waffles',
    578613                    'post_content' => 'Waffles Attachment Description',
    579614                    'post_excerpt' => 'Waffles Attachment Caption',
    580                     'file' => $this->test_file2,
     615                    'file'         => $this->test_file2,
    581616                ),
    582                 'canola' => array(
    583                     'post_title' => 'Canola',
     617                'canola'  => array(
     618                    'post_title'   => 'Canola',
    584619                    'post_content' => 'Canola Attachment Description',
    585620                    'post_excerpt' => 'Canola Attachment Caption',
    586                     'file' => $this->test_file,
     621                    'file'         => $this->test_file,
    587622                ),
    588623            ),
    589             'options' => array(
    590                 'blogname' => 'Starter Content Title',
     624            'options'     => array(
     625                'blogname'        => 'Starter Content Title',
    591626                'blogdescription' => 'Starter Content Tagline',
    592                 'show_on_front'  => 'page',
    593                 'page_on_front'  => '{{home}}',
    594                 'page_for_posts' => '{{blog}}',
     627                'show_on_front'   => 'page',
     628                'page_on_front'   => '{{home}}',
     629                'page_for_posts'  => '{{blog}}',
    595630            ),
    596             'theme_mods' => array(
    597                 'custom_logo' => '{{canola}}',
    598                 'header_image' => '{{waffles}}',
     631            'theme_mods'  => array(
     632                'custom_logo'      => '{{canola}}',
     633                'header_image'     => '{{waffles}}',
    599634                'background_image' => '{{waffles}}',
    600635            ),
     
    605640        $this->assertEmpty( $wp_customize->unsanitized_post_values() );
    606641        $wp_customize->import_theme_starter_content();
    607         $changeset_values = $wp_customize->unsanitized_post_values();
     642        $changeset_values     = $wp_customize->unsanitized_post_values();
    608643        $expected_setting_ids = array(
    609644            'blogname',
     
    698733
    699734        // Test that saving non-starter content on top of the changeset clears the starter_content flag.
    700         $wp_customize->save_changeset_post( array(
    701             'data' => array(
    702                 'blogname' => array( 'value' => 'Starter Content Modified' ),
    703             ),
    704         ) );
     735        $wp_customize->save_changeset_post(
     736            array(
     737                'data' => array(
     738                    'blogname' => array( 'value' => 'Starter Content Modified' ),
     739                ),
     740            )
     741        );
    705742        $changeset_data = $wp_customize->changeset_data();
    706743        $this->assertArrayNotHasKey( 'starter_content', $changeset_data['blogname'] );
     
    708745
    709746        // Test that adding blogname starter content is ignored now that it is modified, but updating a non-modified starter content blog description passes.
    710         $previous_blogname = $changeset_data['blogname']['value'];
     747        $previous_blogname        = $changeset_data['blogname']['value'];
    711748        $previous_blogdescription = $changeset_data['blogdescription']['value'];
    712         $wp_customize->import_theme_starter_content( array(
    713             'options' => array(
    714                 'blogname' => 'Newer Starter Content Title',
    715                 'blogdescription' => 'Newer Starter Content Description',
    716             ),
    717         ) );
     749        $wp_customize->import_theme_starter_content(
     750            array(
     751                'options' => array(
     752                    'blogname'        => 'Newer Starter Content Title',
     753                    'blogdescription' => 'Newer Starter Content Description',
     754                ),
     755            )
     756        );
    718757        $changeset_data = $wp_customize->changeset_data();
    719758        $this->assertEquals( $previous_blogname, $changeset_data['blogname']['value'] );
     
    761800        wp_set_current_user( self::$admin_user_id );
    762801        $did_action_customize_preview_init = did_action( 'customize_preview_init' );
    763         $wp_customize = new WP_Customize_Manager();
     802        $wp_customize                      = new WP_Customize_Manager();
    764803        $wp_customize->customize_preview_init();
    765804        $this->assertEquals( $did_action_customize_preview_init + 1, did_action( 'customize_preview_init' ) );
     
    784823        wp_set_current_user( self::$subscriber_user_id );
    785824        $wp_customize = new WP_Customize_Manager( array( 'messenger_channel' => 'preview-0' ) );
    786         $exception = null;
     825        $exception    = null;
    787826        try {
    788827            $wp_customize->customize_preview_init();
     
    802841    function test_filter_iframe_security_headers() {
    803842        $customize_url = admin_url( 'customize.php' );
    804         $wp_customize = new WP_Customize_Manager();
    805         $headers = $wp_customize->filter_iframe_security_headers( array() );
     843        $wp_customize  = new WP_Customize_Manager();
     844        $headers       = $wp_customize->filter_iframe_security_headers( array() );
    806845        $this->assertArrayHasKey( 'X-Frame-Options', $headers );
    807846        $this->assertArrayHasKey( 'Content-Security-Policy', $headers );
     
    818857        $preview_theme = $this->get_inactive_core_theme();
    819858
    820         $uuid = wp_generate_uuid4();
     859        $uuid              = wp_generate_uuid4();
    821860        $messenger_channel = 'preview-0';
    822         $wp_customize = new WP_Customize_Manager( array(
    823             'changeset_uuid' => $uuid,
    824             'messenger_channel' => $messenger_channel,
    825         ) );
    826         $url = $wp_customize->add_state_query_params( home_url( '/' ) );
    827         $parsed_url = wp_parse_url( $url );
     861        $wp_customize      = new WP_Customize_Manager(
     862            array(
     863                'changeset_uuid'    => $uuid,
     864                'messenger_channel' => $messenger_channel,
     865            )
     866        );
     867        $url               = $wp_customize->add_state_query_params( home_url( '/' ) );
     868        $parsed_url        = wp_parse_url( $url );
    828869        parse_str( $parsed_url['query'], $query_params );
    829870        $this->assertArrayHasKey( 'customize_messenger_channel', $query_params );
     
    833874        $this->assertEquals( $messenger_channel, $query_params['customize_messenger_channel'] );
    834875
    835         $uuid = wp_generate_uuid4();
    836         $wp_customize = new WP_Customize_Manager( array(
    837             'changeset_uuid' => $uuid,
    838             'messenger_channel' => null,
    839             'theme' => $preview_theme,
    840         ) );
    841         $url = $wp_customize->add_state_query_params( home_url( '/' ) );
    842         $parsed_url = wp_parse_url( $url );
     876        $uuid         = wp_generate_uuid4();
     877        $wp_customize = new WP_Customize_Manager(
     878            array(
     879                'changeset_uuid'    => $uuid,
     880                'messenger_channel' => null,
     881                'theme'             => $preview_theme,
     882            )
     883        );
     884        $url          = $wp_customize->add_state_query_params( home_url( '/' ) );
     885        $parsed_url   = wp_parse_url( $url );
    843886        parse_str( $parsed_url['query'], $query_params );
    844887        $this->assertArrayNotHasKey( 'customize_messenger_channel', $query_params );
     
    848891        $this->assertEquals( $preview_theme, $query_params['customize_theme'] );
    849892
    850         $uuid = wp_generate_uuid4();
    851         $wp_customize = new WP_Customize_Manager( array(
    852             'changeset_uuid' => $uuid,
    853             'messenger_channel' => null,
    854             'theme' => $preview_theme,
    855         ) );
    856         $url = $wp_customize->add_state_query_params( 'http://not-allowed.example.com/?q=1' );
    857         $parsed_url = wp_parse_url( $url );
     893        $uuid         = wp_generate_uuid4();
     894        $wp_customize = new WP_Customize_Manager(
     895            array(
     896                'changeset_uuid'    => $uuid,
     897                'messenger_channel' => null,
     898                'theme'             => $preview_theme,
     899            )
     900        );
     901        $url          = $wp_customize->add_state_query_params( 'http://not-allowed.example.com/?q=1' );
     902        $parsed_url   = wp_parse_url( $url );
    858903        parse_str( $parsed_url['query'], $query_params );
    859904        $this->assertArrayNotHasKey( 'customize_messenger_channel', $query_params );
     
    874919        $did_action = array(
    875920            'customize_save_validation_before' => did_action( 'customize_save_validation_before' ),
    876             'customize_save' => did_action( 'customize_save' ),
    877             'customize_save_after' => did_action( 'customize_save_after' ),
    878         );
    879         $uuid = wp_generate_uuid4();
    880 
    881         $wp_customize = $manager = new WP_Customize_Manager( array(
    882             'changeset_uuid' => $uuid,
    883         ) );
     921            'customize_save'                   => did_action( 'customize_save' ),
     922            'customize_save_after'             => did_action( 'customize_save_after' ),
     923        );
     924        $uuid       = wp_generate_uuid4();
     925
     926        $wp_customize = $manager = new WP_Customize_Manager(
     927            array(
     928                'changeset_uuid' => $uuid,
     929            )
     930        );
    884931        $wp_customize = $manager;
    885932        $manager->register_controls();
     
    888935
    889936        $pre_saved_data = array(
    890             'blogname' => array(
     937            'blogname'        => array(
    891938                'value' => 'Overridden Changeset Title',
    892939            ),
     
    895942            ),
    896943        );
    897         $date = ( gmdate( 'Y' ) + 1 ) . '-12-01 00:00:00';
    898         $r = $manager->save_changeset_post( array(
    899             'status' => 'auto-draft',
    900             'title' => 'Auto Draft',
    901             'date_gmt' => $date,
    902             'data' => $pre_saved_data,
    903         ) );
     944        $date           = ( gmdate( 'Y' ) + 1 ) . '-12-01 00:00:00';
     945        $r              = $manager->save_changeset_post(
     946            array(
     947                'status'   => 'auto-draft',
     948                'title'    => 'Auto Draft',
     949                'date_gmt' => $date,
     950                'data'     => $pre_saved_data,
     951            )
     952        );
    904953        $this->assertInternalType( 'array', $r );
    905954
     
    926975        // Test saving with invalid settings, ensuring transaction blocked.
    927976        $previous_saved_data = $saved_data;
    928         $manager->add_setting( 'foo_unauthorized', array(
    929             'capability' => 'do_not_allow',
    930         ) );
    931         $manager->add_setting( 'baz_illegal', array(
    932             'validate_callback' => array( $this, 'return_illegal_error' ),
    933         ) );
    934         $r = $manager->save_changeset_post( array(
    935             'status' => 'auto-draft',
    936             'data' => array(
    937                 'blogname' => array(
    938                     'value' => 'OK',
     977        $manager->add_setting(
     978            'foo_unauthorized', array(
     979                'capability' => 'do_not_allow',
     980            )
     981        );
     982        $manager->add_setting(
     983            'baz_illegal', array(
     984                'validate_callback' => array( $this, 'return_illegal_error' ),
     985            )
     986        );
     987        $r = $manager->save_changeset_post(
     988            array(
     989                'status' => 'auto-draft',
     990                'data'   => array(
     991                    'blogname'         => array(
     992                        'value' => 'OK',
     993                    ),
     994                    'foo_unauthorized' => array(
     995                        'value' => 'No',
     996                    ),
     997                    'bar_unknown'      => array(
     998                        'value' => 'No',
     999                    ),
     1000                    'baz_illegal'      => array(
     1001                        'value' => 'No',
     1002                    ),
    9391003                ),
    940                 'foo_unauthorized' => array(
    941                     'value' => 'No',
    942                 ),
    943                 'bar_unknown' => array(
    944                     'value' => 'No',
    945                 ),
    946                 'baz_illegal' => array(
    947                     'value' => 'No',
    948                 ),
    949             ),
    950         ) );
     1004            )
     1005        );
    9511006        $this->assertInstanceOf( 'WP_Error', $r );
    9521007        $this->assertEquals( 'transaction_fail', $r->get_error_code() );
     
    9701025
    9711026        // Attempt a non-transactional/incremental update.
    972         $wp_customize = $manager = new WP_Customize_Manager( array(
    973             'changeset_uuid' => $uuid,
    974         ) );
     1027        $wp_customize = $manager = new WP_Customize_Manager(
     1028            array(
     1029                'changeset_uuid' => $uuid,
     1030            )
     1031        );
    9751032        $wp_customize = $manager;
    9761033        $manager->register_controls(); // That is, register settings.
    977         $r = $manager->save_changeset_post( array(
    978             'status' => null,
    979             'data' => array(
    980                 'blogname' => array(
    981                     'value' => 'Non-Transactional \o/ <script>unsanitized</script>',
     1034        $r = $manager->save_changeset_post(
     1035            array(
     1036                'status' => null,
     1037                'data'   => array(
     1038                    'blogname'    => array(
     1039                        'value' => 'Non-Transactional \o/ <script>unsanitized</script>',
     1040                    ),
     1041                    'bar_unknown' => array(
     1042                        'value' => 'No',
     1043                    ),
    9821044                ),
    983                 'bar_unknown' => array(
    984                     'value' => 'No',
    985                 ),
    986             ),
    987         ) );
     1045            )
     1046        );
    9881047        $this->assertInternalType( 'array', $r );
    9891048        $this->assertArrayHasKey( 'setting_validities', $r );
     
    9971056        $customize_changeset_save_data_call_count = $this->customize_changeset_save_data_call_count;
    9981057        add_filter( 'customize_changeset_save_data', array( $this, 'filter_customize_changeset_save_data' ), 10, 2 );
    999         $manager->save_changeset_post( array(
    1000             'status' => null,
    1001             'data' => array(
    1002                 'blogname' => array(
    1003                     'value' => 'Filtered',
     1058        $manager->save_changeset_post(
     1059            array(
     1060                'status' => null,
     1061                'data'   => array(
     1062                    'blogname' => array(
     1063                        'value' => 'Filtered',
     1064                    ),
    10041065                ),
    1005             ),
    1006         ) );
     1066            )
     1067        );
    10071068        $this->assertEquals( $customize_changeset_save_data_call_count + 1, $this->customize_changeset_save_data_call_count );
    10081069
    10091070        // Publish the changeset: actions will be doubled since also trashed.
    10101071        $expected_actions = array(
    1011             'wp_trash_post' => 1,
    1012             'clean_post_cache' => 2,
    1013             'transition_post_status' => 2,
    1014             'publish_to_trash' => 1,
    1015             'trash_customize_changeset' => 1,
    1016             'edit_post' => 2,
     1072            'wp_trash_post'                 => 1,
     1073            'clean_post_cache'              => 2,
     1074            'transition_post_status'        => 2,
     1075            'publish_to_trash'              => 1,
     1076            'trash_customize_changeset'     => 1,
     1077            'edit_post'                     => 2,
    10171078            'save_post_customize_changeset' => 2,
    1018             'save_post' => 2,
    1019             'wp_insert_post' => 2,
    1020             'trashed_post' => 1,
    1021         );
    1022         $action_counts = array();
     1079            'save_post'                     => 2,
     1080            'wp_insert_post'                => 2,
     1081            'trashed_post'                  => 1,
     1082        );
     1083        $action_counts    = array();
    10231084        foreach ( array_keys( $expected_actions ) as $action_name ) {
    10241085            $action_counts[ $action_name ] = did_action( $action_name );
     
    10271088        $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    10281089        do_action( 'customize_register', $wp_customize );
    1029         $manager->add_setting( 'scratchpad', array(
    1030             'type' => 'option',
    1031             'capability' => 'exist',
    1032         ) );
     1090        $manager->add_setting(
     1091            'scratchpad', array(
     1092                'type'       => 'option',
     1093                'capability' => 'exist',
     1094            )
     1095        );
    10331096        $manager->get_setting( 'blogname' )->capability = 'exist';
    1034         $original_capabilities = wp_list_pluck( $manager->settings(), 'capability' );
     1097        $original_capabilities                          = wp_list_pluck( $manager->settings(), 'capability' );
    10351098        wp_set_current_user( self::$subscriber_user_id );
    1036         $r = $manager->save_changeset_post( array(
    1037             'status' => 'publish',
    1038             'data' => array(
    1039                 'blogname' => array(
    1040                     'value' => 'Do it live \o/',
     1099        $r = $manager->save_changeset_post(
     1100            array(
     1101                'status' => 'publish',
     1102                'data'   => array(
     1103                    'blogname'   => array(
     1104                        'value' => 'Do it live \o/',
     1105                    ),
     1106                    'scratchpad' => array(
     1107                        'value' => '<script>console.info( "HELLO" )</script>',
     1108                    ),
    10411109                ),
    1042                 'scratchpad' => array(
    1043                     'value' => '<script>console.info( "HELLO" )</script>',
    1044                 ),
    1045             ),
    1046         ) );
     1110            )
     1111        );
    10471112        $this->assertInternalType( 'array', $r );
    10481113        $this->assertEquals( 'Do it live \o/', get_option( 'blogname' ) );
     
    10611126        // Test revisions.
    10621127        add_post_type_support( 'customize_changeset', 'revisions' );
    1063         $uuid = wp_generate_uuid4();
     1128        $uuid         = wp_generate_uuid4();
    10641129        $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
    10651130        do_action( 'customize_register', $manager );
     
    11281193        wp_set_current_user( self::$admin_user_id );
    11291194
    1130         $preview_theme = $this->get_inactive_core_theme();
     1195        $preview_theme      = $this->get_inactive_core_theme();
    11311196        $stashed_theme_mods = array(
    11321197            $preview_theme => array(
     
    11371202        );
    11381203        update_option( 'customize_stashed_theme_mods', $stashed_theme_mods );
    1139         $uuid = wp_generate_uuid4();
    1140         $manager = new WP_Customize_Manager( array(
    1141             'changeset_uuid' => $uuid,
    1142             'theme' => $preview_theme,
    1143         ) );
     1204        $uuid         = wp_generate_uuid4();
     1205        $manager      = new WP_Customize_Manager(
     1206            array(
     1207                'changeset_uuid' => $uuid,
     1208                'theme'          => $preview_theme,
     1209            )
     1210        );
    11441211        $wp_customize = $manager;
    11451212        do_action( 'customize_register', $manager );
     
    11671234        $other_admin_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    11681235
    1169         $uuid = wp_generate_uuid4();
     1236        $uuid         = wp_generate_uuid4();
    11701237        $wp_customize = $this->create_test_manager( $uuid );
    1171         $r = $wp_customize->save_changeset_post( array(
    1172             'status' => 'auto-draft',
    1173             'data' => array(
    1174                 'blogname' => array(
    1175                     'value' => 'Admin 1 Title',
     1238        $r            = $wp_customize->save_changeset_post(
     1239            array(
     1240                'status' => 'auto-draft',
     1241                'data'   => array(
     1242                    'blogname'         => array(
     1243                        'value' => 'Admin 1 Title',
     1244                    ),
     1245                    'scratchpad'       => array(
     1246                        'value' => 'Admin 1 Scratch',
     1247                    ),
     1248                    'background_color' => array(
     1249                        'value' => '#000000',
     1250                    ),
    11761251                ),
    1177                 'scratchpad' => array(
    1178                     'value' => 'Admin 1 Scratch',
    1179                 ),
    1180                 'background_color' => array(
    1181                     'value' => '#000000',
    1182                 ),
    1183             ),
    1184         ) );
     1252            )
     1253        );
    11851254        $this->assertInternalType( 'array', $r );
    11861255        $this->assertEquals(
     
    11891258        );
    11901259        $post_id = $wp_customize->find_changeset_post_id( $uuid );
    1191         $data = json_decode( get_post( $post_id )->post_content, true );
     1260        $data    = json_decode( get_post( $post_id )->post_content, true );
    11921261        $this->assertEquals( self::$admin_user_id, $data['blogname']['user_id'] );
    11931262        $this->assertEquals( self::$admin_user_id, $data['scratchpad']['user_id'] );
     
    11971266        wp_set_current_user( $other_admin_user_id );
    11981267        $wp_customize = $this->create_test_manager( $uuid );
    1199         $r = $wp_customize->save_changeset_post( array(
    1200             'status' => 'auto-draft',
    1201             'data' => array(
    1202                 'blogname' => array(
    1203                     'value' => 'Admin 2 Title',
     1268        $r            = $wp_customize->save_changeset_post(
     1269            array(
     1270                'status' => 'auto-draft',
     1271                'data'   => array(
     1272                    'blogname'         => array(
     1273                        'value' => 'Admin 2 Title',
     1274                    ),
     1275                    'background_color' => array(
     1276                        'value' => '#FFFFFF',
     1277                    ),
    12041278                ),
    1205                 'background_color' => array(
    1206                     'value' => '#FFFFFF',
    1207                 ),
    1208             ),
    1209         ) );
     1279            )
     1280        );
    12101281        $this->assertInternalType( 'array', $r );
    12111282        $this->assertEquals(
     
    12231294        // Attempt to save now as under-privileged user.
    12241295        $wp_customize = $this->create_test_manager( $uuid );
    1225         $r = $wp_customize->save_changeset_post( array(
    1226             'status' => 'auto-draft',
    1227             'data' => array(
    1228                 'blogname' => array(
    1229                     'value' => 'Admin 2 Title', // Identical to what is already in the changeset so will be skipped.
     1296        $r            = $wp_customize->save_changeset_post(
     1297            array(
     1298                'status'  => 'auto-draft',
     1299                'data'    => array(
     1300                    'blogname'   => array(
     1301                        'value' => 'Admin 2 Title', // Identical to what is already in the changeset so will be skipped.
     1302                    ),
     1303                    'scratchpad' => array(
     1304                        'value' => 'Subscriber Scratch',
     1305                    ),
    12301306                ),
    1231                 'scratchpad' => array(
    1232                     'value' => 'Subscriber Scratch',
    1233                 ),
    1234             ),
    1235             'user_id' => self::$subscriber_user_id,
    1236         ) );
     1307                'user_id' => self::$subscriber_user_id,
     1308            )
     1309        );
    12371310        $this->assertInternalType( 'array', $r );
    12381311        $this->assertEquals(
     
    12461319
    12471320        // Manually update the changeset so that the user_id context is not included.
    1248         $data = json_decode( get_post( $post_id )->post_content, true );
     1321        $data                             = json_decode( get_post( $post_id )->post_content, true );
    12491322        $data['blogdescription']['value'] = 'Programmatically-supplied Tagline';
    1250         wp_update_post( wp_slash( array( 'ID' => $post_id, 'post_content' => wp_json_encode( $data ) ) ) );
     1323        wp_update_post(
     1324            wp_slash(
     1325                array(
     1326                    'ID'           => $post_id,
     1327                    'post_content' => wp_json_encode( $data ),
     1328                )
     1329            )
     1330        );
    12511331
    12521332        // Ensure the modifying user set as the current user when each is saved, simulating WP Cron envronment.
     
    12541334        $save_counts = array();
    12551335        foreach ( array_keys( $data ) as $setting_id ) {
    1256             $setting_id = preg_replace( '/^.+::/', '', $setting_id );
     1336            $setting_id                 = preg_replace( '/^.+::/', '', $setting_id );
    12571337            $save_counts[ $setting_id ] = did_action( sprintf( 'customize_save_%s', $setting_id ) );
    12581338        }
     
    12611341            add_filter( sprintf( 'customize_sanitize_%s', $setting->id ), array( $this, 'filter_customize_setting_to_log_current_user' ), 10, 2 );
    12621342        }
    1263         wp_update_post( array( 'ID' => $post_id, 'post_status' => 'publish' ) );
     1343        wp_update_post(
     1344            array(
     1345                'ID'          => $post_id,
     1346                'post_status' => 'publish',
     1347            )
     1348        );
    12641349        foreach ( array_keys( $data ) as $setting_id ) {
    12651350            $setting_id = preg_replace( '/^.+::/', '', $setting_id );
     
    12811366     */
    12821367    protected function create_test_manager( $uuid ) {
    1283         $manager = new WP_Customize_Manager( array(
    1284             'changeset_uuid' => $uuid,
    1285         ) );
     1368        $manager = new WP_Customize_Manager(
     1369            array(
     1370                'changeset_uuid' => $uuid,
     1371            )
     1372        );
    12861373        do_action( 'customize_register', $manager );
    1287         $manager->add_setting( 'blogfounded', array(
    1288             'type' => 'option',
    1289         ) );
    1290         $manager->add_setting( 'blogterminated', array(
    1291             'type' => 'option',
    1292             'capability' => 'do_not_allow',
    1293         ) );
    1294         $manager->add_setting( 'scratchpad', array(
    1295             'type' => 'option',
    1296             'capability' => 'exist',
    1297         ) );
     1374        $manager->add_setting(
     1375            'blogfounded', array(
     1376                'type' => 'option',
     1377            )
     1378        );
     1379        $manager->add_setting(
     1380            'blogterminated', array(
     1381                'type'       => 'option',
     1382                'capability' => 'do_not_allow',
     1383            )
     1384        );
     1385        $manager->add_setting(
     1386            'scratchpad', array(
     1387                'type'       => 'option',
     1388                'capability' => 'exist',
     1389            )
     1390        );
    12981391        return $manager;
    12991392    }
     
    13101403        wp_set_current_user( self::$admin_user_id );
    13111404
    1312         $uuid = wp_generate_uuid4();
    1313         $changeset_post_id = wp_insert_post( array(
    1314             'post_type' => 'customize_changeset',
    1315             'post_content' => '{}',
    1316             'post_name' => $uuid,
    1317             'post_status' => 'auto-draft',
    1318             'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( '-3 days' ) ),
    1319         ) );
    1320 
    1321         $post = get_post( $changeset_post_id );
     1405        $uuid              = wp_generate_uuid4();
     1406        $changeset_post_id = wp_insert_post(
     1407            array(
     1408                'post_type'    => 'customize_changeset',
     1409                'post_content' => '{}',
     1410                'post_name'    => $uuid,
     1411                'post_status'  => 'auto-draft',
     1412                'post_date'    => gmdate( 'Y-m-d H:i:s', strtotime( '-3 days' ) ),
     1413            )
     1414        );
     1415
     1416        $post               = get_post( $changeset_post_id );
    13221417        $original_post_date = $post->post_date;
    13231418
    13241419        $wp_customize = $this->create_test_manager( $uuid );
    1325         $wp_customize->save_changeset_post( array(
    1326             'status' => 'auto-draft',
    1327             'data' => array(
    1328                 'blogname' => array(
    1329                     'value' => 'Admin 1 Title',
     1420        $wp_customize->save_changeset_post(
     1421            array(
     1422                'status' => 'auto-draft',
     1423                'data'   => array(
     1424                    'blogname' => array(
     1425                        'value' => 'Admin 1 Title',
     1426                    ),
    13301427                ),
    1331             ),
    1332         ) );
     1428            )
     1429        );
    13331430
    13341431        $post = get_post( $changeset_post_id );
     
    13491446        $other_admin_user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    13501447
    1351         $uuid = wp_generate_uuid4();
     1448        $uuid         = wp_generate_uuid4();
    13521449        $wp_customize = $this->create_test_manager( $uuid );
    1353         $wp_customize->save_changeset_post( array(
    1354             'status' => 'auto-draft',
    1355             'data' => array(
    1356                 'blogname' => array(
    1357                     'value' => 'Admin 1 Title',
     1450        $wp_customize->save_changeset_post(
     1451            array(
     1452                'status' => 'auto-draft',
     1453                'data'   => array(
     1454                    'blogname'        => array(
     1455                        'value' => 'Admin 1 Title',
     1456                    ),
     1457                    'blogdescription' => array(
     1458                        'value' => 'Admin 1 Tagline',
     1459                    ),
     1460                    'blogfounded'     => array(
     1461                        'value' => '2016',
     1462                    ),
     1463                    'scratchpad'      => array(
     1464                        'value' => 'Admin 1 Scratch',
     1465                    ),
    13581466                ),
    1359                 'blogdescription' => array(
    1360                     'value' => 'Admin 1 Tagline',
    1361                 ),
    1362                 'blogfounded' => array(
    1363                     'value' => '2016',
    1364                 ),
    1365                 'scratchpad' => array(
    1366                     'value' => 'Admin 1 Scratch',
    1367                 ),
    1368             ),
    1369         ) );
     1467            )
     1468        );
    13701469
    13711470        // Make sure that setting properties of unknown and unauthorized settings are rejected.
    13721471        $data = get_post( $wp_customize->changeset_post_id() )->post_content;
    1373         $r = $wp_customize->save_changeset_post( array(
    1374             'data' => array(
    1375                 'unknownsetting' => array(
    1376                     'custom' => 'prop',
     1472        $r    = $wp_customize->save_changeset_post(
     1473            array(
     1474                'data' => array(
     1475                    'unknownsetting' => array(
     1476                        'custom' => 'prop',
     1477                    ),
     1478                    'blogterminated' => array(
     1479                        'custom' => 'prop',
     1480                    ),
    13771481                ),
    1378                 'blogterminated' => array(
    1379                     'custom' => 'prop',
    1380                 ),
    1381             ),
    1382         ) );
     1482            )
     1483        );
    13831484        $this->assertInstanceOf( 'WP_Error', $r['setting_validities']['unknownsetting'] );
    13841485        $this->assertEquals( 'unrecognized', $r['setting_validities']['unknownsetting']->get_error_code() );
     
    13901491        wp_set_current_user( $other_admin_user_id );
    13911492        $wp_customize = $this->create_test_manager( $uuid );
    1392         $r = $wp_customize->save_changeset_post( array(
    1393             'status' => 'auto-draft',
    1394             'data' => array(
    1395                 'blogname' => array(
    1396                     'value' => 'Admin 1 Title', // Unchanged value.
     1493        $r            = $wp_customize->save_changeset_post(
     1494            array(
     1495                'status' => 'auto-draft',
     1496                'data'   => array(
     1497                    'blogname'        => array(
     1498                        'value' => 'Admin 1 Title', // Unchanged value.
     1499                    ),
     1500                    'blogdescription' => array(
     1501                        'value' => 'Admin 1 Tagline Changed', // Changed value.
     1502                    ),
     1503                    'blogfounded'     => array(
     1504                        'extra' => 'blogfounded_param', // New param.
     1505                    ),
     1506                    'scratchpad'      => array(
     1507                        'value' => 'Admin 1 Scratch', // Unchanged value.
     1508                        'extra' => 'background_scratchpad2', // New param.
     1509                    ),
    13971510                ),
    1398                 'blogdescription' => array(
    1399                     'value' => 'Admin 1 Tagline Changed', // Changed value.
    1400                 ),
    1401                 'blogfounded' => array(
    1402                     'extra' => 'blogfounded_param', // New param.
    1403                 ),
    1404                 'scratchpad' => array(
    1405                     'value' => 'Admin 1 Scratch', // Unchanged value.
    1406                     'extra' => 'background_scratchpad2', // New param.
    1407                 ),
    1408             ),
    1409         ) );
     1511            )
     1512        );
    14101513
    14111514        // Note that blogfounded is not included among setting_validities because no value was supplied and it is not unrecognized/unauthorized.
     
    14291532    public function test_save_changeset_post_with_autosave() {
    14301533        wp_set_current_user( self::$admin_user_id );
    1431         $uuid = wp_generate_uuid4();
    1432         $changeset_post_id = wp_insert_post( array(
    1433             'post_type' => 'customize_changeset',
    1434             'post_content' => wp_json_encode( array(
    1435                 'blogname' => array(
    1436                     'value' => 'Auto-draft Title',
     1534        $uuid              = wp_generate_uuid4();
     1535        $changeset_post_id = wp_insert_post(
     1536            array(
     1537                'post_type'    => 'customize_changeset',
     1538                'post_content' => wp_json_encode(
     1539                    array(
     1540                        'blogname' => array(
     1541                            'value' => 'Auto-draft Title',
     1542                        ),
     1543                    )
    14371544                ),
    1438             ) ),
    1439             'post_author' => self::$admin_user_id,
    1440             'post_name' => $uuid,
    1441             'post_status' => 'auto-draft',
    1442         ) );
    1443 
    1444         $wp_customize = new WP_Customize_Manager( array(
    1445             'changeset_uuid' => $uuid,
    1446         ) );
     1545                'post_author'  => self::$admin_user_id,
     1546                'post_name'    => $uuid,
     1547                'post_status'  => 'auto-draft',
     1548            )
     1549        );
     1550
     1551        $wp_customize = new WP_Customize_Manager(
     1552            array(
     1553                'changeset_uuid' => $uuid,
     1554            )
     1555        );
    14471556        $wp_customize->register_controls(); // And settings too.
    14481557
    14491558        // Autosave of an auto-draft overwrites original.
    1450         $wp_customize->save_changeset_post( array(
    1451             'data' => array(
    1452                 'blogname' => array(
    1453                     'value' => 'Autosaved Auto-draft Title',
     1559        $wp_customize->save_changeset_post(
     1560            array(
     1561                'data'     => array(
     1562                    'blogname' => array(
     1563                        'value' => 'Autosaved Auto-draft Title',
     1564                    ),
    14541565                ),
    1455             ),
    1456             'autosave' => true,
    1457         ) );
     1566                'autosave' => true,
     1567            )
     1568        );
    14581569        $this->assertFalse( wp_get_post_autosave( $changeset_post_id, get_current_user_id() ) );
    14591570        $this->assertContains( 'Autosaved Auto-draft Title', get_post( $changeset_post_id )->post_content );
    14601571
    14611572        // Update status to draft for subsequent tests.
    1462         $wp_customize->save_changeset_post( array(
    1463             'data' => array(
    1464                 'blogname' => array(
    1465                     'value' => 'Draft Title',
     1573        $wp_customize->save_changeset_post(
     1574            array(
     1575                'data'     => array(
     1576                    'blogname' => array(
     1577                        'value' => 'Draft Title',
     1578                    ),
    14661579                ),
    1467             ),
    1468             'status' => 'draft',
    1469             'autosave' => false,
    1470         ) );
     1580                'status'   => 'draft',
     1581                'autosave' => false,
     1582            )
     1583        );
    14711584        $this->assertContains( 'Draft Title', get_post( $changeset_post_id )->post_content );
    14721585
    14731586        // Fail: illegal_autosave_with_date_gmt.
    1474         $r = $wp_customize->save_changeset_post( array(
    1475             'autosave' => true,
    1476             'date_gmt' => ( gmdate( 'Y' ) + 1 ) . '-12-01 00:00:00',
    1477         ) );
     1587        $r = $wp_customize->save_changeset_post(
     1588            array(
     1589                'autosave' => true,
     1590                'date_gmt' => ( gmdate( 'Y' ) + 1 ) . '-12-01 00:00:00',
     1591            )
     1592        );
    14781593        $this->assertInstanceOf( 'WP_Error', $r );
    14791594        $this->assertEquals( 'illegal_autosave_with_date_gmt', $r->get_error_code() );
    14801595
    14811596        // Fail: illegal_autosave_with_status.
    1482         $r = $wp_customize->save_changeset_post( array(
    1483             'autosave' => true,
    1484             'status' => 'pending',
    1485         ) );
     1597        $r = $wp_customize->save_changeset_post(
     1598            array(
     1599                'autosave' => true,
     1600                'status'   => 'pending',
     1601            )
     1602        );
    14861603        $this->assertEquals( 'illegal_autosave_with_status', $r->get_error_code() );
    14871604
    14881605        // Fail: illegal_autosave_with_non_current_user.
    1489         $r = $wp_customize->save_changeset_post( array(
    1490             'autosave' => true,
    1491             'user_id' => $this->factory()->user->create( array( 'role' => 'administrator' ) ),
    1492         ) );
     1606        $r = $wp_customize->save_changeset_post(
     1607            array(
     1608                'autosave' => true,
     1609                'user_id'  => $this->factory()->user->create( array( 'role' => 'administrator' ) ),
     1610            )
     1611        );
    14931612        $this->assertEquals( 'illegal_autosave_with_non_current_user', $r->get_error_code() );
    14941613
    14951614        // Try autosave.
    14961615        $this->assertFalse( wp_get_post_autosave( $changeset_post_id, get_current_user_id() ) );
    1497         $r = $wp_customize->save_changeset_post( array(
    1498             'data' => array(
    1499                 'blogname' => array(
    1500                     'value' => 'Autosave Title',
     1616        $r = $wp_customize->save_changeset_post(
     1617            array(
     1618                'data'     => array(
     1619                    'blogname' => array(
     1620                        'value' => 'Autosave Title',
     1621                    ),
    15011622                ),
    1502             ),
    1503             'autosave' => true,
    1504         ) );
     1623                'autosave' => true,
     1624            )
     1625        );
    15051626        $this->assertInternalType( 'array', $r );
    15061627
     
    15221643
    15231644        $manager = $this->create_test_manager( $uuid );
    1524         $manager->save_changeset_post( array(
    1525             'data' => array(
    1526                 'scratchpad' => array(
    1527                     'value' => 'foo',
     1645        $manager->save_changeset_post(
     1646            array(
     1647                'data' => array(
     1648                    'scratchpad' => array(
     1649                        'value' => 'foo',
     1650                    ),
    15281651                ),
    1529             ),
    1530         ) );
     1652            )
     1653        );
    15311654
    15321655        // Create a new manager so post values are unset.
     
    15351658        $this->assertArrayHasKey( 'scratchpad', $manager->changeset_data() );
    15361659
    1537         $manager->save_changeset_post( array(
    1538             'data' => array(
    1539                 'scratchpad' => null,
    1540             ),
    1541         ) );
     1660        $manager->save_changeset_post(
     1661            array(
     1662                'data' => array(
     1663                    'scratchpad' => null,
     1664                ),
     1665            )
     1666        );
    15421667
    15431668        $this->assertArrayNotHasKey( 'scratchpad', $manager->changeset_data() );
     
    15631688        do_action( 'customize_register', $wp_customize );
    15641689        $wp_customize->set_post_value( 'scratchpad', 'Unfiltered<script>evil</script>' );
    1565         $wp_customize->save_changeset_post( array(
    1566             'status' => 'auto-draft',
    1567             'user_id' => self::$admin_user_id,
    1568         ) );
     1690        $wp_customize->save_changeset_post(
     1691            array(
     1692                'status'  => 'auto-draft',
     1693                'user_id' => self::$admin_user_id,
     1694            )
     1695        );
    15691696        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ) );
    15701697        do_action( 'customize_register', $wp_customize );
     
    15771704        do_action( 'customize_register', $wp_customize );
    15781705        $wp_customize->set_post_value( 'scratchpad', 'Unfiltered<script>evil</script>' );
    1579         $wp_customize->save_changeset_post( array(
    1580             'status' => 'auto-draft',
    1581             'user_id' => self::$subscriber_user_id,
    1582         ) );
     1706        $wp_customize->save_changeset_post(
     1707            array(
     1708                'status'  => 'auto-draft',
     1709                'user_id' => self::$subscriber_user_id,
     1710            )
     1711        );
    15831712        $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ) );
    15841713        do_action( 'customize_register', $wp_customize );
     
    15911720        do_action( 'customize_register', $wp_customize );
    15921721        $wp_customize->set_post_value( 'scratchpad', 'Unfiltered<script>evil</script>' );
    1593         $wp_customize->save_changeset_post( array(
    1594             'status' => 'auto-draft',
    1595             'user_id' => self::$admin_user_id,
    1596         ) );
     1722        $wp_customize->save_changeset_post(
     1723            array(
     1724                'status'  => 'auto-draft',
     1725                'user_id' => self::$admin_user_id,
     1726            )
     1727        );
    15971728        $changeset_post_id = $wp_customize->changeset_post_id();
    15981729        wp_set_current_user( 0 );
     
    16291760        $new_sidebar_1 = array_reverse( $new_sidebars_widgets['sidebar-1'] );
    16301761
    1631         $post_id = $this->factory()->post->create( array(
    1632             'post_type' => 'customize_changeset',
    1633             'post_status' => 'draft',
    1634             'post_name' => wp_generate_uuid4(),
    1635             'post_content' => wp_json_encode( array(
    1636                 'sidebars_widgets[sidebar-1]' => array(
    1637                     'value' => $new_sidebar_1,
     1762        $post_id = $this->factory()->post->create(
     1763            array(
     1764                'post_type'    => 'customize_changeset',
     1765                'post_status'  => 'draft',
     1766                'post_name'    => wp_generate_uuid4(),
     1767                'post_content' => wp_json_encode(
     1768                    array(
     1769                        'sidebars_widgets[sidebar-1]' => array(
     1770                            'value' => $new_sidebar_1,
     1771                        ),
     1772                    )
    16381773                ),
    1639             ) ),
    1640         ) );
     1774            )
     1775        );
    16411776
    16421777        // Save the updated sidebar widgets into the options table by publishing the changeset.
     
    16611796        $wp_customize = $this->create_test_manager( wp_generate_uuid4() );
    16621797
    1663         $wp_customize->save_changeset_post( array(
    1664             'date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
    1665             'status' => 'publish',
    1666             'title' => 'Foo',
    1667         ) );
     1798        $wp_customize->save_changeset_post(
     1799            array(
     1800                'date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
     1801                'status'   => 'publish',
     1802                'title'    => 'Foo',
     1803            )
     1804        );
    16681805
    16691806        $this->assertSame( 'future', get_post_status( $wp_customize->changeset_post_id() ) );
     
    16781815     */
    16791816    function test_save_changeset_post_for_bad_changeset() {
    1680         $uuid = wp_generate_uuid4();
    1681         $post_id = wp_insert_post( array(
    1682             'post_type' => 'customize_changeset',
    1683             'post_content' => 'INVALID_JSON',
    1684             'post_name' => $uuid,
    1685             'post_status' => 'auto-draft',
    1686             'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( '-3 days' ) ),
    1687         ) );
     1817        $uuid    = wp_generate_uuid4();
     1818        $post_id = wp_insert_post(
     1819            array(
     1820                'post_type'    => 'customize_changeset',
     1821                'post_content' => 'INVALID_JSON',
     1822                'post_name'    => $uuid,
     1823                'post_status'  => 'auto-draft',
     1824                'post_date'    => gmdate( 'Y-m-d H:i:s', strtotime( '-3 days' ) ),
     1825            )
     1826        );
    16881827        $manager = $this->create_test_manager( $uuid );
    1689         $args = array(
     1828        $args    = array(
    16901829            'data' => array(
    16911830                'blogname' => array(
     
    17011840        }
    17021841
    1703         wp_update_post( array(
    1704             'ID' => $post_id,
    1705             'post_content' => 'null',
    1706         ) );
     1842        wp_update_post(
     1843            array(
     1844                'ID'           => $post_id,
     1845                'post_content' => 'null',
     1846            )
     1847        );
    17071848        $r = $manager->save_changeset_post( $args );
    17081849        $this->assertInstanceOf( 'WP_Error', $r );
     
    17171858    public function test_trash_changeset_post_preserves_properties() {
    17181859        $args = array(
    1719             'post_type' => 'customize_changeset',
    1720             'post_content' => wp_json_encode( array(
    1721                 'blogname' => array(
    1722                     'value' => 'Test',
    1723                 ),
    1724             ) ),
    1725             'post_name' => wp_generate_uuid4(),
    1726             'post_status' => 'draft',
     1860            'post_type'    => 'customize_changeset',
     1861            'post_content' => wp_json_encode(
     1862                array(
     1863                    'blogname' => array(
     1864                        'value' => 'Test',
     1865                    ),
     1866                )
     1867            ),
     1868            'post_name'    => wp_generate_uuid4(),
     1869            'post_status'  => 'draft',
    17271870        );
    17281871
     
    17451888     */
    17461889    function register_scratchpad_setting( WP_Customize_Manager $wp_customize ) {
    1747         $wp_customize->add_setting( 'scratchpad', array(
    1748             'type' => 'option',
    1749             'capability' => 'exist',
    1750             'sanitize_callback' => array( $this, 'filter_sanitize_scratchpad' ),
    1751         ) );
     1890        $wp_customize->add_setting(
     1891            'scratchpad', array(
     1892                'type'              => 'option',
     1893                'capability'        => 'exist',
     1894                'sanitize_callback' => array( $this, 'filter_sanitize_scratchpad' ),
     1895            )
     1896        );
    17521897    }
    17531898
     
    18632008        $manager = $this->manager;
    18642009
    1865         $customized = array(
    1866             'foo' => 'bar',
     2010        $customized          = array(
     2011            'foo'       => 'bar',
    18672012            'baz[quux]' => 123,
    18682013        );
    18692014        $_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
    1870         $post_values = $manager->unsanitized_post_values();
     2015        $post_values         = $manager->unsanitized_post_values();
    18712016        $this->assertEquals( $customized, $post_values );
    18722017        $this->assertEmpty( $manager->unsanitized_post_values( array( 'exclude_post_data' => true ) ) );
     
    18912036        wp_set_current_user( self::$admin_user_id );
    18922037
    1893         $preview_theme = $this->get_inactive_core_theme();
    1894         $stashed_theme_mods = array(
     2038        $preview_theme                          = $this->get_inactive_core_theme();
     2039        $stashed_theme_mods                     = array(
    18952040            $preview_theme => array(
    18962041                'background_color' => array(
     
    19062051        update_option( 'customize_stashed_theme_mods', $stashed_theme_mods );
    19072052
    1908         $post_values = array(
     2053        $post_values         = array(
    19092054            'blogdescription' => 'Post Input Tagline',
    19102055        );
    19112056        $_POST['customized'] = wp_slash( wp_json_encode( $post_values ) );
    19122057
    1913         $uuid = wp_generate_uuid4();
     2058        $uuid           = wp_generate_uuid4();
    19142059        $changeset_data = array(
    1915             'blogname' => array(
     2060            'blogname'        => array(
    19162061                'value' => 'Changeset Title',
    19172062            ),
     
    19202065            ),
    19212066        );
    1922         $this->factory()->post->create( array(
    1923             'post_type' => 'customize_changeset',
    1924             'post_status' => 'auto-draft',
    1925             'post_name' => $uuid,
    1926             'post_content' => wp_json_encode( $changeset_data ),
    1927         ) );
    1928 
    1929         $manager = new WP_Customize_Manager( array(
    1930             'changeset_uuid' => $uuid,
    1931         ) );
     2067        $this->factory()->post->create(
     2068            array(
     2069                'post_type'    => 'customize_changeset',
     2070                'post_status'  => 'auto-draft',
     2071                'post_name'    => $uuid,
     2072                'post_content' => wp_json_encode( $changeset_data ),
     2073            )
     2074        );
     2075
     2076        $manager = new WP_Customize_Manager(
     2077            array(
     2078                'changeset_uuid' => $uuid,
     2079            )
     2080        );
    19322081        $this->assertTrue( $manager->is_theme_active() );
    19332082
     
    19362085        $this->assertEquals(
    19372086            array(
    1938                 'blogname' => 'Changeset Title',
     2087                'blogname'        => 'Changeset Title',
    19392088                'blogdescription' => 'Post Input Tagline',
    19402089            ),
     
    19512100        $this->assertEquals(
    19522101            array(
    1953                 'blogname' => 'Changeset Title',
     2102                'blogname'        => 'Changeset Title',
    19542103                'blogdescription' => 'Post Override Tagline',
    19552104            ),
     
    19592108        $this->assertEquals(
    19602109            array(
    1961                 'blogname' => 'Changeset Title',
     2110                'blogname'        => 'Changeset Title',
    19622111                'blogdescription' => 'Changeset Tagline',
    19632112            ),
     
    19652114        );
    19662115
    1967         $this->assertEmpty( $manager->unsanitized_post_values( array( 'exclude_post_data' => true, 'exclude_changeset' => true ) ) );
     2116        $this->assertEmpty(
     2117            $manager->unsanitized_post_values(
     2118                array(
     2119                    'exclude_post_data' => true,
     2120                    'exclude_changeset' => true,
     2121                )
     2122            )
     2123        );
    19682124
    19692125        // Test unstashing theme mods.
    1970         $manager = new WP_Customize_Manager( array(
    1971             'changeset_uuid' => $uuid,
    1972             'theme' => $preview_theme,
    1973         ) );
     2126        $manager = new WP_Customize_Manager(
     2127            array(
     2128                'changeset_uuid' => $uuid,
     2129                'theme'          => $preview_theme,
     2130            )
     2131        );
    19742132        $this->assertFalse( $manager->is_theme_active() );
    1975         $values = $manager->unsanitized_post_values( array( 'exclude_post_data' => true, 'exclude_changeset' => true ) );
     2133        $values = $manager->unsanitized_post_values(
     2134            array(
     2135                'exclude_post_data' => true,
     2136                'exclude_changeset' => true,
     2137            )
     2138        );
    19762139        $this->assertNotEmpty( $values );
    19772140        $this->assertArrayHasKey( 'background_color', $values );
    19782141        $this->assertEquals( '#000000', $values['background_color'] );
    19792142
    1980         $values = $manager->unsanitized_post_values( array( 'exclude_post_data' => false, 'exclude_changeset' => false ) );
     2143        $values = $manager->unsanitized_post_values(
     2144            array(
     2145                'exclude_post_data' => false,
     2146                'exclude_changeset' => false,
     2147            )
     2148        );
    19812149        $this->assertArrayHasKey( 'background_color', $values );
    19822150        $this->assertArrayHasKey( 'blogname', $values );
     
    19912159    function test_post_value() {
    19922160        wp_set_current_user( self::$admin_user_id );
    1993         $posted_settings = array(
     2161        $posted_settings     = array(
    19942162            'foo' => 'OOF',
    19952163        );
     
    20162184        wp_set_current_user( self::$admin_user_id );
    20172185        $default_value = 'foo_default';
    2018         $setting = $this->manager->add_setting( 'foo', array(
    2019             'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
    2020             'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
    2021         ) );
     2186        $setting       = $this->manager->add_setting(
     2187            'foo', array(
     2188                'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
     2189                'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
     2190            )
     2191        );
    20222192        $this->assertEquals( $default_value, $this->manager->post_value( $setting, $default_value ) );
    20232193        $this->assertEquals( $default_value, $setting->post_value( $default_value ) );
     
    20822252        wp_set_current_user( self::$admin_user_id );
    20832253        $default_value = '0';
    2084         $setting = $this->manager->add_setting( 'numeric', array(
    2085             'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
    2086             'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
    2087         ) );
     2254        $setting       = $this->manager->add_setting(
     2255            'numeric', array(
     2256                'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
     2257                'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
     2258            )
     2259        );
    20882260        $this->assertEquals( $default_value, $this->manager->post_value( $setting, $default_value ) );
    20892261        $this->assertEquals( $default_value, $setting->post_value( $default_value ) );
     
    21262298    function test_validate_setting_values() {
    21272299        wp_set_current_user( self::$admin_user_id );
    2128         $setting = $this->manager->add_setting( 'foo', array(
    2129             'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
    2130             'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
    2131         ) );
     2300        $setting = $this->manager->add_setting(
     2301            'foo', array(
     2302                'validate_callback' => array( $this, 'filter_customize_validate_foo' ),
     2303                'sanitize_callback' => array( $this, 'filter_customize_sanitize_foo' ),
     2304            )
     2305        );
    21322306
    21332307        $post_value = 'bar';
     
    21852359        $this->assertTrue( $setting->validate( 'bad' ) );
    21862360        $setting_validities = $this->manager->validate_setting_values( array( $setting->id => 'bad' ) );
    2187         $validity = $setting_validities[ $setting->id ];
     2361        $validity           = $setting_validities[ $setting->id ];
    21882362        $this->assertInstanceOf( 'WP_Error', $validity );
    21892363        $this->assertEquals( 'minlength', $validity->get_error_code() );
     
    22492423    function test_validate_setting_values_validation_sanitization_order() {
    22502424        wp_set_current_user( self::$admin_user_id );
    2251         $setting = $this->manager->add_setting( 'numeric', array(
    2252             'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
    2253             'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
    2254         ) );
     2425        $setting    = $this->manager->add_setting(
     2426            'numeric', array(
     2427                'validate_callback' => array( $this, 'filter_customize_validate_numeric' ),
     2428                'sanitize_callback' => array( $this, 'filter_customize_sanitize_numeric' ),
     2429            )
     2430        );
    22552431        $post_value = '42';
    22562432        $this->manager->set_post_value( 'numeric', $post_value );
     
    22912467    function test_set_post_value() {
    22922468        wp_set_current_user( self::$admin_user_id );
    2293         $this->manager->add_setting( 'foo', array(
    2294             'sanitize_callback' => array( $this, 'sanitize_foo_for_test_set_post_value' ),
    2295         ) );
     2469        $this->manager->add_setting(
     2470            'foo', array(
     2471                'sanitize_callback' => array( $this, 'sanitize_foo_for_test_set_post_value' ),
     2472            )
     2473        );
    22962474        $setting = $this->manager->get_setting( 'foo' );
    22972475
     
    23402518    function capture_customize_post_value_set_actions() {
    23412519        $action = current_action();
    2342         $args = func_get_args();
     2520        $args   = func_get_args();
    23432521        $this->captured_customize_post_value_set_actions[] = compact( 'action', 'args' );
    23442522    }
     
    23502528     */
    23512529    function test_add_dynamic_settings() {
    2352         $manager = $this->manager;
     2530        $manager     = $this->manager;
    23532531        $setting_ids = array( 'foo', 'bar' );
    23542532        $manager->add_setting( 'foo', array( 'default' => 'foo_default' ) );
     
    23762554        $this->assertFalse( $this->manager->has_published_pages() );
    23772555
    2378         $this->factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'private' ) );
     2556        $this->factory()->post->create(
     2557            array(
     2558                'post_type'   => 'page',
     2559                'post_status' => 'private',
     2560            )
     2561        );
    23792562        $this->assertFalse( $this->manager->has_published_pages() );
    23802563
    2381         $this->factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'publish' ) );
     2564        $this->factory()->post->create(
     2565            array(
     2566                'post_type'   => 'page',
     2567                'post_status' => 'publish',
     2568            )
     2569        );
    23822570        $this->assertTrue( $this->manager->has_published_pages() );
    23832571    }
     
    23982586        $this->manager->nav_menus->customize_register();
    23992587        $setting_id = 'nav_menus_created_posts';
    2400         $setting = $this->manager->get_setting( $setting_id );
     2588        $setting    = $this->manager->get_setting( $setting_id );
    24012589        $this->assertInstanceOf( 'WP_Customize_Filter_Setting', $setting );
    2402         $auto_draft_page = $this->factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'auto-draft' ) );
     2590        $auto_draft_page = $this->factory()->post->create(
     2591            array(
     2592                'post_type'   => 'page',
     2593                'post_status' => 'auto-draft',
     2594            )
     2595        );
    24032596        $this->manager->set_post_value( $setting_id, array( $auto_draft_page ) );
    24042597        $setting->preview();
     
    24152608    function test_register_dynamic_settings() {
    24162609        wp_set_current_user( self::$admin_user_id );
    2417         $posted_settings = array(
     2610        $posted_settings     = array(
    24182611            'foo' => 'OOF',
    24192612            'bar' => 'RAB',
     
    25202713        $this->assertEquals( $preview_url, $this->manager->get_return_url() );
    25212714
    2522         $url = home_url( '/referred/' );
     2715        $url                     = home_url( '/referred/' );
    25232716        $_SERVER['HTTP_REFERER'] = wp_slash( $url );
    25242717        $this->assertEquals( $url, $this->manager->get_return_url() );
    25252718
    2526         $url = 'http://badreferer.example.com/';
     2719        $url                     = 'http://badreferer.example.com/';
    25272720        $_SERVER['HTTP_REFERER'] = wp_slash( $url );
    25282721        $this->assertNotEquals( $url, $this->manager->get_return_url() );
     
    27672960        $section_id = 'foo-section';
    27682961        wp_set_current_user( self::$admin_user_id );
    2769         $manager->add_section( $section_id, array(
    2770             'title'      => 'Section',
    2771             'priority'   => 1,
    2772         ) );
     2962        $manager->add_section(
     2963            $section_id, array(
     2964                'title'    => 'Section',
     2965                'priority' => 1,
     2966            )
     2967        );
    27732968
    27742969        $added_control_ids = array();
    2775         $count = 9;
     2970        $count             = 9;
    27762971        for ( $i = 0; $i < $count; $i += 1 ) {
    2777             $id = 'sort-test-' . $i;
     2972            $id                  = 'sort-test-' . $i;
    27782973            $added_control_ids[] = $id;
    27792974            $manager->add_setting( $id );
    2780             $control = new WP_Customize_Control( $manager, $id, array(
    2781                 'section' => $section_id,
    2782                 'priority' => 1,
    2783                 'setting' => $id,
    2784             ) );
     2975            $control = new WP_Customize_Control(
     2976                $manager, $id, array(
     2977                    'section'  => $section_id,
     2978                    'priority' => 1,
     2979                    'setting'  => $id,
     2980                )
     2981            );
    27852982            $manager->add_control( $control );
    27862983        }
     
    27992996        wp_set_current_user( self::$admin_user_id );
    28002997
    2801         $section_id = 'foo-section';
    2802         $result_section = $manager->add_section( $section_id, array(
    2803             'title'    => 'Section',
    2804             'priority' => 1,
    2805         ) );
     2998        $section_id     = 'foo-section';
     2999        $result_section = $manager->add_section(
     3000            $section_id, array(
     3001                'title'    => 'Section',
     3002                'priority' => 1,
     3003            )
     3004        );
    28063005
    28073006        $this->assertInstanceOf( 'WP_Customize_Section', $result_section );
    28083007        $this->assertEquals( $section_id, $result_section->id );
    28093008
    2810         $section = new WP_Customize_Section( $manager, $section_id, array(
    2811             'title'    => 'Section 2',
    2812             'priority' => 2,
    2813         ) );
     3009        $section        = new WP_Customize_Section(
     3010            $manager, $section_id, array(
     3011                'title'    => 'Section 2',
     3012                'priority' => 2,
     3013            )
     3014        );
    28143015        $result_section = $manager->add_section( $section );
    28153016
     
    28263027        wp_set_current_user( self::$admin_user_id );
    28273028
    2828         $setting_id = 'foo-setting';
     3029        $setting_id     = 'foo-setting';
    28293030        $result_setting = $manager->add_setting( $setting_id );
    28303031
     
    28323033        $this->assertEquals( $setting_id, $result_setting->id );
    28333034
    2834         $setting = new WP_Customize_Setting( $manager, $setting_id );
     3035        $setting        = new WP_Customize_Setting( $manager, $setting_id );
    28353036        $result_setting = $manager->add_setting( $setting );
    28363037
     
    28473048
    28483049        $setting_id = 'dynamic';
    2849         $setting = $manager->add_setting( $setting_id );
     3050        $setting    = $manager->add_setting( $setting_id );
    28503051        $this->assertEquals( 'WP_Customize_Setting', get_class( $setting ) );
    28513052        $this->assertObjectNotHasAttribute( 'custom', $setting );
     
    28973098        wp_set_current_user( self::$admin_user_id );
    28983099
    2899         $panel_id = 'foo-panel';
    2900         $result_panel = $manager->add_panel( $panel_id, array(
    2901             'title'    => 'Test Panel',
    2902             'priority' => 2,
    2903         ) );
     3100        $panel_id     = 'foo-panel';
     3101        $result_panel = $manager->add_panel(
     3102            $panel_id, array(
     3103                'title'    => 'Test Panel',
     3104                'priority' => 2,
     3105            )
     3106        );
    29043107
    29053108        $this->assertInstanceOf( 'WP_Customize_Panel', $result_panel );
    29063109        $this->assertEquals( $panel_id, $result_panel->id );
    29073110
    2908         $panel = new WP_Customize_Panel( $manager, $panel_id, array(
    2909             'title' => 'Test Panel 2',
    2910         ) );
     3111        $panel        = new WP_Customize_Panel(
     3112            $manager, $panel_id, array(
     3113                'title' => 'Test Panel 2',
     3114            )
     3115        );
    29113116        $result_panel = $manager->add_panel( $panel );
    29123117
     
    29203125     */
    29213126    function test_add_control_return_instance() {
    2922         $manager = new WP_Customize_Manager();
     3127        $manager    = new WP_Customize_Manager();
    29233128        $section_id = 'foo-section';
    29243129        wp_set_current_user( self::$admin_user_id );
    2925         $manager->add_section( $section_id, array(
    2926             'title'    => 'Section',
    2927             'priority' => 1,
    2928         ) );
     3130        $manager->add_section(
     3131            $section_id, array(
     3132                'title'    => 'Section',
     3133                'priority' => 1,
     3134            )
     3135        );
    29293136
    29303137        $control_id = 'foo-control';
    29313138        $manager->add_setting( $control_id );
    29323139
    2933         $result_control = $manager->add_control( $control_id, array(
    2934             'section'  => $section_id,
    2935             'priority' => 1,
    2936             'setting'  => $control_id,
    2937         ) );
     3140        $result_control = $manager->add_control(
     3141            $control_id, array(
     3142                'section'  => $section_id,
     3143                'priority' => 1,
     3144                'setting'  => $control_id,
     3145            )
     3146        );
    29383147        $this->assertInstanceOf( 'WP_Customize_Control', $result_control );
    29393148        $this->assertEquals( $control_id, $result_control->id );
    29403149
    2941         $control = new WP_Customize_Control( $manager, $control_id, array(
    2942             'section'  => $section_id,
    2943             'priority' => 1,
    2944             'setting'  => $control_id,
    2945         ) );
     3150        $control        = new WP_Customize_Control(
     3151            $manager, $control_id, array(
     3152                'section'  => $section_id,
     3153                'priority' => 1,
     3154                'setting'  => $control_id,
     3155            )
     3156        );
    29463157        $result_control = $manager->add_control( $control );
    29473158
     
    29973208        return array(
    29983209            'custom-device' => array(
    2999                 'label' => __( 'Enter custom-device preview mode' ),
     3210                'label'   => __( 'Enter custom-device preview mode' ),
    30003211                'default' => true,
    30013212            ),
     
    30203231        wp_set_current_user( self::$admin_user_id );
    30213232
    3022         $controls = array( 'foo' => 2, 'bar' => 4, 'foobar' => 3, 'key' => 1 );
     3233        $controls        = array(
     3234            'foo'    => 2,
     3235            'bar'    => 4,
     3236            'foobar' => 3,
     3237            'key'    => 1,
     3238        );
    30233239        $controls_sorted = array( 'key', 'foo', 'foobar', 'bar' );
    30243240
     
    30273243        foreach ( $controls as $control_id => $priority ) {
    30283244            $this->manager->add_setting( $control_id );
    3029             $this->manager->add_control( $control_id, array(
    3030                 'priority' => $priority,
    3031                 'section'  => 'foosection',
    3032             ) );
     3245            $this->manager->add_control(
     3246                $control_id, array(
     3247                    'priority' => $priority,
     3248                    'section'  => 'foosection',
     3249                )
     3250            );
    30333251        }
    30343252
     
    30453263        wp_set_current_user( self::$admin_user_id );
    30463264
    3047         $sections = array( 'foo' => 2, 'bar' => 4, 'foobar' => 3, 'key' => 1 );
     3265        $sections        = array(
     3266            'foo'    => 2,
     3267            'bar'    => 4,
     3268            'foobar' => 3,
     3269            'key'    => 1,
     3270        );
    30483271        $sections_sorted = array( 'key', 'foo', 'foobar', 'bar' );
    30493272
    30503273        foreach ( $sections as $section_id => $priority ) {
    3051             $this->manager->add_section( $section_id, array(
    3052                 'priority' => $priority,
    3053             ) );
     3274            $this->manager->add_section(
     3275                $section_id, array(
     3276                    'priority' => $priority,
     3277                )
     3278            );
    30543279        }
    30553280
     
    30663291        wp_set_current_user( self::$admin_user_id );
    30673292
    3068         $panels = array( 'foo' => 2, 'bar' => 4, 'foobar' => 3, 'key' => 1 );
     3293        $panels        = array(
     3294            'foo'    => 2,
     3295            'bar'    => 4,
     3296            'foobar' => 3,
     3297            'key'    => 1,
     3298        );
    30693299        $panels_sorted = array( 'key', 'foo', 'foobar', 'bar' );
    30703300
    30713301        foreach ( $panels as $panel_id => $priority ) {
    3072             $this->manager->add_panel( $panel_id, array(
    3073                 'priority' => $priority,
    3074             ) );
     3302            $this->manager->add_panel(
     3303                $panel_id, array(
     3304                    'priority' => $priority,
     3305                )
     3306            );
    30753307        }
    30763308
     
    30883320    function test_sanitize_external_header_video_trim() {
    30893321        $this->manager->register_controls();
    3090         $setting = $this->manager->get_setting( 'external_header_video' );
     3322        $setting   = $this->manager->get_setting( 'external_header_video' );
    30913323        $video_url = 'https://www.youtube.com/watch?v=KiS8rZBeIO0';
    30923324
     
    31003332        );
    31013333
    3102         foreach ( $whitespaces as $whitespace  ) {
     3334        foreach ( $whitespaces as $whitespace ) {
    31033335            $sanitized = $setting->sanitize( $whitespace . $video_url . $whitespace );
    31043336            $this->assertEquals( $video_url, $sanitized );
Note: See TracChangeset for help on using the changeset viewer.