Skip to content

Commit

Permalink
fix (global settings): WooCommerce prevents our plugin sidebar from l…
Browse files Browse the repository at this point in the history
…oading (#2806)

Fixes #2806
  • Loading branch information
bfintal authored Aug 7, 2023
1 parent f52ccdd commit 53e8fd1
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/plugins/global-settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,32 @@ const GlobalSettings = () => {
}
}, [ deviceType, editorDom ] )

const PluginSidebar = window.wp.editSite?.PluginSidebar || window.wp.editPost?.PluginSidebar
if ( ! PluginSidebar ) {
return null
}
// We need to to this for both, because one might be disabled. E.g. in
// WooCommerce, editSite is loaded and stops the sidebar from showing up.
const SideEditorPluginSidebar = window.wp.editSite?.PluginSidebar
const PostEditorPluginSidebar = window.wp.editPost?.PluginSidebar

return (
<PluginSidebar
name="sidebar"
title={ __( 'Stackable Settings', i18n ) }
className="ugb-global-settings__inspector"
icon={ <SVGStackableIcon /> } >
{ applyFilters( 'stackable.global-settings.inspector', null ) }
</PluginSidebar>
<>
{ SideEditorPluginSidebar &&
<SideEditorPluginSidebar
name="sidebar"
title={ __( 'Stackable Settings', i18n ) }
className="ugb-global-settings__inspector"
icon={ <SVGStackableIcon /> } >
{ applyFilters( 'stackable.global-settings.inspector', null ) }
</SideEditorPluginSidebar>
}
{ PostEditorPluginSidebar &&
<PostEditorPluginSidebar
name="sidebar"
title={ __( 'Stackable Settings', i18n ) }
className="ugb-global-settings__inspector"
icon={ <SVGStackableIcon /> } >
{ applyFilters( 'stackable.global-settings.inspector', null ) }
</PostEditorPluginSidebar>
}
</>
)
}

Expand Down

0 comments on commit 53e8fd1

Please sign in to comment.