Skip to content

Commit

Permalink
Merge pull request #134 from alleyinteractive/feature/header-footer-e…
Browse files Browse the repository at this point in the history
…nhancements

LEDE-2616: Header and Footer Enhancements
  • Loading branch information
efuller authored Jun 3, 2024
2 parents a6755f4 + 6da165d commit 4322ba4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
8 changes: 3 additions & 5 deletions blocks/footer/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ export default function Edit({
</>
)}
<div className="wp-block-wp-newsletter-builder-footer__links">
{/* @ts-ignore */}
<preferences>{__('Preferences', 'wp-newsletter-builder')}</preferences>
{' | '}
{/* @ts-ignore */}
<unsubscribe>{__('Unsubscribe', 'wp-newsletter-builder')}</unsubscribe>
<a href="#unsubscribe_preferences">
{__('Manage Subscription Preferences', 'wp-newsletter-builder')}
</a>
</div>
</div>
);
Expand Down
6 changes: 2 additions & 4 deletions blocks/footer/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @package wp-newsletter-builder
*/

$nb_settings = get_option( 'nb_campaign_monitor_settings' );
$nb_settings = get_option( 'nb_settings' );
$nb_footer_settings = is_array( $nb_settings ) ? $nb_settings['footer_settings'] : [];
$nb_facebook_url = $nb_footer_settings['facebook_url'] ?? '';
$nb_twitter_url = $nb_footer_settings['twitter_url'] ?? '';
Expand Down Expand Up @@ -70,8 +70,6 @@
<?php endif; ?>

<div class="wp-block-wp-newsletter-builder-footer__links">
<preferences><u><?php esc_html_e( 'Preferences', 'wp-newsletter-builder' ); ?></u></preferences>
&nbsp;|&nbsp;
<unsubscribe><u><?php esc_html_e( 'Unsubscribe', 'wp-newsletter-builder' ); ?></u></unsubscribe>
<a href="#unsubscribe_preferences"><?php esc_html_e( 'Manage Subscription Preferences', 'wp-newsletter-builder' ); ?></a>
</div>
</div>
4 changes: 2 additions & 2 deletions blocks/header/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
return;
}

$wp_newsletter_builder_block_image_id = get_post_meta( $wp_newsletter_builder_block_post_id, 'nb_newsletter_header_img', true );
if ( empty( $wp_newsletter_builder_block_image_id ) || ! is_int( $wp_newsletter_builder_block_image_id ) ) {
$wp_newsletter_builder_block_image_id = (int) get_post_meta( $wp_newsletter_builder_block_post_id, 'nb_newsletter_header_img', true );

Check failure on line 16 in blocks/header/render.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan PHP 8.2

Cannot cast mixed to int.
if ( empty( $wp_newsletter_builder_block_image_id ) ) {
return;
}
// TODO: Add a check to see if the image exists.
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Newsletter Builder
* Plugin URI: https://github.com/alleyinteractive/wp-newsletter-builder
* Description: Interface to manage email newsletters
* Version: 0.3.15
* Version: 0.3.16
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-newsletter-builder
* Requires at least: 6.2
Expand Down
8 changes: 8 additions & 0 deletions src/class-ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class Ads {
* @return void
*/
public function __construct() {
/**
* Filter to enable/disable ads support.
*/
$support_ads = apply_filters( 'wp_newsletter_builder_enable_ads_support', true );
if ( ! $support_ads ) {
return;
}

add_filter( 'the_content', [ $this, 'insert_ads' ], 8, 1 );
add_filter( 'render_block_wp-newsletter-builder/ad', [ $this, 'render_ad' ], 10, 2 );
add_filter( 'wp_kses_allowed_html', [ $this, 'modify_allowed_html' ], 10, 2 );
Expand Down
18 changes: 17 additions & 1 deletion src/email-providers/class-sendgrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ public function create_campaign( int $newsletter_id, array $list_ids, string $ca
''
);

/**
* Since CSSToInlineStyles strips out {{}} tags, we are settings up placeholders that
* can be replaced after the conversion.
*
* @link https://github.com/tijsverkoyen/CssToInlineStyles/issues/163
*/
if ( str_contains( $html_content, 'href="#unsubscribe"' ) ) {
$html_content = str_replace( 'href="#unsubscribe"', 'href="{{unsubscribe}}"', $html_content );
}

if ( str_contains( $html_content, 'href="#unsubscribe_preferences"' ) ) {
$html_content = str_replace( 'href="#unsubscribe_preferences"', 'href="{{unsubscribe_preferences}}"', $html_content );
}

$text_content = wp_strip_all_tags( $html_content );
$subject = get_post_meta( $newsletter_id, 'nb_newsletter_subject', true );

Expand All @@ -175,7 +189,9 @@ public function create_campaign( int $newsletter_id, array $list_ids, string $ca
$request_body->email_config->generate_plain_content = true;
$request_body->email_config->sender_id = $sender_id ?? 0;
$request_body->email_config->subject = $subject;
$request_body->email_config->suppression_group_id = (int) get_post_meta( $newsletter_id, 'nb_newsletter_suppression_group', true );

// TODO: A suppression group id or a custom unsubscribe url should be options.
$request_body->email_config->custom_unsubscribe_url = home_url() . '/account';

$request_body->send_to->list_ids = $list_ids;
$request_body->send_to->segment_ids = [];
Expand Down

0 comments on commit 4322ba4

Please sign in to comment.