Changeset 1922330
- Timestamp:
- 08/09/2018 02:36:40 PM (8 years ago)
- Location:
- data8-validation-for-contact-form-7/trunk/includes
- Files:
-
- 3 edited
-
d8cf7-validation.php (modified) (2 diffs)
-
d8cf7_instructions.php (modified) (2 diffs)
-
d8gf-validation.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
data8-validation-for-contact-form-7/trunk/includes/d8cf7-validation.php
r1921629 r1922330 18 18 $line = $tag->get_option( 'landline', '(true|false)', true ); 19 19 $mobile = $tag->get_option( 'mobile', '(true|false)', true ); 20 20 21 // Get the allowed prefixes 22 $allowedPrefixesInput = $tag->get_option( 'allowedPrefixes', '', true ); 23 $allowedPrefixArray = []; 24 if ($allowedPrefixesInput != '') { 25 $allowedPrefixArray = explode("_", $allowedPrefixesInput); 26 } 27 $allowedPrefixes = ''; 28 foreach ($allowedPrefixArray as &$prefix) { 29 $allowedPrefixes = ($allowedPrefixes == '' ? $prefix : $allowedPrefixes.','.$prefix); 30 } 31 32 // Get the barred prefixes 33 $barredPrefixesInput = $tag->get_option( 'barredPrefixes', '', true ); 34 $barredPrefixArray = []; 35 if ($barredPrefixesInput != '') { 36 $barredPrefixArray = explode("_", $barredPrefixesInput); 37 } 38 $barredPrefixes = ''; 39 foreach ($barredPrefixArray as &$prefix) { 40 $barredPrefixes = ($barredPrefixes == '' ? $prefix : $barredPrefixes.','.$prefix); 41 } 42 21 43 if ($country == '') 22 44 $country = '44'; … … 41 63 'options' => array ('Option' => array( 42 64 array('Name' => 'UseMobileValidation', 'Value' => $mobile), 43 array('Name' => 'UseLineValidation', 'Value' => $line) 65 array('Name' => 'UseLineValidation', 'Value' => $line), 66 array('Name' => 'AllowedPrefixes', 'Value' => $allowedPrefixes), 67 array('Name' => 'BarredPrefixes', 'Value' => $barredPrefixes) 44 68 )) 45 69 ); -
data8-validation-for-contact-form-7/trunk/includes/d8cf7_instructions.php
r1921629 r1922330 53 53 <li><strong>d8landline</strong> - if the telephone number is a UK landline, use the enhanced Landline Validation service to perform more detailed validation</li> 54 54 <li><strong>d8country_US</strong> - if the telephone number does not include an explicit country code prefix, use the country specified in this option instead. Defaults to GB</li> 55 <li><strong>d8AllowedPrefixes_441_442</strong> - if specified any prefixes (without the leading plus "+" and seperated by an underscore "_") are the only ones allowed</li> 56 <li><strong>d8BarredPrefixes_44151_442</strong> - if specified any prefixes (without the leading plus "+" and seperated by an underscore "_") are barred</li> 55 57 </ul> 56 58 </li> … … 100 102 <li><strong>[tel* your-tel landline:true]</strong> - if the telephone number is a UK landline, use the enhanced Landline Validation service to perform more detailed validation</li> 101 103 <li><strong>[tel* your-tel country:US]</strong> - if the telephone number does not include an explicit country code prefix, use the country specified in this option instead. Defaults to GB</li> 104 <li><strong>[tel* your-tel allowedPrefixes:+441_+442]</strong> - if included only these prefixes will be allowed</li> 105 <li><strong>[tel* your-tel barredPrefixes:+01_+447]</strong> - if included these prefixes will NOT be allowed</li> 102 106 </ul> 103 107 </li> -
data8-validation-for-contact-form-7/trunk/includes/d8gf-validation.php
r1921629 r1922330 49 49 if ( $field->get_input_type() === 'phone' && $result['is_valid'] && $value != '' ) { 50 50 $classes = explode(' ', $field->cssClass); 51 $country = '44'; 51 $country = '44'; 52 52 $line = 'false'; 53 53 $mobile = 'false'; 54 $allowedPrefixes = ''; 55 $barredPrefixes = ''; 54 56 55 57 foreach ($classes as $class) { … … 62 64 if ($class == 'd8mobile') 63 65 $mobile = 'true'; 66 67 // Pull out a list of Allowed Prefixes (if specified) 68 if (startsWith($class, 'd8AllowedPrefixes_')){ 69 $allowedPrefixesInput = substr($class, 10); 70 $allowedPrefixArray = []; 71 if ($allowedPrefixesInput != '') { 72 $allowedPrefixArray = explode("_", $class); 73 } 74 foreach ($allowedPrefixArray as &$prefix) { 75 if ($prefix != 'd8AllowedPrefixes'){ 76 $allowedPrefixes = ($allowedPrefixes == '' ? '+'.$prefix : $allowedPrefixes.','.'+'.$prefix); 77 } 78 } 79 } 80 81 // Pull out a list of Barred Prefixes (if specified) 82 if (startsWith($class, 'd8BarredPrefixes_')){ 83 $barredPrefixesInput = substr($class, 10); 84 $barredPrefixArray = []; 85 if ($barredPrefixesInput != '') { 86 $barredPrefixArray = explode("_", $class); 87 } 88 foreach ($barredPrefixArray as &$prefix) { 89 if ($prefix != 'd8BarredPrefixes_'){ 90 $barredPrefixes = ($barredPrefixes == '' ? '+'.$prefix : $barredPrefixes.','.'+'.$prefix); 91 } 92 } 93 } 64 94 } 65 95 … … 76 106 'options' => array ('Option' => array( 77 107 array('Name' => 'UseMobileValidation', 'Value' => $mobile), 78 array('Name' => 'UseLineValidation', 'Value' => $line) 108 array('Name' => 'UseLineValidation', 'Value' => $line), 109 array('Name' => 'AllowedPrefixes', 'Value' => $allowedPrefixes), 110 array('Name' => 'BarredPrefixes', 'Value' => $barredPrefixes) 79 111 )) 80 112 );
Note: See TracChangeset
for help on using the changeset viewer.