From 902fb6c19a156787ad70a524792690adcf7890c8 Mon Sep 17 00:00:00 2001 From: Pablo Pacheco Date: Tue, 22 Oct 2024 16:35:37 -0300 Subject: [PATCH] v2.9.0 --- .distignore | 15 + composer.json | 10 + email-verification-for-woocommerce.php | 56 +- includes/class-alg-wc-ev-admin.php | 88 ++- includes/class-alg-wc-ev-core.php | 115 ++-- includes/class-alg-wc-ev-emails.php | 49 +- .../class-alg-wc-ev-settings-email.php | 155 +++-- .../class-alg-wc-ev-settings-general.php | 188 +++--- .../class-alg-wc-ev-settings-messages.php | 16 +- ...ails-verification-for-woocommerce-fr_FR.po | 461 ++++++------- ...ails-verification-for-woocommerce-pt_BR.po | 461 ++++++------- langs/emails-verification-for-woocommerce.pot | 639 +++++++++--------- readme.txt | 12 +- vendor/autoload.php | 18 + vendor/composer/ClassLoader.php | 146 +++- vendor/composer/InstalledVersions.php | 44 +- vendor/composer/autoload_classmap.php | 9 +- vendor/composer/autoload_files.php | 2 +- vendor/composer/autoload_namespaces.php | 2 +- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_real.php | 51 +- vendor/composer/autoload_static.php | 7 + vendor/composer/installed.json | 119 +++- vendor/composer/installed.php | 32 +- vendor/composer/platform_check.php | 26 - .../langs/wpfactory-admin-menu.pot | 22 + .../class-wc-settings-menu-item-swapper.php | 218 ++++++ .../src/php/class-wpfactory-admin-menu.php | 411 +++++++++++ .../src/php/trait-singleton.php | 68 ++ .../assets/css/admin.css | 145 ++++ .../assets/css/admin.css.map | 1 + .../assets/css/admin.min.css | 1 + .../langs/wpfactory-cross-selling.pot | 182 +++++ .../src/img/wpfactory.png | Bin 0 -> 2757 bytes .../src/php/class-product-categories.php | 66 ++ .../src/php/class-products.php | 250 +++++++ .../src/php/class-wpfactory-cross-selling.php | 441 ++++++++++++ .../src/php/trait-singleton.php | 70 ++ .../templates/product.php | 25 + .../src/php/class-core.php | 22 +- 40 files changed, 3496 insertions(+), 1149 deletions(-) create mode 100644 .distignore delete mode 100644 vendor/composer/platform_check.php create mode 100644 vendor/wpfactory/wpfactory-admin-menu/langs/wpfactory-admin-menu.pot create mode 100644 vendor/wpfactory/wpfactory-admin-menu/src/php/class-wc-settings-menu-item-swapper.php create mode 100644 vendor/wpfactory/wpfactory-admin-menu/src/php/class-wpfactory-admin-menu.php create mode 100644 vendor/wpfactory/wpfactory-admin-menu/src/php/trait-singleton.php create mode 100644 vendor/wpfactory/wpfactory-cross-selling/assets/css/admin.css create mode 100644 vendor/wpfactory/wpfactory-cross-selling/assets/css/admin.css.map create mode 100644 vendor/wpfactory/wpfactory-cross-selling/assets/css/admin.min.css create mode 100644 vendor/wpfactory/wpfactory-cross-selling/langs/wpfactory-cross-selling.pot create mode 100644 vendor/wpfactory/wpfactory-cross-selling/src/img/wpfactory.png create mode 100644 vendor/wpfactory/wpfactory-cross-selling/src/php/class-product-categories.php create mode 100644 vendor/wpfactory/wpfactory-cross-selling/src/php/class-products.php create mode 100644 vendor/wpfactory/wpfactory-cross-selling/src/php/class-wpfactory-cross-selling.php create mode 100644 vendor/wpfactory/wpfactory-cross-selling/src/php/trait-singleton.php create mode 100644 vendor/wpfactory/wpfactory-cross-selling/templates/product.php diff --git a/.distignore b/.distignore new file mode 100644 index 0000000..3d25d61 --- /dev/null +++ b/.distignore @@ -0,0 +1,15 @@ +/.git +/.github +/node_modules +/.wordpress-org +.idea +.distignore +.eslintrc.js +.gitignore +Makefile +package.json +package-lock.json +readme.md +vendor/wpfactory/wpf-settings-exporter +vendor/wpfactory/wpf-documentor +git-tag.sh \ No newline at end of file diff --git a/composer.json b/composer.json index 06e4fef..d1d48a4 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,20 @@ { "type": "vcs", "url": "https://github.com/wpcodefactory/wpfactory-promoting-notice" + }, + { + "type": "vcs", + "url": "https://github.com/wpcodefactory/wpfactory-cross-selling" + }, + { + "type": "vcs", + "url": "https://github.com/wpcodefactory/wpfactory-admin-menu" } ], "require": { "wpfactory/wpfactory-promoting-notice": "*", + "wpfactory/wpfactory-cross-selling": "*", + "wpfactory/wpfactory-admin-menu": "*", "hashids/hashids": "4.*" }, "config": { diff --git a/email-verification-for-woocommerce.php b/email-verification-for-woocommerce.php index 909b3e7..b9fbb33 100644 --- a/email-verification-for-woocommerce.php +++ b/email-verification-for-woocommerce.php @@ -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.10 +Version: 2.9.0 Author: WPFactory Author URI: https://wpfactory.com Text Domain: emails-verification-for-woocommerce Domain Path: /langs Copyright: © 2024 WPFactory -WC tested up to: 9.2 +WC tested up to: 9.3 Requires Plugins: woocommerce License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -52,7 +52,7 @@ function alg_wc_ev_is_plugin_active( $plugin ) { * Main Alg_WC_Email_Verification Class * * @class Alg_WC_Email_Verification - * @version 2.8.10 + * @version 2.8.11 * @since 1.0.0 */ final class Alg_WC_Email_Verification { @@ -63,7 +63,7 @@ final class Alg_WC_Email_Verification { * @var string * @since 1.0.0 */ - public $version = '2.8.10'; + public $version = '2.9.0'; /** * @var Alg_WC_Email_Verification The single instance of the class @@ -100,11 +100,16 @@ public static function instance() { /** * Initializes the plugin. * - * @version 2.8.10 + * @version 2.9.0 * @since 1.0.0 * @access public */ function init() { + // Adds cross-selling library. + $this->add_cross_selling_library(); + + // Move WC Settings tab to WPFactory menu. + $this->move_wc_settings_tab_to_wpfactory_menu(); // Localization. add_action( 'init', array( $this, 'localize' ) ); @@ -114,7 +119,6 @@ function init() { require_once( 'includes/pro/class-alg-wc-ev-pro.php' ); } - // Include required files. $this->includes(); @@ -123,10 +127,48 @@ function init() { $this->admin(); } - // Generate documentation + // Generate documentation. add_filter( 'wpfpdh_documentation_params_' . plugin_basename( $this->get_filesystem_path() ), array( $this, 'handle_documentation_params' ), 10 ); } + /** + * add_cross_selling_library. + * + * @version 2.9.0 + * @since 2.9.0 + * + * @return void + */ + function add_cross_selling_library(){ + if ( ! is_admin() ) { + return; + } + // Cross-selling library. + $cross_selling = new \WPFactory\WPFactory_Cross_Selling\WPFactory_Cross_Selling(); + $cross_selling->setup( array( 'plugin_file_path' => $this->get_filesystem_path() ) ); + $cross_selling->init(); + } + + /** + * move_wc_settings_tab_to_wpfactory_submenu. + * + * @version 2.9.0 + * @since 2.9.0 + * + * @return void + */ + function move_wc_settings_tab_to_wpfactory_menu() { + if ( ! is_admin() ) { + return; + } + // WC Settings tab as WPFactory submenu item. + $wpf_admin_menu = \WPFactory\WPFactory_Admin_Menu\WPFactory_Admin_Menu::get_instance(); + $wpf_admin_menu->move_wc_settings_tab_to_wpfactory_menu( array( + 'wc_settings_tab_id' => 'alg_wc_ev', + 'menu_title' => __( 'Email Verification', 'order-minimum-amount-for-woocommerce' ), + 'page_title' => __( 'Email Verification', 'order-minimum-amount-for-woocommerce' ), + ) ); + } /** * Handle documentation params managed by the WP Factory diff --git a/includes/class-alg-wc-ev-admin.php b/includes/class-alg-wc-ev-admin.php index 4c862e6..495f89a 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.8.6 + * @version 2.9.0 * @since 1.5.0 * @author WPFactory */ @@ -65,7 +65,7 @@ class Alg_WC_Email_Verification_Admin { /** * Constructor. * - * @version 2.5.8 + * @version 2.9.0 * @since 1.5.0 * @todo (maybe) move more stuff here, e.g. settings, action links etc. */ @@ -104,6 +104,13 @@ function __construct() { } add_filter( 'pre_update_option_alg_wc_ev_verify_guest_email', array( $this, 'create_guest_verification_table' ), 10, 2 ); + + // Hooks the Rich Text Editor field into WooCommerce settings API. + add_action( 'woocommerce_admin_field_alg_wc_ev_editor', array( $this, 'generate_editor_html' ) ); + + // Hooks the custom script into the 'admin_footer' for the editor field. + add_action( 'admin_footer', array( $this, 'enqueue_ev_setting_style_and_script' ) ); + } /** @@ -656,6 +663,83 @@ function render_verified_email_column( $output, $column_name, $user_id ) { return $output; } + /** + * Generate Rich Text Editor HTML. + * + * @version 2.9.0 + * @since 2.9.0 + */ + function generate_editor_html( $value ) { + $option_value = $value['value']; + + // Get the description and tooltip HTML for the field. + $field_description = WC_Admin_Settings::get_field_description( $value ); + $description = $field_description['description']; + $tooltip_html = $field_description['tooltip_html']; + ?> + + + + + + + esc_attr( $value['field_name'] ), + 'editor_class' => esc_attr( $value['class'] ), + 'editor_height' => '', + ); + wp_editor( htmlspecialchars_decode( $option_value, ENT_QUOTES ), $editor_id, $settings ); + ?> + + + + + + + __( 'Send Verify Email', 'emails-verification-for-woocommerce' ), - 'resend' => __( 'Resending....', 'emails-verification-for-woocommerce' ), - 'sent' => __( 'Verification mail sent successfully to billing email, please check inbox and verify ! Resend', 'emails-verification-for-woocommerce' ), - 'already_verified' => __( 'Email id verified !', 'emails-verification-for-woocommerce' ) - ); - - wp_enqueue_script( 'alg-wc-ev-guest-verify', - trailingslashit( alg_wc_ev()->plugin_url() ) . 'includes/js/alg-wc-ev-guest-verify.js', array( 'jquery' ), alg_wc_ev()->version, true ); - wp_localize_script( 'alg-wc-ev-guest-verify', 'email_verification_options', $wc_ev_options ); - } - } + // Verify Guest feature. + add_action( 'wp_footer', array( $this, 'verify_guest_at_checkout_script_footer' ), PHP_INT_MAX ); + add_action( 'wp_ajax_alg_wc_ev_send_guest_verification_email_action', array( $this, 'alg_wc_ev_send_guest_verification_email_action' ) ); + add_action( 'wp_ajax_nopriv_alg_wc_ev_send_guest_verification_email_action', array( $this, 'alg_wc_ev_send_guest_verification_email_action' ) ); + add_action( 'woocommerce_after_checkout_validation', array( $this, 'checkout_validate_guest_email' ), PHP_INT_MAX ); + add_action( 'template_redirect', array( $this, 'checkout_validate_guest_email_message' ) ); + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_guest_feature_scripts' ) ); } /** @@ -1213,20 +1191,53 @@ function get_default_hashids_salt_opt() { return $this->default_hashids_salt_opt; } + /** + * enqueue_guest_feature_scripts. + * + * @version 2.9.0 + * @since 2.9.0 + * + * @return void + */ + function enqueue_guest_feature_scripts() { + if ( + is_user_logged_in() || + 'yes' !== get_option( 'alg_wc_ev_verify_guest_email', 'no' ) || + ! is_checkout() + ) { + return; + } + + $wc_ev_options = array( + 'send' => __( 'Send Verify Email', 'emails-verification-for-woocommerce' ), + 'resend' => __( 'Resending....', 'emails-verification-for-woocommerce' ), + 'sent' => __( 'Verification mail sent successfully to billing email, please check inbox and verify ! Resend', 'emails-verification-for-woocommerce' ), + 'already_verified' => __( 'Email id verified !', 'emails-verification-for-woocommerce' ) + ); + + wp_enqueue_script( 'alg-wc-ev-guest-verify', trailingslashit( alg_wc_ev()->plugin_url() ) . 'includes/js/alg-wc-ev-guest-verify.js', array( 'jquery' ), alg_wc_ev()->version, true ); + wp_localize_script( 'alg-wc-ev-guest-verify', 'email_verification_options', $wc_ev_options ); + } + /** * verify_guest_at_checkout_script_footer. * - * @version 2.7.4 + * @version 2.9.0 * @since 2.5.8 * * @return string */ function verify_guest_at_checkout_script_footer() { + if ( + is_user_logged_in() || + 'yes' !== get_option( 'alg_wc_ev_verify_guest_email', 'no' ) + ) { + return; + } ?>