From bcb5845ab0cdc4ec1117baa239e10e59aba161cf Mon Sep 17 00:00:00 2001 From: WP Date: Fri, 18 Jun 2021 16:55:44 -0300 Subject: [PATCH] v2.1.0 --- .distignore | 1 - .gitattributes | 3 + .gitignore | 3 +- composer.json | 14 + email-verification-for-woocommerce.php | 66 ++- includes/class-alg-wc-ev-admin.php | 6 +- includes/class-alg-wc-ev-core.php | 50 +- .../class-alg-wc-ev-settings-emails.php | 2 +- .../class-alg-wc-ev-settings-general.php | 31 +- .../settings/class-alg-wc-ev-settings.php | 115 +---- langs/emails-verification-for-woocommerce.pot | 194 +++---- readme.txt | 19 +- vendor/autoload.php | 7 + vendor/composer/ClassLoader.php | 479 ++++++++++++++++++ vendor/composer/InstalledVersions.php | 292 +++++++++++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 11 + vendor/composer/autoload_files.php | 10 + vendor/composer/autoload_namespaces.php | 9 + vendor/composer/autoload_psr4.php | 9 + vendor/composer/autoload_real.php | 73 +++ vendor/composer/autoload_static.php | 25 + vendor/composer/installed.json | 38 ++ vendor/composer/installed.php | 33 ++ .../wpf-promoting-notice/.gitattributes | 3 + .../wpfactory-promoting-notice/.gitattributes | 4 + .../wpfactory-promoting-notice/composer.json | 9 + .../src/php/class-core.php | 317 ++++++++++++ .../src/php/functions.php | 22 + 29 files changed, 1642 insertions(+), 224 deletions(-) create mode 100644 .gitattributes create mode 100644 composer.json create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/InstalledVersions.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_files.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php create mode 100644 vendor/composer/installed.json create mode 100644 vendor/composer/installed.php create mode 100644 vendor/wpfactory/wpf-promoting-notice/.gitattributes create mode 100644 vendor/wpfactory/wpfactory-promoting-notice/.gitattributes create mode 100644 vendor/wpfactory/wpfactory-promoting-notice/composer.json create mode 100644 vendor/wpfactory/wpfactory-promoting-notice/src/php/class-core.php create mode 100644 vendor/wpfactory/wpfactory-promoting-notice/src/php/functions.php diff --git a/.distignore b/.distignore index 9851d4d..db53153 100644 --- a/.distignore +++ b/.distignore @@ -1,7 +1,6 @@ /.git /.github /node_modules -/src /.wordpress-org .idea .distignore diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7c4b183 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +.gitignore export-ignore +composer.lock export-ignore +README.md export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 28d8e97..84af9c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -.idea/* \ No newline at end of file +.idea/* +composer.lock \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9f700f4 --- /dev/null +++ b/composer.json @@ -0,0 +1,14 @@ +{ + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/wpcodefactory/wpfactory-promoting-notice" + } + ], + "require": { + "wpfactory/wpfactory-promoting-notice": "*" + }, + "config": { + "preferred-install": "dist" + } +} \ No newline at end of file diff --git a/email-verification-for-woocommerce.php b/email-verification-for-woocommerce.php index 85830dc..9f3337f 100644 --- a/email-verification-for-woocommerce.php +++ b/email-verification-for-woocommerce.php @@ -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' ) ) : /** @@ -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 @@ -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' ) ); @@ -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. @@ -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. * @@ -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__; } diff --git a/includes/class-alg-wc-ev-admin.php b/includes/class-alg-wc-ev-admin.php index f671a2c..e3ac890 100644 --- a/includes/class-alg-wc-ev-admin.php +++ b/includes/class-alg-wc-ev-admin.php @@ -2,7 +2,7 @@ /** * Email Verification for WooCommerce - Admin Class * - * @version 2.0.1 + * @version 2.1.0 * @since 1.5.0 * @author WPFactory */ @@ -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' ) ); } /** diff --git a/includes/class-alg-wc-ev-core.php b/includes/class-alg-wc-ev-core.php index 7d36b03..0b251fc 100644 --- a/includes/class-alg-wc-ev-core.php +++ b/includes/class-alg-wc-ev-core.php @@ -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 */ @@ -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; + } + } } /** diff --git a/includes/settings/class-alg-wc-ev-settings-emails.php b/includes/settings/class-alg-wc-ev-settings-emails.php index fe9d2b7..7bacbd8 100644 --- a/includes/settings/class-alg-wc-ev-settings-emails.php +++ b/includes/settings/class-alg-wc-ev-settings-emails.php @@ -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%;', diff --git a/includes/settings/class-alg-wc-ev-settings-general.php b/includes/settings/class-alg-wc-ev-settings-general.php index 008cd73..1e00d1d 100644 --- a/includes/settings/class-alg-wc-ev-settings-general.php +++ b/includes/settings/class-alg-wc-ev-settings-general.php @@ -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 */ @@ -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`? @@ -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' ) . '
' . + 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' ), '' . '?alg_wc_ev_email_verified_error' . '' ), + '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' ), diff --git a/includes/settings/class-alg-wc-ev-settings.php b/includes/settings/class-alg-wc-ev-settings.php index 138cb21..f4acafe 100644 --- a/includes/settings/class-alg-wc-ev-settings.php +++ b/includes/settings/class-alg-wc-ev-settings.php @@ -2,7 +2,7 @@ /** * Email Verification for WooCommerce - Settings * - * @version 2.0.8 + * @version 2.1.0 * @since 1.0.0 * @author WPFactory */ @@ -32,102 +32,33 @@ function __construct() { require_once( 'class-alg-wc-ev-settings-admin.php' ); require_once( 'class-alg-wc-ev-settings-advanced.php' ); // Create notice about pro - add_action( 'woocommerce_sections_' . $this->id, array( $this, 'create_notice_regarding_pro' ) ); - add_action( 'woocommerce_sections_' . $this->id, array( $this, 'highlight_premium_notice_on_disabled_setting_click' ) ); + add_action( 'admin_init', array( $this, 'add_promoting_notice' ) ); } /** - * highlight_premium_notice_on_disabled_setting_click. + * add_promoting_notice. * - * @version 2.0.8 - * @since 2.0.8 + * @version 2.1.0 + * @since 2.1.0 */ - function highlight_premium_notice_on_disabled_setting_click(){ - if ( '' === apply_filters( 'alg_wc_ev_settings', true ) ) { - return; - } - ?> - - - %s', - 'margin-right:10px;width:38px;vertical-align:middle', - $plugin_icon_url, - 'vertical-align: middle;margin:0 14px 0 0;', - sprintf( __( 'Disabled options can be unlocked using %s', 'emails-verification-for-woocommerce' ), $pro_version_url, '' . $pro_version_title . '' ) - ); - // Button - $button = sprintf( '%s', - 'vertical-align:middle;display:inline-block;margin:0', - $pro_version_url, - 'position:relative;top:3px;margin:0 2px 0 -2px;', - $upgrade_btn_icon_class, - __( 'Upgrade to Pro version', 'emails-verification-for-woocommerce' ) - ); - echo '

' . $message . $button . '

'; - } + function add_promoting_notice() { + $promoting_notice = wpfactory_promoting_notice(); + $promoting_notice->set_args( array( + 'url_requirements' => array( + 'page_filename' => 'admin.php', + 'params' => array( 'page' => 'wc-settings', 'tab' => $this->id ), + ), + 'enable' => true === apply_filters( 'alg_wc_ev_settings', true ), + 'optimize_plugin_icon_contrast' => true, + 'template_variables' => array( + '%pro_version_url%' => 'https://wpfactory.com/item/email-verification-for-woocommerce/', + '%plugin_icon_url%' => 'https://ps.w.org/emails-verification-for-woocommerce/assets/icon-128x128.png', + '%pro_version_title%' => __( 'Email Verification for WooCommerce Pro', 'emails-verification-for-woocommerce' ), + '%main_text%' => __( 'Disabled options can be unlocked using %pro_version_title%', 'emails-verification-for-woocommerce' ), + '%btn_call_to_action%' => __( 'Upgrade to Pro version', 'emails-verification-for-woocommerce' ), + ), + ) ); + $promoting_notice->init(); } /** diff --git a/langs/emails-verification-for-woocommerce.pot b/langs/emails-verification-for-woocommerce.pot index b3d43bf..04b79fe 100644 --- a/langs/emails-verification-for-woocommerce.pot +++ b/langs/emails-verification-for-woocommerce.pot @@ -2,14 +2,14 @@ # This file is distributed under the GNU General Public License v3.0. msgid "" msgstr "" -"Project-Id-Version: Email Verification for WooCommerce 2.0.9\n" +"Project-Id-Version: Email Verification for WooCommerce 2.1.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/emails-verification-for-woocommerce\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2021-05-20T17:41:51+02:00\n" +"POT-Creation-Date: 2021-06-18T21:47:32+02:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.4.0\n" "X-Domain: emails-verification-for-woocommerce\n" @@ -34,7 +34,7 @@ msgstr "" msgid "https://wpfactory.com" msgstr "" -#: email-verification-for-woocommerce.php:191 +#: email-verification-for-woocommerce.php:185 msgid "Go Pro" msgstr "" @@ -158,7 +158,7 @@ msgid "Thank you for your registration. Your account has to be activated before msgstr "" #: includes/class-alg-wc-ev-non-paying-blocker.php:184 -#: includes/settings/class-alg-wc-ev-settings-general.php:374 +#: includes/settings/class-alg-wc-ev-settings-general.php:401 msgid "You need to become a paying customer in order to activate your account." msgstr "" @@ -313,7 +313,8 @@ msgstr "" #: includes/settings/class-alg-wc-ev-settings-advanced.php:119 #: includes/settings/class-alg-wc-ev-settings-general.php:144 -#: includes/settings/class-alg-wc-ev-settings-general.php:302 +#: includes/settings/class-alg-wc-ev-settings-general.php:172 +#: includes/settings/class-alg-wc-ev-settings-general.php:329 msgid "Custom redirect URL" msgstr "" @@ -362,7 +363,7 @@ msgstr "" #: includes/settings/class-alg-wc-ev-settings-advanced.php:162 #: includes/settings/class-alg-wc-ev-settings-emails.php:68 -#: includes/settings/class-alg-wc-ev-settings-general.php:203 +#: includes/settings/class-alg-wc-ev-settings-general.php:230 msgid "Leave the default value if unsure." msgstr "" @@ -487,7 +488,7 @@ msgid "If the %s option is set it will only delete unverified users whose activa msgstr "" #: includes/settings/class-alg-wc-ev-settings-advanced.php:263 -#: includes/settings/class-alg-wc-ev-settings-general.php:171 +#: includes/settings/class-alg-wc-ev-settings-general.php:198 msgid "Expire time" msgstr "" @@ -928,252 +929,273 @@ msgid "Redirect to custom URL" msgstr "" #: includes/settings/class-alg-wc-ev-settings-general.php:158 +#: includes/settings/class-alg-wc-ev-settings-general.php:165 +msgid "Redirect on failure" +msgstr "" + +#: includes/settings/class-alg-wc-ev-settings-general.php:160 +msgid "Redirects customers after unsuccessful verification." +msgstr "" + +#: includes/settings/class-alg-wc-ev-settings-general.php:161 +msgid "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." +msgstr "" + +#: includes/settings/class-alg-wc-ev-settings-general.php:166 +msgid "Redirects to a custom URL if an unverified user tries to login" +msgstr "" + +#: includes/settings/class-alg-wc-ev-settings-general.php:173 +msgid "If empty will redirect to the same page" +msgstr "" + +#: includes/settings/class-alg-wc-ev-settings-general.php:185 msgid "Activation link" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:159 +#: includes/settings/class-alg-wc-ev-settings-general.php:186 msgid "A link sent via email where users can verify their accounts." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:164 +#: includes/settings/class-alg-wc-ev-settings-general.php:191 msgid "One-time activation link" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:165 +#: includes/settings/class-alg-wc-ev-settings-general.php:192 msgid "Prevent activation link from working after the first use" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:172 +#: includes/settings/class-alg-wc-ev-settings-general.php:199 msgid "Ignored if set to zero." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:173 +#: includes/settings/class-alg-wc-ev-settings-general.php:200 msgid "Please note that all activation codes generated before installing the plugin v1.7.0 will be automatically expired." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:174 +#: includes/settings/class-alg-wc-ev-settings-general.php:201 msgid "Expiration time based on the %s option below." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:174 -#: includes/settings/class-alg-wc-ev-settings-general.php:181 +#: includes/settings/class-alg-wc-ev-settings-general.php:201 +#: includes/settings/class-alg-wc-ev-settings-general.php:208 msgid "Expire time unit" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:184 +#: includes/settings/class-alg-wc-ev-settings-general.php:211 msgid "Seconds" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:185 +#: includes/settings/class-alg-wc-ev-settings-general.php:212 msgid "Days" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:191 +#: includes/settings/class-alg-wc-ev-settings-general.php:218 msgid "Expire notice" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:193 -#: includes/settings/class-alg-wc-ev-settings-general.php:402 +#: includes/settings/class-alg-wc-ev-settings-general.php:220 +#: includes/settings/class-alg-wc-ev-settings-general.php:429 msgid "Notice will appear when user will try to verify his email by clicking the email activation link." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:196 +#: includes/settings/class-alg-wc-ev-settings-general.php:223 msgid "Link has expired. You can resend the email with verification link by clicking here." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:202 +#: includes/settings/class-alg-wc-ev-settings-general.php:229 msgid "Email sending trigger" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:210 +#: includes/settings/class-alg-wc-ev-settings-general.php:237 msgid "On \"user register\"" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:211 +#: includes/settings/class-alg-wc-ev-settings-general.php:238 msgid "On \"WooCommerce created customer\"" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:216 +#: includes/settings/class-alg-wc-ev-settings-general.php:243 msgid "Activation email delay" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:217 +#: includes/settings/class-alg-wc-ev-settings-general.php:244 msgid "Delay the activation email" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:218 +#: includes/settings/class-alg-wc-ev-settings-general.php:245 msgid "Try to enable it if the activation emails are getting sent to authenticated users." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:229 +#: includes/settings/class-alg-wc-ev-settings-general.php:256 msgid "Logout unverified users" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:230 +#: includes/settings/class-alg-wc-ev-settings-general.php:257 msgid "Logouts unverified users in some specific situations." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:235 +#: includes/settings/class-alg-wc-ev-settings-general.php:262 msgid "Logout unverified users on \"My Account\" page" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:236 +#: includes/settings/class-alg-wc-ev-settings-general.php:263 msgid "Check if logged user is verified on \"My Account\" page" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:242 +#: includes/settings/class-alg-wc-ev-settings-general.php:269 msgid "Logout unverified users on every page" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:243 +#: includes/settings/class-alg-wc-ev-settings-general.php:270 msgid "Check if logged user is verified on every page of your site" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:250 +#: includes/settings/class-alg-wc-ev-settings-general.php:277 msgid "Redirect to the activate account notice after logout" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:261 -#: includes/settings/class-alg-wc-ev-settings-general.php:267 +#: includes/settings/class-alg-wc-ev-settings-general.php:288 +#: includes/settings/class-alg-wc-ev-settings-general.php:294 msgid "Block checkout" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:262 +#: includes/settings/class-alg-wc-ev-settings-general.php:289 msgid "Blocks checkout process for unverified users." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:268 +#: includes/settings/class-alg-wc-ev-settings-general.php:295 msgid "Blocks checkout process for unverified users (including guests)." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:275 -#: includes/settings/class-alg-wc-ev-settings-general.php:312 -#: includes/settings/class-alg-wc-ev-settings-general.php:369 -#: includes/settings/class-alg-wc-ev-settings-general.php:401 +#: includes/settings/class-alg-wc-ev-settings-general.php:302 +#: includes/settings/class-alg-wc-ev-settings-general.php:339 +#: includes/settings/class-alg-wc-ev-settings-general.php:396 +#: includes/settings/class-alg-wc-ev-settings-general.php:428 msgid "Error notice" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:278 +#: includes/settings/class-alg-wc-ev-settings-general.php:305 msgid "You need to log in and verify your email to place an order." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:288 -#: includes/settings/class-alg-wc-ev-settings-general.php:294 +#: includes/settings/class-alg-wc-ev-settings-general.php:315 +#: includes/settings/class-alg-wc-ev-settings-general.php:321 msgid "Block adding products to cart" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:289 +#: includes/settings/class-alg-wc-ev-settings-general.php:316 msgid "Blocks guests from adding products to the cart." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:295 +#: includes/settings/class-alg-wc-ev-settings-general.php:322 msgid "Blocks guests from adding any products to the cart" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:303 +#: includes/settings/class-alg-wc-ev-settings-general.php:330 msgid "Redirects to a custom URL after the customer is blocked." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:304 +#: includes/settings/class-alg-wc-ev-settings-general.php:331 msgid "Leave it empty if you don't want to redirect." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:316 +#: includes/settings/class-alg-wc-ev-settings-general.php:343 msgid "You need to register and verify your email before adding products to the cart." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:326 -#: includes/settings/class-alg-wc-ev-settings-general.php:332 +#: includes/settings/class-alg-wc-ev-settings-general.php:353 +#: includes/settings/class-alg-wc-ev-settings-general.php:359 msgid "Block non-paying users" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:327 +#: includes/settings/class-alg-wc-ev-settings-general.php:354 msgid "Prevents non-paying users from activating their accounts until they become paying customers, considering the %s option." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:327 +#: includes/settings/class-alg-wc-ev-settings-general.php:354 msgid "Note:" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:327 +#: includes/settings/class-alg-wc-ev-settings-general.php:354 msgid "Probably this option will make more sense if users register only on checkout, or else they won't be able to purchase to activate their accounts using the same email." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:327 -#: includes/settings/class-alg-wc-ev-settings-general.php:360 +#: includes/settings/class-alg-wc-ev-settings-general.php:354 +#: includes/settings/class-alg-wc-ev-settings-general.php:387 msgid "Role checking" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:333 +#: includes/settings/class-alg-wc-ev-settings-general.php:360 msgid "Block activation link until the customer places an order and its status is considered as paid" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:334 +#: includes/settings/class-alg-wc-ev-settings-general.php:361 msgid "Won't block users already verified." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:341 -#: includes/settings/class-alg-wc-ev-settings-general.php:353 +#: includes/settings/class-alg-wc-ev-settings-general.php:368 +#: includes/settings/class-alg-wc-ev-settings-general.php:380 msgid "Verify paying customers automatically" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:342 +#: includes/settings/class-alg-wc-ev-settings-general.php:369 msgid "Activate the account automatically when the order is paid" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:343 +#: includes/settings/class-alg-wc-ev-settings-general.php:370 msgid "The activation email won't be sent if the order cost is not free." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:351 +#: includes/settings/class-alg-wc-ev-settings-general.php:378 msgid "Send activation email only on payment" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:352 +#: includes/settings/class-alg-wc-ev-settings-general.php:379 msgid "Send the activation email only when order status is considered as paid" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:353 +#: includes/settings/class-alg-wc-ev-settings-general.php:380 msgid "Will only send the email if the %s option is disabled or if the corresponding order cost is free." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:361 +#: includes/settings/class-alg-wc-ev-settings-general.php:388 msgid "Blocks non-paying users with one of the following roles." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:361 +#: includes/settings/class-alg-wc-ev-settings-general.php:388 msgid "Probably you just want to mark the \"Customer\" role." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:361 +#: includes/settings/class-alg-wc-ev-settings-general.php:388 msgid "If empty, will work for any role." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:371 +#: includes/settings/class-alg-wc-ev-settings-general.php:398 msgid "The notice will be displayed when user is blocked after trying to login or to verify its email." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:384 +#: includes/settings/class-alg-wc-ev-settings-general.php:411 msgid "Block account verification by email" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:385 +#: includes/settings/class-alg-wc-ev-settings-general.php:412 msgid "Prevents account verification by email." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:390 +#: includes/settings/class-alg-wc-ev-settings-general.php:417 msgid "Email denylist" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:391 +#: includes/settings/class-alg-wc-ev-settings-general.php:418 msgid "Ignored if empty." msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:392 +#: includes/settings/class-alg-wc-ev-settings-general.php:419 msgid "Separate emails with a comma and/or with a new line. You can also use wildcard (%s) here, for example: %s" msgstr "" -#: includes/settings/class-alg-wc-ev-settings-general.php:405 +#: includes/settings/class-alg-wc-ev-settings-general.php:432 msgid "Your email is denied." msgstr "" @@ -1246,35 +1268,35 @@ msgstr "" msgid "Email Verification" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:110 +#: includes/settings/class-alg-wc-ev-settings.php:56 msgid "Email Verification for WooCommerce Pro" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:119 -msgid "Disabled options can be unlocked using %s" +#: includes/settings/class-alg-wc-ev-settings.php:57 +msgid "Disabled options can be unlocked using %pro_version_title%" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:127 +#: includes/settings/class-alg-wc-ev-settings.php:58 msgid "Upgrade to Pro version" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:164 +#: includes/settings/class-alg-wc-ev-settings.php:95 msgid "Reset Settings" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:169 +#: includes/settings/class-alg-wc-ev-settings.php:100 msgid "Reset section settings" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:170 +#: includes/settings/class-alg-wc-ev-settings.php:101 msgid "Reset" msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:171 +#: includes/settings/class-alg-wc-ev-settings.php:102 msgid "Check the box and save changes to reset." msgstr "" -#: includes/settings/class-alg-wc-ev-settings.php:199 -#: includes/settings/class-alg-wc-ev-settings.php:214 +#: includes/settings/class-alg-wc-ev-settings.php:130 +#: includes/settings/class-alg-wc-ev-settings.php:145 msgid "Your settings have been reset." msgstr "" diff --git a/readme.txt b/readme.txt index dcb9dba..3b5a370 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: wpcodefactory Tags: woocommerce, email, verification, email verification, woo commerce Requires at least: 4.4 Tested up to: 5.7 -Stable tag: 2.0.9 +Stable tag: 2.1.0 License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -78,6 +78,15 @@ If just some of them are already enabled and even so it doesn't work, try to ena = How to prevent duplicated success message after account verification? = Please try to use **General > Redirect on success** option as **Do not redirect** += What can I do if the error messages are not showing? = +If an unverified user is trying to login and the error message (Your account has to be activated before you can login...) is not getting displayed you can try two different approaches: + +1. Use the **Redirect on failure** option. +Even if the **Custom redirect URL** option is empty, there will be no problem. +A `?alg_wc_ev_email_verified_error` argument will be added to the URL that could help you displaying the message. + +2. Change the **Advanced > Authenticate filter** option. + == Installation == 1. Upload the entire plugin folder to the `/wp-content/plugins/` directory. @@ -86,6 +95,14 @@ Please try to use **General > Redirect on success** option as **Do not redirect* == Changelog == += 2.1.0 - 18/06/2021 = +* Fix - Free and pro plugins can't be active at the same time. +* Dev - Use wpf-promoting-notice library to add notice on settings page regarding pro version. +* Dev - General - Add "Redirect on failure" option. +* Add FAQ question regarding error messages not getting displayed. +* Add composer setup. +* WC tested up to: 5.4. + = 2.0.9 - 20/05/2021 = * Dev - Messages - Create "Clear previous messages" option trying to avoid duplicated messages. * Dev - Advanced - Prevent login after register - Create "Force redirect" option. diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..e57482f --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + private $vendorDir; + + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + private static $registeredLoaders = array(); + + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..1a28e21 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,292 @@ + + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => '3b6fd52520687e187ccc61088c4e760b03e920d5', + 'name' => '__root__', + ), + 'versions' => + array ( + '__root__' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => '3b6fd52520687e187ccc61088c4e760b03e920d5', + ), + 'wpfactory/wpfactory-promoting-notice' => + array ( + 'pretty_version' => '1.0.5', + 'version' => '1.0.5.0', + 'aliases' => + array ( + ), + 'reference' => '4d248f9ec4755fe6a8fc5ac0e67a098ac6e01f37', + ), + ), +); +private static $canGetVendors; +private static $installedByVendor = array(); + + + + + + + +public static function getInstalledPackages() +{ +$packages = array(); +foreach (self::getInstalled() as $installed) { +$packages[] = array_keys($installed['versions']); +} + + +if (1 === \count($packages)) { +return $packages[0]; +} + +return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); +} + + + + + + + + + +public static function isInstalled($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (isset($installed['versions'][$packageName])) { +return true; +} +} + +return false; +} + + + + + + + + + + + + + + +public static function satisfies(VersionParser $parser, $packageName, $constraint) +{ +$constraint = $parser->parseConstraints($constraint); +$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + +return $provided->matches($constraint); +} + + + + + + + + + + +public static function getVersionRanges($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +$ranges = array(); +if (isset($installed['versions'][$packageName]['pretty_version'])) { +$ranges[] = $installed['versions'][$packageName]['pretty_version']; +} +if (array_key_exists('aliases', $installed['versions'][$packageName])) { +$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); +} +if (array_key_exists('replaced', $installed['versions'][$packageName])) { +$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); +} +if (array_key_exists('provided', $installed['versions'][$packageName])) { +$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); +} + +return implode(' || ', $ranges); +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getVersion($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +if (!isset($installed['versions'][$packageName]['version'])) { +return null; +} + +return $installed['versions'][$packageName]['version']; +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getPrettyVersion($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +if (!isset($installed['versions'][$packageName]['pretty_version'])) { +return null; +} + +return $installed['versions'][$packageName]['pretty_version']; +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getReference($packageName) +{ +foreach (self::getInstalled() as $installed) { +if (!isset($installed['versions'][$packageName])) { +continue; +} + +if (!isset($installed['versions'][$packageName]['reference'])) { +return null; +} + +return $installed['versions'][$packageName]['reference']; +} + +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + + + + + +public static function getRootPackage() +{ +$installed = self::getInstalled(); + +return $installed[0]['root']; +} + + + + + + + +public static function getRawData() +{ +return self::$installed; +} + + + + + + + + + + + + + + + + + + + +public static function reload($data) +{ +self::$installed = $data; +self::$installedByVendor = array(); +} + + + + +private static function getInstalled() +{ +if (null === self::$canGetVendors) { +self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); +} + +$installed = array(); + +if (self::$canGetVendors) { +foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { +if (isset(self::$installedByVendor[$vendorDir])) { +$installed[] = self::$installedByVendor[$vendorDir]; +} elseif (is_file($vendorDir.'/composer/installed.php')) { +$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; +} +} +} + +$installed[] = self::$installed; + +return $installed; +} +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..dee7469 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,11 @@ + $vendorDir . '/composer/InstalledVersions.php', + 'WPFactory\\Promoting_Notice\\Core' => $vendorDir . '/wpfactory/wpfactory-promoting-notice/src/php/class-core.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..491dd66 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,10 @@ + $vendorDir . '/wpfactory/wpfactory-promoting-notice/src/php/functions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit365338cb4b7dc88b2ccda0d9e2eddbb6::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInit365338cb4b7dc88b2ccda0d9e2eddbb6::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequire365338cb4b7dc88b2ccda0d9e2eddbb6($fileIdentifier, $file); + } + + return $loader; + } +} + +function composerRequire365338cb4b7dc88b2ccda0d9e2eddbb6($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..a663522 --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,25 @@ + __DIR__ . '/..' . '/wpfactory/wpfactory-promoting-notice/src/php/functions.php', + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'WPFactory\\Promoting_Notice\\Core' => __DIR__ . '/..' . '/wpfactory/wpfactory-promoting-notice/src/php/class-core.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->classMap = ComposerStaticInit365338cb4b7dc88b2ccda0d9e2eddbb6::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..234e744 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,38 @@ +{ + "packages": [ + { + "name": "wpfactory/wpfactory-promoting-notice", + "version": "1.0.5", + "version_normalized": "1.0.5.0", + "source": { + "type": "git", + "url": "https://github.com/wpcodefactory/wpfactory-promoting-notice.git", + "reference": "4d248f9ec4755fe6a8fc5ac0e67a098ac6e01f37" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wpcodefactory/wpfactory-promoting-notice/zipball/4d248f9ec4755fe6a8fc5ac0e67a098ac6e01f37", + "reference": "4d248f9ec4755fe6a8fc5ac0e67a098ac6e01f37", + "shasum": "" + }, + "time": "2021-06-07T20:53:39+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/php/" + ], + "files": [ + "src/php/functions.php" + ] + }, + "support": { + "source": "https://github.com/wpcodefactory/wpfactory-promoting-notice/tree/1.0.5", + "issues": "https://github.com/wpcodefactory/wpfactory-promoting-notice/issues" + }, + "install-path": "../wpfactory/wpfactory-promoting-notice" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..07effe3 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,33 @@ + + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => '3b6fd52520687e187ccc61088c4e760b03e920d5', + 'name' => '__root__', + ), + 'versions' => + array ( + '__root__' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => '3b6fd52520687e187ccc61088c4e760b03e920d5', + ), + 'wpfactory/wpfactory-promoting-notice' => + array ( + 'pretty_version' => '1.0.5', + 'version' => '1.0.5.0', + 'aliases' => + array ( + ), + 'reference' => '4d248f9ec4755fe6a8fc5ac0e67a098ac6e01f37', + ), + ), +); diff --git a/vendor/wpfactory/wpf-promoting-notice/.gitattributes b/vendor/wpfactory/wpf-promoting-notice/.gitattributes new file mode 100644 index 0000000..7c4b183 --- /dev/null +++ b/vendor/wpfactory/wpf-promoting-notice/.gitattributes @@ -0,0 +1,3 @@ +.gitignore export-ignore +composer.lock export-ignore +README.md export-ignore \ No newline at end of file diff --git a/vendor/wpfactory/wpfactory-promoting-notice/.gitattributes b/vendor/wpfactory/wpfactory-promoting-notice/.gitattributes new file mode 100644 index 0000000..d7d771a --- /dev/null +++ b/vendor/wpfactory/wpfactory-promoting-notice/.gitattributes @@ -0,0 +1,4 @@ +.gitignore export-ignore +composer.lock export-ignore +README.md export-ignore +changelog.md export-ignore \ No newline at end of file diff --git a/vendor/wpfactory/wpfactory-promoting-notice/composer.json b/vendor/wpfactory/wpfactory-promoting-notice/composer.json new file mode 100644 index 0000000..adbc006 --- /dev/null +++ b/vendor/wpfactory/wpfactory-promoting-notice/composer.json @@ -0,0 +1,9 @@ +{ + "name": "wpfactory/wpfactory-promoting-notice", + "autoload": { + "classmap": [ + "src/php/" + ], + "files": ["src/php/functions.php"] + } +} \ No newline at end of file diff --git a/vendor/wpfactory/wpfactory-promoting-notice/src/php/class-core.php b/vendor/wpfactory/wpfactory-promoting-notice/src/php/class-core.php new file mode 100644 index 0000000..0c90b49 --- /dev/null +++ b/vendor/wpfactory/wpfactory-promoting-notice/src/php/class-core.php @@ -0,0 +1,317 @@ + true, + 'notice_template' => '

%content_template%

', + 'lib_dirname' => dirname( __FILE__, 2 ), + 'highlight_notice_on_disabled_opt_click' => true, + 'template_variables' => array(), + 'url_requirements' => array( + 'page_filename' => 'admin.php', + 'params' => array(), + ), + 'display_action' => $this->get_default_display_action( $args ), + 'optimize_plugin_icon_contrast' => false + ) ); + // Template variables + $args['template_variables'] = wp_parse_args( $args['template_variables'], array( + '%notice_class%' => 'wpfactory-promoting-notice notice notice-info inline', + '%pro_version_title%' => __( 'Awesome plugin Pro', 'wpfactory-promoting-notice' ), + '%pro_version_url%' => 'https://wpfactory.com/item/awesome-plugin/', + '%plugin_icon_url%' => 'https://pluginfactory-tastystakes.netdna-ssl.com/img/site/plugin_icon.png', + '%plugin_icon_style%' => 'width:39px;margin-right:10px;vertical-align:middle', + '%btn_icon_class%' => 'wpfactory-pan-btn-icon dashicons-before dashicons-unlock', + '%btn_icon_style%' => 'position:relative;top:3px;margin:0 2px 0 -2px;', + '%btn_style%' => 'vertical-align:middle;display:inline-block;margin:0', + '%btn_call_to_action%' => __( 'Upgrade to Pro version', 'wpfactory-promoting-notice' ), + '%main_text%' => __( 'Disabled options can be unlocked using %pro_version_title%', 'wpfactory-promoting-notice' ), + '%main_text_style%' => 'vertical-align: middle;margin:0 14px 0 0;', + '%content_template%' => '' . + '%main_text%' . + '%btn_call_to_action%', + ) ); + // Set args + $this->args = $args; + } + + /** + * get_default_display_action. + * + * @version 1.0.3 + * @since 1.0.3 + * + * @param $args + * + * @return string + */ + function get_default_display_action( $args ) { + $action_hook = 'admin_notices'; + if ( + isset( $args['url_requirements']['params']['page'] ) + && ! empty( $page = $args['url_requirements']['params']['page'] ) + && isset( $args['url_requirements']['params']['tab'] ) + && ! empty( $tab = $args['url_requirements']['params']['tab'] ) + && 'wc-settings' === $page + ) { + $action_hook = 'woocommerce_sections_' . $tab; + } + return $action_hook; + } + + /** + * init. + * + * @version 1.0.4 + * @since 1.0.0 + */ + function init() { + $args = $this->get_args(); + if ( empty( $args['enable'] ) ) { + return; + } + global $pagenow; + if ( + ! empty( $args['url_requirements'] ) + && ! empty( $page_filename = $args['url_requirements']['page_filename'] ) + && ! empty( $url_params = $args['url_requirements']['params'] ) + && ! empty( $pagenow ) + && $pagenow == $page_filename + && array_intersect_assoc( $url_params, $_GET ) === $url_params + ) { + add_action( 'admin_head', array( $this, 'create_style' ) ); + add_action( 'admin_head', array( $this, 'highlight_notice_on_disabled_setting_click' ) ); + add_action( $args['display_action'], array( $this, 'create_notice' ) ); + } + } + + /** + * decode_template_variables. + * + * @version 1.0.0 + * @since 1.0.0 + * + * @param $template_variables + * + * @return array + */ + function decode_template_variables( $template_variables ) { + $levels = 2; + for ( $i = 1; $i <= $levels; $i ++ ) { + $template_variables = array_map( function ( $v ) use ( $template_variables ) { + return str_replace( array_keys( $template_variables ), $template_variables, $v ); + }, $template_variables ); + } + return $template_variables; + } + + /** + * create_notice. + * + * @version 1.0.0 + * @since 1.0.0 + */ + function create_notice() { + $args = $this->get_args(); + $notice = $args['notice_template']; + $template_variables = $this->decode_template_variables( $args['template_variables'] ); + $notice = str_replace( array_keys( $template_variables ), $template_variables, $notice ); + echo $notice; + } + + /** + * highlight_premium_notice_on_disabled_setting_click. + * + * @version 1.0.0 + * @since 1.0.0 + */ + function highlight_notice_on_disabled_setting_click() { + $args = $this->get_args(); + if ( !( $args['highlight_notice_on_disabled_opt_click'] ) ) { + return; + } + ?> + + get_args(); + $notice_selector = $this->get_notice_selector(); + $image_rendering_style = ' + image-rendering: -moz-crisp-edges; + image-rendering: -o-crisp-edges; + image-rendering: -webkit-optimize-contrast; + image-rendering: crisp-edges; + -ms-interpolation-mode: nearest-neighbor;'; + $image_rendering_style = $args['optimize_plugin_icon_contrast'] ? $image_rendering_style : ''; + ?> + + ', ', + 'item_template' => '{value}' // {key} and {value} allowed + ) ); + $transformed_arr = array_map( function ( $key, $value ) use ( $args ) { + $item = str_replace( array( '{key}', '{value}' ), array( $key, $value ), $args['item_template'] ); + return $item; + }, array_keys( $arr ), $arr ); + return implode( $args['glue'], $transformed_arr ); + } + + /** + * get_args. + * + * @version 1.0.0 + * @since 1.0.0 + * + * @return array + */ + public function get_args() { + return $this->args; + } + + /** + * get_notice_selector. + * + * @version 1.0.3 + * @since 1.0.0 + * + * @return string + */ + function get_notice_selector() { + $args = $this->get_args(); + $selector = '.wpfactory-promoting-notice'; + return $selector; + } + + + } +} \ No newline at end of file diff --git a/vendor/wpfactory/wpfactory-promoting-notice/src/php/functions.php b/vendor/wpfactory/wpfactory-promoting-notice/src/php/functions.php new file mode 100644 index 0000000..8d9fa82 --- /dev/null +++ b/vendor/wpfactory/wpfactory-promoting-notice/src/php/functions.php @@ -0,0 +1,22 @@ +