--- a/bookingor/admin/class-bookingor-admin.php
+++ b/bookingor/admin/class-bookingor-admin.php
@@ -242,7 +242,8 @@
wp_enqueue_script($this->plugin_name . '-full-calendar-list', plugins_url('js/full-calender/packages/list/index.global.js', __FILE__), array('jquery'), '6.10.0', true);
wp_enqueue_script($this->plugin_name . '-full-calendar-time-grid', plugins_url('js/full-calender/packages/timegrid/index.global.js', __FILE__), array('jquery'), '6.10.0', true);
wp_enqueue_script($this->plugin_name . '-full-calendar-interaction', plugins_url('js/full-calender/packages/interaction/index.global.js', __FILE__), array('jquery'), '6.10.0', true);
- wp_localize_script('jquery', 'TCN_BIND', array('GET_URL' => admin_url('admin-ajax.php')));
+ $ajax_nonce = wp_create_nonce('bookingor_ajax_nonce');
+ wp_localize_script('jquery', 'TCN_BIND', array('GET_URL' => admin_url('admin-ajax.php'), 'nonce' => $ajax_nonce));
// tostr
wp_enqueue_script($this->plugin_name . '-toastr', plugin_dir_url(dirname(__FILE__)) . 'includes/toastr/js/jquery.toast.js', array(), '2.1.4', true);
// datepicker
--- a/bookingor/admin/include/booking/booking-control.php
+++ b/bookingor/admin/include/booking/booking-control.php
@@ -110,6 +110,14 @@
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere.
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
$get_book_id = sanitize_text_field(wp_unslash($_REQUEST['booking_stats_id'] ?? ""));
$get_book_status = sanitize_text_field(wp_unslash($_POST['book_status'] ?? ""));
$bookings = $wpdb->get_row(
--- a/bookingor/admin/include/category/category-control.php
+++ b/bookingor/admin/include/category/category-control.php
@@ -38,7 +38,25 @@
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere.
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
if (isset($_REQUEST["id"])) {
- $id = stripslashes(filter_var($_REQUEST["id"], FILTER_SANITIZE_NUMBER_INT)); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ $id = stripslashes(filter_var($_REQUEST["id"], FILTER_SANITIZE_NUMBER_INT)); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.
+
+
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$get_category_in_booking = $wpdb->get_results(
$wpdb->prepare(
@@ -61,8 +79,8 @@
'status' => htmlspecialchars('error'),
'message' => htmlspecialchars('Category is already in use.')
];
- echo wp_json_encode($response);;
- exit;
+ echo wp_json_encode($response);
+ die();
}
}
}
@@ -96,8 +114,8 @@
'status' => htmlspecialchars('success'),
'message' => htmlspecialchars("Category Updated successfully")
];
- echo wp_json_encode($response);;
- exit;
+ echo wp_json_encode($response);
+ die();
}
}
/**
@@ -115,6 +133,22 @@
global $wpdb;
$category = $wpdb->prefix . self::$dp_prefix . 'categories';
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$category_name = sanitize_text_field(wp_unslash($_POST['tcn_category_name'] ?? ""));
$category_icon = absint(wp_unslash($_POST['tcn_category_icon_id'] ?? ""));
$category_status = sanitize_text_field(wp_unslash($_POST['tcn_category_status'] ?? "" ));
@@ -139,8 +173,8 @@
'status' => htmlspecialchars('success'),
'message' => htmlspecialchars('Category Added successfully.')
];
- echo wp_json_encode($response);;
- exit;
+ echo wp_json_encode($response);
+ die();
}
}
/**
@@ -193,7 +227,7 @@
)
);
- echo wp_json_encode($response);;
+ echo wp_json_encode($response);
die;
}
}
--- a/bookingor/admin/include/customer/customer-control.php
+++ b/bookingor/admin/include/customer/customer-control.php
@@ -56,6 +56,22 @@
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
$id = stripslashes(filter_var($_REQUEST["id"] ?? "", FILTER_SANITIZE_NUMBER_INT)); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$get_customer_in_booking = $wpdb->get_results(
$wpdb->prepare(
"SELECT book_id, duration_service, start_time, end_time, picked_date_end, picked_date, service_get_price, paid_amount, payment_method, customer_time_zone, token_code, appoint_status, category_get_id, service_get_id, staff_get_id, location_get_id, updated_at, created_at FROM {$wpdb->prefix}bookingor_booked_appointment WHERE customer_get_id = %d",
--- a/bookingor/admin/include/location/location-control.php
+++ b/bookingor/admin/include/location/location-control.php
@@ -60,6 +60,22 @@
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere.
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$location_title = sanitize_text_field(wp_unslash($_POST['bookingor_location_title'] ?? ''));
$location_icon = sanitize_text_field(wp_unslash($_POST['location_icon_id'] ?? ''));
$location_phone = sanitize_text_field(wp_unslash($_POST['bp_location_phone_number'] ?? ''));
@@ -137,6 +153,22 @@
global $wpdb;
$update_location = $wpdb->prefix . self::$dp_prefix . 'location';
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$location_title = sanitize_text_field(wp_unslash($_POST['bookingor_location_title'] ?? ""));
$location_id = sanitize_text_field(wp_unslash($_POST['location_id'] ?? ""));
$location_icon = sanitize_text_field(wp_unslash($_POST['location_icon_id_update'] ?? ""));
--- a/bookingor/admin/include/notification/notification-control.php
+++ b/bookingor/admin/include/notification/notification-control.php
@@ -47,6 +47,23 @@
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere.
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
if (isset($_REQUEST['action'])) {
+
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$email_get_id = sanitize_text_field(wp_unslash($_POST['email_id'] ?? ""));
$email_subject = sanitize_text_field(wp_unslash($_POST['subject'] ?? ""));
$email_content = wp_kses_post(wp_unslash($_POST['body'] ?? ""));
--- a/bookingor/admin/include/services/service-control.php
+++ b/bookingor/admin/include/services/service-control.php
@@ -138,6 +138,22 @@
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
$service_get_id = isset($_REQUEST['get_service_id']) ? intval($_REQUEST['get_service_id']) : 0;
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Verified elsewhere.
$service_name = sanitize_text_field(wp_unslash($_POST['service_name'] ?? ""));
$service_icon = sanitize_text_field(wp_unslash($_POST['service_icon_id'] ?? ""));
@@ -294,6 +310,23 @@
if (isset($_REQUEST['action'])) {
+
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
//tab basic
$service_name = sanitize_text_field(wp_unslash($_POST['service_name'] ?? ""));
$service_icon = sanitize_text_field(wp_unslash($_POST['service_icon_id'] ?? ""));
@@ -432,6 +465,24 @@
$delete_service = $wpdb->prefix . self::$dp_prefix . 'services';
$delete_staff_assign_service = $wpdb->prefix . self::$dp_prefix . 'staff_assign_service';
$id = sanitize_text_field(wp_unslash(isset($_REQUEST["id"]) ? $_REQUEST["id"] : ""));
+
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
+
$wpdb->delete($delete_service, array(
'service_id' => $id
));
--- a/bookingor/admin/include/staff/staff-control.php
+++ b/bookingor/admin/include/staff/staff-control.php
@@ -118,6 +118,23 @@
$staff_location_assign = $wpdb->prefix . self::$dp_prefix . 'location_assign_staff';
$staff_get_id = isset($_REQUEST['get_staff_id']) ? intval($_REQUEST['get_staff_id']) : 0;
if (isset($_REQUEST['action'])) {
+
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$staff_first_name = sanitize_text_field(isset($_POST['staff_first_name']) ? $_POST['staff_first_name'] : '');
$staff_last_name = sanitize_text_field(isset($_POST['staff_last_name']) ? $_POST['staff_last_name'] : '');
$staff_phone = sanitize_text_field(isset($_POST['staff_phone']) ? $_POST['staff_phone'] : '');
@@ -250,6 +267,22 @@
$assign_staff_service = $wpdb->prefix . self::$dp_prefix . 'staff_assign_service';
$staff_location_assign = $wpdb->prefix . self::$dp_prefix . 'location_assign_staff';
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
$staff_first_name = sanitize_text_field($_POST['staff_first_name'] ?? "");
$staff_last_name = sanitize_text_field($_POST['staff_last_name'] ?? "");
$staff_phone = sanitize_text_field($_POST['staff_phone'] ?? "");
--- a/bookingor/admin/include/templates/templates-control.php
+++ b/bookingor/admin/include/templates/templates-control.php
@@ -13,6 +13,23 @@
public function updates_design_templates()
{
if (isset($_REQUEST['action'])) {
+
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
if (isset($_REQUEST['editingId']) && sanitize_text_field($_REQUEST['editingId']) === '1') {
update_option(self::$name_prefix . '_settings_background_border_active_design_1', sanitize_text_field($_POST['settings_background_border_active_design_1'] . 'px' ?? ''));
update_option(self::$name_prefix . '_settings_background_border_color_design_1', sanitize_text_field($_POST['settings_background_border_color_design_1'] ?? ''));
@@ -174,6 +191,22 @@
public static function bp_settings_get_design_templates_data()
{
if (isset($_REQUEST['action'])) {
+ if (isset($_POST['nonce'])) {
+ if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('Nonce verification failed.')
+ ];
+ }
+ }
+ if (!current_user_can('manage_options')) {
+ $response = [
+ 'status' => htmlspecialchars('error'),
+ 'message' => htmlspecialchars('You do not have permission.')
+ ];
+ echo wp_json_encode($response);
+ die();
+ }
//stripe
$dcimal_point = get_option(self::$name_prefix . '_currency_decimal_point');
get_option(self::$name_prefix . '_settings_stripe_sandbox');
--- a/bookingor/includes/class-bookingor-activator.php
+++ b/bookingor/includes/class-bookingor-activator.php
@@ -34,7 +34,14 @@
ob_flush();
ob_start();
-
+ // Add custom capabilities
+ $role = get_role('administrator');
+ if ($role) {
+ $role->add_cap('bp_delete_category');
+ $role->add_cap('bp_add_category');
+ $role->add_cap('bp_update_category');
+ $role->add_cap('bp_get_category');
+ }
//category
global $wpdb;