WPCF7_SWV_Rule{}
The base class of SWV rules.
Хуков нет.
Использование
$WPCF7_SWV_Rule = new WPCF7_SWV_Rule(); // use class methods
Методы
- public __construct( $properties = '' )
- public get_property( $name )
- public matches( $context )
- public to_array()
- public validate( $context )
Код WPCF7_SWV_Rule{} WPCF7 SWV Rule{} CF7 5.7.5.1
abstract class WPCF7_SWV_Rule { protected $properties = array(); public function __construct( $properties = '' ) { $this->properties = wp_parse_args( $properties, array() ); } /** * Returns true if this rule matches the given context. * * @param array $context Context. */ public function matches( $context ) { $field = $this->get_property( 'field' ); if ( ! empty( $context['field'] ) ) { if ( $field and ! in_array( $field, (array) $context['field'], true ) ) { return false; } } return true; } /** * Validates with this rule's logic. * * @param array $context Context. */ public function validate( $context ) { return true; } /** * Converts the properties to an array. * * @return array Array of properties. */ public function to_array() { return (array) $this->properties; } /** * Returns the property value specified by the given property name. * * @param string $name Property name. * @return mixed Property value. */ public function get_property( $name ) { if ( isset( $this->properties[$name] ) ) { return $this->properties[$name]; } } }