Skip to content

Commit 20b60a4

Browse files
committed
Fix spacing issues.
1 parent 9213520 commit 20b60a4

5 files changed

Lines changed: 40 additions & 22 deletions

File tree

includes/blocks/class-mailchimp-list-subscribe-form-blocks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function register_blocks() {
9191
'unsubscribe_link_text' => array(
9292
'type' => 'string',
9393
'default' => esc_html__( 'unsubscribe from list', 'mailchimp' ),
94-
)
94+
),
9595
);
9696

9797
// Register the Mailchimp List Subscribe Form block.
@@ -110,7 +110,7 @@ public function register_blocks() {
110110
$form_field_block_json_file = MCSF_DIR . 'dist/blocks/mailchimp-form-field/block.json';
111111
if ( file_exists( $form_field_block_json_file ) ) {
112112
$form_field_block_folder = dirname( $form_field_block_json_file );
113-
register_block_type($form_field_block_folder );
113+
register_block_type( $form_field_block_folder );
114114
}
115115

116116
$data = array(

includes/blocks/mailchimp-form-field/field-markup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
$merge_fields = array_filter(
2424
$merge_fields,
25-
function( $field ) use ( $field_tag ) {
25+
function ( $field ) use ( $field_tag ) {
2626
return $field['tag'] === $field_tag;
2727
}
2828
);
2929

30-
$merge_field = current( $merge_fields );
30+
$merge_field = current( $merge_fields );
3131
// Bail if we don't have a merge field.
3232
if ( empty( $merge_field ) ) {
3333
return;

includes/blocks/mailchimp/markup.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@
3737
$unsubscribe_link_text = $attributes['unsubscribe_link_text'] ?? __( 'unsubscribe from list', 'mailchimp' );
3838
$update_existing_subscribers = ( $attributes['update_existing_subscribers'] ?? get_option( 'mc_update_existing' ) === 'on' ) ? 'yes' : 'no';
3939
$double_opt_in = ( $attributes['double_opt_in'] ?? get_option( 'mc_double_optin' ) === 'on' ) ? 'yes' : 'no';
40-
$hash = wp_hash( serialize( array(
41-
'list_id' => $list_id,
42-
'update_existing' => $update_existing_subscribers,
43-
'double_opt_in' => $double_opt_in,
44-
) ) );
40+
$hash = wp_hash(
41+
serialize( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
42+
array(
43+
'list_id' => $list_id,
44+
'update_existing' => $update_existing_subscribers,
45+
'double_opt_in' => $double_opt_in,
46+
)
47+
)
48+
);
4549

4650
// See if we have valid Merge Vars
4751
if ( ! is_array( $merge_fields ) || empty( $list_id ) ) {
@@ -185,11 +189,20 @@
185189
</div>
186190

187191
<?php
188-
echo $content;
192+
/**
193+
* the $content is the html generated from innerBlocks
194+
* it is being created from the save method in JS or the render_callback
195+
* in php and is sanitized.
196+
*
197+
* Re sanitizing it through `wp_kses_post` causes
198+
* embed blocks to break and other core filters don't apply.
199+
* therefore no additional sanitization is done and it is being output as is
200+
*/
201+
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
189202

190203
$visible_inner_blocks = array_filter(
191204
$inner_blocks,
192-
function( $inner_block ) {
205+
function ( $inner_block ) {
193206
return $inner_block['attrs']['visible'] ?? false;
194207
}
195208
);

includes/class-mailchimp-block-form-submission.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ public function handle_form_submission() {
2727
$update_existing = isset( $_POST['mailchimp_sf_update_existing_subscribers'] ) ? sanitize_text_field( wp_unslash( $_POST['mailchimp_sf_update_existing_subscribers'] ) ) : '';
2828
$double_opt_in = isset( $_POST['mailchimp_sf_double_opt_in'] ) ? sanitize_text_field( wp_unslash( $_POST['mailchimp_sf_double_opt_in'] ) ) : '';
2929
$hash = isset( $_POST['mailchimp_sf_hash'] ) ? sanitize_text_field( wp_unslash( $_POST['mailchimp_sf_hash'] ) ) : '';
30-
$expected = wp_hash( serialize( array(
31-
'list_id' => $list_id,
32-
'update_existing' => $update_existing,
33-
'double_opt_in' => $double_opt_in,
34-
) ) );
30+
$expected = wp_hash(
31+
serialize( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
32+
array(
33+
'list_id' => $list_id,
34+
'update_existing' => $update_existing,
35+
'double_opt_in' => $double_opt_in,
36+
)
37+
)
38+
);
3539

3640
// Bail if the hash is invalid.
3741
if ( ! hash_equals( $expected, $hash ) ) {
@@ -285,7 +289,7 @@ protected function set_all_groups_to_false( $interest_groups ) {
285289
foreach ( $interest_groups as $$interest_group ) {
286290
if ( 'hidden' !== $interest_group['type'] ) {
287291
foreach ( $interest_group['groups'] as $group ) {
288-
$id = $group['id'];
292+
$id = $group['id'];
289293
$groups->$id = false;
290294
}
291295
}
@@ -297,12 +301,13 @@ protected function set_all_groups_to_false( $interest_groups ) {
297301
/**
298302
* Get signup form URL for the Mailchimp list.
299303
*
304+
* @param string $list_id The list ID.
300305
* @return string
301306
*/
302307
protected function get_signup_form_url( $list_id ) {
303-
$dc = get_option( 'mc_datacenter' );
304-
$user = get_option( 'mc_user' );
305-
$url = 'https://' . $dc . '.list-manage.com/subscribe?u=' . $user['account_id'] . '&id=' . $list_id;
308+
$dc = get_option( 'mc_datacenter' );
309+
$user = get_option( 'mc_user' );
310+
$url = 'https://' . $dc . '.list-manage.com/subscribe?u=' . $user['account_id'] . '&id=' . $list_id;
306311
return $url;
307312
}
308313
}

lib/mailchimp/mailchimp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ public function post( $endpoint, $body, $method = 'POST', $list_id = '' ) {
183183
update_option( 'mailchimp_sf_auth_error', true );
184184
}
185185

186-
$body = json_decode( $request['body'], true );
187-
$merges = get_option( 'mc_merge_vars' );
186+
$body = json_decode( $request['body'], true );
187+
$merges = get_option( 'mc_merge_vars' );
188188
// Get merge fields for the list if we have a list id.
189189
if ( ! empty( $list_id ) ) {
190190
$merges = get_option( 'mailchimp_sf_merge_fields_' . $list_id );

0 commit comments

Comments
 (0)