Changeset 3334966
- Timestamp:
- 07/27/2025 05:52:40 PM (8 months ago)
- Location:
- codenitive-captcha
- Files:
-
- 8 edited
-
tags/1.0.4/assets/js/scripts.js (modified) (1 diff)
-
tags/1.0.4/includes/class-captcha-config.php (modified) (2 diffs)
-
tags/1.0.4/includes/class-comments-captcha.php (modified) (1 diff)
-
tags/1.0.4/includes/class-forms.php (modified) (3 diffs)
-
trunk/assets/js/scripts.js (modified) (1 diff)
-
trunk/includes/class-captcha-config.php (modified) (2 diffs)
-
trunk/includes/class-comments-captcha.php (modified) (1 diff)
-
trunk/includes/class-forms.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codenitive-captcha/tags/1.0.4/assets/js/scripts.js
r3334736 r3334966 42 42 } 43 43 } 44 45 const siteKey = CodenitCaptchaData?.siteKey; 44 46 45 const siteKey = CodenitCaptchaData?.siteKey; 47 if (siteKey) { 48 const elements = document.querySelectorAll('.codenitcaptcha-recaptcha'); 49 50 elements.forEach((element) => { 51 grecaptcha.render(element, { 52 sitekey: siteKey 53 }); 54 }); 55 } 46 56 47 if (siteKey && document.getElementById('codenitcaptcha-comments-recaptcha')) {48 grecaptcha.render('codenitcaptcha-comments-recaptcha', {49 sitekey: siteKey50 });51 }52 57 53 58 }; -
codenitive-captcha/tags/1.0.4/includes/class-captcha-config.php
r3334736 r3334966 176 176 ), $url ); 177 177 178 \wp_enqueue_script( 'codenitcaptcha-recaptcha-js', CODENITCAPTCHA_PLUGIN_DIR_URL . 'assets/js/scripts.js', array(), '1.0. 4', true );178 \wp_enqueue_script( 'codenitcaptcha-recaptcha-js', CODENITCAPTCHA_PLUGIN_DIR_URL . 'assets/js/scripts.js', array(), '1.0.9', true ); 179 179 \wp_enqueue_script( 'google-recaptcha', $url, array( 'codenitcaptcha-recaptcha-js' ), CODENITCAPTCHA_VERSION, true ); 180 180 … … 225 225 226 226 // Verify nonce first 227 if (!isset($_POST['codenitcaptcha_nonce']) || 228 !\wp_verify_nonce(\sanitize_text_field(\wp_unslash($_POST['codenitcaptcha_nonce'])), 'codenitcaptcha_action')) { 229 return array( 230 'status' => 'error', 231 'message' => 'nonce_invalid' 232 ); 227 if(isset($_POST['wooregister']) && $_POST['wooregister'] == '_codenitcaptcha_nonce_wcc_register') { 228 if (!isset($_POST['codenitcaptcha_nonce_woo_register']) || 229 !\wp_verify_nonce(\sanitize_text_field(\wp_unslash($_POST['codenitcaptcha_nonce_woo_register'])), 'codenitcaptcha_action_woo_register')) { 230 return array( 231 'status' => 'error', 232 'message' => 'nonce_invalid' 233 ); 234 } 235 } else { 236 if (!isset($_POST['codenitcaptcha_nonce']) || 237 !\wp_verify_nonce(\sanitize_text_field(\wp_unslash($_POST['codenitcaptcha_nonce'])), 'codenitcaptcha_action')) { 238 return array( 239 'status' => 'error', 240 'message' => 'nonce_invalid' 241 ); 242 } 233 243 } 234 244 -
codenitive-captcha/tags/1.0.4/includes/class-comments-captcha.php
r3334736 r3334966 36 36 $this->config->maybe_enqueue_script(); 37 37 $site_key = $this->config->get_site_key_v2(); 38 $captcha = '<div id="codenitcaptcha-comments-recaptcha" class="g-recaptcha" data-sitekey="' . \esc_attr($site_key) . '"></div>';38 $captcha = '<div class="g-recaptcha codenitcaptcha-recaptcha" data-sitekey="' . \esc_attr($site_key) . '"></div>'; 39 39 $captcha .= \wp_nonce_field( 'codenitcaptcha_action', 'codenitcaptcha_nonce', true, false ); 40 40 -
codenitive-captcha/tags/1.0.4/includes/class-forms.php
r3334736 r3334966 34 34 35 35 if ( $this->config->get_wcc_register() == 1 ) { 36 \add_action('woocommerce_register_form', array($this, 'display_captcha '), 20);36 \add_action('woocommerce_register_form', array($this, 'display_captcha_woo_register'), 20); 37 37 \add_filter('woocommerce_process_registration_errors', array($this, 'validate_registration_captcha'), 5, 4); 38 38 } … … 111 111 $captcha = '<div id="wccn-captcha-box"><div class="g-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div></div>'; 112 112 } else { 113 $captcha = '<div id="codenitcaptcha-comments-recaptcha" class="g-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div>';113 $captcha = '<div class="g-recaptcha codenitcaptcha-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div>'; 114 114 } 115 115 … … 118 118 119 119 } 120 } 121 122 public function display_captcha_woo_register(){ 123 $captcha = '<div id="codenitcaptcha-wooregister-recaptcha" class="g-recaptcha codenitcaptcha-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div>'; 124 echo '<input type="hidden" name="wooregister" value="_codenitcaptcha_nonce_wcc_register">'; 125 echo \wp_kses_post( \wp_nonce_field( 'codenitcaptcha_action_woo_register', 'codenitcaptcha_nonce_woo_register' )); 126 echo \wp_kses_post( $captcha ); 120 127 } 121 128 -
codenitive-captcha/trunk/assets/js/scripts.js
r3334736 r3334966 42 42 } 43 43 } 44 45 const siteKey = CodenitCaptchaData?.siteKey; 44 46 45 const siteKey = CodenitCaptchaData?.siteKey; 47 if (siteKey) { 48 const elements = document.querySelectorAll('.codenitcaptcha-recaptcha'); 49 50 elements.forEach((element) => { 51 grecaptcha.render(element, { 52 sitekey: siteKey 53 }); 54 }); 55 } 46 56 47 if (siteKey && document.getElementById('codenitcaptcha-comments-recaptcha')) {48 grecaptcha.render('codenitcaptcha-comments-recaptcha', {49 sitekey: siteKey50 });51 }52 57 53 58 }; -
codenitive-captcha/trunk/includes/class-captcha-config.php
r3334736 r3334966 176 176 ), $url ); 177 177 178 \wp_enqueue_script( 'codenitcaptcha-recaptcha-js', CODENITCAPTCHA_PLUGIN_DIR_URL . 'assets/js/scripts.js', array(), '1.0. 4', true );178 \wp_enqueue_script( 'codenitcaptcha-recaptcha-js', CODENITCAPTCHA_PLUGIN_DIR_URL . 'assets/js/scripts.js', array(), '1.0.9', true ); 179 179 \wp_enqueue_script( 'google-recaptcha', $url, array( 'codenitcaptcha-recaptcha-js' ), CODENITCAPTCHA_VERSION, true ); 180 180 … … 225 225 226 226 // Verify nonce first 227 if (!isset($_POST['codenitcaptcha_nonce']) || 228 !\wp_verify_nonce(\sanitize_text_field(\wp_unslash($_POST['codenitcaptcha_nonce'])), 'codenitcaptcha_action')) { 229 return array( 230 'status' => 'error', 231 'message' => 'nonce_invalid' 232 ); 227 if(isset($_POST['wooregister']) && $_POST['wooregister'] == '_codenitcaptcha_nonce_wcc_register') { 228 if (!isset($_POST['codenitcaptcha_nonce_woo_register']) || 229 !\wp_verify_nonce(\sanitize_text_field(\wp_unslash($_POST['codenitcaptcha_nonce_woo_register'])), 'codenitcaptcha_action_woo_register')) { 230 return array( 231 'status' => 'error', 232 'message' => 'nonce_invalid' 233 ); 234 } 235 } else { 236 if (!isset($_POST['codenitcaptcha_nonce']) || 237 !\wp_verify_nonce(\sanitize_text_field(\wp_unslash($_POST['codenitcaptcha_nonce'])), 'codenitcaptcha_action')) { 238 return array( 239 'status' => 'error', 240 'message' => 'nonce_invalid' 241 ); 242 } 233 243 } 234 244 -
codenitive-captcha/trunk/includes/class-comments-captcha.php
r3334736 r3334966 36 36 $this->config->maybe_enqueue_script(); 37 37 $site_key = $this->config->get_site_key_v2(); 38 $captcha = '<div id="codenitcaptcha-comments-recaptcha" class="g-recaptcha" data-sitekey="' . \esc_attr($site_key) . '"></div>';38 $captcha = '<div class="g-recaptcha codenitcaptcha-recaptcha" data-sitekey="' . \esc_attr($site_key) . '"></div>'; 39 39 $captcha .= \wp_nonce_field( 'codenitcaptcha_action', 'codenitcaptcha_nonce', true, false ); 40 40 -
codenitive-captcha/trunk/includes/class-forms.php
r3334736 r3334966 34 34 35 35 if ( $this->config->get_wcc_register() == 1 ) { 36 \add_action('woocommerce_register_form', array($this, 'display_captcha '), 20);36 \add_action('woocommerce_register_form', array($this, 'display_captcha_woo_register'), 20); 37 37 \add_filter('woocommerce_process_registration_errors', array($this, 'validate_registration_captcha'), 5, 4); 38 38 } … … 111 111 $captcha = '<div id="wccn-captcha-box"><div class="g-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div></div>'; 112 112 } else { 113 $captcha = '<div id="codenitcaptcha-comments-recaptcha" class="g-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div>';113 $captcha = '<div class="g-recaptcha codenitcaptcha-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div>'; 114 114 } 115 115 … … 118 118 119 119 } 120 } 121 122 public function display_captcha_woo_register(){ 123 $captcha = '<div id="codenitcaptcha-wooregister-recaptcha" class="g-recaptcha codenitcaptcha-recaptcha" data-sitekey="' . esc_attr($this->config->get_site_key_v2()) . '"></div>'; 124 echo '<input type="hidden" name="wooregister" value="_codenitcaptcha_nonce_wcc_register">'; 125 echo \wp_kses_post( \wp_nonce_field( 'codenitcaptcha_action_woo_register', 'codenitcaptcha_nonce_woo_register' )); 126 echo \wp_kses_post( $captcha ); 120 127 } 121 128
Note: See TracChangeset
for help on using the changeset viewer.