Make WordPress Core


Ignore:
Timestamp:
02/23/2016 06:13:30 PM (9 years ago)
Author:
westonruter
Message:

Customize: Skip exporting partials to client and handling rendering requests if user can't modify associated settings.

Introduces WP_Customize_Partial::check_capabilities() for parity with WP_Customize_Control::check_capabilities().

See #27355.
Fixes #35914.

File:
1 edited

Legend:

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

    r36586 r36643  
    138138     */
    139139    function test_export_preview_data() {
     140        $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
     141        wp_set_current_user( $user_id );
     142        $user = new WP_User( $user_id );
     143        do_action( 'customize_register', $this->wp_customize );
     144        $user->remove_cap( 'top_secret_clearance' );
     145        $this->wp_customize->add_setting( 'top_secret_message', array(
     146            'capability' => 'top_secret_clearance', // The administrator role lacks this.
     147        ) );
    140148        $this->selective_refresh->add_partial( 'blogname', array(
    141149            'selector' => '#site-title',
     150        ) );
     151        $this->selective_refresh->add_partial( 'top_secret_message', array(
     152            'settings' => array( 'top_secret_message' ),
    142153        ) );
    143154        ob_start();
     
    150161        $this->assertInternalType( 'array', $exported_data['partials'] );
    151162        $this->assertArrayHasKey( 'blogname', $exported_data['partials'] );
     163        $this->assertArrayNotHasKey( 'top_secret_message', $exported_data['partials'] );
    152164        $this->assertEquals( '#site-title', $exported_data['partials']['blogname']['selector'] );
    153165        $this->assertArrayHasKey( 'renderQueryVar', $exported_data );
Note: See TracChangeset for help on using the changeset viewer.