Website Summary Files Commits Branches @commit @diff @stats
path: root / wp-content / plugins
diff options
context:
space:
mode:
Commita8d2fdedb5094b5a994f8fce72d965fe1d81a894 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2020-07-12 18:20:36 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2020-07-12 18:20:36 +0300
Filesdfddd581d49336517bab5e5fef4a7bc775c817f5 /wp-content/plugins
tues-interns-2020-a8d2fdedb5094b5a994f8fce72d965fe1d81a894.tar
tues-interns-2020-a8d2fdedb5094b5a994f8fce72d965fe1d81a894.tar.gz
tues-interns-2020-a8d2fdedb5094b5a994f8fce72d965fe1d81a894.zip
Parent1bad284eb5f266c734f85a68db0023bc73bb5495 (diff)
Implimented vehicle horsepower and range following current naming and code standards.
2 files changed, 20 insertions, 4 deletions
-rw-r--r--wp-content/plugins/dx-cars/car_info.php8
-rw-r--r--wp-content/plugins/dx-cars/class.cpt.php16
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 eb8eb48..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' => isset($_FILES['car-images']) ? $this->get_enc_uploaded_img_urls( $_FILES['car-images'] ): null,
+ '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;