Skip to content

Commit

Permalink
noptin 1.2.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mutendebrian committed Jan 5, 2020
1 parent 53c9507 commit d10c5e2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 41 deletions.
3 changes: 2 additions & 1 deletion includes/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ public function maybe_do_action() {

// Docs page
if( isset( $_GET['page'] ) && 'noptin-docs' == $_GET['page'] ) {
wp_redirect( 'https://noptin.com/guide/', 301 );
$url = sprintf( 'https://noptin.com/guide/introduction/?utm_medium=plugin-dashboard&utm_campaign=documentation-link&utm_source=%s', urlencode( get_home_url() ) );
wp_redirect( $url, 301 );
exit;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-noptin-email-newsletters-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function column_date_sent( $item ) {
}

$title = esc_attr( $item->post_date );
echo "<span title='$title'>$date</span>";
echo "<span title='$title' style='border-bottom: 1px dotted #333;'>$date</span>";
}

/**
Expand Down
9 changes: 3 additions & 6 deletions includes/admin/welcome-screen.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="wrap about-wrap">
<h1><?php esc_html_e( 'Welcome To Noptin', 'newsletter-optin-box' ); ?></h1>
<div class="about-text"><?php esc_html_e( 'Noptin is very fast, lightweight and makes it easy to collect email addresses from your website visitors.', 'newsletter-optin-box' ); ?></div>
<div class="about-text"><?php esc_html_e( 'Noptin is fast, lightweight and makes it easy to collect email addresses from your website visitors.', 'newsletter-optin-box' ); ?></div>

<div class="changelog nmi-api-section" style="max-width: 560px;">
<h3 style="text-align: left;color: #1B5E20;"><?php esc_html_e( 'Getting Started', 'newsletter-optin-box' ); ?></h3>
Expand All @@ -20,18 +20,15 @@
<h3 style="text-align: left;color: #1B5E20;"><?php esc_html_e( 'Using the Opt-in Form Editor', 'newsletter-optin-box' ); ?></h3>
<p><?php printf(
esc_html__( 'Noptin also comes with an %s that you can use to build a more advanced email subscription form and embed it in a post, widget or popup lightbox.', 'newsletter-optin-box' ),
sprintf( '<a target="_blank" href="https://noptin.com/guide/email-forms/opt-in-forms-editor/?utm_medium=plugin-dashboard&utm_campaign=welcome&utm_source=%s">opt-in form editor</a>', esc_url( get_home_url() ) )
sprintf( '<a target="_blank" href="https://noptin.com/guide/email-forms/opt-in-forms-editor/?utm_medium=plugin-dashboard&utm_campaign=welcome&utm_source=%s">opt-in forms editor</a>', esc_url( get_home_url() ) )
); ?>
</p>

<p><a target="_blank" href="<?php echo esc_url( get_noptin_new_form_url() ); ?>"><?php esc_html_e( 'Open the editor.', 'newsletter-optin-box' ) ?></a></p>

</div>

<div class="changelog nmi-api-section" style="max-width: 560px;">
<h3 style="text-align: left;color: #1B5E20;"><?php esc_html_e( 'Email Campagins', 'newsletter-optin-box' ); ?></h3>
<p><?php printf(
esc_html__( 'You can to send your email subscribers %sone time emails%s or %sautomated emails%s.', 'newsletter-optin-box' ),
esc_html__( 'You can send your email subscribers %sone time emails%s or %sautomated emails%s.', 'newsletter-optin-box' ),
sprintf( '<a target="_blank" href="https://noptin.com/guide/sending-emails/?utm_medium=plugin-dashboard&utm_campaign=welcome&utm_source=%s">', esc_url( get_home_url() ) ),
'</a>',
sprintf( '<a target="_blank" href="https://noptin.com/guide/email-automations/?utm_medium=plugin-dashboard&utm_campaign=welcome&utm_source=%s">', esc_url( get_home_url() ) ),
Expand Down
34 changes: 15 additions & 19 deletions includes/class-noptin-background-mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,25 @@ public function prepare_campaign_data( $item ) {
public function fetch_subscriber_from_query( $item ) {
global $wpdb;

// Avoid sending the same campaign twice
$meta_query = new WP_Meta_Query( array(
'relation' => 'AND',
array(
'key' => '_campaign_' . $item['key'],
'compare' => 'NOT EXISTS',
),
));

// Subscribers' table
$table = $wpdb->prefix . 'noptin_subscribers';
$table2 = $wpdb->prefix . 'noptin_subscriber_meta';

$key = $wpdb->prepare( '%s', '_campaign_' . $item['key'] );
$to_avoid = $wpdb->get_col( "SELECT noptin_subscriber_id FROM $table2 WHERE meta_key = $key");
// Retrieve join and where clauses
$clauses = $meta_query->get_sql( 'noptin_subscriber', $table, 'id' );

if( empty( $to_avoid ) ) {
$to_avoid = '1=1';
} else {
$to_avoid = implode( ',', $to_avoid );
$to_avoid = "$table.id NOT IN ($to_avoid)";
}



$query = "SELECT $table.id
FROM $table
INNER JOIN $table2 ON ($table.id = $table2.noptin_subscriber_id)
WHERE $to_avoid AND $table.active = 0 AND " . $item['subscribers_query'] .
' LIMIT 1';
$query = "SELECT $table.id FROM $table {$clauses['join']} WHERE {$item['subscribers_query']} AND $table.active = 0 {$clauses['where']} LIMIT 1";

return $wpdb->get_var( $wpdb->prepare( $query, '_campaign_' . $item['key'] ) );
return $wpdb->get_var( $query );

}

}
}
2 changes: 1 addition & 1 deletion includes/class-noptin-inpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct() {
public function append_inpost( $content ) {

// Maybe abort early
if( is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_noptin_actions_page() ){
if( is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_noptin_actions_page() || is_preview() ){
return $content ;
}

Expand Down
25 changes: 16 additions & 9 deletions includes/class-noptin-mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ public function get_email( $data = array() ) {
public function prepare_template( $content, $data ) {

// Ensure the template exists
if(! file_exists( $data['template'] ) ) {
$template = apply_filters( 'noptin_mailer_template', $data['template'], $data );
if(! file_exists( $template ) ) {
return $content;
}

$data['template'] = $template;

// Preview text
$preview = $this->get_preview_text( $data );
$preview = apply_filters( 'noptin_email_preview', $preview, $data );
Expand Down Expand Up @@ -107,17 +110,21 @@ public function prepare_template( $content, $data ) {
// Remove comments
$email_content = preg_replace( "/<!--(.*)-->/Uis", '', $email_content );

if( class_exists( 'DOMDocument' ) ) {

// Emogrify the email
require_once get_noptin_include_dir( 'class-noptin-emogrifier.php' );

// Emogrify the email
require_once get_noptin_include_dir( 'class-noptin-emogrifier.php' );

try {
$emogrifier = new Noptin_Emogrifier( $email_content );
$_email_content = $emogrifier->emogrify();
$email_content = $_email_content;
} catch (Exception $e) {
try {
$emogrifier = new Noptin_Emogrifier( $email_content );
$_email_content = $emogrifier->emogrify();
$email_content = $_email_content;
} catch (Exception $e) {

}

}


// Remove multiple line breaks
$email_content = preg_replace( "/[\r\n]+/", "\n", $email_content );
Expand Down
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ function add_noptin_subscriber( $fields ) {
'email' => $fields['email'],
'first_name' => empty( $fields['first_name'] ) ? '' : $fields['first_name'],
'second_name' => empty( $fields['last_name'] ) ? '' : $fields['last_name'],
'confirm_key' => md5($email) . wp_generate_password(4, false),
'confirm_key' => md5( $fields['email'] ) . wp_generate_password(4, false),
'date_created' => date("Y-m-d"),
);

Expand Down
4 changes: 2 additions & 2 deletions noptin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Description: Easily add a newsletter optin box onto post content, widget or popup
* Author: Picocodes
* Author URI: https://github.com/picocodes
* Version: 1.2.0
* Version: 1.2.1
* Text Domain: noptin
* License: GPL3+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
Expand Down Expand Up @@ -40,7 +40,7 @@ class Noptin{
* @var Plugin version
* @since 1.0.0
*/
public $version = '1.2.0';
public $version = '1.2.1';

/**
* @var Plugin db version
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: newsletter, email newsletter form, email opt-in, email popup, newsletter w
Requires at least: 4.9
Tested up to: 5.3
Requires PHP: 5.3
Version: 1.2.0
Version: 1.2.1
Stable tag: trunk
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -90,3 +90,11 @@ Yeah. Your newsletter subscription forms will take your theme's default styling.
5. Noptin Dashboard
6. Opt-in Forms Editor
7. General Settings Page


== Changelog ==

= 1.2.1 - 2020-01-06 =
- Do not inject shortcode forms on post previews - CHANGED
- check if class DOMDocument exists before emogrifying - ADDED
- New filter to change email templates - ADDED

0 comments on commit d10c5e2

Please sign in to comment.