From 44e8fb553e46b42abc9b2b2425f5bf3bac4a33d7 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 28 Jun 2024 10:19:51 -0600 Subject: [PATCH 1/3] Add a container around the entire widget output. This prevents styling inconsistencies between the shortcode and block output. Add a top margin to match the bottom margin of the sub header --- mailchimp_widget.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mailchimp_widget.php b/mailchimp_widget.php index b34c9bbe..43420e9e 100644 --- a/mailchimp_widget.php +++ b/mailchimp_widget.php @@ -23,6 +23,7 @@ function mailchimp_sf_signup_form( $args = array() ) { // See if we have valid Merge Vars if ( ! is_array( $mv ) ) { + echo '
'; echo wp_kses_post( $before_widget ); ?>
@@ -40,9 +41,12 @@ function mailchimp_sf_signup_form( $args = array() ) {
'; return; } + echo '
'; + if ( ! empty( $before_widget ) ) { echo wp_kses_post( $before_widget ); } @@ -72,7 +76,7 @@ function mailchimp_sf_signup_form( $args = array() ) { } #mc_subheader { line-height: 1.25em; - margin-bottom: 18px; + margin: 18px 0; } .mc_merge_var { margin-bottom: 1.0em; @@ -275,6 +279,8 @@ function mailchimp_sf_signup_form( $args = array() ) { if ( ! empty( $after_widget ) ) { echo wp_kses_post( $after_widget ); } + + echo '
'; } /** From 378a4be9ac0f44e1202e8ffe3e5f8aa72cddb9e2 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 28 Jun 2024 10:23:11 -0600 Subject: [PATCH 2/3] Only add our wrapping container if custom before and after widget fields don't exist. This prevents an extra layer around a normal widget --- mailchimp_widget.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mailchimp_widget.php b/mailchimp_widget.php index 43420e9e..5d43ccf1 100644 --- a/mailchimp_widget.php +++ b/mailchimp_widget.php @@ -23,8 +23,11 @@ function mailchimp_sf_signup_form( $args = array() ) { // See if we have valid Merge Vars if ( ! is_array( $mv ) ) { - echo '
'; - echo wp_kses_post( $before_widget ); + if ( ! empty( $before_widget ) ) { + echo wp_kses_post( $before_widget ); + } else { + echo '
'; + } ?>
'; + if ( ! empty( $after_widget ) ) { + echo wp_kses_post( $after_widget ); + } else { + echo '
'; + } return; } - echo '
'; - if ( ! empty( $before_widget ) ) { echo wp_kses_post( $before_widget ); + } else { + echo '
'; } $header = get_option( 'mc_header_content' ); @@ -278,9 +284,9 @@ function mailchimp_sf_signup_form( $args = array() ) { '; } - - echo '
'; } /** From e9a2dc713e9de23866274ce8b91cc3f6a1bc4427 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 28 Jun 2024 15:04:42 -0600 Subject: [PATCH 3/3] Add our closing container if the variable is empty, ensuring we never miss that closing tag --- mailchimp_widget.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mailchimp_widget.php b/mailchimp_widget.php index 3fbb0a7e..965509b3 100644 --- a/mailchimp_widget.php +++ b/mailchimp_widget.php @@ -45,9 +45,12 @@ function mailchimp_sf_signup_form( $args = array() ) { '; } + return; } @@ -284,7 +287,9 @@ function mailchimp_sf_signup_form( $args = array() ) { '; } }