mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Themes: Introduce responsive embeds support.
Responsive embeds is a way for a theme to opt in to WordPress dynamically scaling the width/height of an embed. When a theme supports responsive embeds, a `wp-embed-responsive` class is added to the `<body>` tag. This information is also presented through the REST API for clients to respect. Merges [43790] and [43791] from the 5.0 branch to trunk. Props desrosj, danielbachhuber, ocean90. Fixes #45125. git-svn-id: https://develop.svn.wordpress.org/trunk@44138 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -189,9 +189,10 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->assertEquals( 1, count( $properties ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $properties );
|
||||
|
||||
$this->assertEquals( 2, count( $properties['theme_supports']['properties'] ) );
|
||||
$this->assertEquals( 3, count( $properties['theme_supports']['properties'] ) );
|
||||
$this->assertArrayHasKey( 'formats', $properties['theme_supports']['properties'] );
|
||||
$this->assertArrayHasKey( 'post-thumbnails', $properties['theme_supports']['properties'] );
|
||||
$this->assertArrayHasKey( 'responsive-embeds', $properties['theme_supports']['properties'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,6 +223,35 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->assertSame( array( 'standard', 'aside', 'video' ), $result[0]['theme_supports']['formats'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test when a theme does not support responsive embeds.
|
||||
*
|
||||
* @ticket 45016
|
||||
*/
|
||||
public function test_theme_supports_responsive_embeds_false() {
|
||||
remove_theme_support( 'responsive-embeds' );
|
||||
$response = self::perform_active_theme_request();
|
||||
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertTrue( isset( $result[0]['theme_supports']['responsive-embeds'] ) );
|
||||
$this->assertFalse( $result[0]['theme_supports']['responsive-embeds'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test when a theme supports responsive embeds.
|
||||
*
|
||||
* @ticket 45016
|
||||
*/
|
||||
public function test_theme_supports_responsive_embeds_true() {
|
||||
remove_theme_support( 'responsive-embeds' );
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertTrue( $result[0]['theme_supports']['responsive-embeds'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test when a theme does not support post thumbnails.
|
||||
*
|
||||
|
||||
@@ -192,4 +192,16 @@ class Tests_Theme_Support extends WP_UnitTestCase {
|
||||
$this->assertEmpty( get_registered_nav_menus() );
|
||||
$this->assertFalse( current_theme_supports( 'menus' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 45125
|
||||
*/
|
||||
function test_responsive_embeds() {
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
$this->assertTrue( current_theme_supports( 'responsive-embeds' ) );
|
||||
remove_theme_support( 'responsive-embeds' );
|
||||
$this->assertFalse( current_theme_supports( 'responsive-embeds' ) );
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
$this->assertTrue( current_theme_supports( 'responsive-embeds' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user