Changeset 2139947
- Timestamp:
- 08/15/2019 10:19:30 AM (7 years ago)
- Location:
- data8-validation-for-contact-form-7
- Files:
-
- 12 added
- 5 edited
-
tags/2.2 (added)
-
tags/2.2/data8-validation-for-contact-form-7.php (added)
-
tags/2.2/includes (added)
-
tags/2.2/includes/d8cf7-validation.php (added)
-
tags/2.2/includes/d8cf7_footer.php (added)
-
tags/2.2/includes/d8cf7_header.php (added)
-
tags/2.2/includes/d8cf7_instructions.php (added)
-
tags/2.2/includes/d8cf7_settings.php (added)
-
tags/2.2/includes/d8gf-validation.php (added)
-
tags/2.2/includes/d8wc-validation.php (added)
-
tags/2.2/plugin_interface.php (added)
-
tags/2.2/readme.txt (added)
-
trunk/data8-validation-for-contact-form-7.php (modified) (1 diff)
-
trunk/includes/d8cf7_settings.php (modified) (1 diff)
-
trunk/includes/d8gf-validation.php (modified) (11 diffs)
-
trunk/includes/d8wc-validation.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
data8-validation-for-contact-form-7/trunk/data8-validation-for-contact-form-7.php
r2135867 r2139947 5 5 Description: This plugin integrates Data8 email, telephone, name and address validation in WooCommerce, Gravity Forms and Contact Form 7 6 6 Author: Data8 7 Version: 2. 17 Version: 2.2 8 8 Author URI: http://www.data-8.co.uk 9 9 */ -
data8-validation-for-contact-form-7/trunk/includes/d8cf7_settings.php
r2121310 r2139947 229 229 </tr> 230 230 <tr> 231 <td><strong>Use Data8 Unusable validation</strong></td>231 <td><strong>Use Data8 Unusable Name Validation</strong></td> 232 232 <td style="text-align:center;"> 233 233 <label class="switch"> -
data8-validation-for-contact-form-7/trunk/includes/d8gf-validation.php
r2121310 r2139947 38 38 } 39 39 40 if (get_option('d8cf7_telephone_validation')) {40 if (get_option('d8cf7_telephone_validation')) 41 41 add_filter( 'gform_field_validation', 'd8_validate_tel_gf', 10, 4 ); 42 }43 42 44 43 function startsWith($haystack, $needle) { … … 78 77 $allowedPrefixesInput = substr($class, 10); 79 78 $allowedPrefixArray = []; 80 if ($allowedPrefixesInput != '') {79 if ($allowedPrefixesInput != '') 81 80 $allowedPrefixArray = explode("_", $class); 82 }81 83 82 foreach ($allowedPrefixArray as &$prefix) { 84 if ($prefix != 'd8AllowedPrefixes') {83 if ($prefix != 'd8AllowedPrefixes') 85 84 $allowedPrefixes = ($allowedPrefixes == '' ? '+'.$prefix : $allowedPrefixes.','.'+'.$prefix); 86 }87 85 } 88 86 } … … 92 90 $barredPrefixesInput = substr($class, 10); 93 91 $barredPrefixArray = []; 94 if ($barredPrefixesInput != '') {92 if ($barredPrefixesInput != '') 95 93 $barredPrefixArray = explode("_", $class); 96 }94 97 95 foreach ($barredPrefixArray as &$prefix) { 98 if ($prefix != 'd8BarredPrefixes_') {96 if ($prefix != 'd8BarredPrefixes_') 99 97 $barredPrefixes = ($barredPrefixes == '' ? '+'.$prefix : $barredPrefixes.','.'+'.$prefix); 100 }101 98 } 102 99 } … … 108 105 'telephoneNumber' => $value, 109 106 'defaultCountry' => $country, 110 'options' => array ( 'Option' => array(111 array('Name' => 'UseMobileValidation', 'Value' => $mobile),112 array('Name' => 'UseLineValidation', 'Value' => $line),113 array('Name' => 'AllowedPrefixes', 'Value' => $allowedPrefixes),114 array('Name' => 'BarredPrefixes', 'Value' => $barredPrefixes),115 array('Name' => 'ApplicationName', 'Value' => 'WordPress')116 ) )107 'options' => array ( 108 'UseMobileValidation' => $mobile, 109 'UseLineValidation' => $line, 110 'AllowedPrefixes' => $allowedPrefixes, 111 'BarredPrefixes' => $barredPrefixes, 112 'ApplicationName' => 'WordPress' 113 ) 117 114 ); 118 115 119 116 $d8cf7_ajax_key = get_option('d8cf7_ajax_key'); 120 if($d8cf7_ajax_key == ""){ return $result; } 117 if($d8cf7_ajax_key == "") 118 return $result; 121 119 122 120 $url = "https://webservices.data-8.co.uk/InternationalTelephoneValidation/IsValid.json?key=" . $d8cf7_ajax_key; … … 128 126 } 129 127 } 130 131 128 return $result; 132 129 } 133 130 134 if (get_option('d8cf7_email_validation_level')) {131 if (get_option('d8cf7_email_validation_level')) 135 132 add_filter( 'gform_field_validation', 'd8_validate_email_gf', 10, 4 ); 136 }137 133 138 134 function d8_validate_email_gf( $result, $value, $form, $field ) { … … 141 137 142 138 $level = get_option('d8cf7_email_validation_level'); 143 if($level == "None"){ return $result; } 144 if($level == ""){ $level = 'MX'; } 139 if($level == "None") 140 return $result; 141 if($level == "") 142 $level = 'MX'; 145 143 146 144 foreach ($classes as $class) { … … 148 146 $level = substr($class, 8); 149 147 } 150 151 148 152 149 // Set up the parameters for the web service call: … … 155 152 'email' => $value, 156 153 'level' => $level, 157 'options' => array ( 'Option' => array(158 array('Name' => 'ApplicationName', 'Value' => 'WordPress')159 ) )154 'options' => array ( 155 'ApplicationName' => 'WordPress' 156 ) 160 157 ); 161 158 162 159 $d8cf7_ajax_key = get_option('d8cf7_ajax_key'); 163 if($d8cf7_ajax_key == ""){ return $result; } 160 if($d8cf7_ajax_key == "") 161 return $result; 164 162 165 163 $url = "https://webservices.data-8.co.uk/EmailValidation/IsValid.json?key=" . $d8cf7_ajax_key; … … 171 169 } 172 170 } 173 174 171 return $result; 175 172 } 176 173 177 if (get_option('d8cf7_salaciousName')) {174 if (get_option('d8cf7_salaciousName')) 178 175 add_filter( 'gform_field_validation', 'd8_validate_name_gf', 10, 4 ); 179 }180 176 181 177 function d8_validate_name_gf ( $result, $value, $form, $field ) { 182 178 if ( $field->type == 'name' ) { 183 184 179 // Input values 185 180 $prefix = rgar( $value, $field->id . '.2' ); … … 198 193 'surname' => $last 199 194 ), 200 'options' => array ( 'Option' => array(201 array('Name' => 'ApplicationName', 'Value' => 'WordPress')202 ) )195 'options' => array ( 196 'ApplicationName' => 'WordPress' 197 ) 203 198 ); 204 199 $d8cf7_ajax_key = get_option('d8cf7_ajax_key'); 205 if($d8cf7_ajax_key == ""){ return $result; } 200 if($d8cf7_ajax_key == "") 201 return $result; 206 202 207 203 $url = "https://webservices.data-8.co.uk/SalaciousName/IsUnusableName.json?key=" . $d8cf7_ajax_key; … … 211 207 $result['is_valid'] = false; 212 208 $result['message'] = "Invalid name."; 213 214 } 215 } 216 209 } 210 } 217 211 return $result; 218 212 } -
data8-validation-for-contact-form-7/trunk/includes/d8wc-validation.php
r2121310 r2139947 18 18 function d8wc_validate(){ 19 19 // telephone validation 20 if(get_option('d8cf7_telephone_validation')) {20 if(get_option('d8cf7_telephone_validation')) 21 21 d8wc_validate_tel('billing_phone'); 22 }23 22 24 23 // email validation 25 if(get_option('d8cf7_email_validation_level') && get_option('d8cf7_email_validation_level') !== "None") {24 if(get_option('d8cf7_email_validation_level') && get_option('d8cf7_email_validation_level') !== "None") 26 25 d8wc_validate_email('billing_email'); 27 }28 26 29 27 // name validation 30 28 if(get_option('d8cf7_salaciousName')){ 31 if(array_key_exists ('billing_first_name', $_POST)) {29 if(array_key_exists ('billing_first_name', $_POST)) 32 30 d8wc_validate_name(array('billing_first_name', 'billing_last_name')); 33 }34 if(array_key_exists ('shipping_first_name', $_POST)) {31 32 if(array_key_exists ('shipping_first_name', $_POST)) 35 33 d8wc_validate_name(array('shipping_first_name', 'shipping_last_name')); 36 }34 37 35 } 38 36 } 39 37 40 38 function d8wc_validate_tel($name) { 41 42 39 $value = isset( $_POST[$name] ) 43 40 ? trim( strtr( (string) $_POST[$name], "\n", " " ) ) … … 55 52 $mobile = 'false'; 56 53 57 if ('' == $value) {54 if ('' == $value) 58 55 return; 59 } elseif ( '' != $value) { 60 56 elseif ( '' != $value) { 61 57 $d8cf7_ajax_key = get_option('d8cf7_ajax_key'); 62 58 … … 68 64 'telephoneNumber' => $value, 69 65 'defaultCountry' => $country, 70 'options' => array ( 'Option' => array(71 array('Name' => 'UseMobileValidation', 'Value' => $mobile),72 array('Name' => 'UseLineValidation', 'Value' => $line),73 array('Name' => 'ApplicationName', 'Value' => 'WordPress')74 ) )66 'options' => array ( 67 'UseMobileValidation' => $mobile, 68 'UseLineValidation' => $line, 69 'ApplicationName' => 'WordPress' 70 ) 75 71 ); 76 72 $url = "https://webservices.data-8.co.uk/InternationalTelephoneValidation/IsValid.json?key=" . $d8cf7_ajax_key; 77 73 $wsresult = ajaxAsyncRequest($url, $params); 78 74 79 if ($wsresult['Status']['Success'] && $wsresult['Result']['ValidationResult'] == 'Invalid') {75 if ($wsresult['Status']['Success'] && $wsresult['Result']['ValidationResult'] == 'Invalid') 80 76 wc_add_notice(__('Invalid telephone number. If the number is correct, try adding the area code i.e. +44 for UK'), 'error' ); 81 }82 77 } 83 78 } … … 85 80 86 81 function d8wc_validate_email($name) { 87 88 82 $value = isset( $_POST[$name] ) 89 83 ? trim( strtr( (string) $_POST[$name], "\n", " " ) ) … … 93 87 94 88 if($level != "None"){ 95 if ($level == '') {89 if ($level == '') 96 90 $level = "MX"; 97 }98 91 99 if ('' == $value) {92 if ('' == $value) 100 93 return; 101 } elseif ( '' != $value) { 102 94 elseif ( '' != $value) { 103 95 $d8cf7_ajax_key = get_option('d8cf7_ajax_key'); 104 96 … … 111 103 'email' => $value, 112 104 'level' => $level, 113 'options' => array ( 'Option' => array(114 array('Name' => 'ApplicationName', 'Value' => 'WordPress')115 ) )105 'options' => array ( 106 'ApplicationName' => 'WordPress' 107 ) 116 108 ); 117 109 $url = "https://webservices.data-8.co.uk/EmailValidation/IsValid.json?key=" . $d8cf7_ajax_key; 118 110 $wsresult = ajaxAsyncRequest($url, $params); 119 111 120 if ($wsresult['Status']['Success'] && $wsresult['Result'] == 'Invalid') {112 if ($wsresult['Status']['Success'] && $wsresult['Result'] == 'Invalid') 121 113 wc_add_notice(__('Invalid email address.'), 'error' ); 122 }123 114 } 124 115 } … … 127 118 128 119 function d8wc_validate_name ($nameArray) { 129 130 120 $firstValue = isset( $_POST[$nameArray[0]] ) 131 121 ? trim( strtr( (string) $_POST[$nameArray[0]], "\n", " " ) ) … … 136 126 : ''; 137 127 138 if ('' == $firstValue) {128 if ('' == $firstValue) 139 129 return; 140 }141 if ('' == $lastValue) {130 131 if ('' == $lastValue) 142 132 return; 143 }144 133 145 134 if('' != $firstValue && '' != $lastValue) { 146 147 135 $d8cf7_ajax_key = get_option('d8cf7_ajax_key'); 148 136 … … 159 147 'surname' => $lastValue 160 148 ), 161 'options' => array ( 'Option' => array(162 array('Name' => 'ApplicationName', 'Value' => 'WordPress')163 ) )149 'options' => array ( 150 'ApplicationName' => 'WordPress' 151 ) 164 152 ); 165 153 $url = "https://webservices.data-8.co.uk/SalaciousName/IsUnusableName.json?key=" . $d8cf7_ajax_key; -
data8-validation-for-contact-form-7/trunk/readme.txt
r2135867 r2139947 122 122 * Fixed application of advanced telephone validation options & defaults 123 123 124 = 2.2 = 125 * Fixed application of advanced telephone validation options in Gravity Forms and WooCommerce 126 124 127 == Upgrade Notice == 125 128 … … 154 157 * Fixed application of advanced telephone validation options & defaults 155 158 159 = 2.2 = 160 * Fixed application of advanced telephone validation options in Gravity Forms and WooCommerce 161 156 162 == Screenshots == 157 163 1. Configuration screen
Note: See TracChangeset
for help on using the changeset viewer.