Skip to content

Commit

Permalink
3.6.2 release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
picocodes committed Oct 24, 2024
1 parent f7a512e commit 5243f34
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-primitives', 'wp-url'), 'version' => '67e4a075b6b19c29f580');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-primitives', 'wp-url'), 'version' => '4daa673e8995726ede04');
2 changes: 1 addition & 1 deletion build/Automation_Rules/assets/js/automation-rule-editor.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '82b9a8a2ac5cf70554f9');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'd44e2d534e1734b7c7db');
2 changes: 1 addition & 1 deletion build/Automation_Rules/assets/js/automation-rules.js

Large diffs are not rendered by default.

207 changes: 193 additions & 14 deletions build/Subscribers/Records.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function get_triggers() {
strtolower( $label )
);

$triggers[ $state ]['extra_args'] = array(
$triggers[ $state ]['extra_args'] = array(
'previous_status' => array(
'label' => __( 'Previous status', 'newsletter-optin-box' ),
'description' => __( 'The previous subscriber status.', 'newsletter-optin-box' ),
Expand Down Expand Up @@ -258,8 +258,8 @@ public function get_triggers() {
'previous_name' => 'add_to_' . $merge_tag,
'description' => sprintf(
/* translators: %s: field label */
__( 'When a %1$s is added to %2$s', 'newsletter-optin-box' ),
strtolower( $this->singular_label ),
__( 'When a %1$s is added to %2$s', 'newsletter-optin-box' ),
strtolower( $this->singular_label ),
strtolower( $field['label'] )
),
'subject' => 'subscriber',
Expand Down Expand Up @@ -288,8 +288,8 @@ public function get_triggers() {
'previous_name' => 'remove_from_' . $merge_tag,
'description' => sprintf(
/* translators: %s: field label */
__( 'When a %1$s is removed from %2$s', 'newsletter-optin-box' ),
strtolower( $this->label ),
__( 'When a %1$s is removed from %2$s', 'newsletter-optin-box' ),
strtolower( $this->label ),
strtolower( $field['label'] )
),
'subject' => 'subscriber',
Expand Down Expand Up @@ -479,7 +479,7 @@ public function on_field_add( $subscriber, $value ) {
* @param \Hizzle\Noptin\DB\Subscriber $subscriber The subscriber.
* @param $campaign_id The campaign that was opened.
*/
public function on_open( $subscriber, $campaign_id ) {
public function on_open( $subscriber, $campaign_id ) {

$subscriber = noptin_get_subscriber( $subscriber );
if ( empty( $subscriber ) || ! is_a( $subscriber, '\Hizzle\Noptin\DB\Subscriber' ) ) {
Expand All @@ -496,7 +496,7 @@ public function on_open( $subscriber, $campaign_id ) {
);

$this->trigger( 'open_email', $args );
}
}

/**
* Fired when a subscriber clicks on a link in an email campaign.
Expand All @@ -505,7 +505,7 @@ public function on_open( $subscriber, $campaign_id ) {
* @param $campaign_id The campaign that was opened.
* @param $url The url that was clicked.
*/
public function on_click( $subscriber, $campaign_id, $url ) {
public function on_click( $subscriber, $campaign_id, $url ) {

$subscriber = noptin_get_subscriber( $subscriber );
if ( empty( $subscriber ) || ! is_a( $subscriber, '\Hizzle\Noptin\DB\Subscriber' ) ) {
Expand All @@ -525,7 +525,7 @@ public function on_click( $subscriber, $campaign_id, $url ) {
);

$this->trigger( 'open_email', $args );
}
}

/**
* Retrieves several subscribers.
Expand Down Expand Up @@ -857,7 +857,7 @@ public function get_test_id() {
* @return array $actions The actions.
*/
public function get_actions() {
return array_merge(
$actions = array_merge(
parent::get_actions(),
array(
'subscribe' => array(
Expand Down Expand Up @@ -965,24 +965,203 @@ public function get_actions() {
),
)
);

// Custom fields.
if ( ! class_exists( '\Noptin\Addons_Pack\Custom_Fields\Main' ) ) {
foreach ( $this->subscriber_fields() as $merge_tag => $field ) {

if ( 'confirmed' === $merge_tag ) {
$field['label'] = __( 'Email confirmation status', 'newsletter-optin-box' );
}

if ( empty( $field['multiple'] ) ) {
$actions[ "change_{$merge_tag}" ] = array(
'label' => sprintf(
// translators: %1$s: Object type label, %2$s: Field label.
__( '%1$s > Update %2$s', 'newsletter-optin-box' ),
$this->singular_label,
$field['label']
),
'description' => sprintf(
/* translators: %s: field label */
__( 'Updates %s', 'newsletter-optin-box' ),
strtolower( $field['label'] )
),
'icon' => array(
'icon' => 'editor-table',
'fill' => '#008000',
),
'callback' => __CLASS__ . '::update_subscriber_field',
'extra_settings' => array(
'email' => array(
'label' => __( 'Subscriber ID or email address', 'newsletter-optin-box' ),
'type' => 'string',
'default' => '[[email]]',
'required' => true,
),
$merge_tag => array(
'el' => 'select',
'label' => $field['label'],
'options' => $field['options'],
'required' => true,
'default' => '',
),
),
);
} else {
$actions[ "add_to_{$merge_tag}" ] = array(
'label' => sprintf(
// translators: %1$s: Object type label, %2$s: Field label.
__( '%1$s > Add to %2$s', 'newsletter-optin-box' ),
$this->singular_label,
$field['label']
),
'description' => sprintf(
/* translators: %s: field label */
__( 'Adds the subscriber to %s', 'newsletter-optin-box' ),
strtolower( $field['label'] )
),
'icon' => array(
'icon' => 'category',
'fill' => '#008000',
),
'callback' => __CLASS__ . '::add_to_subscriber_field',
'extra_settings' => array(
'email' => array(
'label' => __( 'Subscriber ID or email address', 'newsletter-optin-box' ),
'type' => 'string',
'default' => '[[email]]',
'required' => true,
),
$merge_tag => array(
'el' => 'tags' === $merge_tag ? 'input' : 'multi_checkbox_alt',
'label' => $field['label'],
'options' => $field['options'],
'required' => true,
'default' => array(),
),
),
);

$actions[ "remove_from_{$merge_tag}" ] = array(
'label' => sprintf(
// translators: %1$s: Object type label, %2$s: Field label.
__( '%1$s > Remove from %2$s', 'newsletter-optin-box' ),
$this->singular_label,
$field['label']
),
'description' => sprintf(
/* translators: %s: field label */
__( 'Removes the subscriber from %s', 'newsletter-optin-box' ),
strtolower( $field['label'] )
),
'icon' => array(
'icon' => 'category',
'fill' => '#008000',
),
'callback' => __CLASS__ . '::remove_from_subscriber_field',
'extra_settings' => array(
'email' => array(
'label' => __( 'Subscriber ID or email address', 'newsletter-optin-box' ),
'type' => 'string',
'default' => '[[email]]',
'required' => true,
),
$merge_tag => array(
'el' => 'tags' === $merge_tag ? 'input' : 'multi_checkbox_alt',
'label' => $field['label'],
'options' => $field['options'],
'required' => true,
'default' => array(),
),
),
);
}
}
}

return $actions;
}

/**
* Processes a subscriber action.
*
* @param array $args
*/
public static function update_subscriber_field( $args ) {
public static function update_subscriber_field( $args, $action_id = 'custom-field' ) {

if ( empty( $args['email'] ) ) {
return new \WP_Error( 'noptin_invalid_email', 'Invalid email address or subscriber ID.' );
}

$action_args = array();

if ( 'custom-field' === $action_id ) {
$action_args = array(
$args['field_name'] => isset( $args['field_value'] ) ? $args['field_value'] : '',
);
}

if ( 0 === strpos( $action_id, 'change_' ) ) {
$field_name = str_replace( 'change_', '', $action_id );
$action_args = array(
$field_name => isset( $args[ $field_name ] ) ? $args[ $field_name ] : '',
);
}

return update_noptin_subscriber(
$args['email'],
array(
$args['field_name'] => isset( $args['field_value'] ) ? $args['field_value'] : '',
)
$action_args
);
}

/**
* Processes a subscriber action.
*
* @param array $args
*/
public static function add_to_subscriber_field( $args, $action_id ) {

if ( empty( $args['email'] ) ) {
return new \WP_Error( 'noptin_invalid_email', 'Invalid email address or subscriber ID.' );
}

$subscriber = noptin_get_subscriber( $args['email'] );

if ( ! $subscriber->exists() ) {
return new \WP_Error( 'noptin_subscriber_not_found', 'Subscriber not found.' );
}

$field_name = str_replace( 'add_to_', '', $action_id );
$field_value = noptin_parse_list( isset( $args[ $field_name ] ) ? $args[ $field_name ] : array(), true );
$existing = noptin_parse_list( $subscriber->get( $field_name, array() ), true );

$subscriber->set( $field_name, array_unique( array_merge( $existing, $field_value ) ) );
$subscriber->save();
}

/**
* Processes a subscriber action.
*
* @param array $args
*/
public static function remove_from_subscriber_field( $args, $action_id ) {

if ( empty( $args['email'] ) ) {
return new \WP_Error( 'noptin_invalid_email', 'Invalid email address or subscriber ID.' );
}

$subscriber = noptin_get_subscriber( $args['email'] );

if ( ! $subscriber->exists() ) {
return new \WP_Error( 'noptin_subscriber_not_found', 'Subscriber not found.' );
}

$field_name = str_replace( 'remove_from_', '', $action_id );
$field_value = noptin_parse_list( isset( $args[ $field_name ] ) ? $args[ $field_name ] : array(), true );
$existing = noptin_parse_list( $subscriber->get( $field_name, array() ), true );

$subscriber->set( $field_name, array_unique( array_diff( $existing, $field_value ) ) );
$subscriber->save();
}
}
4 changes: 2 additions & 2 deletions includes/class-noptin-custom-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public static function default_fields() {
'label' => __( 'First Name', 'newsletter-optin-box' ),
'visible' => true,
'required' => false,
'predefined' => true,
'predefined' => false,
),
array(
'type' => 'last_name',
'merge_tag' => 'last_name',
'label' => __( 'Last Name', 'newsletter-optin-box' ),
'visible' => true,
'required' => false,
'predefined' => true,
'predefined' => false,
),
array(
'type' => 'email',
Expand Down
8 changes: 8 additions & 0 deletions includes/class-noptin-dynamic-content-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ protected function replace_with_brackets( $content, $escape_function = '' ) {
*/
protected function replace_with_regex( $content, $regex, $escape_function = '' ) {

if ( is_array( $content ) ) {
foreach ( $content as $key => $value ) {
$content[ $key ] = $this->replace_with_regex( $value, $regex, $escape_function );
}

return $content;
}

if ( ! is_string( $content ) || empty( $content ) ) {
return $content;
}
Expand Down
6 changes: 6 additions & 0 deletions includes/field-types/class-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public function filter_db_schema( $schema, $custom_field ) {
)
);

if ( 'first_name' === $custom_field['merge_tag'] || 'last_name' === $custom_field['merge_tag'] ) {
$schema[ $column ]['length'] = 100;
$schema[ $column ]['nullable'] = false;
$schema[ $column ]['default'] = '';
}

// Sanitize options.
if ( is_callable( array( $this, 'sanitize_value' ) ) ) {
$schema[ $column ]['sanitize_callback'] = array( $this, 'sanitize_value' );
Expand Down
4 changes: 4 additions & 0 deletions includes/subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,10 @@ function get_noptin_custom_fields( $public_only = false ) {
}
}

if ( 'first_name' === $field['merge_tag'] || 'last_name' === $field['merge_tag'] ) {
$prepared_field['predefined'] = false;
}

$fields[] = $prepared_field;
}

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: A very fast and lightweight WordPress newsletter plugin
* Author: Noptin Newsletter
* Author URI: https://github.com/picocodes
* Version: 3.6.1
* Version: 3.6.2
* Text Domain: newsletter-optin-box
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
Expand Down Expand Up @@ -46,7 +46,7 @@ class Noptin {
* @var string Plugin version
* @since 1.0.0
*/
public $version = '3.6.1';
public $version = '3.6.2';

/**
* The current database version.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "noptin",
"version": "3.6.0",
"version": "3.6.2",
"private": true,
"description": "WordPress Newsletter Plugin",
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Tags: newsletter, newsletter form, newsletter subscribers, newsletter widget, wo
Requires at least: 6.4
Tested up to: 6.6
Requires PHP: 7.2
Version: 3.6.1
Stable tag: 3.6.1
Version: 3.6.2
Stable tag: 3.6.2
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Donate link: https://noptin.com/products/?utm_source=wp-repo&utm_medium=donate&utm_campaign=readme
Expand Down Expand Up @@ -137,6 +137,9 @@ Yeah. Your newsletter subscription forms will take your theme's default styling.

== Changelog ==

= 3.6.2 =
* Fix: Subscriber imported automated emails not sending.

= 3.6.1 =
* Fix: Submission redirect not working for newsletter forms created using the advanced form builder.

Expand Down
Loading

0 comments on commit 5243f34

Please sign in to comment.