Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not SSR in legacy themes #38

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading