PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 2.0.0
Tutor LMS – eLearning and online course solution v2.0.0
4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Ajax.php
tutor / classes Last commit date
Addons.php 4 years ago Admin.php 4 years ago Ajax.php 4 years ago Announcements.php 4 years ago Assets.php 4 years ago Backend_Page_Trait.php 4 years ago Course.php 4 years ago Course_Filter.php 4 years ago Course_List.php 4 years ago Course_Settings_Tabs.php 4 years ago Course_Widget.php 4 years ago Custom_Validation.php 5 years ago Dashboard.php 4 years ago FormHandler.php 4 years ago Frontend.php 4 years ago Gutenberg.php 4 years ago Instructor.php 4 years ago Instructors_List.php 4 years ago Lesson.php 4 years ago Options_V2.php 4 years ago Post_types.php 4 years ago Private_Course_Access.php 4 years ago Q_and_A.php 4 years ago Question_Answers_List.php 4 years ago Quiz.php 4 years ago Quiz_Attempts_List.php 4 years ago RestAPI.php 4 years ago Reviews.php 4 years ago Rewrite_Rules.php 4 years ago Shortcode.php 4 years ago Student.php 4 years ago Students_List.php 4 years ago Taxonomies.php 4 years ago Template.php 4 years ago Theme_Compatibility.php 5 years ago Tools.php 4 years ago Tools_V2.php 4 years ago Tutor.php 4 years ago TutorEDD.php 4 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 4 years ago Upgrader.php 4 years ago User.php 4 years ago Utils.php 4 years ago Video_Stream.php 4 years ago Withdraw.php 4 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 4 years ago
Ajax.php
570 lines
1 <?php
2 namespace TUTOR;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 class Ajax {
9 public function __construct() {
10
11 add_action( 'wp_ajax_sync_video_playback', array( $this, 'sync_video_playback' ) );
12 add_action( 'wp_ajax_nopriv_sync_video_playback', array( $this, 'sync_video_playback_noprev' ) );
13 add_action( 'wp_ajax_tutor_place_rating', array( $this, 'tutor_place_rating' ) );
14 add_action( 'wp_ajax_delete_tutor_review', array( $this, 'delete_tutor_review' ) );
15
16 add_action( 'wp_ajax_tutor_course_add_to_wishlist', array( $this, 'tutor_course_add_to_wishlist' ) );
17 add_action( 'wp_ajax_nopriv_tutor_course_add_to_wishlist', array( $this, 'tutor_course_add_to_wishlist' ) );
18
19 /**
20 * Get all addons
21 */
22 add_action( 'wp_ajax_tutor_get_all_addons', array( $this, 'tutor_get_all_addons' ) );
23
24 /**
25 * Addon Enable Disable Control
26 */
27 add_action( 'wp_ajax_addon_enable_disable', array( $this, 'addon_enable_disable' ) );
28
29 /**
30 * Ajax login
31 *
32 * @since v.1.6.3
33 */
34 add_action( 'wp_ajax_nopriv_tutor_user_login', array( $this, 'process_ajax_login' ) );
35
36 /**
37 * Announcement
38 *
39 * @since v.1.7.9
40 */
41 add_action( 'wp_ajax_tutor_announcement_create', array( $this, 'create_or_update_annoucement' ) );
42 add_action( 'wp_ajax_tutor_announcement_delete', array( $this, 'delete_annoucement' ) );
43 }
44
45
46
47 /**
48 * Update video information and data when necessary
49 *
50 * @since v.1.0.0
51 */
52 public function sync_video_playback() {
53 tutor_utils()->checking_nonce();
54
55 $user_id = get_current_user_id();
56 $post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : 0;
57 $duration = sanitize_text_field( $_POST['duration'] );
58 $currentTime = sanitize_text_field( $_POST['currentTime'] );
59
60 if ( ! tutor_utils()->has_enrolled_content_access( 'lesson', $post_id ) ) {
61 wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
62 exit;
63 }
64
65 /**
66 * Update posts attached video
67 */
68 $video = tutor_utils()->get_video( $post_id );
69
70 if ( $duration ) {
71 $video['duration_sec'] = $duration; // secs
72 $video['playtime'] = tutor_utils()->playtime_string( $duration );
73 $video['runtime'] = tutor_utils()->playtime_array( $duration );
74 }
75 tutor_utils()->update_video( $post_id, $video );
76
77 /**
78 * Sync Lesson Reading Info by Users
79 */
80
81 $best_watch_time = tutor_utils()->get_lesson_reading_info( $post_id, $user_id, 'video_best_watched_time' );
82 if ( $best_watch_time < $currentTime ) {
83 tutor_utils()->update_lesson_reading_info( $post_id, $user_id, 'video_best_watched_time', $currentTime );
84 }
85
86 if ( tutor_utils()->avalue_dot( 'is_ended', $_POST ) ) {
87 tutor_utils()->mark_lesson_complete( $post_id );
88 }
89 exit();
90 }
91
92 public function sync_video_playback_noprev() {
93
94 }
95
96
97 public function tutor_place_rating() {
98 global $wpdb;
99
100 tutor_utils()->checking_nonce();
101
102 $rating = sanitize_text_field( tutor_utils()->avalue_dot( 'tutor_rating_gen_input', $_POST ) );
103 $course_id = sanitize_text_field( tutor_utils()->avalue_dot( 'course_id', $_POST ) );
104 $review = sanitize_textarea_field( tutor_utils()->avalue_dot( 'review', $_POST ) );
105
106 ! $rating ? $rating = 0 : 0;
107 $rating > 5 ? $rating = 5 : 0;
108
109 $user_id = get_current_user_id();
110 $user = get_userdata( $user_id );
111 $date = date( 'Y-m-d H:i:s', tutor_time() );
112
113 if ( ! tutor_utils()->has_enrolled_content_access( 'course', $course_id ) ) {
114 wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
115 exit;
116 }
117
118 do_action( 'tutor_before_rating_placed' );
119
120 $previous_rating_id = $wpdb->get_var(
121 $wpdb->prepare(
122 "SELECT comment_ID
123 from {$wpdb->comments}
124 WHERE comment_post_ID = %d AND
125 user_id = %d AND
126 comment_type = 'tutor_course_rating'
127 LIMIT 1;",
128 $course_id,
129 $user_id
130 )
131 );
132
133 $review_ID = $previous_rating_id;
134 if ( $previous_rating_id ) {
135 $wpdb->update(
136 $wpdb->comments,
137 array( 'comment_content' => $review ),
138 array( 'comment_ID' => $previous_rating_id )
139 );
140
141 $rating_info = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->commentmeta} WHERE comment_id = %d AND meta_key = 'tutor_rating'; ", $previous_rating_id ) );
142 if ( $rating_info ) {
143 $wpdb->update(
144 $wpdb->commentmeta,
145 array( 'meta_value' => $rating ),
146 array(
147 'comment_id' => $previous_rating_id,
148 'meta_key' => 'tutor_rating',
149 )
150 );
151 } else {
152 $wpdb->insert(
153 $wpdb->commentmeta,
154 array(
155 'comment_id' => $previous_rating_id,
156 'meta_key' => 'tutor_rating',
157 'meta_value' => $rating,
158 )
159 );
160 }
161 } else {
162 $data = array(
163 'comment_post_ID' => esc_sql( $course_id ),
164 'comment_approved' => 'approved',
165 'comment_type' => 'tutor_course_rating',
166 'comment_date' => $date,
167 'comment_date_gmt' => get_gmt_from_date( $date ),
168 'user_id' => $user_id,
169 'comment_author' => $user->user_login,
170 'comment_agent' => 'TutorLMSPlugin',
171 );
172 if ( $review ) {
173 $data['comment_content'] = $review;
174 }
175
176 $wpdb->insert( $wpdb->comments, $data );
177 $comment_id = (int) $wpdb->insert_id;
178 $review_ID = $comment_id;
179
180 if ( $comment_id ) {
181 $result = $wpdb->insert(
182 $wpdb->commentmeta,
183 array(
184 'comment_id' => $comment_id,
185 'meta_key' => 'tutor_rating',
186 'meta_value' => $rating,
187 )
188 );
189
190 do_action( 'tutor_after_rating_placed', $comment_id );
191 }
192 }
193
194 wp_send_json_success(
195 array(
196 'message' => __( 'Rating placed successsully!', 'tutor' ),
197 'review_id' => $review_ID,
198 )
199 );
200 }
201
202 public function delete_tutor_review() {
203 tutor_utils()->checking_nonce();
204
205 $review_id = sanitize_text_field( tutor_utils()->array_get( 'review_id', $_POST ) );
206
207 if ( ! tutor_utils()->can_user_manage( 'review', $review_id, get_current_user_id() ) ) {
208 wp_send_json_error( array( 'message' => __( 'Permissioned Denied!', 'tutor' ) ) );
209 exit;
210 }
211
212 global $wpdb;
213 $wpdb->delete( $wpdb->commentmeta, array( 'comment_id' => $review_id ) );
214 $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $review_id ) );
215
216 wp_send_json_success();
217 }
218
219 public function tutor_course_add_to_wishlist() {
220 tutor_utils()->checking_nonce();
221
222 // Redirect login since only logged in user can add courses to wishlist
223 if ( ! is_user_logged_in() ) {
224 wp_send_json_error(
225 array(
226 'redirect_to' => wp_login_url( wp_get_referer() ),
227 )
228 );
229 }
230
231 global $wpdb;
232 $user_id = get_current_user_id();
233 $course_id = (int) sanitize_text_field( $_POST['course_id'] );
234
235 $if_added_to_list = $wpdb->get_row(
236 $wpdb->prepare(
237 "SELECT * from {$wpdb->usermeta}
238 WHERE user_id = %d
239 AND meta_key = '_tutor_course_wishlist'
240 AND meta_value = %d;",
241 $user_id,
242 $course_id
243 )
244 );
245
246 if ( $if_added_to_list ) {
247 $wpdb->delete(
248 $wpdb->usermeta,
249 array(
250 'user_id' => $user_id,
251 'meta_key' => '_tutor_course_wishlist',
252 'meta_value' => $course_id,
253 )
254 );
255 wp_send_json_success(
256 array(
257 'status' => 'removed',
258 'message' => __( 'Course removed from wish list', 'tutor' ),
259 )
260 );
261 } else {
262 add_user_meta( $user_id, '_tutor_course_wishlist', $course_id );
263 wp_send_json_success(
264 array(
265 'status' => 'added',
266 'message' => __( 'Course added to wish list', 'tutor' ),
267 )
268 );
269 }
270 }
271
272 /**
273 * Prepare addons data
274 */
275 public function prepare_addons_data() {
276 $addons = apply_filters( 'tutor_addons_lists_config', array() );
277 $plugins_data = $addons;
278
279 if ( is_array( $addons ) && count( $addons ) ) {
280 foreach ( $addons as $base_name => $addon ) {
281 $addon_config = tutor_utils()->get_addon_config( $base_name );
282 $is_enabled = (bool) tutor_utils()->avalue_dot( 'is_enable', $addon_config );
283
284 $plugins_data[ $base_name ]['is_enabled'] = $is_enabled;
285
286 $thumbnail_url = tutor()->url . 'assets/images/tutor-plugin.png';
287 if ( file_exists( $addon['path'] . 'assets/images/thumbnail.png' ) ) {
288 $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.png';
289 } elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.jpg' ) ) {
290 $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.jpg';
291 } elseif ( file_exists( $addon['path'] . 'assets/images/thumbnail.svg' ) ) {
292 $thumbnail_url = $addon['url'] . 'assets/images/thumbnail.svg';
293 }
294
295 $plugins_data[ $base_name ]['thumb_url'] = $thumbnail_url;
296
297 /**
298 * Checking if there any dependant plugin exists
299 */
300 $depends = tutor_utils()->array_get( 'depend_plugins', $addon );
301 $plugins_required = array();
302 if ( tutor_utils()->count( $depends ) ) {
303 foreach ( $depends as $plugin_base => $plugin_name ) {
304 if ( ! is_plugin_active( $plugin_base ) ) {
305 $plugins_required[ $plugin_base ] = $plugin_name;
306 }
307 }
308 }
309
310 $depended_plugins = array();
311 foreach ( $plugins_required as $required_plugin ) {
312 array_push( $depended_plugins, $required_plugin );
313 }
314
315 $plugins_data[ $base_name ]['plugins_required'] = $depended_plugins;
316
317 // Check if it's notifications.
318 if ( function_exists( 'tutor_notifications' ) && $base_name == tutor_notifications()->basename ) {
319
320 $required = array();
321 version_compare( PHP_VERSION, '7.2.5', '>=' ) ? 0 : $required[] = __( 'PHP 7.2.5 or greater is required', 'tutor' );
322 ! is_ssl() ? $required[] = __( 'SSL certificate', 'tutor' ) : 0;
323
324 foreach ( array( 'curl', 'gmp', 'mbstring', 'openssl' ) as $ext ) {
325 ! extension_loaded( $ext ) ? $required[] = 'PHP extension <strong>' . $ext . '</strong>' : 0;
326 }
327
328 $plugins_data[ $base_name ]['ext_required'] = $required;
329 }
330 }
331 }
332
333 $prepared_addons = array();
334 foreach ( $plugins_data as $tutor_addon ) {
335 array_push( $prepared_addons, $tutor_addon );
336 }
337
338 return $prepared_addons;
339 }
340
341 /**
342 * Get all notifications
343 */
344 public function tutor_get_all_addons() {
345
346 // Check and verify the request.
347 tutor_utils()->checking_nonce();
348
349 // All good, let's proceed.
350 $all_addons = $this->prepare_addons_data();
351
352 wp_send_json_success(
353 array(
354 'addons' => $all_addons,
355 )
356 );
357 }
358
359 /**
360 * Method for enable / disable addons
361 */
362 public function addon_enable_disable() {
363
364 if ( ! current_user_can( 'manage_options' ) ) {
365 wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
366 }
367
368 $addonsConfig = maybe_unserialize( get_option( 'tutor_addons_config' ) );
369
370 // $isEnable = (bool) sanitize_text_field( tutor_utils()->avalue_dot( 'isEnable', $_POST ) );
371 // $addonFieldName = sanitize_text_field( tutor_utils()->avalue_dot( 'addonFieldName', $_POST ) );
372 $addonFieldNames = json_decode( stripslashes( ( tutor_utils()->avalue_dot( 'addonFieldNames', $_POST ) ) ), true );
373
374 foreach ( $addonFieldNames as $addonFieldName => $isEnable ) {
375 do_action( 'tutor_addon_before_enable_disable' );
376 if ( $isEnable ) {
377 do_action( "tutor_addon_before_enable_{$addonFieldName}" );
378 do_action( 'tutor_addon_before_enable', $addonFieldName );
379 $addonsConfig[ $addonFieldName ]['is_enable'] = 1;
380 update_option( 'tutor_addons_config', $addonsConfig );
381
382 do_action( 'tutor_addon_after_enable', $addonFieldName );
383 do_action( "tutor_addon_after_enable_{$addonFieldName}" );
384 } else {
385 do_action( "tutor_addon_before_disable_{$addonFieldName}" );
386 do_action( 'tutor_addon_before_disable', $addonFieldName );
387 $addonsConfig[ $addonFieldName ]['is_enable'] = 0;
388 update_option( 'tutor_addons_config', $addonsConfig );
389
390 do_action( 'tutor_addon_after_disable', $addonFieldName );
391 do_action( "tutor_addon_after_disable_{$addonFieldName}" );
392 }
393 do_action( 'tutor_addon_after_enable_disable' );
394 }
395
396 wp_send_json_success();
397 }
398
399 /**
400 * Process ajax login
401 *
402 * @since v.1.6.3
403 */
404 public function process_ajax_login() {
405 tutor_utils()->checking_nonce();
406
407 $username = tutor_utils()->array_get( 'log', $_POST );
408 $password = tutor_utils()->array_get( 'pwd', $_POST );
409 $redirect_to = tutor_utils()->array_get( 'redirect_to', $_POST );
410
411 try {
412 $creds = array(
413 'user_login' => trim( wp_unslash( $username ) ),
414 'user_password' => $password,
415 'remember' => isset( $_POST['rememberme'] ),
416 );
417
418 $validation_error = new \WP_Error();
419 $validation_error = apply_filters( 'tutor_process_login_errors', $validation_error, $creds['user_login'], $creds['user_password'] );
420
421 if ( $validation_error->get_error_code() ) {
422 wp_send_json_error(
423 array(
424 'message' => $validation_error->get_error_message(),
425 )
426 );
427 }
428
429 if ( empty( $creds['user_login'] ) ) {
430 wp_send_json_error(
431 array(
432 'message' => __( 'Username is required.', 'tutor' ),
433 )
434 );
435 }
436
437 // On multisite, ensure user exists on current site, if not add them before allowing login.
438 if ( is_multisite() ) {
439 $user_data = get_user_by( is_email( $creds['user_login'] ) ? 'email' : 'login', $creds['user_login'] );
440
441 if ( $user_data && ! is_user_member_of_blog( $user_data->ID, get_current_blog_id() ) ) {
442 add_user_to_blog( get_current_blog_id(), $user_data->ID, 'customer' );
443 }
444 }
445
446 // Perform the login.
447 $user = wp_signon( apply_filters( 'tutor_login_credentials', $creds ), is_ssl() );
448
449 if ( is_wp_error( $user ) ) {
450 wp_send_json_error(
451 array(
452 'message' => $user->get_error_message(),
453 )
454 );
455 } else {
456 // since 1.9.8 do enroll if guest attempt to enroll
457 if ( ! empty( $_POST['tutor_course_enroll_attempt'] ) ) {
458 do_action( 'tutor_do_enroll_after_login_if_attempt', $_POST['tutor_course_enroll_attempt'] );
459 }
460
461 wp_send_json_success(
462 array(
463 'redirect_to' => apply_filters( 'tutor_login_redirect_url', $redirect_to ),
464 )
465 );
466 }
467 } catch ( \Exception $e ) {
468 do_action( 'tutor_login_failed' );
469 wp_send_json_error( apply_filters( 'login_errors', $e->getMessage() ) );
470 }
471 }
472
473 /**
474 * Create/Update announcement
475 *
476 * @since v.1.7.9
477 */
478 public function create_or_update_annoucement() {
479 tutor_utils()->checking_nonce();
480
481 $error = array();
482 $course_id = sanitize_text_field( $_POST['tutor_announcement_course'] );
483 $announcement_title = sanitize_text_field( $_POST['tutor_announcement_title'] );
484 $announcement_summary = sanitize_textarea_field( $_POST['tutor_announcement_summary'] );
485
486 // Check if user can manage this announcment
487 if ( ! tutor_utils()->can_user_manage( 'course', $course_id ) ) {
488 wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
489 }
490
491 // set data and sanitize it
492 $form_data = array(
493 'post_type' => 'tutor_announcements',
494 'post_title' => $announcement_title,
495 'post_content' => $announcement_summary,
496 'post_parent' => $course_id,
497 'post_status' => 'publish',
498 );
499
500 if ( isset( $_POST['announcement_id'] ) ) {
501 $form_data['ID'] = sanitize_text_field( $_POST['announcement_id'] );
502 }
503
504 // validation message set
505 if ( empty( $form_data['post_parent'] ) ) {
506 $error['post_parent'] = __( 'Course name required', 'tutor' );
507
508 }
509
510 if ( empty( $form_data['post_title'] ) ) {
511 $error['post_title'] = __( 'Announcement title required', 'tutor' );
512 }
513
514 if ( empty( $form_data['post_content'] ) ) {
515 $error['post_content'] = __( 'Announcement summary required', 'tutor' );
516
517 }
518
519 if ( empty( $form_data['post_content'] ) ) {
520 $error['post_content'] = __( 'Announcement summary required', 'tutor' );
521
522 }
523
524 // If validation fails
525 if ( count( $error ) > 0 ) {
526 wp_send_json_error(
527 array(
528 'message' => __( 'All fields required!', 'tutor' ),
529 'fields' => $error,
530 )
531 );
532 }
533
534 // insert or update post
535 $post_id = wp_insert_post( $form_data );
536 if ( $post_id > 0 ) {
537 $announcement = get_post( $post_id );
538 $action_type = sanitize_textarea_field( $_POST['action_type'] );
539
540 do_action( 'tutor_announcements/after/save', $post_id, $announcement, $action_type );
541
542 $resp_message = $action_type == 'create' ? __( 'Announcement created successfully', 'tutor' ) : __( 'Announcement updated successfully', 'tutor' );
543 wp_send_json_success( array( 'message' => $resp_message ) );
544 }
545
546 wp_send_json_error( array( 'message' => __( 'Something Went Wrong!', 'tutor' ) ) );
547 }
548
549 /**
550 * Delete announcement
551 *
552 * @since v.1.7.9
553 */
554 public function delete_annoucement() {
555 $announcement_id = sanitize_text_field( $_POST['announcement_id'] );
556 tutor_utils()->checking_nonce();
557
558 if ( ! tutor_utils()->can_user_manage( 'announcement', $announcement_id ) ) {
559 wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) );
560 }
561
562 $delete = wp_delete_post( $announcement_id );
563 if ( $delete ) {
564 wp_send_json_success( array( 'message' => __( 'Announcement deleted successfully', 'tutor' ) ) );
565 }
566
567 wp_send_json_error( array( 'message' => __( 'Announcement delete failed', 'tutor' ) ) );
568 }
569 }
570