Skip to content

Commit

Permalink
v2.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed Jun 21, 2024
1 parent bae6222 commit c66242f
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 112 deletions.
6 changes: 3 additions & 3 deletions email-verification-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Plugin Name: Email Verification for WooCommerce
Plugin URI: https://wpfactory.com/item/email-verification-for-woocommerce/
Description: Verify user emails in WooCommerce. Beautifully.
Version: 2.8.5
Version: 2.8.6
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: emails-verification-for-woocommerce
Domain Path: /langs
Copyright: © 2024 WPFactory
WC tested up to: 8.9
WC tested up to: 9.0
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
Expand Down Expand Up @@ -62,7 +62,7 @@ final class Alg_WC_Email_Verification {
* @var string
* @since 1.0.0
*/
public $version = '2.8.5';
public $version = '2.8.6';

/**
* @var Alg_WC_Email_Verification The single instance of the class
Expand Down
13 changes: 8 additions & 5 deletions includes/class-alg-wc-ev-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Email Verification for WooCommerce - Admin Class.
*
* @version 2.8.5
* @version 2.8.6
* @since 1.5.0
* @author WPFactory
*/
Expand Down Expand Up @@ -332,7 +332,7 @@ function get_query_args_to_remove( $reference ) {
/**
* handle_bulk_actions_users.
*
* @version 2.3.8
* @version 2.8.6
* @since 1.9.6
*
* @param $redirect_to
Expand All @@ -352,7 +352,7 @@ function handle_bulk_user_actions( $redirect_to, $doaction, $user_ids ) {
if ( $user && ! is_wp_error( $user ) ) {
if ( ! alg_wc_ev()->core->is_user_verified( $user ) ) {
$count ++;
alg_wc_ev()->core->emails->reset_and_mail_activation_link( $user_id );
alg_wc_ev()->core->emails->reset_and_mail_activation_link( array( 'user_id' => $user_id ) );
}
}
}
Expand Down Expand Up @@ -530,7 +530,7 @@ function is_user_allowed_to_interact_with_admin_ui( $args = null ) {
/**
* admin_manual_actions.
*
* @version 2.4.8
* @version 2.8.6
* @since 1.1.0
* @todo [next] (maybe) new action: "expire" (i.e. make link expired) (i.e. remove `alg_wc_ev_activation_code_time` meta)
*/
Expand All @@ -553,7 +553,10 @@ function admin_manual_actions() {
exit;
}
if ( $user_id = $this->get_user_id_from_action( 'alg_wc_ev_admin_resend' ) ) {
alg_wc_ev()->core->emails->reset_and_mail_activation_link( $user_id );
alg_wc_ev()->core->emails->reset_and_mail_activation_link( array(
'user_id' => $user_id,
'context' => 'admin_resend',
) );
wp_safe_redirect( add_query_arg( 'alg_wc_ev_admin_resend_done', $user_id, remove_query_arg( $this->actions ) ) );
exit;
}
Expand Down
11 changes: 7 additions & 4 deletions includes/class-alg-wc-ev-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Email Verification for WooCommerce - Core Class.
*
* @version 2.8.2
* @version 2.8.6
* @since 1.0.0
* @author WPFactory
*/
Expand Down Expand Up @@ -883,14 +883,14 @@ function activate_message() {
/**
* resend.
*
* @version 2.4.2
* @version 2.8.6
* @since 1.6.0
* @todo (maybe) rename `alg_wc_ev_user_id`
*/
function resend() {
if (
isset( $_GET['alg_wc_ev_user_id'] ) &&
! empty( $user_id = $_GET['alg_wc_ev_user_id'] ) &&
! empty( $user_id = intval( $_GET['alg_wc_ev_user_id'] ) ) &&
isset( $_GET['alg_wc_ev_nonce'] ) &&
! empty( $nonce = $_GET['alg_wc_ev_nonce'] ) &&
(
Expand All @@ -904,7 +904,10 @@ function resend() {
)
)
) {
$this->emails->reset_and_mail_activation_link( $_GET['alg_wc_ev_user_id'] );
alg_wc_ev()->core->emails->reset_and_mail_activation_link( array(
'user_id' => $user_id,
'context' => 'own_user_resend'
) );
alg_wc_ev_add_notice( $this->messages->get_resend_message()['msg'] );
}
}
Expand Down
24 changes: 15 additions & 9 deletions includes/class-alg-wc-ev-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Email Verification for WooCommerce - Emails Class.
*
* @version 2.8.3
* @version 2.8.6
* @since 1.6.0
* @author WPFactory
*/
Expand Down Expand Up @@ -170,7 +170,7 @@ function alg_wc_ev_email_content_placeholder( $atts ) {
/**
* maybe_send_delayed_activation_email.
*
* @version 2.0.4
* @version 2.8.6
* @since 2.0.2
*/
function maybe_send_delayed_activation_email() {
Expand All @@ -181,22 +181,22 @@ function maybe_send_delayed_activation_email() {
$delayed_email_users_update = array_diff( get_option( 'alg_wc_ev_send_delayed_email_users', array() ), $delayed_email_users );
empty( $delayed_email_users_update ) ? delete_option( 'alg_wc_ev_send_delayed_email_users' ) : update_option( 'alg_wc_ev_send_delayed_email_users', $delayed_email_users_update );
foreach ( $delayed_email_users as $user_id ) {
$this->reset_and_mail_activation_link( $user_id );
$this->reset_and_mail_activation_link( array( 'user_id' => $user_id ) );
}
}
}

/**
* handle_activation_email_sending.
*
* @version 2.4.0
* @version 2.8.6
* @since 2.0.2
*
* @param $user_id
*/
function handle_activation_email_sending( $user_id ) {
if ( 'yes' !== get_option( 'alg_wc_ev_delay_activation_email', 'no' ) ) {
$this->reset_and_mail_activation_link( $user_id );
$this->reset_and_mail_activation_link( array( 'user_id' => $user_id ) );
} else {
$code = alg_wc_ev_generate_user_code();
$this->update_all_user_meta( $user_id, $code );
Expand Down Expand Up @@ -426,13 +426,20 @@ function customer_new_account_reset_and_append_verification_link_fine_tune( $use
/**
* reset_and_mail_activation_link.maybe_send_wc_customer_new_account_email.
*
* @version 2.6.6
* @version 2.8.6
* @since 1.0.0
* @todo (maybe) add `%site_name%` etc. replaced value in `alg_wc_ev_email_subject`
*/
function reset_and_mail_activation_link( $user_id ) {
function reset_and_mail_activation_link( $args = null ) {
$args = wp_parse_args( $args, array(
'user_id' => '',
'context' => '',
) );
$user_id = intval( $args['user_id'] );
$context = $args['context'];
if ( $user_id && apply_filters( 'alg_wc_ev_reset_and_mail_activation_link_validation', true, $user_id, current_filter() ) ) {
// Get data
do_action('alg_wc_ev_reset_and_mail_activation_link', $args );
// Get data.
$user = get_userdata( $user_id );
$code = alg_wc_ev_generate_user_code();
$email_content = $this->get_email_content( array(
Expand All @@ -451,7 +458,6 @@ function reset_and_mail_activation_link( $user_id ) {
if ( ! alg_wc_ev()->core->is_user_verified_by_user_id( $user_id ) ) {
$wc_email_template = get_option( 'alg_wc_ev_wc_email_template', 'simulation' );
$email_template = get_option( 'alg_wc_ev_email_template', 'plain' );

if ( in_array( $email_template, array( 'wc', 'smart' ) ) && 'real_wc_email' === $wc_email_template ) {
do_action('alg_wc_ev_trigger_activation_wc_email', $user_id );
} else {
Expand Down
6 changes: 3 additions & 3 deletions includes/class-alg-wc-ev-non-paying-blocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Email Verification for WooCommerce - Non Paying Blocker.
*
* @version 2.4.0
* @version 2.8.6
* @since 1.9.5
* @author WPFactory
*/
Expand Down Expand Up @@ -123,7 +123,7 @@ function prevent_sending_activation_link_on_user_register_for_non_paying_users(
/**
* mail_activation_link_on_paid_status.
*
* @version 2.2.4
* @version 2.8.6
* @since 2.2.4
*
* @param $order_id
Expand All @@ -143,7 +143,7 @@ function mail_activation_link_on_paid_status( $order_id, $from, $to ) {
in_array( $to, $statuses ) &&
! alg_wc_ev_is_user_verified_by_user_id( $customer_id )
) {
alg_wc_ev()->core->emails->reset_and_mail_activation_link( $customer_id );
alg_wc_ev()->core->emails->reset_and_mail_activation_link( array( 'user_id' => $customer_id ) );
}
}

Expand Down
1 change: 1 addition & 0 deletions includes/settings/class-alg-wc-ev-settings-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ function get_settings() {
'twicedaily' => __( 'Twice daily', 'emails-verification-for-woocommerce' ),
'weekly' => __( 'Weekly', 'emails-verification-for-woocommerce' ),
),
'class' => 'chosen_select',
'id' => 'alg_wc_ev_delete_users_cron_frequency',
'default' => 'weekly',
),
Expand Down
60 changes: 58 additions & 2 deletions includes/settings/class-alg-wc-ev-settings-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Email Verification for WooCommerce - Email Section Settings.
*
* @version 2.8.3
* @version 2.8.6
* @since 1.3.0
* @author WPFactory
*/
Expand All @@ -28,7 +28,7 @@ function __construct() {
/**
* get_settings.
*
* @version 2.8.3
* @version 2.8.6
* @since 1.3.0
*/
function get_settings() {
Expand Down Expand Up @@ -200,6 +200,43 @@ function get_settings() {
'id' => 'alg_wc_ev_fine_tune_activation_email_placement',
'default' => 'no',
),
array(
'title' => __( 'Automatic resending', 'emails-verification-for-woocommerce' ),
'desc' => __( 'Resend the activation email automatically if the user has not yet been verified', 'emails-verification-for-woocommerce' ),
'desc_tip' => __( 'Works for future users, or if a current unverified user receives the activation email manually.', 'emails-verification-for-woocommerce' ),
'type' => 'checkbox',
'id' => 'alg_wc_ev_activation_email_automatic_sending',
'custom_attributes' => apply_filters( 'alg_wc_ev_settings', array( 'disabled' => 'disabled' ) ),
'default' => 'no',
),
array(
'desc' => __( 'Frequency.', 'emails-verification-for-woocommerce' ) . ' ' .
$this->get_frequency_description(),
'type' => 'number',
//'custom_attributes' => array( 'min' => 1 ),
'id' => 'alg_wc_ev_activation_email_automatic_sending_frequency',
'default' => 1,
'custom_attributes' => array_merge( empty( $disabled_arr = apply_filters( 'alg_wc_ev_settings', array( 'disabled' => 'disabled' ) ) ) ? array() : $disabled_arr, array( 'min' => 1 ) ),
),
array(
'desc' => __( 'Unit of time.', 'emails-verification-for-woocommerce' ),
'type' => 'select',
'id' => 'alg_wc_ev_activation_email_automatic_sending_frequency_unit',
'options' => array(
'hour' => __( 'Hours', 'emails-verification-for-woocommerce' ),
'day' => __( 'Days', 'emails-verification-for-woocommerce' ),
),
'class' => 'chosen_select',
'default' => 'day',
'custom_attributes' => apply_filters( 'alg_wc_ev_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'desc' => __( 'Max attempts.', 'emails-verification-for-woocommerce' ),
'type' => 'number',
'id' => 'alg_wc_ev_activation_email_automatic_sending_count_max',
'default' => 3,
'custom_attributes' => array_merge( empty( $disabled_arr = apply_filters( 'alg_wc_ev_settings', array( 'disabled' => 'disabled' ) ) ) ? array() : $disabled_arr, array( 'min' => 1 ) ),
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ev_activation_email',
Expand Down Expand Up @@ -349,6 +386,25 @@ function get_settings() {
return array_merge( $general_opts, $email_placeholder_opts, $activation_email_opts, $confirmation_email_opts, $admin_email_opts );
}

/**
* get_frequency_description.
*
* @version 2.8.6
* @since 2.8.6
*
* @return string
*/
function get_frequency_description() {
$frequency = get_option( 'alg_wc_ev_activation_email_automatic_sending_frequency', '1' );
$unit = get_option( 'alg_wc_ev_activation_email_automatic_sending_frequency_unit', 'day' );
$formatted_words = array(
'hour' => _n( 'hour', 'hours', $frequency, 'emails-verification-for-woocommerce' ),
'day' => _n( 'day', 'days', $frequency, 'emails-verification-for-woocommerce' ),
);

return sprintf( __( 'Send email every %s %s.', 'emails-verification-for-woocommerce' ), (int)$frequency === 1 ? '' : $frequency, $formatted_words[ $unit ] );
}

}

endif;
Expand Down
Loading

0 comments on commit c66242f

Please sign in to comment.