Changeset 3217889
- Timestamp:
- 01/06/2025 05:35:06 PM (15 months ago)
- Location:
- consignment-store-for-woocommerce
- Files:
-
- 36 added
- 8 edited
-
tags/1.8 (added)
-
tags/1.8/README.txt (added)
-
tags/1.8/admin (added)
-
tags/1.8/admin/class-cws-consignment-admin.php (added)
-
tags/1.8/admin/css (added)
-
tags/1.8/admin/css/cws-consignment-admin.css (added)
-
tags/1.8/admin/index.php (added)
-
tags/1.8/admin/js (added)
-
tags/1.8/admin/js/cws-consignment-admin.js (added)
-
tags/1.8/admin/partials (added)
-
tags/1.8/admin/partials/cws-consignment-admin-display.php (added)
-
tags/1.8/admin/partials/cwscs-consignment.jpg (added)
-
tags/1.8/cws-consignment.php (added)
-
tags/1.8/img (added)
-
tags/1.8/includes (added)
-
tags/1.8/includes/class-cws-consignment-activator.php (added)
-
tags/1.8/includes/class-cws-consignment-deactivator.php (added)
-
tags/1.8/includes/class-cws-consignment-i18n.php (added)
-
tags/1.8/includes/class-cws-consignment-loader.php (added)
-
tags/1.8/includes/class-cws-consignment.php (added)
-
tags/1.8/includes/index.php (added)
-
tags/1.8/index.php (added)
-
tags/1.8/js (added)
-
tags/1.8/js/cws_custom.js (added)
-
tags/1.8/languages (added)
-
tags/1.8/languages/cws-consignment.pot (added)
-
tags/1.8/public (added)
-
tags/1.8/public/class-cws-consignment-public.php (added)
-
tags/1.8/public/css (added)
-
tags/1.8/public/css/cws-consignment-public.css (added)
-
tags/1.8/public/index.php (added)
-
tags/1.8/public/js (added)
-
tags/1.8/public/js/cws-consignment-public.js (added)
-
tags/1.8/public/partials (added)
-
tags/1.8/public/partials/cws-consignment-public-display.php (added)
-
tags/1.8/uninstall.php (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/admin/class-cws-consignment-admin.php (modified) (1 diff)
-
trunk/admin/js/cws-consignment-admin.js (modified) (8 diffs)
-
trunk/admin/partials/cws-consignment-admin-display.php (modified) (6 diffs)
-
trunk/cws-consignment.php (modified) (1 diff)
-
trunk/includes/class-cws-consignment.php (modified) (1 diff)
-
trunk/public/class-cws-consignment-public.php (modified) (6 diffs)
-
trunk/public/js/cws-consignment-public.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
consignment-store-for-woocommerce/trunk/README.txt
r3116667 r3217889 3 3 Donate link: https://charlenesweb.ca/donate/ 4 4 Tags: consignment store, consignment for WooCommerce 5 Requires at least: 6. 5.56 Requires PHP: 7.47 Tested up to: 6.68 Stable tag: 1. 7.95 Requires at least: 6.7.1 6 Requires PHP: 8.0 7 Tested up to: 7.4 8 Stable tag: 1.8 9 9 License: GPLv2 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 77 77 78 78 == Changelog == 79 = 1.8 = 80 * Remove reCaptcha 2 from plugin 81 79 82 = 1.7.9 = 80 83 * Go through WP 6.6 compatibility requirements. No changes required. … … 135 138 136 139 == Upgrade Notice == 140 = 1.8 = 141 * Remove reCaptcha 2 from plugin. Update when convenient. 142 137 143 = 1.7.9 = 138 144 * Tag update. Update version when convenient. -
consignment-store-for-woocommerce/trunk/admin/class-cws-consignment-admin.php
r3022689 r3217889 809 809 } 810 810 } 811 }812 return $data;813 }814 815 // get the recaptcha site key and secret -- called from ajax fcn to save settings816 function cwscsGetRecaptchas($version) {817 $myData = cwscsGetSettingByKeyReturnArray($version);818 $data = array('version' => $version);819 if (is_array($myData)) {820 if (isset($myData[0]))821 $data['site_key'] = $myData[0];822 else823 $data['site_key'] = "";824 if (isset($myData[1]))825 $data['secret'] = $myData[1];826 else827 $data['secret'] = "";828 811 } 829 812 return $data; -
consignment-store-for-woocommerce/trunk/admin/js/cws-consignment-admin.js
r3051865 r3217889 2 2 'use strict'; 3 3 $( window ).load(function() { 4 console.log('TEST: loaded');5 4 // Check item approved status and show appropriate email 6 5 $('.cwscheckapproved').click(function () { … … 13 12 $ ('#rejected-email').addClass("cwshidden"); 14 13 $ ('.hideifrejected').removeClass("cwshidden"); 15 console.log("Removed?")16 14 } else if (i == 2) { // rejected 17 15 $ ('#approved-email').addClass("cwshidden"); … … 52 50 break; 53 51 case 4: 54 var btn_text = "Save reCAPTCHA v2";55 break;56 case 5:57 var btn_text = "Save reCAPTCHA v3";58 break;59 case 6:60 52 var btn_text = "Save Emails"; 61 53 break; … … 114 106 break; 115 107 case "btnsave_4": 116 case "btnsave_5": 117 if (thisid == "btnsave_4") { 118 var ext = "v2"; 119 var contentid = "contenttab_4"; 120 var cwscs_method = "saverecaptchav2"; 121 } else { 122 var ext = "v3"; 123 var contentid = "contenttab_5"; 124 var cwscs_method = "saverecaptchav3"; 125 } 126 // allowed to set it to blank 127 if (typeof $('#cwscs_version' + ext).val() != "undefined" && typeof $('#cwscs_site_key' + ext).val() != "undefined" && typeof $('#cwscs_secret' + ext).val() != "undefined") { 128 var cwscs_value = $('#cwscs_site_key' + ext).val() + '::' + $('#cwscs_secret' + ext).val(); 129 var cwscs_key = $('#cwscs_version' + ext).val(); 130 } else { 131 var cwscs_key = ""; 132 var cwscs_value = ""; 133 } 134 break; 135 case "btnsave_6": 136 var contentid = "contenttab_6"; 108 var contentid = "contenttab_4"; 137 109 var cwscs_method = "saveemails"; 138 110 var cwscs_key = "emails"; … … 144 116 break; 145 117 default: 146 console.log('TEST: not found');147 118 var cwscs_method = ""; 148 119 break; 149 120 } 150 console.log('TEST: at end and ' + cwscs_key);151 121 if (cwscs_key == "") { 152 122 $('#cwscs_msg').html('<p class="failmsg">Could not update. Please refresh and try again.</p>'); … … 253 223 return ct; 254 224 } 255 // Recaptcha settings256 function showRecaptchaSettings(data) {257 var ct = "";258 var site_key = "";259 var secret = "";260 var version = "";261 var ext = "";262 if (data) {263 for (var key in data) {264 switch (key) {265 case "version":266 if (data[key] == "recaptcha-v2") {267 var ct = '<h3>Google reCAPTCHA v2</h3>';268 var version = "recaptcha-v2";269 var ext = "v2";270 } else if (data[key] == "recaptcha-v3") {271 var ct = '<h3>Google reCAPTCHA v3</h3>';272 var version = "recaptcha-v3";273 var ext = "v3";274 } else {275 var ct = '<h3>Google reCAPTCHA</h3>';276 }277 break;278 case "site_key":279 var site_key = data[key];280 break;281 case "secret":282 var secret = data[key];283 break;284 } // END switch285 } // END loop on data286 }287 ct += '<input type="hidden" name="version" id="cwscs_version' + ext + '" value="' + version + '" /> <p> <label for="cwscs_site_key' + ext + '">Site Key</label><br /> <input type="text" name="cwscs_site_key' + ext + '" id="cwscs_site_key' + ext + '" value="' + site_key + '" style="width:350px"/> </p> <p> <label for="cwscs_secret' + ext + '">Secret</label><br /> <input type="text" name="cwscs_secret" id="cwscs_secret' + ext + '" value="' + secret + '" style="width:350px"/> </p>';288 return ct;289 }290 225 291 226 // Email settings … … 310 245 //////////////////////////////// ADMIN SPINNER FUNCTIONS ///////////////////////////////// 311 246 function startAdminSpinner(title) { 312 console.log("Start spinner");313 247 if (!title || title == "") { 314 248 title = "Processing..."; … … 319 253 function stopAdminSpinner() { 320 254 jQuery('#myoverlay').remove(); 321 console.log('stopped spinner'); 322 } 255 } -
consignment-store-for-woocommerce/trunk/admin/partials/cws-consignment-admin-display.php
r3022689 r3217889 276 276 //////////////////////////////////////////////////////////////////////////////////////////// 277 277 function cwscsShowSettingsMenu($menu_slug, $msg) { 278 $tabs = array("General", "Categories", "Store Policy", "Store Splits", " Google reCAPTCHA v2", "Google reCAPTCHA v3", "Emails");278 $tabs = array("General", "Categories", "Store Policy", "Store Splits", "Emails"); 279 279 $icons = array("dashicons-admin-tools", "dashicons-category", "dashicons-edit", "dashicons-chart-pie", "dashicons-admin-generic", "dashicons-admin-generic", "dashicons-email-alt"); 280 280 $content = cwscsGetSettingsContent(); … … 283 283 <div class="cwscs_tab">'; 284 284 foreach ($tabs as $i => $tab) { 285 if ($i == 0 || $i == 5) { // hide General and recaptcha v3285 if ($i == 0 || $i == 5) { // hide General 286 286 echo ' 287 287 <button class="cwscs_tablinks cwshidden" id="btntab_'.esc_html($i).'"><span class="dashicons '.esc_html($icons[$i]).'"></span>'.esc_html($tab).'</button>'; … … 341 341 $allSplits = cwscsGetAllSplits(); 342 342 $content[] = cwscsShowStoreSplits($mySplits, $allSplits); 343 344 // recaptcha v2345 $myRecaptcha = cwscsGetSettingByKeyReturnArray("recaptcha-v2");346 $content[] = cwscsShowRecaptcha($myRecaptcha, "recaptcha-v2");347 348 // recaptcha v3349 //$myRecaptcha = cwscsGetSettingByKeyReturnArray("recaptcha-v3"); no v3 for now350 //$content[] = cwscsShowRecaptcha($myRecaptcha, "recaptcha-v3");351 $content[] = "";352 343 353 344 // Emails … … 493 484 } 494 485 495 // Display the recaptcha options496 function cwscsShowRecaptcha($myRecaptcha, $version) {497 // any current values?498 $site_key = "";499 $secret = "";500 if ($version == "recaptcha-v2")501 $ext = 'v2';502 else503 $ext = 'v3';504 if (is_array($myRecaptcha)) {505 if (isset($myRecaptcha[0]) && $myRecaptcha[0] != "")506 $site_key = $myRecaptcha[0];507 if (isset($myRecaptcha[1]) && $myRecaptcha[1] != "")508 $secret = $myRecaptcha[1];509 }510 $ct = '511 <input type="hidden" name="version" id="cwscs_version'.$ext.'" value="'.$version.'" />512 <p>513 <label for="cwscs_site_key'.$ext.'">Site Key</label><br />514 <input type="text" name="cwscs_site_key" id="cwscs_site_key'.$ext.'" value="'.$site_key.'" style="width:350px"/>515 </p>516 <p>517 <label for="cwscs_secret'.$ext.'">Secret</label><br />518 <input type="text" name="cwscs_secret" id="cwscs_secret'.$ext.'" value="'.$secret.'" style="width:350px"/>519 </p>';520 return $ct;521 }522 486 // Show the email settings form 523 487 function cwscsShowEmails($emails) { … … 598 562 <li>Store Policy</li> 599 563 <li>Store Splits</li> 600 <li>Google reCAPTCHA v2</li>601 564 <li>Emails</li> 602 565 </ol> … … 613 576 <p>Check which splits to display on the Add Item form. These are only show to Administrators. </p> 614 577 <p>By default, there are 2 splits available. </p> 615 <h4>Google reCAPTCHA v2</h4>616 <p>Enter your site key and secret to enable the Google reCAPTCHA v2 "I am not a robot" checkbox on the Add Item form.</p>617 578 <h4>Emails</h4> 618 579 <p>Enter the send from email or leave blank to use the WordPress default address.</p> -
consignment-store-for-woocommerce/trunk/cws-consignment.php
r3116667 r3217889 17 17 * Plugin URI: https://charlenesweb.ca/ 18 18 * Description: Consignment Store for WooCommerce 19 * Version: 1. 7.919 * Version: 1.8 20 20 * Author: Charlene's Web Services 21 21 * Author URI: https://charlenesweb.ca/plugins -
consignment-store-for-woocommerce/trunk/includes/class-cws-consignment.php
r3116667 r3217889 71 71 $this->version = PLUGIN_NAME_VERSION; 72 72 } else { 73 $this->version = '1. 7.9';73 $this->version = '1.8'; 74 74 } 75 75 $this->plugin_name = 'cws-consignment'; -
consignment-store-for-woocommerce/trunk/public/class-cws-consignment-public.php
r3051874 r3217889 93 93 94 94 wp_enqueue_script($this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/cws-consignment-public.js', array( 'jquery' ), $this->version, false ); 95 96 // do we need the reCaptcha scripts? Check for keys. Do v2 then v3 97 $myRecaptcha = cwscsGetSettingByKeyReturnArray("recaptcha-v2"); 98 if (isset($myRecaptcha) && is_array($myRecaptcha) && isset($myRecaptcha[0]) && isset($myRecaptcha[1]) && $myRecaptcha[0] != "" && $myRecaptcha[1] != "") { 99 wp_register_script( 100 'cwscs-google-recaptchav2', 101 'https://www.google.com/recaptcha/api.js', 102 array(), 103 $this->version, 104 true 105 ); 106 wp_enqueue_script("cwscs-google-recaptchav2"); 107 } 108 /* no v3 for now 109 else { // check for v3 110 $myRecaptcha = cwscsGetSettingByKeyReturnArray("recaptcha-v3"); 111 if (isset($myRecaptcha) && is_array($myRecaptcha) && isset($myRecaptcha[0]) && isset($myRecaptcha[1]) && $myRecaptcha[0] != "" && $myRecaptcha[1] != "") { 112 wp_register_script( 113 'cwscs-google-recaptchav3', 114 'https://www.google.com/recaptcha/api.js', 115 array(), 116 $this->version, 117 true 118 ); 119 wp_enqueue_script('cwscs-google-recaptchav3', "https://www.google.com/recaptcha/api.js?render=".$myRecaptcha[0]."&ver=".$this->version); 120 } 121 } 122 */ 95 123 96 // for ajax functions 124 97 wp_localize_script( … … 248 221 } // END is logged in 249 222 250 // get recaptcha settings - do here since need if submitted251 $recaptcha = cwscsGetMyRecaptcha();252 223 $max_upload_size = wp_max_upload_size(); 253 224 $displayMaxSize = $max_upload_size/1000000; … … 256 227 // validate the form before doing anything 257 228 $ok = true; 258 if (isset($recaptcha) && isset($recaptcha['version']) && $recaptcha['version'] == "v2") { 259 if (!isset($_POST['g-recaptcha-response'])) { 260 $results = array('status'=>0, 'error'=>'Please check captcha checkbox. '); 261 $ok = false; 262 } else 263 $secret = $recaptcha['secret']; 264 } else 265 $secret = ""; // not in play 229 $secret = ""; // not in play 266 230 // check sku if admin 267 231 if ($admin && (!isset($_POST['sku']) || $_POST['sku'] == "")) { … … 516 480 $ct .= '<input type="hidden" name="policy_accepted" id="policy_accepted" value=2 >'; 517 481 } 518 // recaptcha? save a hidden field if so to help with processing 519 $isRc3 = false; 482 520 483 $disabled = ""; 521 if (isset($recaptcha) && isset($recaptcha['version'])) {522 if ($recaptcha['version'] == "v2") {523 $ct .= '524 <input type="hidden" name="rc2" id="rc2" value="'.esc_html($recaptcha['site_key']).'" >525 <div class="clear"> </div>526 <div class="g-recaptcha" data-sitekey="'.esc_attr($recaptcha['site_key']).'" data-callback="cc_enableSubmitBtn">></div>527 <br/>';528 $disabled = 'disabled="disabled" ';529 }530 /* no recaptcha v3 for now531 elseif ($recaptcha['version'] == "v3") {532 $ct .= '<input type="hidden" name="rc3" id="rc3" value="'.$recaptcha['site_key'].'" >';533 $isRc3 = true;534 }*/535 }536 484 $ct .= ' 537 485 <p id="cwscs_errormsg" class="failmsg cwshidden"></p> … … 744 692 return $results; 745 693 } 746 // Get recaptcha settings, if any 747 function cwscsGetMyRecaptcha() { 748 $results = array(); 749 750 $myRecaptcha = cwscsGetSettingByKeyReturnArray("recaptcha-v2"); 751 if (isset($myRecaptcha) && is_array($myRecaptcha) && isset($myRecaptcha[0]) && isset($myRecaptcha[1]) && $myRecaptcha[0] != "" && $myRecaptcha[1] != "") { 752 $results = array("version"=>"v2", "site_key"=>$myRecaptcha[0], "secret"=>$myRecaptcha[1]); 753 } else { // check for v3 754 $myRecaptcha = cwscsGetSettingByKeyReturnArray("recaptcha-v3"); 755 if (isset($myRecaptcha) && is_array($myRecaptcha) && isset($myRecaptcha[0]) && isset($myRecaptcha[1]) && $myRecaptcha[0] != "" && $myRecaptcha[1] != "") { 756 $results = array("version"=>"v3", "site_key"=>$myRecaptcha[0], "secret"=>$myRecaptcha[1]); 757 } 758 } 759 return $results; 760 } 761 // validate the additem form including recaptcha 694 695 // validate the additem form 762 696 function cwscsValidateAddItem($secret) { 763 697 $status = 1; … … 776 710 $status = 0; 777 711 } 778 if ($status == 1 && $secret != "") { // validate recaptcha if in play 779 if(!isset($_POST['g-recaptcha-response'])){ 780 $error .= 'Please check the the reCaptcha checkbox. '; 781 $status = 0; 782 } else { 783 $captcha = sanitize_text_field($_POST['g-recaptcha-response']); 784 $ip = $_SERVER['REMOTE_ADDR']; 785 // post request to server 786 $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secret) . '&response=' . urlencode($captcha); 787 //$response = file_get_contents($url); 788 $response = wp_remote_get($url); 789 $status = 0; // pessimist 790 if ( is_array( $response ) && !is_wp_error( $response ) ) { 791 $headers = $response['headers']; // array of http header lines 792 $body = wp_remote_retrieve_body( $response ) ; // array of http header lines 793 $response_code = wp_remote_retrieve_response_code( $response ); 794 if ($response_code == 200) { 795 $responseBody = json_decode($body, true); 796 if ($responseBody['success'] === true) { 797 $status = 1; 798 } elseif ($responseBody['error-codes'] && $responseBody['error-codes'][0] == "timeout-or-duplicate") { 799 $error = "Your form has expired. Please fill in the form below and click Add Item. "; 800 } else { 801 $error = 'You did not pass the anti-spam check and we cannot accept your submission. ;'; 802 } 803 } else 804 $error = 'We could not contact Google to validate the form. Please try again later. '; 805 } elseif (!is_wp_error( $response )) { 806 $error = 'We could not contact Google to validate the form. Please try again later. '; 807 } else 808 $error = 'We could not contact Google to validate the form. Please try again later. '; 809 } 810 } 712 811 713 $results = array('status'=>$status, 'error'=>$error); 812 714 return $results; -
consignment-store-for-woocommerce/trunk/public/js/cws-consignment-public.js
r3051874 r3217889 41 41 }); // END toggledivbyid 42 42 43 // Handle additem form submit - if recaptcha v3 then have to intercept43 // Handle additem form submit 44 44 $('#cwscs_formadditem').submit(function() { 45 45 cwsStartSpinner("Please wait...") ;
Note: See TracChangeset
for help on using the changeset viewer.