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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51257 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-06-29 12:56:41 +00:00
parent a4a84bc730
commit a0efb5bf06

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' ) ||