Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed Jun 18, 2021
1 parent 524ee31 commit bcb5845
Show file tree
Hide file tree
Showing 29 changed files with 1,642 additions and 224 deletions.
1 change: 0 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/.git
/.github
/node_modules
/src
/.wordpress-org
.idea
.distignore
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gitignore export-ignore
composer.lock export-ignore
README.md export-ignore
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.idea/*
.idea/*
composer.lock
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wpcodefactory/wpfactory-promoting-notice"
}
],
"require": {
"wpfactory/wpfactory-promoting-notice": "*"
},
"config": {
"preferred-install": "dist"
}
}
66 changes: 30 additions & 36 deletions email-verification-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@
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.0.9
Version: 2.1.0
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: emails-verification-for-woocommerce
Domain Path: /langs
Copyright: © 2021 WPFactory
WC tested up to: 5.3
WC tested up to: 5.4
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

// Handle is_plugin_active function
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}

// Check for active plugins
if (
! is_plugin_active( 'woocommerce/woocommerce.php' ) ||
( 'email-verification-for-woocommerce.php' === basename( __FILE__ ) && is_plugin_active( 'email-verification-for-woocommerce-pro/email-verification-for-woocommerce-pro.php' ) )
) {
return;
}

if ( ! class_exists( 'Alg_WC_Email_Verification' ) ) :
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
endif;

if ( ! class_exists( 'Alg_WC_Email_Verification' ) ) :

/**
Expand All @@ -33,7 +50,7 @@ final class Alg_WC_Email_Verification {
* @var string
* @since 1.0.0
*/
public $version = '2.0.9';
public $version = '2.1.0';

/**
* @var Alg_WC_Email_Verification The single instance of the class
Expand Down Expand Up @@ -68,20 +85,12 @@ public static function instance() {
/**
* Alg_WC_Email_Verification Constructor.
*
* @version 1.9.8
* @version 2.1.0
* @since 1.0.0
* @access public
*/
function __construct() {

// Check for active plugins
if (
! $this->is_plugin_active( 'woocommerce/woocommerce.php' ) ||
( 'email-verification-for-woocommerce.php' === basename( __FILE__ ) && $this->is_plugin_active( 'email-verification-for-woocommerce-pro/email-verification-for-woocommerce-pro.php' ) )
) {
return;
}

// Localization
add_action( 'init', array( $this, 'localize' ) );

Expand All @@ -99,27 +108,27 @@ function __construct() {
}

// Generate documentation
//add_filter( 'wpfpdh_documentation_params_' . plugin_basename( $this->plugin_file() ), array( $this, 'handle_documentation_params' ), 10 );
add_filter( 'wpfpdh_documentation_params_' . plugin_basename( $this->get_filesystem_path() ), array( $this, 'handle_documentation_params' ), 10 );
}

/**
* Handle documentation params managed by the WP Factory
*
* @version 2.0.2
* @version 2.1.0
* @since 2.0.0
*
* @param $params
*
* @return mixed
*/
/*function handle_documentation_params( $params ) {
function handle_documentation_params( $params ) {
$params['wc_tab_id'] = 'alg_wc_ev';
$params['pro_settings_filter'] = 'alg_wc_ev_settings';
$params['text_file_update_params']=array(
$params['pro_settings_filter'] = 'alg_wc_ev_settings';
/*$params['text_file_update_params']=array(
'text_file_path' => WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'test' .DIRECTORY_SEPARATOR.'test.txt' //plugin_dir_path( $this->plugins_dir . DIRECTORY_SEPARATOR . $plugin_file ) ) ) . DIRECTORY_SEPARATOR . 'readme.txt'
);
);*/
return $params;
}*/
}

/**
* localize.
Expand All @@ -133,21 +142,6 @@ function localize() {
load_plugin_textdomain( 'emails-verification-for-woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
}

/**
* is_plugin_active.
*
* @version 1.2.0
* @since 1.2.0
*/
function is_plugin_active( $plugin ) {
return ( function_exists( 'is_plugin_active' ) ? is_plugin_active( $plugin ) :
(
in_array( $plugin, apply_filters( 'active_plugins', ( array ) get_option( 'active_plugins', array() ) ) ) ||
( is_multisite() && array_key_exists( $plugin, ( array ) get_site_option( 'active_sitewide_plugins', array() ) ) )
)
);
}

