template( 'general' )->func( 'breadcrumb' ) ); endif; // ===== upstudy_lp_course_page_title_section_03 if ( class_exists('LearnPress') && function_exists( 'upstudy_course_page_title_section_00' ) && Upstudy::setting( 'lp_single_page_layout' ) == '1') { add_action( 'learn-press/course-content-summary', 'upstudy_course_page_title_section_00', 35 ); } //** ==== LearnPress add body class ** ==== function add_body_classes_for_lp_lms( $classes ) { $prefix = '_upstudy_'; $post_id = upstudy_get_id(); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_single_excerpt = Upstudy::setting( 'lp_single_excerpt' ); // Get body class for LearnPress lms profile page if ( class_exists('LearnPress') && $lp_single_page_layout && is_singular( 'lp_course' )) { $classes[] = 'single-course-layout-0'.$lp_single_page_layout.''; } // End - Get body class for LearnPress lms profile page // Get body class for lp lms course excerpt if ( class_exists('LearnPress') && $lp_single_excerpt && is_singular( 'lp_course' )) { $classes[] = 'has__excerpt'; } // Get body class for tutor lms course excerpt if ( function_exists('tutor') && $tutor_single_excerpt && is_singular( 'courses' )) { $classes[] = 'has__excerpt'; } // Get body class for tutor lms course meta $has_meta = ( Upstudy::setting( 'lp_instructor_single' ) ) ? true : false; if ( class_exists('LearnPress') && $has_meta && is_singular( 'lp_course' )) { $classes[] = 'has__meta'; } // Finally $classes return return $classes; } add_filter( 'body_class', 'add_body_classes_for_lp_lms' ); /** * Learnpress course info */ if (!function_exists('upstudy_lp_course_info')) { function upstudy_lp_course_info() { global $post; $post_id = $post->ID; // Prefix $prefix = '_upstudy_'; $course_id = get_the_ID(); $course = learn_press_get_course(); $lp_duration = get_post_meta(get_the_ID(), '_lp_duration'); $lp_deliver_type = get_post_meta(get_the_ID(), '_lp_deliver_type'); $lp_offline_course = get_post_meta(get_the_ID(), '_lp_offline_course'); $lp_address = get_post_meta(get_the_ID(), '_lp_address'); $lp_offline_lesson_count = get_post_meta(get_the_ID(), '_lp_offline_lesson_count'); $lp_external_link_buy_course = get_post_meta(get_the_ID(), '_lp_external_link_buy_course'); $lp_students = get_post_meta(get_the_ID(), '_lp_students'); $lp_retake_count = get_post_meta(get_the_ID(), '_lp_retake_count'); $lp_curriculum = get_post_meta(get_the_ID(), '_lp_curriculum'); $lp_quizzes = $course->get_curriculum_items('lp_quiz'); $lp_custom_features_position = Upstudy::setting( 'lp_custom_features_position' ); $lp_course_feature_quizzes = Upstudy::setting( 'lp_course_feature_quizzes' ); $lp_course_feature_duration = Upstudy::setting( 'lp_course_feature_duration' ); $lp_course_feature_lessons = Upstudy::setting( 'lp_course_feature_lessons' ); $lp_course_feature_max_tudents = Upstudy::setting( 'lp_course_feature_max_tudents' ); $lp_course_feature_enroll = Upstudy::setting( 'lp_course_feature_enroll' ); $lp_course_feature_retake_count = Upstudy::setting( 'lp_course_feature_retake_count' ); $lp_course_feature_skill_level = Upstudy::setting( 'lp_course_feature_skill_level' ); $lp_course_feature_language = Upstudy::setting( 'lp_course_feature_language' ); $lp_course_feature_assessments = Upstudy::setting( 'lp_course_feature_assessments' ); $lp_course_feature_cat = Upstudy::setting( 'lp_course_feature_cat' ); $lp_course_feature_quizzes_show = Upstudy::setting( 'lp_course_feature_quizzes_show' ); $lp_course_feature_duration_show = Upstudy::setting( 'lp_course_feature_duration_show' ); $lp_single_course_price = Upstudy::setting( 'lp_single_course_price' ); $lp_single_enroll_btn = Upstudy::setting( 'lp_single_enroll_btn' ); $lp_course_feature_lessons_show = Upstudy::setting( 'lp_course_feature_lessons_show' ); $lp_course_feature_max_students_show = Upstudy::setting( 'lp_course_feature_max_students_show' ); $lp_course_feature_enroll_show = Upstudy::setting( 'lp_course_feature_enroll_show' ); $lp_course_feature_retake_count_show = Upstudy::setting( 'lp_course_feature_retake_count_show' ); $lp_course_feature_skill_level_show = Upstudy::setting( 'lp_course_feature_skill_level_show' ); $lp_course_feature_language_show = Upstudy::setting( 'lp_course_feature_language_show' ); $lp_course_feature_assessments_show = Upstudy::setting( 'lp_course_feature_assessments_show' ); $lp_course_feature_cat_show = Upstudy::setting( 'lp_course_feature_cat_show' ); $lp_intro_video_position = Upstudy::setting( 'lp_intro_video_position' ); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_single_info_heading = Upstudy::setting( 'lp_single_info_heading' ); $lp_instructor_single = Upstudy::setting( 'lp_instructor_single' ); $lp_course_feature_Lessons_offline_show = Upstudy::setting( 'lp_course_feature_Lessons_offline_show' ); $lp_course_feature_offline_lesson = Upstudy::setting( 'lp_course_feature_offline_lesson' ); $lp_course_feature_Lessons_dt_show = Upstudy::setting( 'lp_course_feature_Lessons_dt_show' ); $lp_course_feature_offline_dt = Upstudy::setting( 'lp_course_feature_offline_dt' ); $lp_course_feature_address_offline_show = Upstudy::setting( 'lp_course_feature_address_offline_show' ); $lp_course_feature_offline_address = Upstudy::setting( 'lp_course_feature_offline_address' ); $upstudy_lp_video = get_post_meta( get_the_ID(), 'upstudy_lp_video', 1 ); echo '
'; if ($lp_single_info_heading) { echo '

