From 73dc4360eeb4ad76d4b711ef7f1b75b07da26fc4 Mon Sep 17 00:00:00 2001 From: Nate Conley Date: Wed, 26 Jun 2024 17:58:27 -1000 Subject: [PATCH] Do not SSR in legacy themes --- includes/blocks/mailchimp/edit.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/includes/blocks/mailchimp/edit.js b/includes/blocks/mailchimp/edit.js index b8f9ac8..b83b450 100644 --- a/includes/blocks/mailchimp/edit.js +++ b/includes/blocks/mailchimp/edit.js @@ -2,14 +2,33 @@ import { useBlockProps } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { Placeholder, Button, Disabled } from '@wordpress/components'; import ServerSideRender from '@wordpress/server-side-render'; +import { useSelect } from '@wordpress/data'; import Icon from './icon'; +const disallowedThemesSSR = [ + 'twentytwentyone', + 'twentytwenty', + 'twentynineteen', + 'twentyeighteen', + 'twentyseventeen', + 'twentysixteen', + 'twentyfifteen', + 'twentyfourteen', +]; + export const BlockEdit = ({ isSelected }) => { const blockProps = useBlockProps(); + const isDisallowedThemeSSR = useSelect((select) => { + const currentTheme = select('core').getCurrentTheme(); + if (!currentTheme || (!'template') in currentTheme) { + return false; + } + return disallowedThemesSSR.includes(currentTheme.template); + }); return (
- {isSelected ? ( + {isSelected || isDisallowedThemeSSR ? (