html' ) ) { /** * Return target audience in course single page. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_target_audience_html( $echo = true ) { ob_start(); tutor_load_template( 'single.course.course-target-audience' ); $output = apply_filters( 'tutor_course/single/audience_html', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_material_includes' ) ) { /** * Return course material includes. * * @since 1.0.0 * * @param int $course_id course ID. * * @return array */ function tutor_course_material_includes( $course_id = 0 ) { if ( ! $course_id ) { $course_id = get_the_ID(); } $target_audience = get_post_meta( $course_id, '_tutor_course_material_includes', true ); $target_audience_array = array(); if ( $target_audience ) { $target_audience_array = explode( "\n", $target_audience ); } $array = array_filter( array_map( 'trim', $target_audience_array ) ); return apply_filters( 'tutor_course/single/material_includes', $array, $course_id ); } } if ( ! function_exists( 'tutor_course_material_includes_html' ) ) { /** * Return course material includes HTML. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string */ function tutor_course_material_includes_html( $echo = true ) { ob_start(); tutor_load_template( 'single.course.material-includes' ); $output = apply_filters( 'tutor_course/single/material_includes', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_instructors_html' ) ) { /** * Return course instructors HTML. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_instructors_html( $echo = true ) { $display_course_instructors = tutor_utils()->get_option( 'display_course_instructors' ); if ( ! $display_course_instructors ) { return null; } ob_start(); tutor_load_template( 'single.course.instructors' ); $output = apply_filters( 'tutor_course/single/instructors_html', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_target_reviews_html' ) ) { /** * Return course reviews HTML. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_target_reviews_html( $echo = true ) { ob_start(); tutor_load_template( 'single.course.reviews' ); $output = apply_filters( 'tutor_course/single/reviews_html', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_content' ) ) { /** * Course single page main content / description. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_content( $echo = true ) { ob_start(); tutor_load_template( 'single.course.course-content' ); $output = apply_filters( 'tutor_course/single/content', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_lead_info' ) ) { /** * Course single page lead info. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_lead_info( $echo = true ) { ob_start(); $course_id = get_the_ID(); $course_post_type = tutor()->course_post_type; $query_course = new WP_Query( apply_filters( 'tutor_course_lead_info_args', array( 'p' => $course_id, 'post_type' => $course_post_type, ) ) ); if ( $query_course->have_posts() ) { while ( $query_course->have_posts() ) { $query_course->the_post(); tutor_load_template( 'single.course.lead-info' ); } wp_reset_postdata(); } $output = apply_filters( 'tutor_course/single/lead_info', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_enrolled_lead_info' ) ) { /** * Course enrolled lead info. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_enrolled_lead_info( $echo = true ) { ob_start(); $course_id = get_the_ID(); $course_post_type = tutor()->course_post_type; $query_course = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type, ) ); if ( $query_course->have_posts() ) { while ( $query_course->have_posts() ) { $query_course->the_post(); tutor_load_template( 'single.course.lead-info' ); } wp_reset_postdata(); } $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_lesson_lead_info' ) ) { /** * Lesson lead info. * * @since 1.0.0 * * @param int $lesson_id lesson id. * @param bool $echo whether to echo content. * * @return string|void */ function tutor_lesson_lead_info( $lesson_id = 0, $echo = true ) { if ( ! $lesson_id ) { $lesson_id = get_the_ID(); } ob_start(); $course_id = tutor_utils()->get_course_id_by( 'lesson', $lesson_id ); $course_post_type = tutor()->course_post_type; $query_course = new WP_Query( array( 'p' => $course_id, 'post_type' => $course_post_type, ) ); if ( $query_course->have_posts() ) { while ( $query_course->have_posts() ) { $query_course->the_post(); tutor_load_template( 'single.course.lead-info' ); } wp_reset_postdata(); } $output = apply_filters( 'tutor_course/single/enrolled/lead_info', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_course_video' ) ) { /** * Course video. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_video( $echo = true ) { ob_start(); tutor_load_template( 'single.video.video' ); $output = apply_filters( 'tutor_course/single/video', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_lesson_video' ) ) { /** * Lesson video. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_lesson_video( $echo = true ) { ob_start(); tutor_load_template( 'single.video.video' ); $output = apply_filters( 'tutor_lesson/single/video', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'get_tutor_posts_attachments' ) ) { /** * Get all lessons attachments. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function get_tutor_posts_attachments( $echo = true ) { ob_start(); tutor_load_template( 'global.attachments' ); $output = apply_filters( 'tutor_lesson/single/attachments', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_lesson_content' ) ) { /** * Render Lesson Main Content. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_lesson_content( $echo = true ) { ob_start(); tutor_load_template( 'single.lesson.content' ); $output = apply_filters( 'tutor_lesson/single/content', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_lesson_mark_complete_html' ) ) { /** * Lesson mark complete HTML. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_lesson_mark_complete_html( $echo = true ) { ob_start(); tutor_load_template( 'single.lesson.complete_form' ); $output = apply_filters( 'tutor_lesson/single/complete_form', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } /** * Course question and answer. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_question_and_answer( $echo = true ) { ob_start(); tutor_load_template( 'single.course.enrolled.question_and_answer' ); $output = apply_filters( 'tutor_course/single/question_and_answer', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } /** * Render course info tab content. * * @since 2.0.0 * @since 2.0.5 updated. * * @return void */ function tutor_course_info_tab() { tutor_course_content(); tutor_course_benefits_html(); tutor_course_topics(); } /** * Course announcements. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_course_announcements( $echo = true ) { ob_start(); tutor_load_template( 'single.course.enrolled.announcements' ); $output = apply_filters( 'tutor_course/single/announcements', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } /** * Single quiz top. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_single_quiz_top( $echo = true ) { ob_start(); tutor_load_template( 'single.quiz.top' ); $output = apply_filters( 'tutor_single_quiz/top', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } /** * Single quiz body. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_single_quiz_body( $echo = true ) { ob_start(); tutor_load_template( 'single.quiz.body' ); $output = apply_filters( 'tutor_single_quiz/body', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- data already escaped inside template file } return $output; } /** * Get the quiz description. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_single_quiz_content( $echo = true ) { ob_start(); tutor_load_template( 'single.quiz.content' ); $output = apply_filters( 'tutor_single_quiz/content', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } /** * Single quiz no course belongs. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_single_quiz_no_course_belongs( $echo = true ) { ob_start(); tutor_load_template( 'single.quiz.no_course_belongs' ); $output = apply_filters( 'tutor_single_quiz/no_course_belongs', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } /** * Single quiz contents. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function single_quiz_contents( $echo = true ) { ob_start(); tutor_load_template( 'single.quiz.single_quiz_contents' ); $output = apply_filters( 'tutor_single_quiz/single_quiz_contents', ob_get_clean() ); if ( $echo ) { echo $output; //phpcs:ignore -- already escaped inside template file } return $output; } /** * Get course level. * * @since 1.0.0 * * @param int $course_id course ID. * * @return string|bool */ function get_tutor_course_level( $course_id = 0 ) { if ( ! $course_id ) { $course_id = get_the_ID(); } if ( ! $course_id ) { return ''; } $course_level = get_post_meta( $course_id, '_tutor_course_level', true ); if ( $course_level ) { return tutor_utils()->course_levels( $course_level ); } return false; } if ( ! function_exists( 'get_tutor_course_duration_context' ) ) { /** * Get course duration context. * * @since 1.0.0 * * @param int $course_id course ID. * @param bool $short_form whether to use short form. * * @return string|bool */ function get_tutor_course_duration_context( $course_id = 0, $short_form = false ) { if ( ! $course_id ) { $course_id = get_the_ID(); } if ( ! $course_id ) { return ''; } $duration = get_post_meta( $course_id, '_course_duration', true ); $duration_hours = tutor_utils()->avalue_dot( 'hours', $duration ); $duration_minutes = tutor_utils()->avalue_dot( 'minutes', $duration ); $duration_seconds = tutor_utils()->avalue_dot( 'seconds', $duration ); $hour_format = $short_form ? __( 'h', 'tutor' ) : ' ' . ( $duration_hours > 1 ? __( 'hours', 'tutor' ) : __( 'hour', 'tutor' ) ); $minute_format = $short_form ? __( 'm', 'tutor' ) : ' ' . ( $duration_minutes > 1 ? __( 'minutes', 'tutor' ) : __( 'minute', 'tutor' ) ); $second_format = $short_form ? __( 's', 'tutor' ) : ' ' . ( $duration_seconds > 1 ? __( 'seconds', 'tutor' ) : __( 'second', 'tutor' ) ); if ( $duration ) { $output = ''; if ( $duration_hours > 0 ) { $output .= '' . $duration_hours . '' . $hour_format . ''; } if ( $duration_minutes > 0 ) { $output .= '' . $duration_minutes . '' . $minute_format . ''; } if ( ! $duration_hours && ! $duration_minutes && $duration_seconds > 0 ) { $output .= '' . $duration_seconds . '' . $second_format . ''; } return $output; } return false; } } if ( ! function_exists( 'get_tutor_course_categories' ) ) { /** * Get course categories. * * @since 1.0.0 * * @param int $course_id course ID. * * @return array|bool|WP_Error */ function get_tutor_course_categories( $course_id = 0 ) { if ( ! $course_id ) { $course_id = get_the_ID(); } $terms = get_the_terms( $course_id, CourseModel::COURSE_CATEGORY ); return $terms; } } if ( ! function_exists( 'get_tutor_course_tags' ) ) { /** * Get course tags. * * @since 1.0.0 * * @param int $course_id course ID. * * @return array|false|WP_Error */ function get_tutor_course_tags( $course_id = 0 ) { if ( ! $course_id ) { $course_id = get_the_ID(); } $terms = get_the_terms( $course_id, CourseModel::COURSE_TAG ); return $terms; } } if ( ! function_exists( 'tutor_course_tags_html' ) ) { /** * Template for course tags html. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string */ function tutor_course_tags_html( $echo = true ) { ob_start(); tutor_load_template( 'single.course.tags' ); $output = apply_filters( 'tutor_course/single/tags_html', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore } return $output; } } if ( ! function_exists( 'tutor_lesson_sidebar_question_and_answer' ) ) { /** * Get Q&A in lesson sidebar. * * @since 1.0.0 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_lesson_sidebar_question_and_answer( $echo = true ) { ob_start(); tutor_load_template( 'single.lesson.sidebar_question_and_answer' ); $output = apply_filters( 'tutor_lesson/single/sidebar_question_and_answer', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'tutor_assignment_content' ) ) { /** * Get Assignment content. * * @since 1.3.3 * * @param bool $echo whether to echo content. * * @return string|void */ function tutor_assignment_content( $echo = true ) { $output = apply_filters( 'tutor_assignment/single/content', '' ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } } if ( ! function_exists( 'get_tnotice' ) ) { /** * Get notice. * * @since 1.4.0 * * @param string $msg message. * @param string $title title. * @param string $type type. * * @return string */ function get_tnotice( $msg = '', $title = 'Success', $type = 'success' ) { $output = '
¡
'; if ( $title ) { $output .= '

' . $title . '

'; } $output .= '

' . $msg . '

'; return $output; } } /** * Next Previous Pagination. * * @since 1.4.7 * * @param int $course_content_id course content ID. * @param bool $echo whether to echo content. * * @return string|void */ function tutor_next_previous_pagination( $course_content_id = 0, $echo = true ) { $content_id = tutor_utils()->get_post_id( $course_content_id ); $contents = tutor_utils()->get_course_prev_next_contents_by_id( $content_id ); $previous_id = $contents->previous_id; $next_id = $contents->next_id; ob_start(); do_action( 'tutor_lesson_next_previous_pagination_before' ); tutor_load_template( 'single.next-previous-pagination', compact( 'previous_id', 'next_id' ) ); do_action( 'tutor_lesson_next_previous_pagination_after' ); $output = apply_filters( 'tutor/single/next_previous_pagination', ob_get_clean() ); if ( $echo ) { echo tutor_kses_html( $output ); //phpcs:ignore -- already escaped inside template file } return $output; } if ( ! function_exists( 'tutor_load_template_from_custom_path' ) ) { /** * Load custom template from any given file. * * @since 1.9.8 * * @param string $template template path. * @param array $data data to pass. * @param bool $once whether to include once. * * @return void */ function tutor_load_template_from_custom_path( $template = null, $data = array(), $once = true ) { do_action( 'tutor_load_template_from_custom_path_before', $template, $data ); if ( file_exists( $template ) ) { if ( $once ) { include_once $template; } else { include $template; } } do_action( 'tutor_load_template_from_custom_path_after', $template, $data ); } } if ( ! function_exists( 'tutor_enrolled_course_progress' ) ) { /** * Load enrolled course progress template. * * @since 2.0.0 * * @return void */ function tutor_enrolled_course_progress() { global $wp_query; $query_vars = $wp_query->query_vars; if ( isset( $query_vars['tutor_dashboard_page'] ) && 'enrolled-courses' === $query_vars['tutor_dashboard_page'] ) { tutor_load_template_from_custom_path( tutor()->path . 'templates/loop/enrolled-course-progress.php', '', false ); } } } if ( ! function_exists( 'tutor_permission_denied_template' ) ) { /** * Load permission denied template. * * It will load permission denied template & return so not code * after this will execute * * @since 2.2.0 * * @param integer $post_id post id if 0 then current post id will be used. * * @return void */ function tutor_permission_denied_template( int $post_id = 0 ) { if ( ! $post_id ) { $post_id = get_the_ID(); } $args = array( 'headline' => __( 'Permission Denied', 'tutor' ), 'message' => __( 'You don\'t have the right to edit this course', 'tutor' ), 'description' => __( 'Please make sure you are logged in to correct account', 'tutor' ), 'button' => array( 'url' => get_permalink( $post_id ), 'text' => __( 'View Course', 'tutor' ), ), ); tutor_load_template( 'permission-denied', $args ); return; } } if ( ! function_exists( 'get_template_buffer' ) ) { /** * Render a template and return its output as a string. * * @since 4.0.0 * * @param string $template Template file path or slug. * @param array $data Data to be passed to the template. * @param bool $once Whether the template should be loaded only once. * Defaults to true. * * @return string Rendered template output. */ function get_template_buffer( $template, $data, $once = true ) { ob_start(); tutor_load_template_from_custom_path( $template, $data, $once ); return ob_get_clean(); } }