mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@36643 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -273,7 +273,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WP_Customize_Partial::json() default.
|
||||
* Test WP_Customize_Partial::json().
|
||||
*
|
||||
* @see WP_Customize_Partial::json()
|
||||
*/
|
||||
@@ -300,6 +300,33 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
$this->assertArrayHasKey( 'containerInclusive', $exported );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WP_Customize_Partial::check_capabilities().
|
||||
*
|
||||
* @see WP_Customize_Partial::check_capabilities()
|
||||
*/
|
||||
function test_check_capabilities() {
|
||||
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
|
||||
do_action( 'customize_register', $this->wp_customize );
|
||||
$partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array(
|
||||
'settings' => array( 'blogname' ),
|
||||
) );
|
||||
$this->assertTrue( $partial->check_capabilities() );
|
||||
|
||||
$partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array(
|
||||
'settings' => array( 'blogname', 'non_existing' ),
|
||||
) );
|
||||
$this->assertFalse( $partial->check_capabilities() );
|
||||
|
||||
$this->wp_customize->add_setting( 'top_secret_message', array(
|
||||
'capability' => 'top_secret_clearance',
|
||||
) );
|
||||
$partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array(
|
||||
'settings' => array( 'blogname', 'top_secret_clearance' ),
|
||||
) );
|
||||
$this->assertFalse( $partial->check_capabilities() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user