@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace WFV\Contract; |
| 3 | -defined( 'ABSPATH' ) || die(); |
|
| 3 | +defined('ABSPATH') || die(); |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -14,12 +14,12 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @return |
| 16 | 16 | */ |
| 17 | - public function checked_if( $field = null, $value = null ); |
|
| 17 | + public function checked_if($field = null, $value = null); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @return |
| 21 | 21 | */ |
| 22 | - public function display( $field = null, callable $callback = null ); |
|
| 22 | + public function display($field = null, callable $callback = null); |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @return |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @return |
| 41 | 41 | */ |
| 42 | - public function selected_if( $field = null, $value = null ); |
|
| 42 | + public function selected_if($field = null, $value = null); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @return |
@@ -49,6 +49,6 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @return |
| 51 | 51 | */ |
| 52 | - public function is_valid( $factory ); |
|
| 52 | + public function is_valid($factory); |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || die(); |
|
| 2 | +defined('ABSPATH') || die(); |
|
| 3 | 3 | /* |
| 4 | 4 | Plugin Name: WFV - Form Validation |
| 5 | 5 | Plugin URI: https://macder.github.io/wfv/ |
@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | License URI: https://github.com/macder/wp-form-validation/blob/master/LICENSE |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -define( 'WFV_VALIDATE_VERSION', '0.11.0' ); |
|
| 15 | -define( 'WFV_VALIDATE__MINIMUM_WP_VERSION', '3.7' ); |
|
| 16 | -define( 'WFV_VALIDATE__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
| 17 | -define( 'WFV_VALIDATE__ACTION_POST', 'validate_form' ); |
|
| 14 | +define('WFV_VALIDATE_VERSION', '0.11.0'); |
|
| 15 | +define('WFV_VALIDATE__MINIMUM_WP_VERSION', '3.7'); |
|
| 16 | +define('WFV_VALIDATE__PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
| 17 | +define('WFV_VALIDATE__ACTION_POST', 'validate_form'); |
|
| 18 | 18 | |
| 19 | -require_once WFV_VALIDATE__PLUGIN_DIR . '/vendor/autoload.php'; |
|
| 19 | +require_once WFV_VALIDATE__PLUGIN_DIR.'/vendor/autoload.php'; |
|
| 20 | 20 | |
| 21 | 21 | use WFV\Client; |
| 22 | 22 | use WFV\Agent\InspectionAgent; |
@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | * @param array $form Form arguments |
| 35 | 35 | * @param bool $trim Trim whitespace from beginning and end of string |
| 36 | 36 | */ |
| 37 | -function wfv_create( $action, array &$form, $trim = true ) { |
|
| 38 | - $inspect = new InspectionAgent( $action ); |
|
| 39 | - $input = ( true === $inspect->safe_submit() ) ? $_POST : array(); |
|
| 37 | +function wfv_create($action, array &$form, $trim = true) { |
|
| 38 | + $inspect = new InspectionAgent($action); |
|
| 39 | + $input = (true === $inspect->safe_submit()) ? $_POST : array(); |
|
| 40 | 40 | |
| 41 | - $builder = new FormArtisan( $form ); |
|
| 42 | - $form = new Client( ( new Director( $action ) ) |
|
| 43 | - ->with( 'input', [ $input, $trim ] ) |
|
| 44 | - ->with( 'rules' ) |
|
| 45 | - ->with( 'errors' ) |
|
| 46 | - ->with( 'validator' ) |
|
| 47 | - ->compose( $builder ) |
|
| 41 | + $builder = new FormArtisan($form); |
|
| 42 | + $form = new Client((new Director($action)) |
|
| 43 | + ->with('input', [$input, $trim]) |
|
| 44 | + ->with('rules') |
|
| 45 | + ->with('errors') |
|
| 46 | + ->with('validator') |
|
| 47 | + ->compose($builder) |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - if( $input ) { |
|
| 51 | - wfv_validate( $form ); |
|
| 50 | + if ($input) { |
|
| 51 | + wfv_validate($form); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * @param FormComposite $form |
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | -function wfv_validate( FormInterface $form ) { |
|
| 64 | - $factory = ( new ValidatorFactory() ) |
|
| 65 | - ->add( $form->rules()->unique() ); |
|
| 66 | - return $form->is_valid( $factory ); |
|
| 63 | +function wfv_validate(FormInterface $form) { |
|
| 64 | + $factory = (new ValidatorFactory()) |
|
| 65 | + ->add($form->rules()->unique()); |
|
| 66 | + return $form->is_valid($factory); |
|
| 67 | 67 | } |