diff options
| Commit | f9de01e28fffc124cdc76c9a32ea0164accf7033 (patch) | |
|---|---|---|
| Author | 2020-07-06 16:43:12 +0300 | |
| Committer | 2020-07-06 16:43:12 +0300 | |
| Files | a286e87e36c1ca6fdc70435179202db462983997 | |
| tues-interns-2020-feature-cars-validation.tar tues-interns-2020-feature-cars-validation.tar.gz tues-interns-2020-feature-cars-validation.zip | ||
| Parent | 1733ff402e872b958c11f3fcfb6257e0a9d213fe (diff) | |
A message is shown when a field value is invalid. feature-cars-validation
1 files changed, 3 insertions, 4 deletions
| -rw-r--r-- | wp-content/plugins/dx-cars/class.cpt.php | 7 |
diff --git a/wp-content/plugins/dx-cars/class.cpt.php b/wp-content/plugins/dx-cars/class.cpt.php index 9adb344..19c40fe 100644 --- a/wp-content/plugins/dx-cars/class.cpt.php +++ b/wp-content/plugins/dx-cars/class.cpt.php @@ -49,16 +49,15 @@ class Vehicles { // Cycle through the $events_meta array. // Note, in this example we just have one item, but this is helpful if you have multiple. foreach ( $events_meta as $key => $value ) { - // Don't store custom data twice if ( 'revision' === $post->post_type ) { return; } switch( $key ) { - case 'car-year': if( strcmp( "1769", $value ) > 0 || strcmp( "2020", $value ) < 0 ) return; break; - case 'car-millage': - case 'car-price': if( strcmp( "0", $value ) > 0 ) return; break; + case 'car-year': if( strcmp( "1769", $value ) > 0 || strcmp( get_the_date('Y'), $value ) < 0 ) wp_die('Invalid year.'); break; + case 'car-millage': if( strcmp( "0", $value ) > 0 ) wp_die('Invalid millage.'); break; + case 'car-price': if( strcmp( "0", $value ) > 0 ) wp_die('Invalid price.'); break; } if ( get_post_meta( $post_id, $key, false ) ) { |
