Skip to content

Commit

Permalink
3.7.1 release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
picocodes committed Jan 6, 2025
1 parent 9046337 commit 00911d7
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build/Forms/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ public function get_cached( $key, $default = '' ) {
$this->cached = array_merge( $this->cached, (array) $form_state );
}

if ( ! empty( $this->cached['gdprCheckbox'] ) && ! empty( $this->cached['gdprConsentText'] ) ) {
if ( ! empty( $this->cached['gdprCheckbox'] ) && 'false' !== $this->cached['gdprCheckbox'] && ! empty( $this->cached['gdprConsentText'] ) ) {
$this->cached['acceptance'] = $this->cached['gdprCheckbox'] ? $this->cached['gdprConsentText'] : '';
}
}
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.7.0
* Version: 3.7.1
* 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.7.0';
public $version = '3.7.1';

/**
* The current database version.
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.7
Requires PHP: 7.2
Version: 3.7.0
Stable tag: 3.7.0
Version: 3.7.1
Stable tag: 3.7.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Donate link: https://noptin.com/pricing/?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.7.1 =
* Fix: Classic newsletter subscription forms requiring GDPR acceptance even if not enabled.

= 3.7.0 =
* Add: Make it possible to skip sending new post notifications on certain week days.

Expand Down
54 changes: 41 additions & 13 deletions src/Objects/Generic_Post_Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,12 @@ public function get_fields() {
'label' => __( 'Status', 'newsletter-optin-box' ),
'type' => 'string',
'actions' => array( $action ),
'options' => get_post_statuses(),
'options' => array_merge(
get_post_statuses(),
array(
'future' => __( 'Scheduled', 'newsletter-optin-box' ),
)
),
),
'comment_status' => array(
'label' => __( 'Comment Status', 'newsletter-optin-box' ),
Expand Down Expand Up @@ -477,6 +482,7 @@ protected function get_list_shortcode_template() {
* @return array $actions The actions.
*/
public function get_actions() {
$is_vowel = in_array( strtolower( $this->singular_label[0] ), array( 'a', 'e', 'i', 'o', 'u' ), true );
return array_merge(
parent::get_actions(),
array(
Expand All @@ -487,11 +493,17 @@ public function get_actions() {
__( '%s > Create or Update', 'newsletter-optin-box' ),
$this->singular_label
),
'description' => sprintf(
/* translators: %s: Object type label. */
__( 'Create or update a %s', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'description' => $is_vowel ?
sprintf(
/* translators: %s: Object type label. */
__( 'Create or update an %s', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
) :
sprintf(
/* translators: %s: Object type label. */
__( 'Create or update a %s', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'callback' => array( $this, 'create_post' ),
),
),
Expand All @@ -503,11 +515,17 @@ public function get_actions() {
__( '%s > Delete', 'newsletter-optin-box' ),
$this->singular_label
),
'description' => sprintf(
/* translators: %s: Object type label. */
__( 'Delete a %s', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'description' => $is_vowel ?
sprintf(
/* translators: %s: Object type label. */
__( 'Delete an %s', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
) :
sprintf(
/* translators: %s: Object type label. */
__( 'Delete a %s', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'callback' => array( $this, 'delete_post' ),
'extra_settings' => array(
'force_delete' => array(
Expand Down Expand Up @@ -537,7 +555,15 @@ protected function prepare_create_post_args( $args ) {

foreach ( $args as $key => $value ) {
if ( 'id' === $key ) {
$post_info['ID'] = $value;
if ( is_numeric( $value ) ) {
$post_info['ID'] = $value;
}

$existing = get_page_by_path( sanitize_title( $value ), OBJECT, $this->type );

if ( $existing ) {
$post_info['ID'] = $existing->ID;
}
continue;
}

Expand Down Expand Up @@ -570,7 +596,7 @@ protected function prepare_create_post_args( $args ) {
continue;
}

if ( in_array( $key, array( 'title', 'excerpt', 'content', 'status' ), true ) ) {
if ( in_array( $key, array( 'title', 'excerpt', 'content', 'status', 'parent', 'date' ), true ) ) {
$post_info[ "post_$key" ] = $value;
continue;
}
Expand Down Expand Up @@ -615,6 +641,8 @@ protected function prepare_create_post_args( $args ) {
$post_info['meta_input'][ $key ] = $value;
}

$post_info = apply_filters( 'noptin_post_prepare_create_post_args', $post_info, $args );

if ( empty( $post_info['meta_input'] ) ) {
unset( $post_info['meta_input'] );
}
Expand Down
49 changes: 34 additions & 15 deletions src/Objects/Post_Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function get_triggers() {
);
}

$is_vowel = in_array( strtolower( substr( $this->singular_label, 0, 1 ) ), array( 'a', 'e', 'i', 'o', 'u' ), true );
return array_merge(
parent::get_triggers(),
array(
Expand All @@ -113,11 +114,17 @@ public function get_triggers() {
__( '%s > Published', 'newsletter-optin-box' ),
$this->singular_label
),
'description' => sprintf(
/* translators: %s: Object type label. */
__( 'When a %s is published', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'description' => $is_vowel ?
sprintf(
/* translators: %s: Object type label. */
__( 'When an %s is published', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
) :
sprintf(
/* translators: %s: Object type label. */
__( 'When a %s is published', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'subject' => 'post_author',
'mail_config' => array(
'object_type' => $this->object_type,
Expand Down Expand Up @@ -147,11 +154,17 @@ public function get_triggers() {
__( '%s > Unpublished', 'newsletter-optin-box' ),
$this->singular_label
),
'description' => sprintf(
/* translators: %s: Object type label. */
__( 'When a %s is unpublished', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'description' => $is_vowel ?
sprintf(
/* translators: %s: Object type label. */
__( 'When an %s is unpublished', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
) :
sprintf(
/* translators: %s: Object type label. */
__( 'When a %s is unpublished', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'subject' => 'post_author',
),
$this->type . '_deleted' => array(
Expand All @@ -160,11 +173,17 @@ public function get_triggers() {
__( '%s > Deleted', 'newsletter-optin-box' ),
$this->singular_label
),
'description' => sprintf(
/* translators: %s: Object type label. */
__( 'When a %s is deleted', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'description' => $is_vowel ?
sprintf(
/* translators: %s: Object type label. */
__( 'When an %s is deleted', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
) :
sprintf(
/* translators: %s: Object type label. */
__( 'When a %s is deleted', 'newsletter-optin-box' ),
strtolower( $this->singular_label )
),
'subject' => 'post_author',
),
)
Expand Down

0 comments on commit 00911d7

Please sign in to comment.