/**
* Include required core files used in admin and on the frontend.
*
Expand Down Expand Up @@ -239,11 +233,11 @@ function plugin_path() {
/**
* Get the plugin file.
*
* @version 1.7.0
* @version 2.1.0
* @since 1.7.0
* @return string
*/
function plugin_file() {
function get_filesystem_path() {
return __FILE__;
}

Expand Down
6 changes: 3 additions & 3 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.0.1
* @version 2.1.0
* @since 1.5.0
* @author WPFactory
*/
Expand Down Expand Up @@ -212,11 +212,11 @@ function schedule_delete_unverified_users_cron() {
/**
* unschedule_delete_unverified_users_cron_on_deactivation.
*
* @version 1.7.0
* @version 2.1.0
* @since 1.7.0
*/
function unschedule_delete_unverified_users_cron_on_deactivation() {
register_deactivation_hook( alg_wc_ev()->plugin_file(), array( $this, 'unschedule_delete_unverified_users_cron' ) );
register_deactivation_hook( alg_wc_ev()->get_filesystem_path(), array( $this, 'unschedule_delete_unverified_users_cron' ) );
}

/**
Expand Down
50 changes: 49 additions & 1 deletion includes/class-alg-wc-ev-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Alg_WC_Email_Verification_Core {
/**
* Constructor.
*
* @version 2.0.5
* @version 2.1.0
* @since 1.0.0
* @todo [next] (maybe) `[alg_wc_ev_translate]` to description in readme.txt
*/
Expand Down Expand Up @@ -53,6 +53,54 @@ function __construct() {
add_action( 'alg_wc_ev_user_account_activated', array( $this, 'display_success_activation_message' ) );
add_action( 'init', array( $this, 'display_success_activation_message' ) );
add_filter( 'wp_redirect', array( $this, 'remove_success_activation_message' ) );
// Error message
add_action( 'init', array( $this, 'display_error_activation_message' ) );
// Redirects on failure
add_action( 'wp_login_failed', array( $this, 'redirect_on_failure' ), 10, 2 );
}

/**
* display_error_activation_message.
*
* @version 2.1.0
* @since 2.1.0
*/
function display_error_activation_message() {
if (
isset( $_GET['alg_wc_ev_email_verified_error'] )
&& ! empty( $user_id = $_GET['alg_wc_ev_email_verified_error'] )
&& ! empty( $user = get_user_by( 'ID', $user_id ) )
) {
$message = apply_filters( 'alg_wc_ev_block_unverified_user_login_error_message', alg_wc_ev()->core->messages->get_error_message( $user->ID ), $user );
alg_wc_ev_add_notice( $message );
}
}

/**
* redirect_on_failure.
*
* @version 2.1.0
* @since 2.1.0
*
* @param $username
* @param $error
*/
function redirect_on_failure( $username, $error ) {
if (
'yes' === get_option( 'alg_wc_ev_redirect_on_failure', 'no' )
&& in_array( 'alg_wc_ev_email_verified_error', $error->get_error_codes() )
) {
$user = get_user_by( 'email', $username );
if ( ! $user ) {
$user = get_user_by( 'login', $username );
}
if ( $user ) {
wp_redirect( add_query_arg( array(
'alg_wc_ev_email_verified_error' => $user->ID
), get_option( 'alg_wc_ev_redirect_on_failure_url', '' ) ) );
exit;
}
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/settings/class-alg-wc-ev-settings-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function get_settings() {
array(
'title' => __( 'Subject', 'emails-verification-for-woocommerce' ),
'desc' => $this->available_placeholders_desc( $this->get_default_email_placeholders() ),
'type' => 'text',
'type' => 'text',
'id' => 'alg_wc_ev_admin_email_subject',
'default' => __( 'User email has been verified', 'emails-verification-for-woocommerce' ),
'css' => 'width:100%;',
Expand Down
31 changes: 29 additions & 2 deletions includes/settings/class-alg-wc-ev-settings-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Email Verification for WooCommerce - General Section Settings
*
* @version 2.0.8
* @version 2.1.0
* @since 1.0.0
* @author WPFactory
*/
Expand Down Expand Up @@ -40,7 +40,7 @@ function get_user_roles_options() {
/**
* get_settings.
*
* @version 2.0.8
* @version 2.1.0
* @since 1.0.0
* @todo [next] Logout unverified users on every page: better description
* @todo [next] (maybe) `alg_wc_ev_delay_wc_email`: default to `yes`?
Expand Down Expand Up @@ -154,6 +154,33 @@ function get_settings() {
'type' => 'sectionend',
'id' => 'alg_wc_ev_redirect_on_success_options',
),
array(
'title' => __( 'Redirect on failure', 'emails-verification-for-woocommerce' ),
'type' => 'title',
'desc' => __( 'Redirects customers after unsuccessful verification.', 'emails-verification-for-woocommerce' ) . '<br />' .
sprintf( __( 'This will also append a %s argument to the URL that could help you displaying the error message in case you have issues with that.', 'emails-verification-for-woocommerce' ), '<code>' . '?alg_wc_ev_email_verified_error' . '</code>' ),
'id' => 'alg_wc_ev_redirect_on_failure_options',
),
array(
'title' => __( 'Redirect on failure', 'emails-verification-for-woocommerce' ),
'desc' => __( 'Redirects to a custom URL if an unverified user tries to login', 'emails-verification-for-woocommerce' ),
'type' => 'checkbox',
'id' => 'alg_wc_ev_redirect_on_failure',
'default' => 'no'
),
array(
'title' => __( 'Custom redirect URL', 'emails-verification-for-woocommerce' ),
'desc_tip' => __( 'If empty will redirect to the same page', 'emails-verification-for-woocommerce' ),
'type' => 'text',
'id' => 'alg_wc_ev_redirect_on_failure_url',
'default' => '',
'css' => 'width:100%;',
'alg_wc_ev_raw' => true,
),
array(
'type' => 'sectionend',
'id' => 'alg_wc_ev_redirect_on_failure_options',
),
array(
'title' => __( 'Activation link', 'emails-verification-for-woocommerce' ),
'desc' => __( 'A link sent via email where users can verify their accounts.', 'emails-verification-for-woocommerce' ),
Expand Down
Loading

0 comments on commit bcb5845

Please sign in to comment.