Skip to content

Commit

Permalink
feat: add spacer block support
Browse files Browse the repository at this point in the history
Closes #100
  • Loading branch information
adekbadek committed Apr 21, 2020
1 parent 05d761f commit 996cb69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
8 changes: 8 additions & 0 deletions includes/class-newspack-newsletters-renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ private static function render_mjml_component( $block, $is_in_column = false, $i

break;

/**
* Spacer block.
*/
case 'core/spacer':
$attrs['height'] = $attrs['height'] . 'px';
$block_mjml_markup .= '<mj-spacer ' . self::array_to_attributes( $attrs ) . '/>';
break;

/**
* Social links block.
*/
Expand Down
19 changes: 10 additions & 9 deletions includes/class-newspack-newsletters.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static function newsletters_allowed_block_types( $allowed_block_types, $p
return $allowed_block_types;
}
return array(
'core/spacer',
'core/block',
'core/group',
'core/paragraph',
Expand Down Expand Up @@ -321,7 +322,7 @@ public static function api_get_keys() {
$mailchimp_api_key = self::mailchimp_api_key();
$mjml_api_key = get_option( 'newspack_newsletters_mjml_api_key', false );
$mjml_api_secret = get_option( 'newspack_newsletters_mjml_api_secret', false );

$keys = [
'mailchimp_api_key' => $mailchimp_api_key,
'mjml_api_key' => $mjml_api_key,
Expand All @@ -345,8 +346,8 @@ public static function api_set_keys( $request ) {
$errors = [];

if ( empty( $mailchimp_api_key ) ) {
$wp_error->add(
'newspack_newsletters_invalid_keys_mailchimp',
$wp_error->add(
'newspack_newsletters_invalid_keys_mailchimp',
__( 'Please input a Mailchimp API key.', 'newspack-newsletters' )
);
} else {
Expand All @@ -359,16 +360,16 @@ public static function api_set_keys( $request ) {
if ( $ping ) {
update_option( 'newspack_newsletters_mailchimp_api_key', $mailchimp_api_key );
} else {
$wp_error->add(
'newspack_newsletters_invalid_keys_mailchimp',
$wp_error->add(
'newspack_newsletters_invalid_keys_mailchimp',
__( 'Please input a valid Mailchimp API key.', 'newspack-newsletters' )
);
}
}

if ( empty( $mjml_api_key ) || empty( $mjml_api_secret ) ) {
$wp_error->add(
'newspack_newsletters_invalid_keys_mjml',
$wp_error->add(
'newspack_newsletters_invalid_keys_mjml',
__( 'Please input MJML application ID and secret key.', 'newspack-newsletters' )
);
} else {
Expand All @@ -392,8 +393,8 @@ public static function api_set_keys( $request ) {
update_option( 'newspack_newsletters_mjml_api_key', $mjml_api_key );
update_option( 'newspack_newsletters_mjml_api_secret', $mjml_api_secret );
} else {
$wp_error->add(
'newspack_newsletters_invalid_keys_mjml',
$wp_error->add(
'newspack_newsletters_invalid_keys_mjml',
__( 'Please input valid MJML application ID and secret key.', 'newspack-newsletters' )
);
}
Expand Down

0 comments on commit 996cb69

Please sign in to comment.