Changeset 3000911
- Timestamp:
- 11/23/2023 11:53:16 PM (2 years ago)
- Location:
- optional-email/trunk
- Files:
-
- 2 edited
-
optional-email.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
optional-email/trunk/optional-email.php
r2914887 r3000911 3 3 Plugin Name: Optional Email 4 4 Description: Makes email optional field for registration 5 Version: 1.3. 75 Version: 1.3.9 6 6 Author: Nael Concescu 7 7 Author URI: https://cv.nael.pro/ 8 8 Plugin URI: https://cv.nael.pro/ 9 9 */ 10 11 require_once plugin_dir_path( __FILE__ ) . 'inc/woocommerce.php'; 10 12 11 13 /** … … 186 188 ?> 187 189 <script type="text/javascript"> 188 jQuery('#reg_passmail').hide(); 189 let text = jQuery('label[for=user_email]').html(); 190 if (text && text.length) { 191 if (text.includes("<?php _e( 'Email Address:', 'default' ) ?>")) { 192 text = text.replace("<?php _e( 'Email Address:', 'default' ) ?>", "<?php echo __( 'Email Address: (optional)', 'optional-email' ) ?>"); 193 } else if (text.includes("<?php _e( 'Email Address:', 'default' ) ?>")) { 194 text = text.replace("<?php _e( 'Email Address:', 'default' ) ?>", "<?php echo __( 'Email Address: (optional)', 'optional-email' ) ?>"); 195 } else { 196 text = text.replace("<?php _e( 'Email', 'default' ) ?>", "<?php echo __( 'Email (optional)', 'optional-email' ) ?>"); 197 text = text.replace("<?php _e( 'E-mail', 'default' ) ?>", "<?php echo __( 'E-mail (optional)', 'optional-email' ) ?>"); 190 jQuery(document).ready(function ($) { 191 $('#reg_passmail').hide(); 192 let email_fld = $('label[for=user_email], label[for=reg_email]'); 193 let text = email_fld.html(); 194 195 // Define an array of search and replace pairs. 196 let replacements = [ 197 {search: '<?php echo esc_html( __( 'Email Address:', 'default' ) ); ?>', replace: '<?php echo esc_html( __( 'Email Address: (optional)', 'optional-email' ) ); ?>'}, 198 {search: '<?php echo esc_html( __( 'Email Address:', 'default' ) ); ?>', replace: '<?php echo esc_html( __( 'Email Address: (optional)', 'optional-email' ) ); ?>'}, 199 {search: '<?php echo esc_html( __( 'Email address', 'woocommerce' ) ); ?>', replace: '<?php echo esc_html( __( 'Email Address (optional)', 'optional-email' ) ); ?>'}, 200 {search: '<?php echo esc_html( __( 'Email', 'default' ) ); ?>', replace: '<?php echo esc_html( __( 'Email (optional)', 'optional-email' ) ); ?>'}, 201 {search: '<?php echo esc_html( __( 'E-mail', 'default' ) ); ?>', replace: '<?php echo esc_html( __( 'E-mail (optional)', 'optional-email' ) ); ?>'} 202 ]; 203 204 if (text && text.length) { 205 // Iterate through the array and perform replacements 206 for (let i = 0; i < replacements.length; i++) { 207 let pattern = new RegExp(replacements[i].search, 'gi'); 208 209 // Check if there are matches 210 if (text.match(pattern)) { 211 // Make the replacement 212 text = text.replace(pattern, replacements[i].replace); 213 // Break out of the loop since a replacement has been made 214 break; 215 } 216 } 217 218 // Replace email field text with the new optional. 219 email_fld.html(text); 198 220 } 199 jQuery('label[for=user_email]').html(text); 200 } 201 202 // Another text to replace 203 text = jQuery('#setupform').html(); 204 if (text && text.length) { 205 text = text.replace("<?php esc_attr_e( 'We send your registration email to this address. (Double-check your email address before continuing.)', 'default' ) ?>", ''); 206 jQuery('#setupform').html(text); 207 } 221 222 // Another text to replace 223 text = jQuery('#setupform').html(); 224 if (text && text.length) { 225 text = text.replace("<?php esc_attr_e( 'We send your registration email to this address. (Double-check your email address before continuing.)', 'default' ) ?>", ''); 226 jQuery('#setupform').html(text); 227 } 228 }); 208 229 </script> 209 230 <?php 210 231 } 211 // For register page 212 add_action( 'login_footer', 'oe_login_footer', 1 ); 213 // For MU signup page 214 add_action( 'after_signup_form', 'oe_login_footer', 1 ); 232 add_action( 'login_footer', 'oe_login_footer', 1 ); // For register page. 233 add_action( 'after_signup_form', 'oe_login_footer', 1 ); // For MU signup page. 234 add_action( 'woocommerce_register_form_end', 'oe_login_footer', 1 ); // Runs at the end of the WooCommerce register form. 215 235 216 236 function oe_login_scripts() { -
optional-email/trunk/readme.txt
r2914887 r3000911 3 3 Tags: email field, registration email, profile email, password registration 4 4 Requires at least: 4.6 5 Tested up to: 6. 36 Stable tag: 1.3. 75 Tested up to: 6.9 6 Stable tag: 1.3.9 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 16 16 Also will add a password field on the registration page. 17 17 Supports multisite. 18 Supports WooCommerce. 18 19 19 20 Plugin support [Optional Email Plugin](https://cv.nael.pro/ "Optional Email Plugin") … … 29 30 1. Registration form 30 31 2. Profile form 32 3. WooCommerce registration form 33 4. WooCommerce edit account form 31 34 32 35 == Changelog == 33 36 37 = 1.3.9 = 38 * Added support for the WooCommerce. 39 * Tested with WordPress version 6.9 40 34 41 = 1.3.7 = 35 42 * Tested with WordPress version 6.2
Note: See TracChangeset
for help on using the changeset viewer.