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;
|
static $block_id = 0;
|
||||||
$block_id++;
|
$block_id++;
|
||||||
|
|
||||||
$align = 'center';
|
|
||||||
if ( isset( $attributes['align'] ) && in_array( $attributes['align'], array( 'left', 'right', 'full' ), true ) ) {
|
|
||||||
$align = $attributes['align'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'echo' => false,
|
'echo' => false,
|
||||||
'hierarchical' => ! empty( $attributes['showHierarchy'] ),
|
'hierarchical' => ! empty( $attributes['showHierarchy'] ),
|
||||||
|
@ -46,10 +41,14 @@ function render_block_core_categories( $attributes ) {
|
||||||
$type = 'list';
|
$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'] ) ) {
|
if ( isset( $attributes['className'] ) ) {
|
||||||
$class .= ' ' . $attributes['className'];
|
$class .= " {$attributes['className']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$block_content = sprintf(
|
$block_content = sprintf(
|
||||||
|
|
|
@ -5,32 +5,34 @@
|
||||||
* @package gutenberg
|
* @package gutenberg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
if ( ! function_exists( 'gutenberg_draft_or_post_title' ) ) {
|
||||||
* Get the post title.
|
/**
|
||||||
*
|
* Get the post title.
|
||||||
* The post title is fetched and if it is blank then a default string is
|
*
|
||||||
* returned.
|
* The post title is fetched and if it is blank then a default string is
|
||||||
*
|
* returned.
|
||||||
* Copied from `wp-admin/includes/template.php`, but we can't include that
|
*
|
||||||
* file because:
|
* Copied from `wp-admin/includes/template.php`, but we can't include that
|
||||||
*
|
* file because:
|
||||||
* 1. It causes bugs with test fixture generation and strange Docker 255 error
|
*
|
||||||
* codes.
|
* 1. It causes bugs with test fixture generation and strange Docker 255 error
|
||||||
* 2. It's in the admin; ideally we *shouldn't* be including files from the
|
* codes.
|
||||||
* admin for a block's output. It's a very small/simple function as well,
|
* 2. It's in the admin; ideally we *shouldn't* be including files from the
|
||||||
* so duplicating it isn't too terrible.
|
* admin for a block's output. It's a very small/simple function as well,
|
||||||
*
|
* so duplicating it isn't too terrible.
|
||||||
* @since 3.3.0
|
*
|
||||||
*
|
* @since 3.3.0
|
||||||
* @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.
|
* @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 ) {
|
*/
|
||||||
$title = get_the_title( $post );
|
function gutenberg_draft_or_post_title( $post = 0 ) {
|
||||||
if ( empty( $title ) ) {
|
$title = get_the_title( $post );
|
||||||
$title = __( '(no title)', 'gutenberg' );
|
if ( empty( $title ) ) {
|
||||||
|
$title = __( '(no title)', 'gutenberg' );
|
||||||
|
}
|
||||||
|
return esc_html( $title );
|
||||||
}
|
}
|
||||||
return esc_html( $title );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -722,6 +722,10 @@ function get_body_class( $class = '' ) {
|
||||||
$classes[] = 'wp-custom-logo';
|
$classes[] = 'wp-custom-logo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( current_theme_supports( 'responsive-embeds' ) ) {
|
||||||
|
$classes[] = 'wp-embed-responsive';
|
||||||
|
}
|
||||||
|
|
||||||
$page = $wp_query->get( 'page' );
|
$page = $wp_query->get( 'page' );
|
||||||
|
|
||||||
if ( ! $page || $page < 2 )
|
if ( ! $page || $page < 2 )
|
||||||
|
|
|
@ -111,8 +111,9 @@ class WP_REST_Themes_Controller extends WP_REST_Controller {
|
||||||
$formats = array_merge( array( 'standard' ), $formats );
|
$formats = array_merge( array( 'standard' ), $formats );
|
||||||
$data['theme_supports']['formats'] = $formats;
|
$data['theme_supports']['formats'] = $formats;
|
||||||
|
|
||||||
$data['theme_supports']['post-thumbnails'] = false;
|
$data['theme_supports']['post-thumbnails'] = false;
|
||||||
$post_thumbnails = get_theme_support( 'post-thumbnails' );
|
$data['theme_supports']['responsive-embeds'] = (bool) get_theme_support( 'responsive-embeds' );
|
||||||
|
$post_thumbnails = get_theme_support( 'post-thumbnails' );
|
||||||
|
|
||||||
if ( $post_thumbnails ) {
|
if ( $post_thumbnails ) {
|
||||||
// $post_thumbnails can contain a nested array of post types.
|
// $post_thumbnails can contain a nested array of post types.
|
||||||
|
@ -156,16 +157,21 @@ class WP_REST_Themes_Controller extends WP_REST_Controller {
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'properties' => array(
|
'properties' => array(
|
||||||
'formats' => array(
|
'formats' => array(
|
||||||
'description' => __( 'Post formats supported.' ),
|
'description' => __( 'Post formats supported.' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
),
|
),
|
||||||
'post-thumbnails' => array(
|
'post-thumbnails' => array(
|
||||||
'description' => __( 'Whether the theme supports post thumbnails.' ),
|
'description' => __( 'Whether the theme supports post thumbnails.' ),
|
||||||
'type' => array( 'array', 'bool' ),
|
'type' => array( 'array', 'bool' ),
|
||||||
'readonly' => true,
|
'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.1.0 The `title-tag` feature was added
|
||||||
* @since 4.5.0 The `customize-selective-refresh-widgets` 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 4.7.0 The `starter-content` feature was added
|
||||||
|
* @since 5.0.0 The `responsive-embeds` feature was added.
|
||||||
*
|
*
|
||||||
* @global array $_wp_theme_features
|
* @global array $_wp_theme_features
|
||||||
*
|
*
|
||||||
* @param string $feature The feature being added. Likely core values include 'post-formats',
|
* @param string $feature The feature being added. Likely core values include 'post-formats',
|
||||||
* 'post-thumbnails', 'html5', 'custom-logo', 'custom-header-uploads',
|
* '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.
|
* @param mixed $args,... Optional extra arguments to pass along with certain features.
|
||||||
* @return void|bool False on failure, void otherwise.
|
* @return void|bool False on failure, void otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue