request), '/profile/') !== false && function_exists('tutor') && $tutor_hide_profile_page_header == true ) { $classes[] = 'upstudy_tutor_profile_page'; } // Get body class for tutor lms profile page if ( function_exists('tutor') && $tutor_single_page_layout && is_singular( 'courses' )) { $classes[] = 'single-course-layout-0'.$tutor_single_page_layout.''; } // 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( 'tutor_instructor_single' ) || Upstudy::setting( 'tutor_single_wishlist' ) ) ? true : false; if ( function_exists('tutor') && $has_meta && is_singular( 'courses' )) { $classes[] = 'has__meta'; } // Finally $classes return return $classes; } add_filter( 'body_class', 'add_body_classes_for_tutor_lms' ); /** * Display Course Category */ if ( ! function_exists( 'upstudy_tutor_course_category' ) ) { function upstudy_tutor_course_category() { global $post; $post_id = $post->ID; ?>

'course-category', 'orderby' => 'name', 'order' => 'ASC' ); $terms = get_categories($args); if ($terms && ! is_wp_error($terms)): ?>
'; if ( !in_array( $tutor_single_page_layout, array('5')) ) { echo '

' . esc_html__( 'Course Includes', 'upstudy' ) . '

'; } echo ''; echo ''; } } /** * Display related courses Content */ if ( ! function_exists( 'upstudy_tutor_related_course_content' ) ) { function upstudy_tutor_related_course_content( $postType = 'courses', $postID = null, $totalPosts = null, $relatedBy = null) { $tutor_related_course_title = Upstudy::setting( 'tutor_related_course_title' ); $tutor_related_course_items = Upstudy::setting( 'tutor_related_course_items' ); $tutor_related_course_by = Upstudy::setting( 'tutor_related_course_by' ); $tutor_related_course_columns = Upstudy::setting( "tutor_related_course_columns" ); $args = array( 'style' => $style = Upstudy::setting( 'tutor_course_archive_style' ) ); global $post, $related_posts_custom_query_args; if (null === $postID) $postID = $post->ID; if (null === $totalPosts) $totalPosts = $tutor_related_course_items; if (null === $relatedBy) $relatedBy = $tutor_related_course_by; if (null === $postType) $postType = 'courses'; // 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 '
'; 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_tutor_related_course_sidebar' ) ) { function upstudy_tutor_related_course_sidebar( $postType = 'courses', $postID = null, $totalPosts = null, $relatedBy = null) { $tutor_related_course_title = Upstudy::setting( 'tutor_related_course_title' ); $tutor_related_course_items = Upstudy::setting( 'tutor_related_course_items' ); $tutor_related_course_by = Upstudy::setting( 'tutor_related_course_by' ); $tutor_related_course_style = Upstudy::setting( 'tutor_related_course_style' ); $final_tutor_related_course_style = ($tutor_related_course_style == 'square') ? 'square' : 'round'; global $post, $related_posts_custom_query_args; if (null === $postID) $postID = $post->ID; if (null === $totalPosts) $totalPosts = $tutor_related_course_items; if (null === $relatedBy) $relatedBy = $tutor_related_course_by; if (null === $postType) $postType = 'courses'; // 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 '
'; echo '
'; if ( $tutor_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '
'; if ( $tutor_single_review ) : $course_rating = tutor_utils()->get_course_rating( get_the_ID() ); echo '
'; echo ''; echo tutor_utils()->star_rating_generator_v2( $course_rating->rating_avg, null, false, '', 'lg' ); echo ''; echo ''; $total_text = ('1' == $course_rating) ? esc_html__(' Rating', 'upstudy') : esc_html__(' Ratings', 'upstudy'); echo esc_attr(' ('); echo esc_html( $course_rating->rating_count > 0 ? $course_rating->rating_count : 0 ); echo esc_html($total_text); echo esc_attr(')'); echo ''; echo '
'; // End .upstudy-rating-wrap endif; echo '<'.$tutor_single_title_tag.' class="page-title has-text-align-left">'; the_title(); echo ''; echo '
'; if ( $tutor_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; upstudy_breadcrumb_shapes(); // get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo ''; } endif; // ===== upstudy_tutor_course_page_title_section_03 if ( ! function_exists( 'upstudy_tutor_course_page_title_section_03' ) ) : function upstudy_tutor_course_page_title_section_03( $title = null, $has_bg_image = null, $extra_style = null ) { $tutor_single_excerpt = Upstudy::setting( 'tutor_single_excerpt' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); $tutor_single_page_layout = Upstudy::setting( 'tutor_single_page_layout' ); $tutor_header_color = ( $tutor_single_page_layout == '4' ) ? 'light' : 'dark' ; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $tutor_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '<'.$tutor_single_title_tag.' class="course-title">'; the_title(); echo ''; if ( $tutor_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; // get_template_part( 'tutor/tpl-part/single/meta', 'review-update' ); get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; /** * Course page title section upstudy_tutor_course_page_title_section_05 */ if ( ! function_exists( 'upstudy_tutor_course_page_title_section_05' ) ) : function upstudy_tutor_course_page_title_section_05( $title = null, $has_bg_image = null, $extra_style = null ) { $tutor_single_excerpt = Upstudy::setting( 'tutor_single_excerpt' ); $tutor_single_review = Upstudy::setting( 'tutor_single_review' ); $tutor_single_last_update = Upstudy::setting( 'tutor_single_last_update' ); $tutor_single_page_layout = Upstudy::setting( 'tutor_single_page_layout' ); $tutor_header_color = ( $tutor_single_page_layout == '4' ) ? 'light' : 'dark' ; $tutor_single_title_tag = Upstudy::setting( 'tutor_single_title_tag' ); $header_page_title_align = Upstudy::setting( 'header_page_title_align' ); $tutor_course_header_style = Upstudy::setting( 'tutor_course_header_style' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; if ( $tutor_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '
'; // echo '
'; // if (!get_the_terms(get_the_ID(), 'course-category')) { // esc_html_e('Uncategorized', 'upstudy'); // } else { // echo get_the_term_list(get_the_ID(), 'course-category', ''); // } // echo '
'; if ( $tutor_single_review ) : $course_rating = tutor_utils()->get_course_rating( get_the_ID() ); echo '
'; echo ''; echo tutor_utils()->star_rating_generator_v2( $course_rating->rating_avg, null, false, '', 'lg' ); echo ''; echo ''; $total_text = ('1' == $course_rating) ? esc_html__(' Rating', 'upstudy') : esc_html__(' Ratings', 'upstudy'); echo esc_attr(' ('); echo esc_html( $course_rating->rating_count > 0 ? $course_rating->rating_count : 0 ); echo esc_html($total_text); echo esc_attr(')'); echo ''; echo '
'; // End .upstudy-rating-wrap endif; echo '<'.$tutor_single_title_tag.' class="page-title has-text-align-'.$header_page_title_align.'">'; the_title(); echo ''; echo '
'; if ( $tutor_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; upstudy_breadcrumb_shapes(); get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; // ===== upstudy_tutor_course_page_title_section_04 ==== if ( ! function_exists( 'upstudy_tutor_course_page_title_section_04' ) ) : function upstudy_tutor_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_'; $tutor_single_excerpt = Upstudy::setting( 'tutor_single_excerpt' ); $tutor_single_review = Upstudy::setting( 'tutor_single_review' ); $tutor_single_last_update = Upstudy::setting( 'tutor_single_last_update' ); $tutor_single_page_layout = Upstudy::setting( 'tutor_single_page_layout' ); $tutor_header_color = ( $tutor_single_page_layout == '4' ) ? 'light' : 'dark' ; $page_header_img = get_post_meta($post_id, $prefix . 'header_img', true); $tutor_intro_video_position = Upstudy::setting( 'tutor_intro_video_position' ); $tutor_single_social_shear = Upstudy::setting( 'tutor_single_social_shear ' ); $breadcrumb_show = Upstudy::setting( 'breadcrumb_show' ); $shortcode_breadcrumb = Upstudy::setting( 'shortcode_breadcrumb' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); $custom_page_header_img = get_post_meta( get_the_ID(), '_upstudy_header_img', 1 ); $page_title_image_sourse = ( !empty( $custom_page_header_img )) ? $custom_page_header_img : get_header_image() ; echo '
'; echo '
'; echo '
'; echo '
'; if ( $tutor_single_page_layout == '5' ) { get_template_part( 'tutor/tpl-part/single/media', 'header' ); } echo '
'; // End upstudy-col-lg-4 echo '
'; echo '
'; if ( $tutor_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '<'.$tutor_single_title_tag.' class="course-title">'; the_title(); echo ''; if ( $tutor_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; // End upstudy-col-lg-8 echo '
'; // End upstudy-row echo '
'; // End upstudy-container echo '
'; // End upstudy-course-top-info } endif; // ===== upstudy_tutor_course_page_title_section_06 if ( ! function_exists( 'upstudy_tutor_course_page_title_section_06' ) ) : function upstudy_tutor_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 ); $tutor_course_header_style = Upstudy::setting( 'tutor_course_header_style' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '<'.$tutor_single_title_tag.' class="entry-title">'; the_title(); echo ''; echo '
'; echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; // ===== upstudy_tutor_course_page_title_section_07 if ( ! function_exists( 'upstudy_tutor_course_page_title_section_07' ) ) : function upstudy_tutor_course_page_title_section_07( $title = null, $has_bg_image = null, $extra_style = null ) { $custom_page_header_img = get_post_meta( get_the_ID(), '_upstudy_header_img', 1 ); $tutor_course_header_style = Upstudy::setting( 'tutor_course_header_style' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '<'.$tutor_single_title_tag.' class="entry-title">'; the_title(); echo ''; echo '
'; echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; /** * Course page title section upstudy_tutor_course_page_title_section_08 */ if ( ! function_exists( 'upstudy_tutor_course_page_title_section_08' ) ) : function upstudy_tutor_course_page_title_section_08( $title = null, $has_bg_image = null, $extra_style = null ) { $tutor_single_excerpt = Upstudy::setting( 'tutor_single_excerpt' ); $tutor_single_review = Upstudy::setting( 'tutor_single_review' ); $tutor_single_last_update = Upstudy::setting( 'tutor_single_last_update' ); $tutor_single_page_layout = Upstudy::setting( 'tutor_single_page_layout' ); $tutor_header_color = 'upstudy-dark-header'; $tutor_single_title_tag = Upstudy::setting( 'tutor_single_title_tag' ); $header_page_title_align = 'left'; $tutor_course_header_style = Upstudy::setting( 'tutor_course_header_style' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $tutor_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '<'.$tutor_single_title_tag.' class="course-title">'; the_title(); echo ''; if ( $tutor_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; echo '
'; echo '
'; tutor_load_template( 'single.course.course-entry-box' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; /** * Course page title section upstudy_tutor_course_page_title_section_09 */ if ( ! function_exists( 'upstudy_tutor_course_page_title_section_09' ) ) : function upstudy_tutor_course_page_title_section_09( $title = null, $has_bg_image = null, $extra_style = null ) { $tutor_single_excerpt = Upstudy::setting( 'tutor_single_excerpt' ); $tutor_single_review = Upstudy::setting( 'tutor_single_review' ); $tutor_single_last_update = Upstudy::setting( 'tutor_single_last_update' ); $tutor_single_page_layout = Upstudy::setting( 'tutor_single_page_layout' ); $tutor_header_color = 'upstudy-dark-header'; $tutor_single_title_tag = Upstudy::setting( 'tutor_single_title_tag' ); $header_page_title_align = 'left'; $tutor_course_header_style = Upstudy::setting( 'tutor_course_header_style' ); $tutor_single_breadcrumb = Upstudy::setting( 'tutor_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $tutor_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '<'.$tutor_single_title_tag.' class="course-title">'; the_title(); echo ''; if ( $tutor_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; get_template_part( 'tutor/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; echo '
'; echo '
'; get_template_part( 'tutor/tpl-part/single/media', 'content' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; /** * upstudy_tutor_course_page_title_section_10 */ if ( ! function_exists( 'upstudy_tutor_course_page_title_section_10' ) ) : function upstudy_tutor_course_page_title_section_10( $title = null, $extra_style = null ) { $breadcrumb_show = Upstudy::setting( 'breadcrumb_show' ) ?: true; $bg_meta_image = get_post_meta( get_the_ID(), '_upstudy_header_img', true ); $bg_meta_color = get_post_meta( get_the_ID(), '_upstudy_page_title_bg_color', true ); $bg_framework_image = get_header_image(); $bg_framework_color = Upstudy::setting( 'header_banner_overlay_color' ) ?: 'header_image'; if ( $bg_meta_color ) : $style[] = 'background-color:' . $bg_meta_color; elseif ( $bg_framework_color ) : $style[] = 'background-color:' . $bg_framework_color; endif; if ( $bg_meta_image ) : $style[] = 'background-image:url(\''.esc_url( $bg_meta_image ).'\' )'; $has_bg_image = 'upstudy-breadcrumb-has-bg'; elseif ( ! $default_breadcrumb_at_page ) : $breadcrumb_img = get_header_image(); if ( isset( $breadcrumb_img['url'] ) && ! empty( $breadcrumb_img['url'] ) ) : $style[] = 'background-image:url(\'' . esc_url( $breadcrumb_img['url'] ) . '\' )'; $has_bg_image = 'upstudy-breadcrumb-has-bg'; endif; endif; echo '
'; echo '
'; echo '
'; echo '<'.$tutor_single_title_tag.' class="entry-title">'; the_title(); echo ''; echo '
'; if ($breadcrumb_show) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '
'; echo '
'; } endif; // ====== Old existing functions /** * Course Search Post Type */ add_filter( 'upstudy_course_search_post_type', 'upstudy_tl_course_search_post_type' ); if ( ! function_exists( 'upstudy_tl_course_search_post_type' ) ) : function upstudy_tl_course_search_post_type() { return 'courses'; } endif; /** * Generate wishlist icon * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_tutor_wishlist_icon' ) ) : function upstudy_tutor_wishlist_icon( $course_id ) { $course_id = get_the_ID(); $is_wish_listed = tutor_utils()->is_wishlisted( $course_id ); $login_url_attr = ''; $action_class = ''; if ( is_user_logged_in() ) { $action_class = apply_filters( 'tutor_wishlist_btn_class', 'tutor-course-wishlist-btn' ); } else { $action_class = apply_filters( 'tutor_popup_login_class', 'tutor-open-login-modal' ); if ( ! tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ) ) { $login_url_attr = 'data-login_url="' . esc_url( wp_login_url() ) . '"'; } } //phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- $login_url_attr contain safe data echo ' '; } endif; /** * Sale tag for promotional courses * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_tutor_course_sale_tag' ) ) : function upstudy_tutor_course_sale_tag() { $course_price = tutor_utils()->get_raw_course_price( get_the_ID() ); $regular_price = $course_price->regular_price; $sale_price = $course_price->sale_price; if ( empty( $sale_price ) ) : return; endif; if ( $regular_price != $sale_price ) : printf( '%s', apply_filters( 'upstudy_course_sale_tag_text', __( 'Sale', 'upstudy' ) ) ); endif; } endif; /** * post_class extends for tutor courses * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_tutor_course_class' ) ) : function upstudy_tutor_course_class( $default = array() ) { $terms = get_the_terms( get_the_ID(), 'course-category' ); $terms_html = array(); if ( $terms ) : foreach ( $terms as $term ) : $terms_html[] = $term->slug; endforeach; endif; $all_classes = array_merge( $terms_html, $default ); $classes = apply_filters( 'upstudy_tutor_course_class', $all_classes ); post_class( $classes ); } endif;