← All changes
|
app/Services/Integrations/Elementor/ElementorIntegration.php
+11
-4
1.10.0
→
2.5.0
View file →
| @@ -19,12 +19,10 @@ | ||
| 19 | 19 | add_action('elementor/editor/before_enqueue_scripts', [$this, 'editorScripts']); |
| 20 | 20 | add_action('elementor/editor/after_enqueue_scripts', [$this, 'editorScripts']); |
| 21 | 21 | |
| 22 | 22 | add_action('wp_ajax_get_calendar_events', [$this, 'ajaxGetCalendarEvents']); |
| 23 | - add_action('wp_ajax_nopriv_get_calendar_events', [$this, 'ajaxGetCalendarEvents']); | |
| 24 | 23 | |
| 25 | 24 | add_action('wp_ajax_get_event_hash', [$this, 'ajaxGetEventHash']); |
| 26 | - add_action('wp_ajax_nopriv_get_event_hash', [$this, 'ajaxGetEventHash']); | |
| 27 | 25 | } |
| 28 | 26 | |
| 29 | 27 | public function editorScripts() |
| 30 | 28 | { |
| @@ -101,16 +99,20 @@ | ||
| 101 | 99 | wp_send_json_error(['message' => __('Nonce verification failed', 'fluent-booking')]); |
| 102 | 100 | exit; |
| 103 | 101 | } |
| 104 | 102 | |
| 103 | + if (!current_user_can('edit_posts')) { | |
| 104 | + wp_send_json_error(['message' => __('You do not have permission to perform this action', 'fluent-booking')]); | |
| 105 | + exit; | |
| 106 | + } | |
| 107 | + | |
| 105 | 108 | if (!isset($_POST['cal_id'])) { |
| 106 | 109 | wp_send_json_error(['message' => __('No calendar ID provided', 'fluent-booking')]); |
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | $calId = intval($_POST['cal_id']); |
| 110 | - $events = []; // Fetch events using your getCalendarEvents method or similar | |
| 113 | + $events = []; | |
| 111 | 114 | |
| 112 | - // Example of fetching events (you need to replace this with your actual method) | |
| 113 | 115 | $events = $this->getCalendarEvents($calId); |
| 114 | 116 | |
| 115 | 117 | wp_send_json_success($events); |
| 116 | 118 | } |
| @@ -117,8 +119,13 @@ | ||
| 117 | 119 | |
| 118 | 120 | public function ajaxGetEventHash() { |
| 119 | 121 | if (!isset($_POST['security']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['security'])), 'calendar_events_nonce')) { |
| 120 | 122 | wp_send_json_error(['message' => __('Nonce verification failed', 'fluent-booking')]); |
| 123 | + exit; | |
| 124 | + } | |
| 125 | + | |
| 126 | + if (!current_user_can('edit_posts')) { | |
| 127 | + wp_send_json_error(['message' => __('You do not have permission to perform this action', 'fluent-booking')]); | |
| 121 | 128 | exit; |
| 122 | 129 | } |
| 123 | 130 | |
| 124 | 131 | $eventId = isset($_POST['event_id']) ? intval($_POST['event_id']) : null; |