'; echo esc_html( $lp_single_info_heading ); echo '

'; } echo ''; if ( $lp_single_enroll_btn ) { // Buttons. // LP()->template( 'course' )->course_buttons(); learn_press_get_template( 'single-course/buttons' ); } echo '
'; } } /** * Display Course Category */ if ( ! function_exists( 'upstudy_lp_course_category' ) ) { function upstudy_lp_course_category() { global $post; $post_id = $post->ID; ?>

'course_category', 'orderby' => 'name', 'order' => 'ASC' ); $terms = get_categories($args); if ($terms && ! is_wp_error($terms)): ?>
ID; if (null === $totalPosts) $totalPosts = $lp_related_course_items; if (null === $relatedBy) $relatedBy = $lp_related_course_by; if (null === $postType) $postType = 'lp_course'; // Build our basic custom query arguments if ($relatedBy === 'category') { $categories = get_the_category( $post->ID ); $catidlist = ''; foreach( $categories as $category) { $catidlist .= $category->cat_ID . ","; } // Build our category based custom query arguments $related_posts_custom_query_args = array( 'post_type' => $postType, 'posts_per_page' => $totalPosts, // Number of related posts to display 'post__not_in' => array($postID), // Ensure that the current post is not displayed 'orderby' => 'rand', // Randomize the results 'cat' => $catidlist, // Select posts in the same categories as the current post ); } if ($relatedBy === 'tags') { // Get the tags for the current post $tags = wp_get_post_tags($postID); // If the post has tags, run the related post tag query if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; // Build our tag related custom query arguments $related_posts_custom_query_args = array( 'post_type' => $postType, 'tag__in' => $tag_ids, // Select posts with related tags 'posts_per_page' => $totalPosts, // Number of related posts to display 'post__not_in' => array($postID), // Ensure that the current post is not displayed 'orderby' => 'rand', // Randomize the results ); } else { // If the post does not have tags, run the standard related posts query $related_posts_custom_query_args = array( 'post_type' => $postType, 'posts_per_page' => $totalPosts, // Number of related posts to display 'post__not_in' => array($postID), // Ensure that the current post is not displayed 'orderby' => 'rand', // Randomize the results ); } } $lp_related_course_columns = Upstudy::setting( 'lp_related_course_columns' ); $style = Upstudy::setting( 'lp_course_archive_style' ); if ( 'default' === $style ) : $style = Upstudy::setting( 'lp_course_archive_style' ); endif; $layout_data = array( 'style' => $style ); // Initiate the custom query $custom_query = new WP_Query( $related_posts_custom_query_args ); // Run the loop and output data for the results if ( $custom_query->have_posts() ) : echo '
'; echo ''; echo '
'; echo '
'; while ( $custom_query->have_posts() ) : $custom_query->the_post(); echo ''; endwhile; echo '
'; endif; // Reset postdata wp_reset_postdata(); } } /** * Display related courses sidebar */ if ( ! function_exists( 'upstudy_lp_related_course_sidebar' ) ) { function upstudy_lp_related_course_sidebar( $postType = 'lp_course', $postID = null, $totalPosts = null, $relatedBy = null) { $lp_related_course_title = Upstudy::setting( 'lp_related_course_title' ); $lp_related_course_items = Upstudy::setting( 'lp_related_course_items' ); $lp_related_course_by = Upstudy::setting( 'lp_related_course_by' ); $lp_related_course_style = Upstudy::setting( 'lp_related_course_style' ); $final_lp_related_course_style = ($lp_related_course_style == 'square') ? 'square' : 'round'; global $post, $related_posts_custom_query_args; if (null === $postID) $postID = $post->ID; if (null === $totalPosts) $totalPosts = $lp_related_course_items; if (null === $relatedBy) $relatedBy = $lp_related_course_by; if (null === $postType) $postType = 'lp_course'; // Build our basic custom query arguments if ($relatedBy === 'category') { $categories = get_the_category( $post->ID ); $catidlist = ''; foreach( $categories as $category) { $catidlist .= $category->cat_ID . ","; } // Build our category based custom query arguments $related_posts_custom_query_args = array( 'post_type' => $postType, 'posts_per_page' => $totalPosts, // Number of related posts to display 'post__not_in' => array($postID), // Ensure that the current post is not displayed 'orderby' => 'rand', // Randomize the results 'cat' => $catidlist, // Select posts in the same categories as the current post ); } if ($relatedBy === 'tags') { // Get the tags for the current post $tags = wp_get_post_tags($postID); // If the post has tags, run the related post tag query if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; // Build our tag related custom query arguments $related_posts_custom_query_args = array( 'post_type' => $postType, 'tag__in' => $tag_ids, // Select posts with related tags 'posts_per_page' => $totalPosts, // Number of related posts to display 'post__not_in' => array($postID), // Ensure that the current post is not displayed 'orderby' => 'rand', // Randomize the results ); } else { // If the post does not have tags, run the standard related posts query $related_posts_custom_query_args = array( 'post_type' => $postType, 'posts_per_page' => $totalPosts, // Number of related posts to display 'post__not_in' => array($postID), // Ensure that the current post is not displayed 'orderby' => 'rand', // Randomize the results ); } } // Initiate the custom query $custom_query = new WP_Query( $related_posts_custom_query_args ); // Run the loop and output data for the results if ( $custom_query->have_posts() ) : echo ''; endif; // Reset postdata wp_reset_postdata(); } } /** * upstudy_lp_course_page_title_section_08 */ if ( ! function_exists( 'upstudy_lp_course_page_title_section_08' ) ) : function upstudy_lp_course_page_title_section_08( $title = null, $has_bg_image = null, $extra_style = null ) { global $post; $post_id = $post->ID; // Prefix $prefix = '_upstudy_'; $course_id = get_the_ID(); $course = learn_press_get_course(); $lp_students = get_post_meta(get_the_ID(), '_lp_students'); $lp_retake_count = get_post_meta(get_the_ID(), '_lp_retake_count'); $lp_curriculum = get_post_meta(get_the_ID(), '_lp_curriculum'); $lp_custom_features_position = Upstudy::setting( 'lp_custom_features_position' ); $lp_course_feature_quizzes = Upstudy::setting( 'lp_course_feature_quizzes' ); $lp_course_feature_duration = Upstudy::setting( 'lp_course_feature_duration' ); $lp_course_feature_lessons = Upstudy::setting( 'lp_course_feature_lessons' ); $lp_course_feature_max_tudents = Upstudy::setting( 'lp_course_feature_max_tudents' ); $lp_course_feature_enroll = Upstudy::setting( 'lp_course_feature_enroll' ); $lp_course_feature_retake_count = Upstudy::setting( 'lp_course_feature_retake_count' ); $lp_course_feature_skill_level = Upstudy::setting( 'lp_course_feature_skill_level' ); $lp_course_feature_language = Upstudy::setting( 'lp_course_feature_language' ); $lp_course_feature_assessments = Upstudy::setting( 'lp_course_feature_assessments' ); $lp_course_feature_cat = Upstudy::setting( 'lp_course_feature_cat' ); $lp_course_feature_quizzes_show = Upstudy::setting( 'lp_course_feature_quizzes_show' ); $lp_course_feature_duration_show = Upstudy::setting( 'lp_course_feature_duration_show' ); $lp_single_course_price = Upstudy::setting( 'lp_single_course_price' ); $lp_single_enroll_btn = Upstudy::setting( 'lp_single_enroll_btn' ); $lp_course_feature_lessons_show = Upstudy::setting( 'lp_course_feature_lessons_show' ); $lp_course_feature_max_students_show = Upstudy::setting( 'lp_course_feature_max_students_show' ); $lp_course_feature_enroll_show = Upstudy::setting( 'lp_course_feature_enroll_show' ); $lp_course_feature_retake_count_show = Upstudy::setting( 'lp_course_feature_retake_count_show' ); $lp_course_feature_skill_level_show = Upstudy::setting( 'lp_course_feature_skill_level_show' ); $lp_course_feature_language_show = Upstudy::setting( 'lp_course_feature_language_show' ); $lp_course_feature_assessments_show = Upstudy::setting( 'lp_course_feature_assessments_show' ); $lp_course_feature_cat_show = Upstudy::setting( 'lp_course_feature_cat_show' ); $lp_intro_video_position = Upstudy::setting( 'lp_intro_video_position' ); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_single_info_heading = Upstudy::setting( 'lp_single_info_heading' ); $lp_instructor_single = Upstudy::setting( 'lp_instructor_single' ); $lp_single_excerpt = Upstudy::setting( 'lp_single_excerpt' ); $lp_single_review = Upstudy::setting( 'lp_single_review' ); $lp_single_last_update = Upstudy::setting( 'lp_single_last_update' ); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_header_color = 'upstudy-dark-header'; $header_title_tag = Upstudy::setting( 'header_title_tag' ); $header_page_title_align = 'left'; $lp_course_header_style = Upstudy::setting( 'lp_course_header_style' ); $lp_single_breadcrumb = Upstudy::setting( 'lp_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $lp_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '

