Skip to content

Commit

Permalink
Merge pull request #38 from mailchimp/feat/theme-compat
Browse files Browse the repository at this point in the history
Do not SSR in legacy themes
  • Loading branch information
dkotter authored Jun 27, 2024
2 parents f7af061 + 35351a7 commit 3eb0fd6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
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
4 changes: 4 additions & 0 deletions mailchimp_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ function mailchimp_sf_signup_form( $args = array() ) {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 10px 8px;
width: 100%;
}
.mc_input.mc_phone {
width: auto;
}
select.mc_select {
margin-top: 0.5em;
padding: 10px 8px;
width: 100%;
}
.mc_address_label {
Expand All @@ -101,6 +103,7 @@ function mailchimp_sf_signup_form( $args = array() ) {
display: block;
}
.mc_address_label ~ select {
padding: 10px 8px;
width: 100%;
}
.mc_list li {
Expand All @@ -117,6 +120,7 @@ function mailchimp_sf_signup_form( $args = array() ) {
}
#mc_signup_submit {
margin-top: 1.5em;
padding: 10px 8px;
width: 80%;
}
#mc_unsub_link a {
Expand Down
4 changes: 3 additions & 1 deletion views/css/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
}
ul.mc_list {
list-style-type: none;
margin-left: 0;
padding-left: 0;
}
ul.mc_list li {
font-size: 12px;
Expand All @@ -81,4 +83,4 @@
#ui-datepicker-div.show .ui-datepicker-year {
display: inline;
padding-left: 3px
}
}

0 comments on commit 3eb0fd6

Please sign in to comment.