From cf1261ebf098dc0e644544ca2e57ceadfe51c476 Mon Sep 17 00:00:00 2001 From: pgmatev Date: Mon, 13 Jul 2020 19:03:33 +0300 Subject: fixed saving after validation; changed file names to match proposed naming --- .../plugins/dx-cars/car-info-display-callback.php | 27 ++++++ wp-content/plugins/dx-cars/dx-cars.php | 23 ----- wp-content/plugins/dx-cars/dx-vehicles.php | 23 +++++ wp-content/plugins/dx-users/class.cm.php | 108 --------------------- wp-content/plugins/dx-users/dx-users.php | 2 +- wp-content/plugins/dx-users/users-class.php | 99 +++++++++++++++++++ 6 files changed, 150 insertions(+), 132 deletions(-) create mode 100644 wp-content/plugins/dx-cars/car-info-display-callback.php delete mode 100644 wp-content/plugins/dx-cars/dx-cars.php create mode 100644 wp-content/plugins/dx-cars/dx-vehicles.php delete mode 100644 wp-content/plugins/dx-users/class.cm.php create mode 100644 wp-content/plugins/dx-users/users-class.php (limited to 'wp-content/plugins') diff --git a/wp-content/plugins/dx-cars/car-info-display-callback.php b/wp-content/plugins/dx-cars/car-info-display-callback.php new file mode 100644 index 0000000..b8931aa --- /dev/null +++ b/wp-content/plugins/dx-cars/car-info-display-callback.php @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + ' ); + } + ?> + +
(might need page refresh):' ) ?>
diff --git a/wp-content/plugins/dx-cars/dx-cars.php b/wp-content/plugins/dx-cars/dx-cars.php deleted file mode 100644 index e4bdaf0..0000000 --- a/wp-content/plugins/dx-cars/dx-cars.php +++ /dev/null @@ -1,23 +0,0 @@ -init(); - $tax->init(); - $tax1 -> init(); diff --git a/wp-content/plugins/dx-cars/dx-vehicles.php b/wp-content/plugins/dx-cars/dx-vehicles.php new file mode 100644 index 0000000..e4bdaf0 --- /dev/null +++ b/wp-content/plugins/dx-cars/dx-vehicles.php @@ -0,0 +1,23 @@ +init(); + $tax->init(); + $tax1 -> init(); diff --git a/wp-content/plugins/dx-users/class.cm.php b/wp-content/plugins/dx-users/class.cm.php deleted file mode 100644 index beb0b1c..0000000 --- a/wp-content/plugins/dx-users/class.cm.php +++ /dev/null @@ -1,108 +0,0 @@ - 'phone-number', - // 'label' => 'Phone number', - // ), - // array( - // 'service' => 'address', - // 'label' => 'Address', - // ), - // ); - - // foreach ( $new_methods as $method ) { - // if( ! isset( $contact_methods[$method['service']] ) ) { - // $contact_methods[$method['service']] = $method['label']; - // } - // } - - // return $contact_methods; - // } - function render_profile_fields( $user ) { ?> - -

More Information

- - - - - - - - - - -
-
-
-
-
- - 10) { - $errors->add( 'phone', "ERROR: The maximum phone length is 10 characters." ); - $error_check = true; - } - - if ( preg_match( $phone_regex, $_POST['phone'] ) == 0 ) { - $errors->add( 'phone', "ERROR: Not a valid phone number." ); - $error_check = true; - } - - if( $error_check ) { - error_log("shareni bomboni"); - return $errors; - } - - error_log("shareni bomboni sled if"); - add_action( 'edit_user_profile_update', array( $this, 'save_profile_fields' ) ); - add_action( 'personal_options_update', array( $this, 'save_profile_fields' ) ); - - } - - function validate_profile_address( $errors, $update, $user ) { - $error_check = false; - // validate input fields - if ( !empty( $_POST['address'] ) && strlen( $_POST['address'] ) > 255 ) { - $errors->add( 'address', "ERROR: The maximum address length is 255 characters." ); //test validation; TO DO define proper validation - $error_check = true; - } - - if( $error_check ){ - return $errors; - } - - add_action( 'edit_user_profile_update', array( $this, 'save_profile_fields' ) ); - add_action( 'personal_options_update', array( $this, 'save_profile_fields' ) ); - - } - - function save_profile_fields( $id ) { - // save input fields values - if ( !current_user_can( 'edit_user', $id ) ) - return false; - - if ( isset( $_POST['phone'] ) ) - update_user_meta( $id, 'phone', $_POST['phone'] ); - - if ( isset( $_POST['address'] ) ) - update_user_meta( $id, 'address', $_POST['address'] ); - } -} \ No newline at end of file diff --git a/wp-content/plugins/dx-users/dx-users.php b/wp-content/plugins/dx-users/dx-users.php index a12b985..f85b596 100644 --- a/wp-content/plugins/dx-users/dx-users.php +++ b/wp-content/plugins/dx-users/dx-users.php @@ -11,7 +11,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); -include 'class.cm.php'; +include 'users-class.php'; $users = new Users; $users->init(); diff --git a/wp-content/plugins/dx-users/users-class.php b/wp-content/plugins/dx-users/users-class.php new file mode 100644 index 0000000..958d12b --- /dev/null +++ b/wp-content/plugins/dx-users/users-class.php @@ -0,0 +1,99 @@ + 'phone-number', + // 'label' => 'Phone number', + // ), + // array( + // 'service' => 'address', + // 'label' => 'Address', + // ), + // ); + + // foreach ( $new_methods as $method ) { + // if( ! isset( $contact_methods[$method['service']] ) ) { + // $contact_methods[$method['service']] = $method['label']; + // } + // } + + // return $contact_methods; + // } + function render_profile_fields( $user ) { ?> + +

More Information

+ + + + + + + + + + +
+
+
+
+
+ + 10) { + + $errors->add( 'phone', "ERROR: The maximum phone length is 10 characters." ); + + } + if ( preg_match( $phone_regex, $_POST['phone'] ) == 0 ) { + + $errors->add( 'phone', "ERROR: Not a valid phone number." ); + } + + return $errors; + + } + + function save_profile_fields( $id ) { + + // save input fields values + $phone_regex = "/08[789]\d{7}/u"; + + if ( !current_user_can( 'edit_user', $id ) ) + return false; + + if ( isset( $_POST['phone'] )) { + + if ( preg_match( $phone_regex, $_POST['phone'] ) == 1 ) { + update_user_meta( $id, 'phone', sanitize_text_field( $_POST['phone'] ) ); + } + } + + if ( isset( $_POST['address'] ) ) { + update_user_meta( $id, 'address', sanitize_text_field( $_POST['address'] ) ); + } + } +} \ No newline at end of file -- cgit v1.3.1-26-gb76a