Skip to content

Commit 73dc436

Browse files
committed
Do not SSR in legacy themes
1 parent f7af061 commit 73dc436

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

includes/blocks/mailchimp/edit.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@ import { useBlockProps } from '@wordpress/block-editor';
22
import { __ } from '@wordpress/i18n';
33
import { Placeholder, Button, Disabled } from '@wordpress/components';
44
import ServerSideRender from '@wordpress/server-side-render';
5+
import { useSelect } from '@wordpress/data';
56
import Icon from './icon';
67

8+
const disallowedThemesSSR = [
9+
'twentytwentyone',
10+
'twentytwenty',
11+
'twentynineteen',
12+
'twentyeighteen',
13+
'twentyseventeen',
14+
'twentysixteen',
15+
'twentyfifteen',
16+
'twentyfourteen',
17+
];
18+
719
export const BlockEdit = ({ isSelected }) => {
820
const blockProps = useBlockProps();
21+
const isDisallowedThemeSSR = useSelect((select) => {
22+
const currentTheme = select('core').getCurrentTheme();
23+
if (!currentTheme || (!'template') in currentTheme) {
24+
return false;
25+
}
26+
return disallowedThemesSSR.includes(currentTheme.template);
27+
});
928

1029
return (
1130
<div {...blockProps}>
12-
{isSelected ? (
31+
{isSelected || isDisallowedThemeSSR ? (
1332
<Placeholder
1433
icon={Icon}
1534
label={__('Mailchimp Block', 'mailchimp_i18n')}

0 commit comments

Comments
 (0)