mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Twenty Seventeen: Fix incorrect $content_width
value in theme
This addresses a major bug. Incorrectly setting the `$content_width` causes media embeds to end up with the wrong aspect ratio, among other issues. This fix uses `template_redirect`, to ensure conditional theme tags can be used. It also defines a default value at `after_theme_setup` so that plugins have something to work with at `init`. Props sstoqnov, laurelfulford, obenland. Fixes #39272. Built from https://develop.svn.wordpress.org/trunk@39635 git-svn-id: http://core.svn.wordpress.org/trunk@39575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
443bcb03bd
commit
7a8e17d50a
@ -55,6 +55,9 @@ function twentyseventeen_setup() {
|
|||||||
|
|
||||||
add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true );
|
add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true );
|
||||||
|
|
||||||
|
// Set the default content width.
|
||||||
|
$GLOBALS['content_width'] = 525;
|
||||||
|
|
||||||
// This theme uses wp_nav_menu() in two locations.
|
// This theme uses wp_nav_menu() in two locations.
|
||||||
register_nav_menus( array(
|
register_nav_menus( array(
|
||||||
'top' => __( 'Top Menu', 'twentyseventeen' ),
|
'top' => __( 'Top Menu', 'twentyseventeen' ),
|
||||||
@ -199,10 +202,23 @@ add_action( 'after_setup_theme', 'twentyseventeen_setup' );
|
|||||||
*/
|
*/
|
||||||
function twentyseventeen_content_width() {
|
function twentyseventeen_content_width() {
|
||||||
|
|
||||||
$content_width = 700;
|
$content_width = $GLOBALS['content_width'];
|
||||||
|
|
||||||
|
// Get layout.
|
||||||
|
$page_layout = get_theme_mod( 'page_layout' );
|
||||||
|
|
||||||
|
// Check if layout is one column.
|
||||||
|
if ( 'one-column' === $page_layout ) {
|
||||||
if ( twentyseventeen_is_frontpage() ) {
|
if ( twentyseventeen_is_frontpage() ) {
|
||||||
$content_width = 1120;
|
$content_width = 644;
|
||||||
|
} elseif ( is_page() ) {
|
||||||
|
$content_width = 740;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if is single post and there is no sidebar.
|
||||||
|
if ( is_single() && ! is_active_sidebar( 'sidebar-1' ) ) {
|
||||||
|
$content_width = 740;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,7 +230,7 @@ function twentyseventeen_content_width() {
|
|||||||
*/
|
*/
|
||||||
$GLOBALS['content_width'] = apply_filters( 'twentyseventeen_content_width', $content_width );
|
$GLOBALS['content_width'] = apply_filters( 'twentyseventeen_content_width', $content_width );
|
||||||
}
|
}
|
||||||
add_action( 'after_setup_theme', 'twentyseventeen_content_width', 0 );
|
add_action( 'template_redirect', 'twentyseventeen_content_width', 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register custom fonts.
|
* Register custom fonts.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.8-alpha-39626';
|
$wp_version = '4.8-alpha-39635';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
Block a user