Skip to content

Commit 3eb0fd6

Browse files
authored
Merge pull request #38 from mailchimp/feat/theme-compat
Do not SSR in legacy themes
2 parents f7af061 + 35351a7 commit 3eb0fd6

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
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')}

mailchimp_widget.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ function mailchimp_sf_signup_form( $args = array() ) {
8686
-moz-box-sizing: border-box;
8787
-webkit-box-sizing: border-box;
8888
box-sizing: border-box;
89+
padding: 10px 8px;
8990
width: 100%;
9091
}
9192
.mc_input.mc_phone {
9293
width: auto;
9394
}
9495
select.mc_select {
9596
margin-top: 0.5em;
97+
padding: 10px 8px;
9698
width: 100%;
9799
}
98100
.mc_address_label {
@@ -101,6 +103,7 @@ function mailchimp_sf_signup_form( $args = array() ) {
101103
display: block;
102104
}
103105
.mc_address_label ~ select {
106+
padding: 10px 8px;
104107
width: 100%;
105108
}
106109
.mc_list li {
@@ -117,6 +120,7 @@ function mailchimp_sf_signup_form( $args = array() ) {
117120
}
118121
#mc_signup_submit {
119122
margin-top: 1.5em;
123+
padding: 10px 8px;
120124
width: 80%;
121125
}
122126
#mc_unsub_link a {

views/css/frontend.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
}
7272
ul.mc_list {
7373
list-style-type: none;
74+
margin-left: 0;
75+
padding-left: 0;
7476
}
7577
ul.mc_list li {
7678
font-size: 12px;
@@ -81,4 +83,4 @@
8183
#ui-datepicker-div.show .ui-datepicker-year {
8284
display: inline;
8385
padding-left: 3px
84-
}
86+
}

0 commit comments

Comments
 (0)