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. Merges [39635] to the 4.7 branch. Fixes #39272. Built from https://develop.svn.wordpress.org/branches/4.7@39650 git-svn-id: http://core.svn.wordpress.org/branches/4.7@39590 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9edb03c095
commit
61fb79c097
|
@ -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'];
|
||||||
|
|
||||||
if ( twentyseventeen_is_frontpage() ) {
|
// Get layout.
|
||||||
$content_width = 1120;
|
$page_layout = get_theme_mod( 'page_layout' );
|
||||||
|
|
||||||
|
// Check if layout is one column.
|
||||||
|
if ( 'one-column' === $page_layout ) {
|
||||||
|
if ( twentyseventeen_is_frontpage() ) {
|
||||||
|
$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.7.1-alpha-39646';
|
$wp_version = '4.7.1-alpha-39650';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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