@@ -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\FormComposite; |
| 22 | 22 | use WFV\Agent\InspectionAgent; |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | * @param array $form Form arguments |
| 34 | 34 | * @param bool $trim Trim whitespace from beginning and end of string |
| 35 | 35 | */ |
| 36 | -function wfv_create( $action, array &$form, $trim = true ) { |
|
| 37 | - $inspect = new InspectionAgent( $action ); |
|
| 38 | - $input = ( true === $inspect->safe_submit() ) ? $_POST : array(); |
|
| 36 | +function wfv_create($action, array &$form, $trim = true) { |
|
| 37 | + $inspect = new InspectionAgent($action); |
|
| 38 | + $input = (true === $inspect->safe_submit()) ? $_POST : array(); |
|
| 39 | 39 | |
| 40 | - $builder = new FormArtisan( $form ); |
|
| 41 | - $form = ( new Director( $action ) ) |
|
| 42 | - ->with( 'input', [ $input, $trim ] ) |
|
| 43 | - ->with( 'rules' ) |
|
| 44 | - ->with( 'errors' ) |
|
| 45 | - ->with( 'validator' ) |
|
| 46 | - ->compose( $builder ); |
|
| 40 | + $builder = new FormArtisan($form); |
|
| 41 | + $form = (new Director($action)) |
|
| 42 | + ->with('input', [$input, $trim]) |
|
| 43 | + ->with('rules') |
|
| 44 | + ->with('errors') |
|
| 45 | + ->with('validator') |
|
| 46 | + ->compose($builder); |
|
| 47 | 47 | |
| 48 | - if( $input ) { |
|
| 49 | - wfv_validate( $form ); |
|
| 48 | + if ($input) { |
|
| 49 | + wfv_validate($form); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | * @param FormComposite $form |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | -function wfv_validate( FormComposite $form ) { |
|
| 62 | - $factory = ( new ValidatorFactory() ) |
|
| 63 | - ->add( $form->rules()->unique() ); |
|
| 64 | - return $form->validate( $factory )->is_valid(); |
|
| 61 | +function wfv_validate(FormComposite $form) { |
|
| 62 | + $factory = (new ValidatorFactory()) |
|
| 63 | + ->add($form->rules()->unique()); |
|
| 64 | + return $form->validate($factory)->is_valid(); |
|
| 65 | 65 | } |