Skip to content

Commit

Permalink
Do not SSR in legacy themes
Browse files Browse the repository at this point in the history
  • Loading branch information
nateconley committed Jun 27, 2024
1 parent f7af061 commit 73dc436
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion includes/blocks/mailchimp/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div {...blockProps}>
{isSelected ? (
{isSelected || isDisallowedThemeSSR ? (
<Placeholder
icon={Icon}
label={__('Mailchimp Block', 'mailchimp_i18n')}
Expand Down

0 comments on commit 73dc436

Please sign in to comment.