'; the_title(); echo '

'; if ( $lp_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; get_template_part( 'learnpress/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; echo '
'; echo '
'; echo '
'; if ($lp_single_course_price) { LP()->template( 'course' )->courses_loop_item_price(); } if ( $lp_single_enroll_btn ) { learn_press_get_template( 'single-course/buttons' ); } echo '
'; echo '
'; echo '
    '; if ($lp_custom_features_position == 'top') { get_template_part( 'learnpress/tpl-part/single/meta', 'custom' ); } $total_students = $course->get_users_enrolled() ? $course->get_users_enrolled() : 0; $students_text = ('1' == $total_students) ? esc_html__(' Student Enrolled', 'upstudy') : esc_html__(' Students Enrolled', 'upstudy'); if ( $lp_students && $lp_course_feature_enroll_show ) { echo '
  • '; echo ''; echo ''; echo wp_kses_post($total_students); echo wp_kses_post($students_text); echo ''; echo '
  • '; } $total_lesson = $course->get_items('lp_lesson', false) ? count($course->get_items('lp_lesson', false)) : 0; $lesson_text = ('1' == $total_lesson) ? esc_html__(' Total Lesson', 'upstudy') : esc_html__(' Total Lessons', 'upstudy'); if ( $lp_course_feature_lessons_show) { echo '
  • '; echo ''; echo ''; echo wp_kses_post( $total_lesson ); echo wp_kses_post( $lesson_text ); echo ''; echo '
  • '; } $lp_duration = get_post_meta(get_the_ID(), '_lp_duration'); $duration_text = esc_html__('Duration ', 'upstudy'); if ($lp_course_feature_duration_show && !empty($lp_duration)) { echo '
  • '; echo ''; echo ''; echo wp_kses_post($duration_text); echo wp_kses_post($lp_duration[0]); echo ''; echo '
  • '; } echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; // ===== upstudy_lp_course_page_title_section_06 if ( ! function_exists( 'upstudy_lp_course_page_title_section_06' ) ) : function upstudy_lp_course_page_title_section_06( $title = null, $has_bg_image = null, $extra_style = null ) { $custom_page_header_img = get_post_meta( get_the_ID(), '_upstudy_header_img', 1 ); $lp_single_breadcrumb = Upstudy::setting( 'lp_single_breadcrumb' ); $lp_course_header_style = Upstudy::setting( 'lp_course_header_style' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '

