Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/simply-schedule-appointments/includes/class-appointment-model.php
+++ b/simply-schedule-appointments/includes/class-appointment-model.php
@@ -93,6 +93,7 @@
add_filter( 'ssa/appointment/before_insert', array( $this, 'sanitize_text_fields' ), 7, 1 );
add_filter( 'ssa/appointment/before_update', array( $this, 'sanitize_text_fields' ), 7, 1 );
add_filter( 'ssa/appointment/before_update', array( $this, 'prevent_canceling_a_reserved_appointment' ), 1, 2 );
+ add_filter( 'ssa/appointment/before_update', array( $this, 'prevent_abandoning_a_booked_appointment' ), PHP_INT_MAX, 3 );
add_filter( 'ssa/appointment/before_insert', array( $this, 'default_appointment_status' ), 5, 1 );
@@ -261,6 +262,33 @@
}
/**
+ * A booked appointment is never abandoned. A hold cleanup or a failed-payment webhook can
+ * read it as held just before a payment or a form submission books it.
+ * Hooked last, so the status is read just before the database write.
+ *
+ * @param array $data
+ * @param array $data_before
+ * @param int $appointment_id
+ * @return array
+ */
+ public function prevent_abandoning_a_booked_appointment( $data, $data_before, $appointment_id ) {
+ if ( empty( $data['status'] ) || ! self::is_an_abandoned_status( $data['status'] ) ) {
+ return $data;
+ }
+
+ if ( ! self::is_a_booked_status( $this->db_get_field( 'status', $appointment_id ) ) ) {
+ return $data;
+ }
+
+ $data['error'] = array(
+ 'code' => 'invalid_status',
+ 'message' => __( 'Cannot update status to abandoned', 'simply-schedule-appointments' ),
+ );
+
+ return $data;
+ }
+
+ /**
* Customer-scoped status policy. A holder of an id_token / public nonce
* may only use the status field to cancel — three flows are accepted:
*
@@ -2218,7 +2246,9 @@
if ( is_user_logged_in() ) {
$appointment = new SSA_Appointment_Object( $params['id'] );
- if ( $appointment->customer_id == get_current_user_id() ) {
+ // The account saved on a booking owns it, unless it was saved there only
+ // by an email that account never proved (SSA_Trusted_Email).
+ if ( $appointment->customer_id == get_current_user_id() && ! $this->plugin->trusted_email->is_claimed_by_unproven_email( get_current_user_id(), array( 'id' => (int) $params['id'] ) ) ) {
return true;
}
}
@@ -2550,8 +2580,9 @@
return self::READ_ACCESS_FULL;
}
- // customer_id 0 must never match an anonymous caller's user id 0.
- if ( ! empty( $item['customer_id'] ) && (int) $item['customer_id'] === get_current_user_id() ) {
+ // customer_id 0 must never match an anonymous caller's user id 0. A row
+ // saved under the caller only by an email they never proved is not theirs.
+ if ( ! empty( $item['customer_id'] ) && (int) $item['customer_id'] === get_current_user_id() && ! $this->plugin->trusted_email->is_claimed_by_unproven_email( get_current_user_id(), $item ) ) {
return self::READ_ACCESS_FULL;
}
--- a/simply-schedule-appointments/includes/class-async-action-model.php
+++ b/simply-schedule-appointments/includes/class-async-action-model.php
@@ -248,7 +248,7 @@
$action = 'ssa_async_' . $hook;
}
- ssa()->async_action_model->queue_action( $hook, $action, $priority, $payload, $object_type, $object_id, $action_group, $meta );
+ return ssa()->async_action_model->queue_action( $hook, $action, $priority, $payload, $object_type, $object_id, $action_group, $meta );
}
function ssa_complete_action( $action_id, $response = array() ) {
--- a/simply-schedule-appointments/includes/class-elementor.php
+++ b/simply-schedule-appointments/includes/class-elementor.php
@@ -20,7 +20,7 @@
*
* @var string The plugin version.
*/
- const VERSION = '1.6.13.4';
+ const VERSION = '1.6.13.9';
/**
* Minimum Elementor Version
@@ -29,7 +29,7 @@
*
* @var string Minimum Elementor version required to run the plugin.
*/
- const MINIMUM_ELEMENTOR_VERSION = '1.6.13.4';
+ const MINIMUM_ELEMENTOR_VERSION = '1.6.13.9';
/**
* Minimum PHP Version
@@ -38,7 +38,7 @@
*
* @var string Minimum PHP version required to run the plugin.
*/
- const MINIMUM_PHP_VERSION = '1.6.13.4';
+ const MINIMUM_PHP_VERSION = '1.6.13.9';
/**
* Instance
--- a/simply-schedule-appointments/includes/class-notifications.php
+++ b/simply-schedule-appointments/includes/class-notifications.php
@@ -187,7 +187,13 @@
'id' => $notification['id'],
);
// ssa_debug_log( $notification, 1, 'Notification queued' );
- ssa_queue_action( $hook, $action_to_fire, 10, $payload, 'appointment', $appointment_id, 'notifications', $meta );
+ $action_id = ssa_queue_action( $hook, $action_to_fire, 10, $payload, 'appointment', $appointment_id, 'notifications', $meta );
+ if ( empty( $action_id ) ) {
+ global $wpdb;
+ ssa_debug_log( 'Notification ID ' . $notification['id'] . ' could not be queued for appointment ID ' . $appointment_id . '. wpdb last_error: ' . $wpdb->last_error, 10 );
+ $this->insert_revision_on_notification_not_sent( $notification, $payload, esc_html__( 'It could not be added to the sending queue.', 'simply-schedule-appointments' ) );
+ continue;
+ }
$action_noun = $payload['action_noun'];
$action_verb = $payload['action_verb'];
$data_after = $payload['appointment'];
@@ -810,6 +816,22 @@
return $projected;
}
+ /**
+ * Records in the appointment's history that a queued notification was not sent, and why.
+ */
+ private function insert_revision_on_notification_not_sent( $notification, $payload, $reason ) {
+ $recipients = ! empty( $notification['sent_to'] ) ? $notification['sent_to'] : ( ! empty( $notification['sms_to'] ) ? $notification['sms_to'] : array() );
+
+ $this->plugin->revision_model->insert_revision_on_notification_canceled( (int) $payload['appointment']['id'], array(
+ 'data_after' => $payload['appointment'],
+ 'data_before' => isset( $payload['data_before'] ) ? $payload['data_before'] : array(),
+ 'recipient_type' => is_array( $recipients ) ? ssa_get_recipient_type_for_recipients_array( $recipients ) : '',
+ 'notification_type' => isset( $notification['type'] ) ? $notification['type'] : '',
+ 'notification_title' => isset( $notification['title'] ) ? $notification['title'] : '',
+ 'notification_cancelation_reason' => $reason,
+ ) );
+ }
+
public function fail_async_action( $async_action, $error_code = 500, $error_message = '', $context = array() ) {
$response = array(
'status_code' => $error_code,
@@ -895,16 +917,22 @@
return $appointment_object->customer_has_not_opted_in();
}
- public function should_fire_notification( $single_notification_settings, $payload ) {
+ /**
+ * $skip_reason is set when a notification that would otherwise go out is held back,
+ * so the queue runner can record why; checks that hold back no real send leave it empty.
+ */
+ public function should_fire_notification( $single_notification_settings, $payload, &$skip_reason = '' ) {
// ssa_debug_log( __FUNCTION__ .'()' );
// ssa_debug_log( $single_notification_settings, 1, '$single_notification_settings' );
// ssa_debug_log( $payload, 1, '$payload' );
if ( ! $this->plugin->settings_installed->is_enabled( 'notifications' ) ) {
+ $skip_reason = esc_html__( 'Notifications are turned off on this site.', 'simply-schedule-appointments' );
return false;
}
if ( isset( $single_notification_settings['active'] ) && empty( $single_notification_settings['active'] ) ) {
+ $skip_reason = esc_html__( 'This notification is turned off.', 'simply-schedule-appointments' );
return false; // if it isn't set yet, then the settings may have been stored before the active toggle existed. They default on, so if 'active' isn't set, we'll assume it should be on.
}
@@ -930,6 +958,7 @@
}
if ( $this->customer_has_not_opted_in( $appointment_object, $single_notification_settings ) ) {
+ $skip_reason = esc_html__( 'The customer did not opt in to notifications.', 'simply-schedule-appointments' );
return false;
}
@@ -950,9 +979,11 @@
// We shouldn't send notifications if the appointment was canceled after this action was queued
if ( $payload['action'] !== 'appointment_canceled' ) {
if ( ! $appointment_object->is_group_parent() || $appointment_object->is_group_canceled() ) {
- return false;
+ $skip_reason = esc_html__( 'The appointment was canceled.', 'simply-schedule-appointments' );
+ return false;
} else if( in_array( '{{customer_email}}', $single_notification_settings['sent_to'] ) ) {
// this is a cancelled group parent, and this is not the staff email skip it
+ $skip_reason = esc_html__( 'The appointment was canceled.', 'simply-schedule-appointments' );
return false;
}
}
@@ -962,6 +993,7 @@
if ( $appointment_object->status === 'abandoned' ) {
// We shouldn't send notifications if the appointment was abandoned after this action was queued
if ( $payload['action'] !== 'appointment_abandoned') {
+ $skip_reason = esc_html__( 'The appointment was abandoned.', 'simply-schedule-appointments' );
return false;
}
// unless this is specifically an "appointment_abandoned" trigger, in which case we continue on...
@@ -970,6 +1002,7 @@
if ( $single_notification_settings['when'] === 'before' && $single_notification_settings['trigger'] === 'appointment_start_date' ) {
// We shouldn't send notifications if the appointment already started and this was supposed to go out *before* the appointment start time
if ( ssa_datetime() >= $appointment_object->start_date_datetime ) {
+ $skip_reason = esc_html__( 'The appointment had already started.', 'simply-schedule-appointments' );
return false;
}
}
@@ -996,6 +1029,7 @@
}
// We've reached this in error, default to not sending the notification
+ $skip_reason = esc_html__( 'Notification configuration no longer applies to this appointment.', 'simply-schedule-appointments' );
return false;
}
@@ -1032,18 +1066,22 @@
if ( empty( $payload['notification']['id'] ) || $payload['notification']['id'] != $notification['id'] ) {
continue; // skip any non-matches
}
- if ( ! $this->should_fire_notification( $notification, $payload ) ) {
- $responses[] = array(
- 'action' => $payload['action'],
- 'skipped' => true,
- 'notification' => $notification,
- );
- continue;
- }
-
try {
+ $skip_reason = '';
+ if ( ! $this->should_fire_notification( $notification, $payload, $skip_reason ) ) {
+ if ( '' !== $skip_reason ) {
+ $this->insert_revision_on_notification_not_sent( $notification, $payload, $skip_reason );
+ }
+ $responses[] = array(
+ 'action' => $payload['action'],
+ 'skipped' => true,
+ 'notification' => $notification,
+ );
+ continue;
+ }
+
$response = $this->fire_notification( $notification, $payload );
- } catch ( Exception $e ) {
+ } catch ( Throwable $e ) {
// The appointment can be deleted while its notification renders.
// Fail this action instead of ending the rest of the queue run.
if ( empty( $this->plugin->appointment_model->db_get_field( 'id', $appointment_id ) ) ) {
@@ -1055,7 +1093,13 @@
);
return;
}
- throw $e;
+
+ // any other error fails only this action too; the message is left out because it can carry credentials
+ $error = get_class( $e ) . ' in ' . basename( $e->getFile() ) . ':' . $e->getLine();
+ ssa_debug_log( 'Notification ID ' . $notification['id'] . ' for appointment ID ' . $appointment_id . ' was not sent: ' . $error, 10 );
+ $this->fail_async_action( $async_action, 500, 'Notification was not sent: ' . $error, array( 'appointment_id' => $appointment_id ) );
+ $this->insert_revision_on_notification_not_sent( $notification, $payload, esc_html__( 'An error stopped it from being sent.', 'simply-schedule-appointments' ) );
+ return;
}
$responses[] = array(
--- a/simply-schedule-appointments/includes/class-paypal-ipn-listener.php
+++ b/simply-schedule-appointments/includes/class-paypal-ipn-listener.php
@@ -23,7 +23,7 @@
* @package PHP-PayPal-IPN
* @author Micah Carrick
* @copyright (c) 2011 - Micah Carrick
- * @version 1.6.13.4
+ * @version 1.6.13.9
* @license http://opensource.org/licenses/gpl-3.0.html
*/
--- a/simply-schedule-appointments/includes/class-shortcodes.php
+++ b/simply-schedule-appointments/includes/class-shortcodes.php
@@ -1034,6 +1034,16 @@
$atts['customer_information'] = wp_get_current_user()->user_email;
}
+ // The account's own email matches bookings only while SSA_Trusted_Email
+ // trusts it: any user can change their account email without confirming
+ // it. Until then the template asks the customer to verify the address.
+ $customer = wp_get_current_user();
+ $untrusted_email = '';
+ if ( $customer->exists() && $atts['customer_information'] === $customer->user_email && ! $this->plugin->trusted_email->is_trusted( $customer ) ) {
+ $untrusted_email = $customer->user_email;
+ $atts['customer_information'] = '';
+ }
+
ob_start();
include $this->plugin->dir( 'templates/customer/upcoming-appointments.php' );
$output = ob_get_clean();
--- a/simply-schedule-appointments/includes/class-trusted-email.php
+++ b/simply-schedule-appointments/includes/class-trusted-email.php
@@ -0,0 +1,304 @@
+<?php
+/**
+ * Simply Schedule Appointments Trusted Email.
+ *
+ * @package Simply_Schedule_Appointments
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * Decides when an account's email may stand in for the account.
+ *
+ * Any user can change their own email through POST /wp/v2/users/me with no
+ * confirmation, and a sign-up that sets its own password shows nothing about
+ * its address either. So an email stops counting on an unconfirmed self-change
+ * or a self sign-up, and counts again once the site has reached the address:
+ * an admin's action, core's profile-page email confirmation, a password reset
+ * through the emailed link, a multisite activation link, or the verification
+ * link My Appointments emails. Accounts from before this rule carry no flag and
+ * match as they always did.
+ */
+class SSA_Trusted_Email {
+ const UNTRUSTED_META = 'ssa_untrusted_email';
+ const LINK_META = 'ssa_email_verification_link';
+
+ const SEND_ACTION = 'ssa_send_email_verification';
+ const KEY_ARG = 'ssa_verify_email_key';
+ const LOGIN_ARG = 'ssa_verify_email_login';
+
+ protected $plugin = null;
+
+ // Sign-ups flagged during this request, for trust_after_activation().
+ private $flagged_now = array();
+
+ // Whether this request's Verify my email click sent the link, for the
+ // template; null when there was no click.
+ public $verification_sent = null;
+
+ public function __construct( $plugin ) {
+ $this->plugin = $plugin;
+ $this->hooks();
+ }
+
+ public function hooks() {
+ // Priority 9: SSA_Staff_Model links by email on these hooks at the default
+ // priority, and has to see the verdict.
+ add_action( 'user_register', array( $this, 'distrust_self_signup' ), 9 );
+ add_action( 'profile_update', array( $this, 'handle_email_change' ), 9, 2 );
+ add_action( 'password_reset', array( $this, 'trust_after_password_reset' ) );
+ add_action( 'after_password_reset', array( $this, 'trust_after_password_reset' ) );
+ add_action( 'wpmu_activate_user', array( $this, 'trust_after_activation' ) );
+ add_action( 'wpmu_activate_blog', array( $this, 'trust_after_blog_activation' ), 10, 2 );
+ // On the front end, not admin-post.php: WooCommerce and lock-down plugins
+ // keep customers out of wp-admin.
+ add_action( 'init', array( $this, 'handle_verification_requests' ) );
+ }
+
+ public function handle_verification_requests() {
+ // The link counts only while its own account is logged in: whoever reads
+ // the inbox may be someone else, and their click must not vouch for it.
+ $link_user = $this->get_link_user();
+ if ( $link_user && get_current_user_id() === $link_user->ID ) {
+ delete_user_meta( $link_user->ID, self::LINK_META );
+ $this->trust( $link_user->ID );
+ }
+
+ if ( empty( $_POST[ self::SEND_ACTION ] ) || ! is_user_logged_in() ) {
+ return;
+ }
+
+ $nonce = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : '';
+ if ( ! wp_verify_nonce( $nonce, self::SEND_ACTION ) ) {
+ return;
+ }
+
+ $return_url = isset( $_POST['ssa_return_url'] ) ? esc_url_raw( wp_unslash( $_POST['ssa_return_url'] ) ) : '';
+
+ $this->verification_sent = $this->send_verification_email( wp_get_current_user(), wp_validate_redirect( $return_url, home_url( '/' ) ) );
+ }
+
+ // The link carries a token of SSA's own, not core's password reset key: core
+ // wipes that key at every login, and a customer who opens the link logged out
+ // has to log in first. The token is stored with the address it was sent to,
+ // so it proves only that address.
+ public function send_verification_email( WP_User $user, $return_url ) {
+ $last_link = get_user_meta( $user->ID, self::LINK_META, true );
+ if ( ! empty( $last_link['time'] ) && time() - $last_link['time'] < 5 * MINUTE_IN_SECONDS ) {
+ return false;
+ }
+
+ $key = wp_generate_password( 32, false );
+ update_user_meta(
+ $user->ID,
+ self::LINK_META,
+ array(
+ 'key' => wp_hash( $key ),
+ 'email' => $user->user_email,
+ 'time' => time(),
+ )
+ );
+
+ $link = add_query_arg(
+ array(
+ self::KEY_ARG => $key,
+ self::LOGIN_ARG => rawurlencode( $user->user_login ),
+ ),
+ $return_url
+ );
+
+ $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
+ /* translators: %s: the site's name */
+ $subject = sprintf( __( '[%s] Verify your email address', 'simply-schedule-appointments' ), $site_name );
+ $message = __( 'Open this link to verify your email address and see your appointments:', 'simply-schedule-appointments' ) . "rnrn"
+ . $link . "rnrn"
+ . __( 'If you did not ask for this, you can ignore this email.', 'simply-schedule-appointments' );
+
+ return wp_mail( $user->user_email, $subject, $message );
+ }
+
+ // The account whose unused verification link this request carries. Null when
+ // the link is missing, wrong, over a day old, or was sent to an address the
+ // account no longer has.
+ public function get_link_user() {
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended -- the emailed token is the check.
+ if ( ! isset( $_GET[ self::KEY_ARG ], $_GET[ self::LOGIN_ARG ] ) ) {
+ return null;
+ }
+
+ $key = sanitize_text_field( wp_unslash( $_GET[ self::KEY_ARG ] ) );
+ $user = get_user_by( 'login', sanitize_text_field( wp_unslash( $_GET[ self::LOGIN_ARG ] ) ) );
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
+
+ $link = $user ? get_user_meta( $user->ID, self::LINK_META, true ) : array();
+ if (
+ empty( $link['key'] )
+ || ! hash_equals( $link['key'], wp_hash( $key ) )
+ || time() - $link['time'] > DAY_IN_SECONDS
+ || strtolower( $link['email'] ) !== strtolower( $user->user_email )
+ ) {
+ return null;
+ }
+
+ return $user;
+ }
+
+ public function is_trusted( $user ) {
+ $user = $user instanceof WP_User ? $user : get_userdata( (int) $user );
+ if ( empty( $user ) || empty( $user->user_email ) ) {
+ return false;
+ }
+
+ return ! in_array( strtolower( $user->user_email ), get_user_meta( $user->ID, self::UNTRUSTED_META ), true );
+ }
+
+ // Whether a booking saved under this account got there only by an email the
+ // account holds or held unproven: the booking code saves a booking under
+ // whichever account has its email. A booking the account made itself while
+ // logged in is its own either way.
+ public function is_claimed_by_unproven_email( $user_id, array $appointment ) {
+ $unproven = $user_id ? get_user_meta( $user_id, self::UNTRUSTED_META ) : array();
+ if ( empty( $unproven ) ) {
+ return false;
+ }
+
+ // A REST `fields` projection can hand over a row without the columns this
+ // decides on, or with them still encoded, so read the stored row then.
+ if ( ! isset( $appointment['author_id'] ) || ! is_array( $appointment['customer_information'] ?? null ) ) {
+ $appointment = (array) $this->plugin->appointment_model->get( $appointment['id'] ?? 0 );
+ }
+
+ if ( ! isset( $appointment['author_id'] ) ) {
+ return true;
+ }
+
+ // A row saved through the API can hold Email as a list. It matches no
+ // address, so it counts as unproven.
+ $email = $appointment['customer_information']['Email'] ?? '';
+
+ return (int) $appointment['author_id'] !== (int) $user_id && ( ! is_string( $email ) || in_array( strtolower( $email ), $unproven, true ) );
+ }
+
+ // Leaves out, from the logged-in account's lists, the bookings that are its
+ // own only by such an email.
+ public function only_own_bookings( array $appointments ) {
+ $user_id = get_current_user_id();
+
+ return array_values(
+ array_filter(
+ $appointments,
+ function ( $appointment ) use ( $user_id ) {
+ return (int) $appointment['customer_id'] !== $user_id || ! $this->is_claimed_by_unproven_email( $user_id, $appointment );
+ }
+ )
+ );
+ }
+
+ // The logged-in account's bookings for a customer list. A hidden booking must
+ // not use up one of the list's places, so this reads on until the list is full.
+ public function query_own_bookings( array $args ) {
+ $number = isset( $args['number'] ) ? (int) $args['number'] : 0;
+ $args['offset'] = 0;
+ $own = array();
+
+ do {
+ $page = $this->plugin->appointment_model->query( $args );
+ // Keyed by id: rows that tie on the sort column can repeat across reads.
+ $own += array_column( $this->only_own_bookings( $page ), null, 'id' );
+ $args['offset'] += count( $page );
+ } while ( $number > 0 && count( $own ) < $number && count( $page ) === $number );
+
+ return array_slice( array_values( $own ), 0, $number > 0 ? $number : null );
+ }
+
+ public function distrust_self_signup( $user_id ) {
+ if ( ! $this->is_operator_acting_on( $user_id ) ) {
+ $this->distrust( get_userdata( $user_id ) );
+ $this->flagged_now[ (int) $user_id ] = true;
+ }
+ }
+
+ public function handle_email_change( $user_id, $old_user_data ) {
+ $user = get_userdata( $user_id );
+ if ( empty( $user ) || empty( $old_user_data->user_email ) || strtolower( $user->user_email ) === strtolower( $old_user_data->user_email ) ) {
+ return;
+ }
+
+ if ( $this->is_operator_acting_on( $user_id ) || $this->is_core_confirmed_change( $user ) ) {
+ delete_user_meta( $user_id, self::UNTRUSTED_META, strtolower( $user->user_email ) );
+ } elseif ( get_current_user_id() === (int) $user_id || ! $this->is_trusted( $old_user_data ) ) {
+ // The account's own change, or one by no one that inherits the old address's standing.
+ $this->distrust( $user );
+ }
+ }
+
+ // The flag keeps the address, one row each. An address the account moves on
+ // from without proving stays on record, for only_own_bookings().
+ private function distrust( WP_User $user ) {
+ if ( $this->is_trusted( $user ) ) {
+ add_user_meta( $user->ID, self::UNTRUSTED_META, strtolower( $user->user_email ) );
+ }
+ }
+
+ // Core's reset screen and WooCommerce's both reach this only after checking the
+ // key they emailed, and core voids that key on any email change, so a reset
+ // proves the current address. WooCommerce fires only password_reset before 10.9.0.
+ public function trust_after_password_reset( $user ) {
+ $this->trust( $user->ID );
+ }
+
+ // Multisite creates the account only from the activation link it emailed to
+ // the sign-up's address, so an account this activation created is proven. One
+ // that existed before may have changed its email since the link was sent.
+ public function trust_after_activation( $user_id ) {
+ if ( isset( $this->flagged_now[ (int) $user_id ] ) ) {
+ $this->trust( $user_id );
+ }
+ }
+
+ public function trust_after_blog_activation( $blog_id, $user_id ) {
+ $this->trust_after_activation( $user_id );
+ }
+
+ // A proof that arrives after the sign-up or email change, so what waited on it
+ // (a team member's record) can link now. An email change needs no signal:
+ // profile_update already carries it.
+ private function trust( $user_id ) {
+ $user = get_userdata( $user_id );
+ if ( $user && delete_user_meta( $user_id, self::UNTRUSTED_META, strtolower( $user->user_email ) ) ) {
+ do_action( 'ssa/user/email_trusted', (int) $user_id );
+ }
+ }
+
+ // Someone allowed to edit the user, or a WP-CLI run, vouches for the address.
+ private function is_operator_acting_on( $user_id ) {
+ if ( defined( 'WP_CLI' ) && WP_CLI ) {
+ return true;
+ }
+
+ $current_user_id = get_current_user_id();
+
+ return $current_user_id && (int) $user_id !== $current_user_id && current_user_can( 'edit_user', $user_id );
+ }
+
+ // Core fires no hook of its own for the profile-page change it confirms by
+ // email, so this checks it the way user-edit.php does, before core deletes the hash.
+ private function is_core_confirmed_change( WP_User $user ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- the stored hash below is the check, as in core.
+ if ( empty( $_GET['newuseremail'] ) || get_current_user_id() !== $user->ID ) {
+ return false;
+ }
+
+ $new_email = get_user_meta( $user->ID, '_new_email', true );
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- the stored hash is the check.
+ $hash = sanitize_text_field( wp_unslash( $_GET['newuseremail'] ) );
+
+ return is_array( $new_email )
+ && ! empty( $new_email['hash'] )
+ && ! empty( $new_email['newemail'] )
+ && hash_equals( $new_email['hash'], $hash )
+ && strtolower( trim( $new_email['newemail'] ) ) === strtolower( $user->user_email );
+ }
+}
--- a/simply-schedule-appointments/simply-schedule-appointments.php
+++ b/simply-schedule-appointments/simply-schedule-appointments.php
@@ -3,7 +3,7 @@
* Plugin Name: Simply Schedule Appointments
* Plugin URI: https://simplyscheduleappointments.com
* Description: Easy appointment scheduling
- * Version: 1.6.13.4
+ * Version: 1.6.13.9
* Requires PHP: 7.4
* Author: NSquared
* Author URI: https://nsquared.io/
@@ -15,7 +15,7 @@
* @link https://simplyscheduleappointments.com
*
* @package Simply_Schedule_Appointments
- * @version 1.6.13.4
+ * @version 1.6.13.9
*
* Built using generator-plugin-wp (https://github.com/WebDevStudios/generator-plugin-wp)
*/
@@ -188,6 +188,7 @@
public $tracking;
public $translation_settings;
public $translation;
+ public $trusted_email;
public $upgrade;
public $users;
public $utils;
@@ -211,7 +212,7 @@
* @var string
* @since 0.0.0
*/
- const VERSION = '1.6.13.4';
+ const VERSION = '1.6.13.9';
/**
* URL of plugin directory.
@@ -339,6 +340,7 @@
'customers' => 'SSA_Customers',
'customer_information' => 'SSA_Customer_Information',
+ 'trusted_email' => 'SSA_Trusted_Email',
'scheduling_max_per_day' => 'SSA_Scheduling_Max_Per_Day',
--- a/simply-schedule-appointments/templates/customer/past-appointments.php
+++ b/simply-schedule-appointments/templates/customer/past-appointments.php
@@ -6,7 +6,7 @@
// $atts are defined in class-shortcodes.php
// don't try to load this file directly, instead call ssa()->shortcodes->ssa_past_appointments()
-$past_appointments = ssa()->appointment_model->query( $atts );
+$past_appointments = ssa()->trusted_email->query_own_bookings( $atts );
$settings = ssa()->settings->get();
$date_format = SSA_Utils::localize_default_date_strings( 'F j, Y g:i a' ) . ' (T)';
--- a/simply-schedule-appointments/templates/customer/upcoming-appointments.php
+++ b/simply-schedule-appointments/templates/customer/upcoming-appointments.php
@@ -3,10 +3,10 @@
exit; // Exit if accessed directly.
}
-// $atts are defined in class-shortcodes.php
+// $atts, and $untrusted_email when the account's email is not yet trusted, are defined in class-shortcodes.php
// don't try to load this file directly, instead call ssa()->shortcodes->ssa_upcoming_appointments()
-$upcoming_appointments = ssa()->appointment_model->query( $atts );
+$upcoming_appointments = ssa()->trusted_email->query_own_bookings( $atts );
$settings = ssa()->settings->get();
$date_format = SSA_Utils::localize_default_date_strings($settings['global']['date_format']);
@@ -14,8 +14,43 @@
?>
<div class="ssa-upcoming-appointments-container" role="region" aria-labelledby="appointments-heading">
<div class="ssa-upcoming-appointments">
+ <?php if ( ! empty( $untrusted_email ) ) : ?>
+ <?php $verification_sent = ssa()->trusted_email->verification_sent; ?>
+ <div class="ssa-unconfirmed-email-notice">
+ <?php if ( true === $verification_sent ) : ?>
+ <p role="status">
+ <?php
+ /* translators: %s: the account's email address */
+ echo esc_html( sprintf( __( 'We sent a link to %s. Open it to verify your email address.', 'simply-schedule-appointments' ), $untrusted_email ) );
+ ?>
+ </p>
+ <?php else : ?>
+ <p>
+ <?php
+ /* translators: %s: the account's email address */
+ echo esc_html( sprintf( __( 'Appointments booked with %s appear here once you verify this email address.', 'simply-schedule-appointments' ), $untrusted_email ) );
+ ?>
+ </p>
+ <?php if ( false === $verification_sent ) : ?>
+ <p role="alert"><?php esc_html_e( 'We could not send a new link. Check your inbox for one sent earlier, or try again in 5 minutes.', 'simply-schedule-appointments' ); ?></p>
+ <?php endif; ?>
+ <form method="post">
+ <?php wp_nonce_field( SSA_Trusted_Email::SEND_ACTION, '_wpnonce', false ); ?>
+ <input type="hidden" name="ssa_return_url" value="<?php echo esc_url( get_permalink() ? get_permalink() : home_url( '/' ) ); ?>">
+ <button type="submit" name="<?php echo esc_attr( SSA_Trusted_Email::SEND_ACTION ); ?>" value="1"><?php esc_html_e( 'Verify my email', 'simply-schedule-appointments' ); ?></button>
+ </form>
+ <?php endif; ?>
+ </div>
+ <?php endif; ?>
<?php if ( ! is_user_logged_in() ) : ?>
- <?php echo wp_kses_post( $atts['logged_out_message'] ); ?>
+ <?php $link_user = ssa()->trusted_email->get_link_user(); ?>
+ <?php if ( $link_user ) : ?>
+ <?php // A verification link opened logged out counts once its own account logs in; the form returns here. ?>
+ <p><?php esc_html_e( 'Log in to finish verifying your email address.', 'simply-schedule-appointments' ); ?></p>
+ <?php wp_login_form( array( 'value_username' => $link_user->user_email ) ); ?>
+ <?php else : ?>
+ <?php echo wp_kses_post( $atts['logged_out_message'] ); ?>
+ <?php endif; ?>
<?php elseif ( empty( $upcoming_appointments ) && !empty( $atts['block_settings']['no_results_message'] ) ) : ?>
<?php echo wp_kses_post( $atts['block_settings']['no_results_message'] ); ?>
<?php elseif ( empty( $upcoming_appointments ) ) : ?>
--- a/simply-schedule-appointments/vendor/composer/installed.php
+++ b/simply-schedule-appointments/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '0154c234b48a9c3ad8264efabcc413baf3da760e',
+ 'reference' => '3a9a0183b89246becadd0e68c418c1e0df1889ff',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '0154c234b48a9c3ad8264efabcc413baf3da760e',
+ 'reference' => '3a9a0183b89246becadd0e68c418c1e0df1889ff',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),