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. Props desrosj. Fixes #45125. Built from https://develop.svn.wordpress.org/branches/5.0@43790 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8efbcce93b
commit
8caf4f9260
|
@ -16,11 +16,6 @@ function render_block_core_categories( $attributes ) {
|
|||
static $block_id = 0;
|
||||
$block_id++;
|
||||
|
||||
$align = 'center';
|
||||
if ( isset( $attributes['align'] ) && in_array( $attributes['align'], array( 'left', 'right', 'full' ), true ) ) {
|
||||
$align = $attributes['align'];
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'echo' => false,
|
||||
'hierarchical' => ! empty( $attributes['showHierarchy'] ),
|
||||
|
@ -46,10 +41,14 @@ function render_block_core_categories( $attributes ) {
|
|||
$type = 'list';
|
||||
}
|
||||
|
||||
$class = "wp-block-categories wp-block-categories-{$type} align{$align}";
|
||||
$class = "wp-block-categories wp-block-categories-{$type}";
|
||||
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= " align{$attributes['align']}";
|
||||
}
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
$class .= " {$attributes['className']}";
|
||||
}
|
||||
|
||||
$block_content = sprintf(
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* @package gutenberg
|
||||
*/
|
||||
|
||||
/**
|
||||
if ( ! function_exists( 'gutenberg_draft_or_post_title' ) ) {
|
||||
/**
|
||||
* Get the post title.
|
||||
*
|
||||
* The post title is fetched and if it is blank then a default string is
|
||||
|
@ -25,12 +26,13 @@
|
|||
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
|
||||
* @return string The post title if set; "(no title)" if no title is set.
|
||||
*/
|
||||
function gutenberg_draft_or_post_title( $post = 0 ) {
|
||||
function gutenberg_draft_or_post_title( $post = 0 ) {
|
||||
$title = get_the_title( $post );
|
||||
if ( empty( $title ) ) {
|
||||
$title = __( '(no title)', 'gutenberg' );
|
||||
}
|
||||
return esc_html( $title );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -722,6 +722,10 @@ function get_body_class( $class = '' ) {
|
|||
$classes[] = 'wp-custom-logo';
|
||||
}
|
||||
|
||||
if ( current_theme_supports( 'responsive-embeds' ) ) {
|
||||
$classes[] = 'wp-embed-responsive';
|
||||
}
|
||||
|
||||
$page = $wp_query->get( 'page' );
|
||||
|
||||
if ( ! $page || $page < 2 )
|
||||
|
|
|
@ -112,6 +112,7 @@ class WP_REST_Themes_Controller extends WP_REST_Controller {
|
|||
$data['theme_supports']['formats'] = $formats;
|
||||
|
||||
$data['theme_supports']['post-thumbnails'] = false;
|
||||
$data['theme_supports']['responsive-embeds'] = (bool) get_theme_support( 'responsive-embeds' );
|
||||
$post_thumbnails = get_theme_support( 'post-thumbnails' );
|
||||
|
||||
if ( $post_thumbnails ) {
|
||||
|
@ -166,6 +167,11 @@ class WP_REST_Themes_Controller extends WP_REST_Controller {
|
|||
'type' => array( 'array', 'bool' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'responsive-embeds' => array(
|
||||
'description' => __( 'Whether the theme supports responsive embedded content.', 'gutenberg' ),
|
||||
'type' => 'bool',
|
||||
'readonly' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -2210,12 +2210,14 @@ function get_theme_starter_content() {
|
|||
* @since 4.1.0 The `title-tag` feature was added
|
||||
* @since 4.5.0 The `customize-selective-refresh-widgets` feature was added
|
||||
* @since 4.7.0 The `starter-content` feature was added
|
||||
* @since 5.0.0 The `responsive-embeds` feature was added.
|
||||
*
|
||||
* @global array $_wp_theme_features
|
||||
*
|
||||
* @param string $feature The feature being added. Likely core values include 'post-formats',
|
||||
* 'post-thumbnails', 'html5', 'custom-logo', 'custom-header-uploads',
|
||||
* 'custom-header', 'custom-background', 'title-tag', 'starter-content', etc.
|
||||
* 'custom-header', 'custom-background', 'title-tag', 'starter-content',
|
||||
* 'responsive-embeds/', etc.
|
||||
* @param mixed $args,... Optional extra arguments to pass along with certain features.
|
||||
* @return void|bool False on failure, void otherwise.
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-43789';
|
||||
$wp_version = '5.0-alpha-43790';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue