From a0efb5bf06c3768b95e15e615589f774865d758a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 29 Jun 2021 12:56:41 +0000 Subject: [PATCH] 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 --- src/wp-content/themes/twentyseventeen/assets/js/global.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyseventeen/assets/js/global.js b/src/wp-content/themes/twentyseventeen/assets/js/global.js index 9b4db2353b..966889233c 100644 --- a/src/wp-content/themes/twentyseventeen/assets/js/global.js +++ b/src/wp-content/themes/twentyseventeen/assets/js/global.js @@ -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' ) ||