'; echo the_title(); echo '

'; echo '
'; echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; get_template_part( 'learnpress/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; /** * Course page title section upstudy_lp_course_page_title_section_05 */ if ( ! function_exists( 'upstudy_lp_course_page_title_section_05' ) ) : function upstudy_lp_course_page_title_section_05( $title = null, $has_bg_image = null, $extra_style = null ) { global $post; $post_id = $post->ID; $course_id = $post_id; $user_id = get_current_user_id(); $current_id = $post->ID; $course = learn_press_get_course(); $prefix = '_upstudy_'; //$lp_course_header_image = get_post_meta( get_the_ID(), '_upstudy_lp_course_header_image', 1 ); $lp_single_excerpt = Upstudy::setting( 'lp_single_excerpt' ); $lp_single_review = Upstudy::setting( 'lp_single_review' ); $lp_single_last_update = Upstudy::setting( 'lp_single_last_update' ); $lp_instructor_single = Upstudy::setting( 'lp_instructor_single' ); $lp_course_feature_quizzes_show = Upstudy::setting( 'lp_course_feature_quizzes_show' ); $lp_course_feature_duration_show = Upstudy::setting( 'lp_course_feature_duration_show' ); $lp_course_feature_lessons_show = Upstudy::setting( 'lp_course_feature_lessons_show' ); $lp_course_feature_max_students_show = Upstudy::setting( 'lp_course_feature_max_students_show' ); $lp_course_feature_enroll_show = Upstudy::setting( 'lp_course_feature_enroll_show' ); $lp_course_feature_retake_count_show = Upstudy::setting( 'lp_course_feature_retake_count_show' ); $lp_course_feature_skill_level_show = Upstudy::setting( 'lp_course_feature_skill_level_show' ); $lp_course_feature_language_show = Upstudy::setting( 'lp_course_feature_language_show' ); $lp_course_feature_assessments_show = Upstudy::setting( 'lp_course_feature_assessments_show' ); $lp_course_feature_cat_show = Upstudy::setting( 'lp_course_feature_cat_show' ); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_header_color = ( $lp_single_page_layout == '4' ) ? 'light' : 'dark' ; $header_title_tag = Upstudy::setting( 'header_title_tag' ); $header_page_title_align = Upstudy::setting( 'header_page_title_align' ); $lp_course_header_style = Upstudy::setting( 'lp_course_header_style' ); $lp_single_breadcrumb = Upstudy::setting( 'lp_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; if ( $lp_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '
'; if ( class_exists( 'LP_Addon_Course_Review_Preload' ) ) : echo '
'; upstudy_lp_course_ratings(); echo '
'; endif; echo '<'.$header_title_tag.' class="page-title has-text-align-'.$header_page_title_align.'">'; the_title(); echo ''; echo '
'; if ( $lp_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; upstudy_breadcrumb_shapes(); get_template_part( 'learnpress/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; // ===== upstudy_lp_course_page_title_section_03 if ( ! function_exists( 'upstudy_lp_course_page_title_section_03' ) ) : function upstudy_lp_course_page_title_section_03( $title = null, $has_bg_image = null, $extra_style = null ) { $lp_single_excerpt = Upstudy::setting( 'lp_single_excerpt' ); $lp_single_breadcrumb = Upstudy::setting( 'lp_single_breadcrumb' ); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_header_color = ( $lp_single_page_layout == '4' ) ? 'light' : 'dark' ; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $lp_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '

'; the_title(); echo '

'; if ( $lp_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; // get_template_part( 'lp/tpl-part/single/meta', 'review-update' ); get_template_part( 'learnpress/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; // ===== upstudy_lp_course_page_title_section_04 ==== if ( ! function_exists( 'upstudy_lp_course_page_title_section_04' ) ) : function upstudy_lp_course_page_title_section_04( $title = null, $has_bg_image = null, $extra_style = null ) { global $post; $post_id = $post->ID; $course_id = $post_id; $user_id = get_current_user_id(); $current_id = $post->ID; $prefix = '_upstudy_'; $lp_single_excerpt = Upstudy::setting( 'lp_single_excerpt' ); $lp_single_review = Upstudy::setting( 'lp_single_review' ); $lp_single_last_update = Upstudy::setting( 'lp_single_last_update' ); $lp_single_page_layout = Upstudy::setting( 'lp_single_page_layout' ); $lp_header_color = ( $lp_single_page_layout == '4' ) ? 'light' : 'dark' ; $page_header_img = get_post_meta($post_id, $prefix . 'header_img', true); $lp_intro_video_position = Upstudy::setting( 'lp_intro_video_position' ); $lp_single_social_shear = Upstudy::setting( 'lp_single_social_shear ' ); $breadcrumb_show = Upstudy::setting( 'breadcrumb_show' ); $shortcode_breadcrumb = Upstudy::setting( 'shortcode_breadcrumb' ); $lp_single_breadcrumb = Upstudy::setting( 'lp_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $lp_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '

'; the_title(); echo '

'; if ( $lp_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; get_template_part( 'learnpress/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; // End upstudy-col-lg-8 echo '
'; if ( $lp_single_page_layout == '5' ) { get_template_part( 'learnpress/tpl-part/single/media', 'header' ); } echo '
'; // End upstudy-col-lg-4 echo '
'; // End upstudy-row echo '
'; // End upstudy-container echo '
'; // End upstudy-course-top-info } endif; // ======================================================================================================================== /** * Display related courses sidebar */ if (!function_exists('upstudy_related_courses')) { function upstudy_related_courses() { $related_courses = upstudy_get_related_courses(null, array('posts_per_page' => 3)); if ( $related_courses) { $ids = wp_list_pluck($related_courses, 'ID'); ?>
slug; } } $args = array( 'posts_per_page' => $limit, 'paged' => 1, 'ignore_sticky_posts' => 1, 'post__not_in' => array($course_id), 'post_type' => 'lp_course', ); if ( $tag_ids) { $args['tax_query'] = array( array( 'taxonomy' => 'course_tag', 'field' => 'slug', 'terms' => $tag_ids, ), ); } $related = array(); if ( $posts = new WP_Query($args)) { global $post; while ($posts->have_posts()) { $posts->the_post(); $related[] = $post; } } wp_reset_postdata(); return $related; } } /** * @upstudy_extra_user_profile_fields */ if (!function_exists('upstudy_extra_user_profile_fields')) { function upstudy_extra_user_profile_fields($user) { $user_info = get_the_author_meta('lp_info', $user->ID); ?>

get_origin_price() != $course->get_price() ) : printf( '%s', apply_filters( 'upstudy_course_sale_tag_text', __( 'Sale', 'upstudy' ) ) ); endif; } endif; /** * Sale percentage tag for promotional courses */ if ( ! function_exists( 'upstudy_lp_course_sale_offer_in_percentage' ) ) : function upstudy_lp_course_sale_offer_in_percentage() { $course = LP_Global::course(); $discount = round( 100 * ($course->get_origin_price() - $course->get_price()) / $course->get_origin_price() ); $offer = apply_filters( 'upstudy_course_sale_offer_text', __( 'Off', 'upstudy' ) ); return $discount.'%' . ' ' . $offer; } endif; /** * Add html span tag to wrap decimal separator. */ if ( ! function_exists( 'upstudy_lp_course_price_decimal_separator' ) ) : function upstudy_lp_course_price_decimal_separator( $origin_price ) { $decimal_number = intval( LP()->settings->get( 'number_of_decimals' ) ); $decimal_separator = LP()->settings->get( 'decimals_separator' ); if ( $decimal_number > 0 && ! empty( $decimal_separator ) ) : $decimal_position = strpos( $origin_price, $decimal_separator ); $decimal_part = substr( $origin_price, $decimal_position, $decimal_number + 1 ); $decimal_html = '' . $decimal_part . ''; $origin_price = str_replace( $decimal_part, $decimal_html, $origin_price ); endif; return $origin_price; } endif; /** * Course instructor */ if ( ! function_exists( 'upstudy_lp_course_instructor' ) ) : function upstudy_lp_course_instructor( $thumb_size = 60 ) { echo '
'; printf( get_avatar( get_the_author_meta( 'ID' ), $thumb_size ) ); echo '
'; echo ''; echo '
'; the_author(); echo '
'; echo '
'; echo '
'; } endif; /** * Course category */ if ( ! function_exists( 'upstudy_lp_course_first_category' ) ) : function upstudy_lp_course_first_category() { $first_cat = upstudy_category_by_id( get_the_id(), 'course_category' ); if ( ! empty( $first_cat) ) : echo '
'; echo ''; echo '
'; echo ''; echo wp_kses_post( $first_cat ); echo ''; echo '
'; echo '
'; endif; } endif; /** * Display course ratings */ if ( ! function_exists( 'upstudy_lp_course_ratings' ) ) : function upstudy_lp_course_ratings() { if ( ! class_exists( 'LP_Addon_Course_Review_Preload' ) ) : return; endif; $course_rate_res = learn_press_get_course_rate( get_the_ID(), false ); $course_rate = $course_rate_res['rated']; $total = $course_rate_res['total']; $ratings = learn_press_get_course_rate_total( get_the_ID() ); $rating_text = __( 'Rating', 'upstudy' ); $ratings_text = __( 'Ratings', 'upstudy' ); echo '
'; learn_press_course_review_template( 'rating-stars.php', array( 'rated' => $course_rate ) ); echo ''; echo esc_html( '(' . number_format( $course_rate, 1 ) ) . '/ '; echo esc_html( $ratings ) . ' '; // if ( (int)$ratings > 1 ) : // echo esc_html( $ratings_text ); // else : // echo esc_html( $rating_text ); // endif; echo ')'; echo '
'; } endif; /** * Display course ratings alter */ if ( ! function_exists( 'upstudy_lp_course_ratings_alter' ) ) : function upstudy_lp_course_ratings_alter( $show_rating = false ) { if ( ! class_exists( 'LP_Addon_Course_Review_Preload' ) ) : return; endif; $course_rate_res = learn_press_get_course_rate( get_the_ID(), false ); $course_rate = $course_rate_res['rated']; $total = $course_rate_res['total']; $ratings = learn_press_get_course_rate_total( get_the_ID() ); echo '
'; learn_press_course_review_template( 'rating-stars.php', array( 'rated' => $course_rate ) ); if ( $show_rating ) : echo ''; echo esc_html( '(' . number_format( $course_rate, 1 ) . ')' ); echo ''; else : echo ''; printf( _nx( '(%s Review)', '(%s Reviews)', $ratings, 'Ratings', 'upstudy' ), number_format_i18n( $ratings ) ); echo ''; endif; echo '
'; } endif; /** * Display course rating value only */ if ( ! function_exists( 'upstudy_lp_course_rating_value' ) ) : function upstudy_lp_course_rating_value() { if ( ! class_exists( 'LP_Addon_Course_Review_Preload' ) ) : return; endif; $course_rate_res = learn_press_get_course_rate( get_the_ID(), false ); $course_rate = $course_rate_res['rated']; $total = $course_rate_res['total']; $ratings = learn_press_get_course_rate_total( get_the_ID() ); return number_format( $course_rate, 1 ); } endif; /** * Generate wishlist icon */ if ( ! function_exists( 'upstudy_lp_wishlist_icon' ) ) : function upstudy_lp_wishlist_icon( $course_id ){ $user_id = get_current_user_id(); if ( ! class_exists( 'LP_Addon_Wishlist' ) || ! $course_id ) : return; endif; if ( ! $user_id ) : echo ''; return; endif; $classes = array( 'course-wishlist' ); $state = learn_press_user_wishlist_has_course( $course_id, $user_id ) ? 'on' : 'off'; if ( 'on' === $state ) : $classes[] = 'on'; endif; $classes = apply_filters( 'learn_press_course_wishlist_button_classes', $classes, $course_id ); $title = ( 'on' === $state ) ? __( 'Remove this course from your wishlist', 'upstudy' ) : __( 'Add this course to your wishlist', 'upstudy' ); printf( '', join( " ", $classes ), $course_id, wp_create_nonce( 'course-toggle-wishlist' ), $title ); } endif; /** * Curriculum section title */ if ( ! function_exists( 'upstudy_lp_curriculum_section_title' ) ) : function upstudy_lp_curriculum_section_title( $section ) { learn_press_get_template( 'custom/curriculum-title.php', array( 'section' => $section ) ); } endif; /** * LearnPress Course * @return boolean */ function upstudy_is_lp_courses() { if ( learn_press_is_courses() || learn_press_is_course_tag() || learn_press_is_course_category() || learn_press_is_course_tax() || learn_press_is_search() ) : return true; endif; return false; } /** * LP breadcrumb delimiter */ add_filter( 'learn_press_breadcrumb_defaults', 'upstudy_lp_breadcrumb_delimiter' ); if( ! function_exists( 'upstudy_lp_breadcrumb_delimiter' ) ) : function upstudy_lp_breadcrumb_delimiter( $args ) { $args['delimiter'] = ''; return $args; } endif; /** * indexing result of courses */ if( ! function_exists( 'upstudy_lp_course_index_result' ) ) : function upstudy_lp_course_index_result( $total ) { if ( 0 === $total ) : $result = __( 'There are no available courses!', 'upstudy' ); elseif ( 1 === $total ) : $result = __( 'Showing only one result.', 'upstudy' ); else : $courses_per_page = absint( LP()->settings->get( 'archive_course_limit' ) ); $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $from = 1 + ( $paged - 1 ) * $courses_per_page; $to = ( $paged * $courses_per_page > $total ) ? $total : $paged * $courses_per_page; if ( $from == $to ) : $result = sprintf( __( 'Showing Last Course Of %s Results', 'upstudy' ), $total ); else : $result = sprintf( __( 'Showing %s-%s Of %s Results', 'upstudy' ), '' . $from, $to . '', '' . $total . '' ); endif; endif; echo wp_kses_post( $result ); } endif; /** * Course archive top bar */ if( ! function_exists( 'upstudy_lp_course_header_top_bar' ) ) : function upstudy_lp_course_header_top_bar( $query ) { global $wp_query; $top_bar = true; $index = true; $search_bar = true; if ( true == $index && true == $search_bar ) : $column = 'upstudy-col-md-6'; else : $column = 'upstudy-col-md-12'; endif; if ( ( true == $top_bar ) && ( true == $index || true == $search_bar ) ) : echo '
'; echo '
'; if ( true == $index ) : echo '
'; echo ''; upstudy_lp_course_index_result( $query->found_posts ); echo ''; echo '
'; endif; if ( true == $search_bar ) : echo '
'; echo ''; echo '
'; endif; echo '
'; echo '
'; endif; } endif; /** * Course archive search bar */ if( ! function_exists( 'upstudy_lp_course_archive_search_bar' ) ) : function upstudy_lp_course_archive_search_bar() { /* * remove param action="' . esc_url( get_post_type_archive_link( 'lp_course' ) ) . '" * if you don't want to redirect to course category archive */ echo ''; } endif; /** * Main Content Wrapper Class for LearnPress * Course Archive & Course Details */ add_filter( 'upstudy_main_content_inner', 'upstudy_lp_main_content_wrapper_class' ); if( ! function_exists( 'upstudy_lp_main_content_wrapper_class' ) ) : function upstudy_lp_main_content_wrapper_class( $class ) { if ( learn_press_is_courses() || learn_press_is_course_tag() || learn_press_is_course_category() || learn_press_is_course_tax() || learn_press_is_search() ) : $class = ''; elseif ( is_singular( 'lp_course' ) ) : $class = ' upstudy-row'; endif; return $class; } endif; /** * Remove and Modify Tab Items From * LearnPress Course Details Page */ add_filter( 'learn-press/course-tabs', 'upstudy_lp_instructor_tab_modify' ); if( ! function_exists( 'upstudy_lp_instructor_tab_modify' ) ) : function upstudy_lp_instructor_tab_modify( $tabs ) { $lp_overview_tab_text = Upstudy::setting( 'lp_overview_tab_text' ); $lp_curriculum_tab_text = Upstudy::setting( 'lp_curriculum_tab_text' ); $lp_instructor_tab_show = Upstudy::setting( 'lp_instructor_tab_show' ); $lp_instructor_tab_text = Upstudy::setting( 'lp_instructor_tab_text' ); $lp_faqs_tab_show = Upstudy::setting( 'lp_faqs_tab_show' ); $lp_faqs_tab_text = Upstudy::setting( 'lp_faqs_tab_text' ); $lp_curriculum_tab_show = Upstudy::setting( 'lp_curriculum_tab_show' ); $lp_review_tab_show = Upstudy::setting( 'lp_review_tab_show' ); $lp_reviews_tab_text = Upstudy::setting( 'lp_reviews_tab_text' ); if ( $lp_overview_tab_text ) : $tabs['overview']['title'] = $lp_overview_tab_text; endif; if ( true == $lp_instructor_tab_show ) : if ( $lp_overview_tab_text ) : $tabs['instructor']['title'] = $lp_instructor_tab_text; endif; else : unset( $tabs['instructor'] ); endif; if ( true == $lp_curriculum_tab_show ) : if ( $lp_curriculum_tab_text ) : $tabs['curriculum']['title'] = $lp_curriculum_tab_text; endif; else : unset( $tabs['curriculum'] ); endif; if ( isset( $tabs['faqs'] ) && ! empty( $tabs['faqs'] ) ) : if ( true == $lp_faqs_tab_show ) : if ( $lp_faqs_tab_text ) : $tabs['faqs']['title'] = $lp_faqs_tab_text; endif; else : unset( $tabs['faqs'] ); endif; endif; if ( class_exists( 'LP_Addon_Course_Review_Preload' ) ) : if ( true == $lp_review_tab_show ) : if ( $lp_overview_tab_text ) : $tabs['reviews']['title'] = $lp_reviews_tab_text; endif; else : unset( $tabs['reviews'] ); endif; endif; return $tabs; } endif; /** * Remove and Modify Tab Items From * LearnPress Course Details Page (---Offline Courses--) */ add_filter( 'learn-press/course-tabs', 'upstudy_lp_offline_course_tab_modify' ); if( ! function_exists( 'upstudy_lp_offline_course_tab_modify' ) ) : function upstudy_lp_offline_course_tab_modify( $tabs ) { $lp_deliver_type = get_post_meta(get_the_ID(), '_lp_deliver_type'); $lp_offline_course = get_post_meta(get_the_ID(), '_lp_offline_course'); $lp_address = get_post_meta(get_the_ID(), '_lp_address'); $lp_offline_lesson_count = get_post_meta(get_the_ID(), '_lp_offline_lesson_count'); if ( isset( $lp_offline_course[0] ) && $lp_offline_course[0] === 'yes' ) { unset( $tabs['curriculum'] ); } return $tabs; } endif; /** * Override Button (---Offline Courses--) */ function custom_learnpress_external_link_text( $text, $course_id ) { $lp_offline_course = get_post_meta( $course_id, '_lp_offline_course', true ); if ( is_array( $lp_offline_course ) && isset( $lp_offline_course[0] ) && $lp_offline_course[0] === 'yes' ) { return esc_html__( 'More info', 'upstudy' ); } return esc_html__( 'Contact To Request', 'upstudy' ); } add_filter( 'learn-press/course-external-link-text', 'custom_learnpress_external_link_text', 10, 2 ); /** * Course Taxonomy Archive Page Query * Only for Category( 'course_category' ) and * Tag( 'course_tag' ) Archive Pages */ add_filter( 'upstudy_lp_course_archive_args', 'upstudy_lp_course_taxonomy_filter_archive' ); if( ! function_exists( 'upstudy_lp_course_taxonomy_filter_archive' ) ) : function upstudy_lp_course_taxonomy_filter_archive( $args ) { $category = get_queried_object(); if ( learn_press_is_course_archive() ) : if ( isset( $category->taxonomy ) && 'course_category' === $category->taxonomy ) : $args['tax_query'] = array( array( 'taxonomy' => 'course_category', 'field' => 'term_id', 'terms' => array( $category->term_id ) ) ); elseif ( isset( $category->taxonomy ) && 'course_tag' === $category->taxonomy ) : $args['tax_query'] = array( array( 'taxonomy' => 'course_tag', 'field' => 'term_id', 'terms' => array( $category->term_id ) ) ); endif; endif; return $args; } endif; /** * Course Archive Search Filter */ add_filter( 'upstudy_lp_course_archive_args', 'upstudy_lp_course_search_filter_archive' ); if( ! function_exists( 'upstudy_lp_course_search_filter_archive' ) ) : function upstudy_lp_course_search_filter_archive( $args ) { if ( learn_press_is_course_archive() ) : if ( isset( $_REQUEST['tpc_lp_course_filter'] ) && 'lp_course_search' === $_REQUEST['tpc_lp_course_filter'] ) : $args['s'] = sanitize_text_field( $_REQUEST['search_query'] ); endif; endif; return $args; } endif; /** * Course Archive Main Filter */ add_filter( 'upstudy_lp_course_archive_args', 'upstudy_lp_course_category_filter_archive' ); if( ! function_exists( 'upstudy_lp_course_category_filter_archive' ) ) : function upstudy_lp_course_category_filter_archive( $args ) { if ( learn_press_is_course_archive() ) : if ( ! empty( $_GET['filter-category'] ) ) : if ( is_array( $_GET['filter-category'] ) ) : $args['tax_query'] = array( array( 'taxonomy' => 'course_category', 'field' => 'term_id', 'terms' => array_map( 'sanitize_text_field', $_GET['filter-category'] ), 'compare' => 'IN' ) ); else : $args['tax_query'] = array( array( 'taxonomy' => 'course_category', 'field' => 'term_id', 'terms' => sanitize_text_field( $_GET['filter-category'] ), 'compare' => '==' ) ); endif; endif; if ( ! empty( $_GET['filter-level'] ) ) : if ( is_array( $_GET['filter-level'] ) ) : $args['meta_query'][] = array( 'key' => '_lp_level', 'value' => array_map( 'sanitize_text_field', $_GET['filter-level'] ), 'compare' => 'IN' ); else : $args['meta_query'][] = array( 'key' => '_lp_level', 'value' => sanitize_text_field( $_GET['filter-level'] ), 'compare' => '=' ); endif; endif; endif; return $args; } endif; /** * Course Duration * */ if( ! function_exists( 'upstudy_lp_course_duration_customize' ) ) : function upstudy_lp_course_duration_customize( $duration ) { $duration_number = absint( $duration ); $duration_text = str_replace( $duration_number, '', $duration ); $duration_text = trim( $duration_text ); switch ( $duration_text ) : case 'minute': $duration_text = $duration_number > 1 ? __( 'minutes', 'upstudy' ) : __( 'minute', 'upstudy' ); break; case 'hour': $duration_text = $duration_number > 1 ? __( 'hours', 'upstudy' ) : __( 'hour', 'upstudy' ); break; case 'day': $duration_text = $duration_number > 1 ? __( 'days', 'upstudy' ) : __( 'day', 'upstudy' ); break; case 'week': $duration_text = $duration_number > 1 ? __( 'weeks', 'upstudy' ) : __( 'week', 'upstudy' ); break; endswitch; return $duration_number . ' ' . $duration_text; } endif;