| @@ -165,8 +165,9 @@ | ||
| 165 | 165 | update_post_meta( $post_ID, '_tutor_attachments', $attachments ); |
| 166 | 166 | } else { |
| 167 | 167 | delete_post_meta( $post_ID, '_tutor_attachments' ); |
| 168 | 168 | } |
| 169 | + | |
| 169 | 170 | } |
| 170 | 171 | |
| 171 | 172 | /** |
| 172 | 173 | * Get lesson details data. |
| @@ -579,10 +580,9 @@ | ||
| 579 | 580 | * @param array $args arguments. |
| 580 | 581 | * @return mixed based on arguments |
| 581 | 582 | */ |
| 582 | 583 | public static function get_comments( array $args ) { |
| 583 | - $args['type'] = 'comment'; | |
| 584 | - $comments = get_comments( $args ); | |
| 584 | + $comments = get_comments( $args ); | |
| 585 | 585 | return $comments; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
| @@ -608,147 +608,5 @@ | ||
| 608 | 608 | $comment_data = wp_parse_args( $request, $default_data ); |
| 609 | 609 | return wp_insert_comment( $comment_data ); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - /** | |
| 613 | - * Check if lesson has content | |
| 614 | - * | |
| 615 | - * @since 3.9.0 | |
| 616 | - * | |
| 617 | - * @param int $lesson_id Lesson ID. | |
| 618 | - * | |
| 619 | - * @return bool True if lesson has content, false otherwise. | |
| 620 | - */ | |
| 621 | - public static function has_lesson_content( $lesson_id ) { | |
| 622 | - /** | |
| 623 | - * If lesson has no content, lesson tab will be hidden. | |
| 624 | - * To enable elementor and SCORM, only admin can see lesson tab. | |
| 625 | - * | |
| 626 | - * @since 2.2.2 | |
| 627 | - */ | |
| 628 | - return apply_filters( | |
| 629 | - 'tutor_has_lesson_content', | |
| 630 | - User::is_admin() || ! in_array( trim( get_the_content() ), array( null, '', ' ' ), true ), | |
| 631 | - $lesson_id | |
| 632 | - ); | |
| 633 | - } | |
| 634 | - | |
| 635 | - /** | |
| 636 | - * Check if lesson has attachments | |
| 637 | - * | |
| 638 | - * @since 3.9.0 | |
| 639 | - * | |
| 640 | - * @param int $lesson_id Lesson ID. | |
| 641 | - * | |
| 642 | - * @return bool True if lesson has attachments, false otherwise. | |
| 643 | - */ | |
| 644 | - public static function has_lesson_attachment( $lesson_id ) { | |
| 645 | - return count( tutor_utils()->get_attachments( $lesson_id ) ) > 0; | |
| 646 | - } | |
| 647 | - | |
| 648 | - /** | |
| 649 | - * Check if comments are enabled for lessons | |
| 650 | - * | |
| 651 | - * @since 3.9.0 | |
| 652 | - * | |
| 653 | - * @return bool True if comments are enabled, false otherwise. | |
| 654 | - */ | |
| 655 | - public static function is_comment_enabled() { | |
| 656 | - return tutor_utils()->get_option( 'enable_comment_for_lesson' ) && comments_open() && is_user_logged_in(); | |
| 657 | - } | |
| 658 | - | |
| 659 | - /** | |
| 660 | - * Check if lesson has comments | |
| 661 | - * | |
| 662 | - * @since 3.9.0 | |
| 663 | - * | |
| 664 | - * @param int $lesson_id Lesson ID. | |
| 665 | - * | |
| 666 | - * @return int Number of comments for the lesson. | |
| 667 | - */ | |
| 668 | - public static function has_lesson_comment( $lesson_id ) { | |
| 669 | - return (int) get_comments_number( $lesson_id ); | |
| 670 | - } | |
| 671 | - | |
| 672 | - /** | |
| 673 | - * Get navigation items for lesson single page | |
| 674 | - * | |
| 675 | - * @since 3.9.0 | |
| 676 | - * | |
| 677 | - * @param int $lesson_id Lesson ID. | |
| 678 | - * | |
| 679 | - * @return array navigation items array | |
| 680 | - */ | |
| 681 | - public static function get_nav_items( $lesson_id ) { | |
| 682 | - $nav_items = array(); | |
| 683 | - | |
| 684 | - if ( self::has_lesson_content( $lesson_id ) ) { | |
| 685 | - $nav_items['overview'] = array( | |
| 686 | - 'label' => __( 'Overview', 'tutor' ), | |
| 687 | - 'value' => 'overview', | |
| 688 | - 'icon' => 'document-text', | |
| 689 | - ); | |
| 690 | - } | |
| 691 | - | |
| 692 | - if ( self::has_lesson_attachment( $lesson_id ) ) { | |
| 693 | - $nav_items['files'] = array( | |
| 694 | - 'label' => __( 'Exercise Files', 'tutor' ), | |
| 695 | - 'value' => 'files', | |
| 696 | - 'icon' => 'paperclip', | |
| 697 | - ); | |
| 698 | - } | |
| 699 | - | |
| 700 | - if ( self::is_comment_enabled() ) { | |
| 701 | - $nav_items['comments'] = array( | |
| 702 | - 'label' => __( 'Comments', 'tutor' ), | |
| 703 | - 'value' => 'comments', | |
| 704 | - 'icon' => 'comment', | |
| 705 | - ); | |
| 706 | - } | |
| 707 | - | |
| 708 | - $nav_items = apply_filters( 'tutor_lesson_single_nav_items', $nav_items ); | |
| 709 | - $nav_items = array_values( $nav_items ); | |
| 710 | - | |
| 711 | - return $nav_items; | |
| 712 | - } | |
| 713 | - | |
| 714 | - /** | |
| 715 | - * Get navigation contents for lesson single page | |
| 716 | - * | |
| 717 | - * @since 3.9.0 | |
| 718 | - * | |
| 719 | - * @param int $lesson_id Lesson ID. | |
| 720 | - * | |
| 721 | - * @return array navigation contents array | |
| 722 | - */ | |
| 723 | - public static function get_nav_contents( $lesson_id ) { | |
| 724 | - $nav_contents = array(); | |
| 725 | - | |
| 726 | - if ( self::has_lesson_content( $lesson_id ) ) { | |
| 727 | - $nav_contents['overview'] = array( | |
| 728 | - 'label' => __( 'Overview', 'tutor' ), | |
| 729 | - 'value' => 'overview', | |
| 730 | - 'template_path' => 'single.lesson.parts.overview', | |
| 731 | - ); | |
| 732 | - } | |
| 733 | - | |
| 734 | - if ( self::has_lesson_attachment( $lesson_id ) ) { | |
| 735 | - $nav_contents['files'] = array( | |
| 736 | - 'label' => __( 'Files', 'tutor' ), | |
| 737 | - 'value' => 'files', | |
| 738 | - 'template_path' => 'single.lesson.parts.files', | |
| 739 | - ); | |
| 740 | - } | |
| 741 | - | |
| 742 | - if ( self::is_comment_enabled() ) { | |
| 743 | - $nav_contents['comments'] = array( | |
| 744 | - 'label' => __( 'Comments', 'tutor' ), | |
| 745 | - 'value' => 'comments', | |
| 746 | - 'template_path' => 'single.lesson.parts.comments', | |
| 747 | - ); | |
| 748 | - } | |
| 749 | - | |
| 750 | - $nav_contents = apply_filters( 'tutor_lesson_single_nav_contents', $nav_contents ); | |
| 751 | - | |
| 752 | - return $nav_contents; | |
| 753 | - } | |
| 754 | 612 | } |