diff options
Merge branch 'feature-cars-cpt' of https://github.com/DevriX/tues-interns-2020 into feature-users-cm
2 files changed, 20 insertions, 4 deletions
| -rw-r--r-- | wp-content/plugins/dx-cars/car_info.php | 8 | ||||
| -rw-r--r-- | wp-content/plugins/dx-cars/class.cpt.php | 16 |
diff --git a/wp-content/plugins/dx-cars/car_info.php b/wp-content/plugins/dx-cars/car_info.php index b8931aa..2253fc7 100644 --- a/wp-content/plugins/dx-cars/car_info.php +++ b/wp-content/plugins/dx-cars/car_info.php @@ -8,6 +8,14 @@ <td><input type="text" name="car-millage" value="<?php echo( sanitize_text_field( get_post_meta( get_the_ID(), __( 'car-millage' ), true ) ) ) ?>"></td> </tr> <tr> + <td><?php _e( 'Horsepower:' ) ?></td> + <td><input type="text" name="car-horsepower" value="<?php echo( sanitize_text_field( get_post_meta( get_the_ID(), __( 'car-horsepower' ), true ) ) ) ?>"></td> + </tr> + <tr> + <td><?php _e( 'Range:' ) ?></td> + <td><input type="text" name="car-range" value="<?php echo( sanitize_text_field( get_post_meta( get_the_ID(), __( 'car-range' ), true ) ) ) ?>"></td> + </tr> + <tr> <td><?php _e( 'Price:' ) ?></td> <td><input type="text" name="car-price" value="<?php echo( sanitize_text_field( get_post_meta( get_the_ID(), __( 'car-price' ), true ) ) ) ?>"></td> </tr> diff --git a/wp-content/plugins/dx-cars/class.cpt.php b/wp-content/plugins/dx-cars/class.cpt.php index 03bdec3..f17a82b 100644 --- a/wp-content/plugins/dx-cars/class.cpt.php +++ b/wp-content/plugins/dx-cars/class.cpt.php @@ -76,10 +76,12 @@ class Vehicles { // Now that we're authenticated, time to save the data. // This sanitizes the data from the field and saves it into an array $events_meta. $events_meta = array( - 'car-year' => sanitize_text_field( isset( $_POST['car-year'] ) ? $_POST['car-year'] : null ), - 'car-millage' => sanitize_text_field( isset( $_POST['car-millage'] ) ? $_POST['car-millage'] : null ), - 'car-price' => sanitize_text_field( isset( $_POST['car-price'] ) ? $_POST['car-price'] : null ), - 'car-images' => $this->get_enc_uploaded_img_urls( $_FILES['car-images'] ), + 'car-year' => sanitize_text_field( isset( $_POST['car-year'] ) ? $_POST['car-year'] : null ), + 'car-millage' => sanitize_text_field( isset( $_POST['car-millage'] ) ? $_POST['car-millage'] : null ), + 'car-horsepower' => sanitize_text_field( isset( $_POST['car-horsepower'] ) ? $_POST['car-horsepower'] : null ), + 'car-range' => sanitize_text_field( isset( $_POST['car-range'] ) ? $_POST['car-range'] : null ), + 'car-price' => sanitize_text_field( isset( $_POST['car-price'] ) ? $_POST['car-price'] : null ), + 'car-images' => isset($_FILES['car-images']) ? $this->get_enc_uploaded_img_urls( $_FILES['car-images'] ): null, ); // Cycle through the $events_meta array. @@ -101,6 +103,12 @@ class Vehicles { case 'car-millage': if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid millage.' ); break; + case 'car-horsepower': + if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid horsepower.' ); + break; + case 'car-range': + if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid range.' ); + break; case 'car-price': if( strcmp( "0", $value ) > 0 ) wp_die( 'Invalid price.' ); break; |
