rebase from live enviornment
This commit is contained in:
36
wp/plugins/contact-form-7/includes/swv/rules/date.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/date.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_DateRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'date';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! wpcf7_is_date( $i ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_date',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
48
wp/plugins/contact-form-7/includes/swv/rules/dayofweek.php
Normal file
48
wp/plugins/contact-form-7/includes/swv/rules/dayofweek.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_DayofweekRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'dayofweek';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$acceptable_values = (array) $this->get_property( 'accept' );
|
||||
$acceptable_values = array_map( 'intval', $acceptable_values );
|
||||
$acceptable_values = array_filter( $acceptable_values );
|
||||
$acceptable_values = array_unique( $acceptable_values );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( wpcf7_is_date( $i ) ) {
|
||||
$datetime = date_create_immutable( $i, wp_timezone() );
|
||||
$dow = (int) $datetime->format( 'N' );
|
||||
|
||||
if ( ! in_array( $dow, $acceptable_values, true ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_dayofweek',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
36
wp/plugins/contact-form-7/includes/swv/rules/email.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/email.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_EmailRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'email';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! wpcf7_is_email( $i ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_email',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
43
wp/plugins/contact-form-7/includes/swv/rules/enum.php
Normal file
43
wp/plugins/contact-form-7/includes/swv/rules/enum.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_EnumRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'enum';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$acceptable_values = (array) $this->get_property( 'accept' );
|
||||
$acceptable_values = array_map( 'strval', $acceptable_values );
|
||||
$acceptable_values = array_filter( $acceptable_values );
|
||||
$acceptable_values = array_unique( $acceptable_values );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! in_array( $i, $acceptable_values, true ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_enum',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
63
wp/plugins/contact-form-7/includes/swv/rules/file.php
Normal file
63
wp/plugins/contact-form-7/includes/swv/rules/file.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_FileRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'file';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['file'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_FILES[$field]['name'] ) ? $_FILES[$field]['name'] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$acceptable_filetypes = array();
|
||||
|
||||
foreach ( (array) $this->get_property( 'accept' ) as $accept ) {
|
||||
if ( preg_match( '/^\.[a-z0-9]+$/i', $accept ) ) {
|
||||
$acceptable_filetypes[] = strtolower( $accept );
|
||||
} else {
|
||||
foreach ( wpcf7_convert_mime_to_ext( $accept ) as $ext ) {
|
||||
$acceptable_filetypes[] = sprintf(
|
||||
'.%s',
|
||||
strtolower( trim( $ext, ' .' ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$acceptable_filetypes = array_unique( $acceptable_filetypes );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
$last_period_pos = strrpos( $i, '.' );
|
||||
|
||||
if ( false === $last_period_pos ) { // no period
|
||||
return new WP_Error( 'wpcf7_invalid_file',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
$suffix = strtolower( substr( $i, $last_period_pos ) );
|
||||
|
||||
if ( ! in_array( $suffix, $acceptable_filetypes, true ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_file',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
42
wp/plugins/contact-form-7/includes/swv/rules/maxdate.php
Normal file
42
wp/plugins/contact-form-7/includes/swv/rules/maxdate.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MaxDateRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'maxdate';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( ! wpcf7_is_date( $threshold ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( wpcf7_is_date( $i ) and $threshold < $i ) {
|
||||
return new WP_Error( 'wpcf7_invalid_maxdate',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
40
wp/plugins/contact-form-7/includes/swv/rules/maxfilesize.php
Normal file
40
wp/plugins/contact-form-7/includes/swv/rules/maxfilesize.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MaxFileSizeRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'maxfilesize';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['file'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_FILES[$field]['size'] ) ? $_FILES[$field]['size'] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
if ( empty( $input ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( $threshold < array_sum( $input ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_maxfilesize',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
40
wp/plugins/contact-form-7/includes/swv/rules/maxitems.php
Normal file
40
wp/plugins/contact-form-7/includes/swv/rules/maxitems.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MaxItemsRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'maxitems';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( ! wpcf7_is_number( $threshold ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( (int) $threshold < count( $input ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_maxitems',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
46
wp/plugins/contact-form-7/includes/swv/rules/maxlength.php
Normal file
46
wp/plugins/contact-form-7/includes/swv/rules/maxlength.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MaxLengthRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'maxlength';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
if ( empty( $input ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
$total += wpcf7_count_code_units( $i );
|
||||
}
|
||||
|
||||
$threshold = (int) $this->get_property( 'threshold' );
|
||||
|
||||
if ( $total <= $threshold ) {
|
||||
return true;
|
||||
} else {
|
||||
return new WP_Error( 'wpcf7_invalid_maxlength',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
42
wp/plugins/contact-form-7/includes/swv/rules/maxnumber.php
Normal file
42
wp/plugins/contact-form-7/includes/swv/rules/maxnumber.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MaxNumberRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'maxnumber';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( ! wpcf7_is_number( $threshold ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( wpcf7_is_number( $i ) and (float) $threshold < (float) $i ) {
|
||||
return new WP_Error( 'wpcf7_invalid_maxnumber',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
42
wp/plugins/contact-form-7/includes/swv/rules/mindate.php
Normal file
42
wp/plugins/contact-form-7/includes/swv/rules/mindate.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MinDateRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'mindate';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( ! wpcf7_is_date( $threshold ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( wpcf7_is_date( $i ) and $i < $threshold ) {
|
||||
return new WP_Error( 'wpcf7_invalid_mindate',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
40
wp/plugins/contact-form-7/includes/swv/rules/minfilesize.php
Normal file
40
wp/plugins/contact-form-7/includes/swv/rules/minfilesize.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MinFileSizeRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'minfilesize';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['file'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_FILES[$field]['size'] ) ? $_FILES[$field]['size'] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
if ( empty( $input ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( array_sum( $input ) < $threshold ) {
|
||||
return new WP_Error( 'wpcf7_invalid_minfilesize',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
40
wp/plugins/contact-form-7/includes/swv/rules/minitems.php
Normal file
40
wp/plugins/contact-form-7/includes/swv/rules/minitems.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MinItemsRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'minitems';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( ! wpcf7_is_number( $threshold ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( count( $input ) < (int) $threshold ) {
|
||||
return new WP_Error( 'wpcf7_invalid_minitems',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
46
wp/plugins/contact-form-7/includes/swv/rules/minlength.php
Normal file
46
wp/plugins/contact-form-7/includes/swv/rules/minlength.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MinLengthRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'minlength';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
if ( empty( $input ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
$total += wpcf7_count_code_units( $i );
|
||||
}
|
||||
|
||||
$threshold = (int) $this->get_property( 'threshold' );
|
||||
|
||||
if ( $threshold <= $total ) {
|
||||
return true;
|
||||
} else {
|
||||
return new WP_Error( 'wpcf7_invalid_minlength',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
42
wp/plugins/contact-form-7/includes/swv/rules/minnumber.php
Normal file
42
wp/plugins/contact-form-7/includes/swv/rules/minnumber.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_MinNumberRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'minnumber';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
$threshold = $this->get_property( 'threshold' );
|
||||
|
||||
if ( ! wpcf7_is_number( $threshold ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( wpcf7_is_number( $i ) and (float) $i < (float) $threshold ) {
|
||||
return new WP_Error( 'wpcf7_invalid_minnumber',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
36
wp/plugins/contact-form-7/includes/swv/rules/number.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/number.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_NumberRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'number';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! wpcf7_is_number( $i ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_number',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
36
wp/plugins/contact-form-7/includes/swv/rules/required.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/required.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_RequiredRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'required';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
if ( empty( $input ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_required',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_RequiredFileRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'requiredfile';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['file'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
|
||||
$input = isset( $_FILES[$field]['tmp_name'] )
|
||||
? $_FILES[$field]['tmp_name'] : '';
|
||||
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
if ( empty( $input ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_requiredfile',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
36
wp/plugins/contact-form-7/includes/swv/rules/tel.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/tel.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_TelRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'tel';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! wpcf7_is_tel( $i ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_tel',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
36
wp/plugins/contact-form-7/includes/swv/rules/time.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/time.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_TimeRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'time';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! wpcf7_is_time( $i ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_time',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
36
wp/plugins/contact-form-7/includes/swv/rules/url.php
Normal file
36
wp/plugins/contact-form-7/includes/swv/rules/url.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPCF7_SWV_URLRule extends WPCF7_SWV_Rule {
|
||||
|
||||
const rule_name = 'url';
|
||||
|
||||
public function matches( $context ) {
|
||||
if ( false === parent::matches( $context ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $context['text'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validate( $context ) {
|
||||
$field = $this->get_property( 'field' );
|
||||
$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
|
||||
$input = wpcf7_array_flatten( $input );
|
||||
$input = wpcf7_exclude_blank( $input );
|
||||
|
||||
foreach ( $input as $i ) {
|
||||
if ( ! wpcf7_is_url( $i ) ) {
|
||||
return new WP_Error( 'wpcf7_invalid_url',
|
||||
$this->get_property( 'error' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user