Make WordPress Core


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

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/selective-refresh-ajax.php

    r41293 r42343  
    141141                $this->setup_valid_render_partials_request_environment();
    142142                $context_data = array();
    143                 $placements = array( $context_data );
    144 
    145                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    146                         'foo' => $placements,
    147                 ) ) );
     143                $placements   = array( $context_data );
     144
     145                $_POST['partials'] = wp_slash(
     146                        wp_json_encode(
     147                                array(
     148                                        'foo' => $placements,
     149                                )
     150                        )
     151                );
    148152
    149153                ob_start();
     
    177181                $this->wp_customize->selective_refresh->add_partial( 'foo', array( 'settings' => array( 'home' ) ) );
    178182                $context_data = array();
    179                 $placements = array( $context_data );
    180 
    181                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    182                         'foo' => $placements,
    183                 ) ) );
     183                $placements   = array( $context_data );
     184
     185                $_POST['partials'] = wp_slash(
     186                        wp_json_encode(
     187                                array(
     188                                        'foo' => $placements,
     189                                )
     190                        )
     191                );
    184192
    185193                $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    186                 $count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
     194                $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    187195                ob_start();
    188196                try {
     
    209217                $this->setup_valid_render_partials_request_environment();
    210218                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    211                 $this->wp_customize->add_setting( 'secret_message', array(
    212                         'capability' => 'top_secret_clearance',
    213                 ) );
     219                $this->wp_customize->add_setting(
     220                        'secret_message', array(
     221                                'capability' => 'top_secret_clearance',
     222                        )
     223                );
    214224                $this->wp_customize->selective_refresh->add_partial( 'secret_message', array( 'settings' => 'secret_message' ) );
    215225
    216                 $context_data = array();
    217                 $placements = array( $context_data );
    218                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    219                         'secret_message' => $placements,
    220                 ) ) );
     226                $context_data      = array();
     227                $placements        = array( $context_data );
     228                $_POST['partials'] = wp_slash(
     229                        wp_json_encode(
     230                                array(
     231                                        'secret_message' => $placements,
     232                                )
     233                        )
     234                );
    221235
    222236                ob_start();
     
    240254                $this->wp_customize->selective_refresh->add_partial( 'bar', array( 'settings' => 'bar' ) );
    241255
    242                 $context_data = array();
    243                 $placements = array( $context_data );
    244                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    245                         'bar' => $placements,
    246                 ) ) );
     256                $context_data      = array();
     257                $placements        = array( $context_data );
     258                $_POST['partials'] = wp_slash(
     259                        wp_json_encode(
     260                                array(
     261                                        'bar' => $placements,
     262                                )
     263                        )
     264                );
    247265
    248266                ob_start();
     
    291309                $this->setup_valid_render_partials_request_environment();
    292310
    293                 $this->wp_customize->selective_refresh->add_partial( 'test_blogname', array(
    294                         'settings' => array( 'blogname' ),
    295                         'render_callback' => array( $this, 'render_callback_blogname' ),
    296                 ) );
     311                $this->wp_customize->selective_refresh->add_partial(
     312                        'test_blogname', array(
     313                                'settings'        => array( 'blogname' ),
     314                                'render_callback' => array( $this, 'render_callback_blogname' ),
     315                        )
     316                );
    297317
    298318                $context_data = array();
    299                 $placements = array( $context_data );
    300 
    301                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    302                         'test_blogname' => $placements,
    303                 ) ) );
     319                $placements   = array( $context_data );
     320
     321                $_POST['partials'] = wp_slash(
     322                        wp_json_encode(
     323                                array(
     324                                        'test_blogname' => $placements,
     325                                )
     326                        )
     327                );
    304328
    305329                $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    306                 $count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
     330                $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    307331                ob_start();
    308332                try {
     
    333357                if ( 'test_dynamic_blogname' === $partial_id ) {
    334358                        $partial_args = array(
    335                                 'settings' => array( 'blogname' ),
     359                                'settings'        => array( 'blogname' ),
    336360                                'render_callback' => array( $this, 'render_callback_blogname' ),
    337361                        );
     
    402426
    403427                $context_data = array();
    404                 $placements = array( $context_data );
    405 
    406                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    407                         'test_dynamic_blogname' => $placements,
    408                 ) ) );
     428                $placements   = array( $context_data );
     429
     430                $_POST['partials'] = wp_slash(
     431                        wp_json_encode(
     432                                array(
     433                                        'test_dynamic_blogname' => $placements,
     434                                )
     435                        )
     436                );
    409437
    410438                $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    411                 $count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
     439                $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    412440                ob_start();
    413441                try {
     
    434462                $this->setup_valid_render_partials_request_environment();
    435463
    436                 $this->wp_customize->selective_refresh->add_partial( 'test_blogname', array(
    437                         'settings' => array( 'blogname' ),
    438                         'render_callback' => array( $this, 'render_callback_blogname' ),
    439                 ) );
    440                 $this->wp_customize->selective_refresh->add_partial( 'test_blogdescription', array(
    441                         'settings' => array( 'blogdescription' ),
    442                         'render_callback' => array( $this, 'render_callback_blogdescription' ),
    443                 ) );
     464                $this->wp_customize->selective_refresh->add_partial(
     465                        'test_blogname', array(
     466                                'settings'        => array( 'blogname' ),
     467                                'render_callback' => array( $this, 'render_callback_blogname' ),
     468                        )
     469                );
     470                $this->wp_customize->selective_refresh->add_partial(
     471                        'test_blogdescription', array(
     472                                'settings'        => array( 'blogdescription' ),
     473                                'render_callback' => array( $this, 'render_callback_blogdescription' ),
     474                        )
     475                );
    444476
    445477                $placement_context_data = array();
    446478
    447                 $_POST['partials'] = wp_slash( wp_json_encode( array(
    448                         'test_blogname' => array( $placement_context_data ),
    449                         'test_blogdescription' => array( $placement_context_data, $placement_context_data ),
    450                 ) ) );
     479                $_POST['partials'] = wp_slash(
     480                        wp_json_encode(
     481                                array(
     482                                        'test_blogname'        => array( $placement_context_data ),
     483                                        'test_blogdescription' => array( $placement_context_data, $placement_context_data ),
     484                                )
     485                        )
     486                );
    451487
    452488                $count_customize_render_partials_before = has_action( 'customize_render_partials_before' );
    453                 $count_customize_render_partials_after = has_action( 'customize_render_partials_after' );
     489                $count_customize_render_partials_after  = has_action( 'customize_render_partials_after' );
    454490                ob_start();
    455491                try {
     
    474510        function tearDown() {
    475511                $this->expected_partial_ids = null;
    476                 $this->wp_customize = null;
     512                $this->wp_customize         = null;
    477513                unset( $GLOBALS['wp_customize'] );
    478514                unset( $GLOBALS['wp_scripts'] );
Note: See TracChangeset for help on using the changeset viewer.