| @@ -463,22 +463,22 @@ | ||
| 463 | 463 | public function tutor_save_topic(){ |
| 464 | 464 | tutor_utils()->checking_nonce(); |
| 465 | 465 | |
| 466 | 466 | // Check required fields |
| 467 | - if (empty($_POST['topic_title']) ) { | |
| 468 | - wp_send_json_error(array('message' => __('Topic title is required!', 'tutor'))); | |
| 467 | + if ( empty( Input::post( 'topic_title' ) ) ) { | |
| 468 | + wp_send_json_error( array( 'message' => __( 'Topic title is required!', 'tutor' ) ) ); | |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | // Gather parameters |
| 472 | - $course_id = (int) tutor_utils()->avalue_dot('topic_course_id', $_POST); | |
| 473 | - $topic_id = (int) tutor_utils()->avalue_dot('topic_id', $_POST); | |
| 474 | - $topic_title = sanitize_text_field( $_POST['topic_title'] ); | |
| 475 | - $topic_summery = wp_kses_post( $_POST['topic_summery'] ); | |
| 472 | + $course_id = Input::post( 'topic_course_id', 0, Input::TYPE_INT ); | |
| 473 | + $topic_id = Input::post( 'topic_id', 0, Input::TYPE_INT ); | |
| 474 | + $topic_title = Input::post( 'topic_title' ); | |
| 475 | + $topic_summery = wp_kses_post( $_POST['topic_summery'] ); | |
| 476 | 476 | $next_topic_order_id = tutor_utils()->get_next_topic_order_id($course_id, $topic_id); |
| 477 | 477 | |
| 478 | 478 | // Validate if user can manage the topic |
| 479 | - if(!tutor_utils()->can_user_manage('course', $course_id) || ($topic_id && !tutor_utils()->can_user_manage('topic', $topic_id))) { | |
| 480 | - wp_send_json_error( array('message'=>__('Access Denied', 'tutor')) ); | |
| 479 | + if ( ! tutor_utils()->can_user_manage( 'course', $course_id ) || ( $topic_id && !tutor_utils()->can_user_manage('topic', $topic_id ) ) ) { | |
| 480 | + wp_send_json_error( array( 'message' => __( 'Access Denied', 'tutor' ) ) ); | |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | // Create payload to create/update the topic |
| 484 | 484 | $post_arr = array( |
| @@ -495,9 +495,9 @@ | ||
| 495 | 495 | |
| 496 | 496 | ob_start(); |
| 497 | 497 | include tutor()->path.'views/metabox/course-contents.php'; |
| 498 | 498 | |
| 499 | - wp_send_json_success(array( | |
| 499 | + wp_send_json_success( array( | |
| 500 | 500 | 'topic_title' => $topic_title, |
| 501 | 501 | 'course_contents' => ob_get_clean() |
| 502 | 502 | )); |
| 503 | 503 | } |