Twenty Seventeen: Avoid JS errors when displaying legacy widgets.

Make sure the `$sidebar` variable is defined and has at least one entry in the array, before adding the `.below-entry-meta` class to elements below the entry meta.

Previously, the theme expected sidebar markup to exist on the page if sidebars are defined, but that markup is missing since only the widget itself and headers/footers of the page are loaded in the iframe used to display legacy widgets (widgets added prior to WordPress 5.8).

Props Clorith, Boniu91, desrosj.
Fixes #53512.
Built from https://develop.svn.wordpress.org/trunk@51257


git-svn-id: http://core.svn.wordpress.org/trunk@50866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-06-29 12:57:56 +00:00
parent 600d611e0d
commit c804143db6
2 changed files with 4 additions and 2 deletions

View File

@ -111,7 +111,9 @@
function belowEntryMetaClass( param ) {
var sidebarPos, sidebarPosBottom;
if ( ! $body.hasClass( 'has-sidebar' ) || (
if ( ! $body.hasClass( 'has-sidebar' ) ||
typeof $sidebar === 'undefined' ||
$sidebar.length < 1 || (
$body.hasClass( 'search' ) ||
$body.hasClass( 'single-attachment' ) ||
$body.hasClass( 'error404' ) ||

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-beta4-51256';
$wp_version = '5.8-beta4-51257';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.