Skip to content

Commit

Permalink
v2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed Oct 22, 2024
1 parent 3948295 commit 902fb6c
Show file tree
Hide file tree
Showing 40 changed files with 3,496 additions and 1,149 deletions.
15 changes: 15 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
56 changes: 49 additions & 7 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.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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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' ) );
Expand All @@ -114,7 +119,6 @@ function init() {
require_once( 'includes/pro/class-alg-wc-ev-pro.php' );
}


// Include required files.
$this->includes();

Expand All @@ -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
Expand Down
88 changes: 86 additions & 2 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.6
* @version 2.9.0
* @since 1.5.0
* @author WPFactory
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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' ) );

}

/**
Expand Down Expand Up @@ -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'];
?>
<tr class="<?php echo esc_attr( $value['row_class'] ); ?>">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?><?php echo $tooltip_html; ?></label>
</th>
<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?> alg-wc-editor">
<?php echo $description; ?>
<?php
$editor_id = esc_attr( $value['id'] );
$settings = array(
'textarea_name' => esc_attr( $value['field_name'] ),
'editor_class' => esc_attr( $value['class'] ),
'editor_height' => '',
);
wp_editor( htmlspecialchars_decode( $option_value, ENT_QUOTES ), $editor_id, $settings );
?>
</td>
</tr>

<?php
}

/**
* Enqueue styles and scripts for settings page.
*
* @version 2.9.0
* @since 2.9.0
*/
function enqueue_ev_setting_style_and_script() {
if (
isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) &&
'wc-settings' === wc_clean( $_GET['page'] ) && 'alg_wc_ev' === wc_clean( $_GET['tab'] ) && in_array( wc_clean( $_GET['section'] ), array( 'emails', 'messages' ), true )
) {
?>
<style>
.woocommerce table.form-table .alg-wc-editor textarea {
width: 100%;
}
</style>
<script>
jQuery( document ).ready( function ( $ ) {

// Listen for changes in TinyMCE editor (Visual Editor).
if ( typeof tinyMCE !== "undefined" ) {

$( '.alg-wc-editor' ).each( function () {
const editor_container = $( this );
const editor_id = editor_container.find( '.wp-editor-area' ).attr( 'id' );

const editor = tinyMCE.get( editor_id );

if ( editor ) {
editor.on( 'Change', function () {
$( `#${editor_id}` ).trigger( 'input' );
} );
}
} );
}
} );
</script>
<?php
}
}

}

endif;
Expand Down
Loading

0 comments on commit 902fb6c

Please sign in to comment.