is_main_query() ) : return; endif; if ( isset( $_GET['ldauthor'] ) ) : $ldauthor = $_GET['ldauthor']; else : $ldauthor = false; endif; if ( is_author() && ( 'true' == $ldauthor ) && ( true == $author_redirect_to_courses ) ) : $query->set( 'post_type', array( 'sfwd-courses' ) ); endif; } endif; /** * LearnDash specific scripts & stylesheets. * * @return void * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_ld_scripts' ) ) : function upstudy_ld_scripts() { wp_enqueue_style( 'upstudy-ld-style', get_template_directory_uri() . '/assets/css/learndash.css', array(), UPSTUDY_THEME_VERSION ); if ( is_singular( 'sfwd-courses' ) ) : wp_enqueue_style( 'jquery-fancybox' ); wp_enqueue_script( 'jquery-fancybox' ); endif; } endif; add_action( 'wp_enqueue_scripts', 'upstudy_ld_scripts' ); /** * post_class extends for learndash courses * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_ld_course_class' ) ) : function upstudy_ld_course_class( $default = array() ) { $terms = get_the_terms( get_the_ID(), 'ld_course_category' ); $terms_html = array(); if ( is_array( $terms ) ) : foreach ( $terms as $term ) : $terms_html[] = $term->slug; endforeach; endif; $all_classes = array_merge( $terms_html, $default ); $classes = apply_filters( 'upstudy_ld_course_class', $all_classes ); post_class( $classes ); } endif; /** * Content area class */ add_filter( 'upstudy_content_area_class', 'upstudy_ld_content_area_class' ); if ( ! function_exists( 'upstudy_ld_content_area_class' ) ) : function upstudy_ld_content_area_class ( $class ) { if ( is_post_type_archive( 'sfwd-courses' ) || is_tax( 'ld_course_category' ) || is_tax( 'ld_course_tag' ) ) : $course_layout = 'full_width'; if ( 'right' === $course_layout ) : $class = 'upstudy-col-lg-9'; elseif ( 'left' === $course_layout ) : $class = 'upstudy-col-lg-9 upstudy-order-1'; elseif ( 'full_width' === $course_layout ) : $class = 'upstudy-col-lg-12'; endif; endif; if ( is_singular( 'sfwd-courses' ) ) : $single_course_layout = 'full_width'; if ( 'right' === $single_course_layout ) : $class = 'upstudy-col-lg-9'; elseif ( 'left' === $single_course_layout ) : $class = 'upstudy-col-lg-9 upstudy-order-1'; elseif ( 'full_width' === $single_course_layout ) : $class = 'upstudy-col-lg-12'; endif; endif; return $class; } endif; /** * Content area class for Author( As Instructor ) Archive */ add_filter( 'upstudy_content_area_class', 'upstudy_ld_author_archive_content_area_class' ); if ( ! function_exists( 'upstudy_ld_author_archive_content_area_class' ) ) : function upstudy_ld_author_archive_content_area_class ( $class ) { $author_redirect_to_courses = apply_filters( 'upstudy_ld_author_redirect_to_course', false ); if ( isset( $_GET['ldauthor'] ) ) : $ldauthor = $_GET['ldauthor']; else : $ldauthor = false; endif; if ( true == $author_redirect_to_courses && 'true' == $ldauthor ) : $class = 'upstudy-col-lg-12'; endif; return $class; } endif; /** * Archive & Single Sidebar Type */ add_filter( 'upstudy_archive_sidebar_layout', 'upstudy_archive_ld_sidebar_layout' ); add_filter( 'upstudy_single_sidebar_layout', 'upstudy_archive_ld_sidebar_layout' ); if ( ! function_exists( 'upstudy_archive_ld_sidebar_layout' ) ) : function upstudy_archive_ld_sidebar_layout ( $class ) { if ( is_post_type_archive( 'sfwd-courses' ) || is_tax( 'ld_course_category' ) || is_tax( 'ld_course_tag' ) || is_singular( 'sfwd-courses' ) ) : $class = 'no-sidebar'; endif; return $class; } endif; /** * Single Course Thumbnail */ if ( ! function_exists( 'upstudy_ld_single_course_thumbnail' ) ) : function upstudy_ld_single_course_thumbnail(){ $thumb_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); if ( isset( $thumb_src ) && ! empty( $thumb_src ) ) : $thumb_url = $thumb_src[0]; else : $thumb_url = get_template_directory_uri() . '/assets/images/no-image-found.png'; endif; echo '
'; } endif; /** * Course Search Post Type */ add_filter( 'upstudy_course_search_post_type', 'upstudy_ld_course_search_post_type' ); if ( ! function_exists( 'upstudy_ld_course_search_post_type' ) ) : function upstudy_ld_course_search_post_type() { return 'sfwd-courses'; } endif; /** * Header Course Category Slug */ add_filter( 'upstudy_header_course_lms_cat_slug', 'upstudy_header_course_ld_cat_slug' ); if ( ! function_exists( 'upstudy_header_course_ld_cat_slug' ) ) : function upstudy_header_course_ld_cat_slug() { return 'ld_course_category'; } endif; /** * Count Course Data */ if ( ! function_exists( 'upstudy_ld_count_published_posts' ) ) : function upstudy_ld_count_published_posts( $post_type ) { $count_posts = wp_count_posts( $post_type ); if ( $count_posts->publish ) : return $count_posts->publish; else : return 0; endif; } endif; /** * Course Archive Search Filter */ add_filter( 'upstudy_ld_course_archive_args', 'upstudy_ld_course_search_filter_archive' ); if( ! function_exists( 'upstudy_ld_course_search_filter_archive' ) ) : function upstudy_ld_course_search_filter_archive( $args ) { if ( is_post_type_archive( 'sfwd-courses' ) ) : if ( isset( $_REQUEST['tpc_ld_course_filter'] ) && 'ld_course_search' === $_REQUEST['tpc_ld_course_filter'] ) : $args['s'] = sanitize_text_field( $_REQUEST['search_query'] ); endif; endif; return $args; } endif; /** * indexing result of courses */ if( ! function_exists( 'upstudy_ld_course_index_result' ) ) : function upstudy_ld_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 = Upstudy::setting( 'ld_course_per_page' ) ? Upstudy::setting( 'ld_course_per_page' ) : 9; $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 search bar */ if( ! function_exists( 'upstudy_ld_course_archive_search_bar' ) ) : function upstudy_ld_course_archive_search_bar() { /* * remove param action="' . esc_url( get_post_type_archive_link( 'sfwd-courses ) ) . '" * if you don't want to redirect to course category archive */ echo ''; } endif; /** * Course archive top bar */ if( ! function_exists( 'upstudy_ld_course_header_top_bar' ) ) : function upstudy_ld_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_ld_course_index_result( $query->found_posts ); echo ''; echo '
'; endif; if ( true == $search_bar ) : echo '
'; echo ''; echo '
'; endif; echo '
'; echo '
'; endif; } endif; /** * LearnDash Course Rating Active * */ if( ! function_exists( 'is_upstudy_ld_rating_enable' ) ) : function is_upstudy_ld_rating_enable() { $status = true; return $status; } endif; /** * Get Woocommerce course price * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_get_wc_course_price' ) ) : function upstudy_get_wc_course_price( $product_id = null ) { if ( empty( $product_id ) ) : return ''; endif; $product = wc_get_product( $product_id ); if ( ! $product ) : return ''; endif; return $product->get_price_html(); } endif; /** * Currency symbols * * @param string $currency currency code such as USD, EUR * @param int $course_id course ID * @return string currency symbol * * @since 1.0.0 */ if ( ! function_exists( 'upstudy_ld_course_currency_symbols' ) ) : function upstudy_ld_course_currency_symbols( $currency, $course_id = null ) { $currency_symbols = apply_filters( 'upstudy_ld_course_currency_symbols', array( 'AED' => 'د.إ', 'AFN' => '؋', 'ALL' => 'L', 'AMD' => 'AMD', 'ANG' => 'ƒ', 'AOA' => 'Kz', 'ARS' => '$', 'AUD' => '$', 'AWG' => 'Afl.', 'AZN' => 'AZN', 'BAM' => 'KM', 'BBD' => '$', 'BDT' => '৳', 'BGN' => 'лв.', 'BHD' => '.د.ب', 'BIF' => 'Fr', 'BMD' => '$', 'BND' => '$', 'BOB' => 'Bs.', 'BRL' => 'R$', 'BSD' => '$', 'BTC' => '฿', 'BTN' => 'Nu.', 'BWP' => 'P', 'BYR' => 'Br', 'BYN' => 'Br', 'BZD' => '$', 'CAD' => '$', 'CDF' => 'Fr', 'CHF' => 'CHF', 'CLP' => '$', 'CNY' => '¥', 'COP' => '$', 'CRC' => '₡', 'CUC' => '$', 'CUP' => '$', 'CVE' => '$', 'CZK' => 'Kč', 'DJF' => 'Fr', 'DKK' => 'DKK', 'DOP' => 'RD$', 'DZD' => 'د.ج', 'EGP' => 'EGP', 'ERN' => 'Nfk', 'ETB' => 'Br', 'EUR' => '€', 'FJD' => '$', 'FKP' => '£', 'GBP' => '£', 'GEL' => '₾', 'GGP' => '£', 'GHS' => '₵', 'GIP' => '£', 'GMD' => 'D', 'GNF' => 'Fr', 'GTQ' => 'Q', 'GYD' => '$', 'HKD' => '$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', 'HUF' => 'Ft', 'IDR' => 'Rp', 'ILS' => '₪', 'IMP' => '£', 'INR' => '₹', 'IQD' => 'ع.د', 'IRR' => '﷼', 'IRT' => 'تومان', 'ISK' => 'kr.', 'JEP' => '£', 'JMD' => '$', 'JOD' => 'د.ا', 'JPY' => '¥', 'KES' => 'KSh', 'KGS' => 'сом', 'KHR' => '៛', 'KMF' => 'Fr', 'KPW' => '₩', 'KRW' => '₩', 'KWD' => 'د.ك', 'KYD' => '$', 'KZT' => '₸', 'LAK' => '₭', 'LBP' => 'ل.ل', 'LKR' => 'රු', 'LRD' => '$', 'LSL' => 'L', 'LYD' => 'ل.د', 'MAD' => 'د.م.', 'MDL' => 'MDL', 'MGA' => 'Ar', 'MKD' => 'ден', 'MMK' => 'Ks', 'MNT' => '₮', 'MOP' => 'P', 'MRU' => 'UM', 'MUR' => '₨', 'MVR' => '.ރ', 'MWK' => 'MK', 'MXN' => '$', 'MYR' => 'RM', 'MZN' => 'MT', 'NAD' => 'N$', 'NGN' => '₦', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => '₨', 'NZD' => '$', 'OMR' => 'ر.ع.', 'PAB' => 'B/.', 'PEN' => 'S/', 'PGK' => 'K', 'PHP' => '₱', 'PKR' => '₨', 'PLN' => 'zł', 'PRB' => 'р.', 'PYG' => '₲', 'QAR' => 'ر.ق', 'RMB' => '¥', 'RON' => 'lei', 'RSD' => 'рсд', 'RUB' => '₽', 'RWF' => 'Fr', 'SAR' => 'ر.س', 'SBD' => '$', 'SCR' => '₨', 'SDG' => 'ج.س.', 'SEK' => 'kr', 'SGD' => '$', 'SHP' => '£', 'SLL' => 'Le', 'SOS' => 'Sh', 'SRD' => '$', 'SSP' => '£', 'STN' => 'Db', 'SYP' => 'ل.س', 'SZL' => 'L', 'THB' => '฿', 'TJS' => 'ЅМ', 'TMT' => 'm', 'TND' => 'د.ت', 'TOP' => 'T$', 'TRY' => '₺', 'TTD' => '$', 'TWD' => 'NT$', 'TZS' => 'Sh', 'UAH' => '₴', 'UGX' => 'UGX', 'USD' => '$', 'UYU' => '$', 'UZS' => 'UZS', 'VEF' => 'Bs F', 'VES' => 'Bs.S', 'VND' => '₫', 'VUV' => 'Vt', 'WST' => 'T', 'XAF' => 'CFA', 'XCD' => '$', 'XOF' => 'CFA', 'XPF' => 'Fr', 'YER' => '﷼', 'ZAR' => 'R', 'ZMW' => 'ZK' ) ); return isset( $currency_symbols[ $currency ] ) ? $currency_symbols[ $currency ] : $currency; } endif; function upstudy_learndash_get_courses( $args = array() ) { $args = wp_parse_args( $args, array( 'author' => '', 'fields' => '' ) ); extract($args); $query_args = array( 'post_type' => 'sfwd-courses', 'post_status' => 'publish' ); if ( ! empty( $author ) ) : $query_args['author'] = $author; endif; if ( ! empty( $fields ) ) : $query_args['fields'] = $fields; endif; $loop = new WP_Query($query_args); $posts = array(); if ( ! empty( $loop->posts ) ) : $posts = $loop->posts; endif; return $posts; } /** * LearnDash compatibility * * @package Upstudy */ // add_body_classes_for_ld_lms // upstudy_ld_course_info // upstudy_ld_course_category // upstudy_ld_related_course_content // upstudy_ld_related_course_sidebar // upstudy_ld_course_page_title_section_03 // upstudy_ld_course_page_title_section_04 // upstudy_ld_course_page_title_section_05 // upstudy_ld_course_page_title_section_06 //** ==== LearnDash add body class ** ==== function add_body_classes_for_ld_lms( $classes ) { $prefix = '_upstudy_'; $post_id = upstudy_get_id(); $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $final_ld_single_page_layout = ''; if ( $ld_single_page_layout == '5' ) : $final_ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); elseif ( $ld_single_page_layout == '4' ) : $final_ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); elseif ( $ld_single_page_layout == '3' ) : $final_ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); elseif ( $ld_single_page_layout == '2' ) : $final_ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); elseif ( $ld_single_page_layout == '1' ) : $final_ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); endif; //End single page layout // Get body class for learndash lms profile page if ( class_exists('SFWD_LMS') && $final_ld_single_page_layout && is_singular( 'sfwd-courses' )) { $classes[] = 'single-course-layout-0'.$final_ld_single_page_layout.''; } // Get body class for ld lms course excerpt global $post; $post_id = $post->ID; $course_id = $post_id; $user_id = get_current_user_id(); $current_id = $post->ID; $prefix = '_upstudy_'; $ld_cg_short_description = get_post_meta( $post_id, '_learndash_course_grid_short_description', true ); $mb_short_description = get_post_meta( $post_id, '_upstudy_ld_excerpt', true ); $short_description = ($ld_cg_short_description) ? $ld_cg_short_description : $mb_short_description; if ( class_exists('SFWD_LMS') && $short_description && is_singular( 'sfwd-courses' )) { $classes[] = 'has__excerpt'; } // Get body class for ld lms course meta $has_meta = ( Upstudy::setting( 'ld_instructor_single' ) ) ? true : false; if ( class_exists('SFWD_LMS') && $has_meta && is_singular( 'sfwd-courses' )) { $classes[] = 'has__meta'; } // Finally $classes return return $classes; } add_filter( 'body_class', 'add_body_classes_for_ld_lms' ); // ==== Display Course info / upstudy_ld_course_info ===== if ( ! function_exists( 'upstudy_ld_course_info' ) ) { function upstudy_ld_course_info() { $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $ld_intro_video_position = Upstudy::setting( 'ld_intro_video_position' ); $ld_instructor_single = Upstudy::setting( 'ld_instructor_single' ); $ld_instructor_single_text = Upstudy::setting( 'ld_instructor_single_text' ); $ld_single_duration = Upstudy::setting( 'ld_single_duration' ); $ld_single_duration_text = Upstudy::setting( 'ld_single_duration_text' ); $ld_lesson_single = Upstudy::setting( 'ld_lesson_single' ); $ld_lesson_single_text = Upstudy::setting( 'ld_lesson_single_text' ); $ld_enrolled_single = Upstudy::setting( 'ld_enrolled_single' ); $ld_enrolled_single_text = Upstudy::setting( 'ld_enrolled_single_text' ); $ld_single_topic = Upstudy::setting( 'ld_single_topic' ); $ld_single_topic_text = Upstudy::setting( 'ld_single_topic_text' ); $ld_single_cat = Upstudy::setting( 'ld_single_cat' ); $ld_single_cat_text = Upstudy::setting( 'ld_single_cat_text' ); $ld_single_language = Upstudy::setting( 'ld_single_language' ); $ld_single_language_text = Upstudy::setting( 'ld_single_language_text' ); $ld_single_info_heading = Upstudy::setting( 'ld_single_info_heading'); $ld_custom_features_position = Upstudy::setting( 'ld_custom_features_position' ); $ld_single_certificate = Upstudy::setting( 'ld_single_certificate' ); if ( !in_array( $ld_single_page_layout, array('5')) ) { get_template_part( 'learndash/tpl-part/single/single', 'media' ); } echo '
'; if ($ld_single_info_heading) { echo '

' . esc_html($ld_single_info_heading) . '

'; } echo ''; echo '
'; } } // ===== Display Course Category / upstudy_ld_course_category ===== if ( ! function_exists( 'upstudy_ld_course_category' ) ) { function upstudy_ld_course_category() { global $post; $post_id = $post->ID; echo '
'; echo '
'; echo '

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

'; $args = array( 'taxonomy' => 'ld_course_category', 'orderby' => 'name', 'order' => 'ASC' ); $terms = get_categories($args); if ($terms && !is_wp_error($terms)) { echo ''; } echo '
'; echo '
'; } } /** * Display related courses Content */ if ( ! function_exists( 'upstudy_ld_related_course_content' ) ) { function upstudy_ld_related_course_content( $postType = 'sfwd-courses', $postID = null, $totalPosts = null, $relatedBy = null) { $ld_related_course_title = Upstudy::setting( 'ld_related_course_title' ); $ld_related_course_items = Upstudy::setting( 'ld_related_course_items' ); $ld_related_course_by = Upstudy::setting( 'ld_related_course_by' ); $ld_related_course_columns = Upstudy::setting( 'ld_related_course_columns' ); $args = array( 'style' => $style = Upstudy::setting( 'ld_course_archive_style' ) ); global $post, $related_posts_custom_query_args; if (null === $postID) $postID = $post->ID; if (null === $totalPosts) $totalPosts = $ld_related_course_items; if (null === $relatedBy) $relatedBy = $ld_related_course_by; if (null === $postType) $postType = 'sfwd-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_ld_related_course_sidebar' ) ) { function upstudy_ld_related_course_sidebar( $postType = 'sfwd-courses', $postID = null, $totalPosts = null, $relatedBy = null) { $ld_related_course_title = Upstudy::setting( 'ld_related_course_title' ); $ld_related_course_items = Upstudy::setting( 'ld_related_course_items' ); $ld_related_course_by = Upstudy::setting( 'ld_related_course_by' ); $ld_related_course_style = Upstudy::setting( 'ld_related_course_style' ); $final_ld_related_course_style = ($ld_related_course_style == 'square') ? 'square' : 'round'; global $post, $related_posts_custom_query_args; if (null === $postID) $postID = $post->ID; if (null === $totalPosts) $totalPosts = $ld_related_course_items; if (null === $relatedBy) $relatedBy = $ld_related_course_by; if (null === $postType) $postType = 'sfwd-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 ''; endif; // Reset postdata wp_reset_postdata(); } } /** * Filter search redirect to sfwd-courses-search.php */ function upstudy_ld_archive_search_template($template) { global $wp_query; $post_type = get_query_var('post_type'); if( isset($_GET['s']) && $post_type == 'sfwd-courses' ) { return locate_template('sfwd-courses-search.php'); // redirect to sfwd-courses-search.php } return $template; } add_filter('template_include', 'upstudy_ld_archive_search_template'); /** * LearnDash course archive page post_per_page */ function upstudy_ld_archive_course_post_per_page( $query ) { $ld_course_per_page = Upstudy::setting( 'ld_course_per_page' ); if ( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'sfwd-courses' ) ) { $query->set( 'posts_per_page', $ld_course_per_page ); } return; } add_action( 'pre_get_posts', 'upstudy_ld_archive_course_post_per_page', 15 ); // ===== upstudy_ld_course_page_title_section_03 if ( ! function_exists( 'upstudy_ld_course_page_title_section_03' ) ) : function upstudy_ld_course_page_title_section_03( $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_'; $ld_cg_short_description = get_post_meta( $post_id, '_learndash_course_grid_short_description', true ); $mb_short_description = get_post_meta( $post_id, '_upstudy_ld_excerpt', true ); $short_description = ($ld_cg_short_description) ? $ld_cg_short_description : $mb_short_description; $ld_single_excerpt = Upstudy::setting( 'ld_single_excerpt' ); $ld_single_breadcrumb = Upstudy::setting( 'ld_single_breadcrumb' ); $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $ld_header_color = ( $ld_single_page_layout == '4' ) ? 'light' : 'dark' ; $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() ; if (!empty($custom_page_header_img)) { echo '
'; } else { echo '
'; } echo '
'; echo '
'; echo '
'; echo '
'; if ( $ld_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '

'; the_title(); echo '

'; if ( $ld_single_excerpt) : echo '
'; echo '

'; echo esc_html($short_description); echo '

'; echo '
'; endif; // get_template_part( 'learndash/tpl-part/single/meta', 'review-update' ); get_template_part( 'learndash/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; /** * Course page title section upstudy_ld_course_page_title_section_05 */ if ( ! function_exists( 'upstudy_ld_course_page_title_section_05' ) ) : function upstudy_ld_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; $prefix = '_upstudy_'; $ld_cg_short_description = get_post_meta( $post_id, '_learndash_course_grid_short_description', true ); $mb_short_description = get_post_meta( $post_id, '_upstudy_ld_excerpt', true ); $short_description = ($ld_cg_short_description) ? $ld_cg_short_description : $mb_short_description; $ld_single_excerpt = Upstudy::setting( 'ld_single_excerpt' ); $ld_single_review = Upstudy::setting( 'ld_single_review' ); $ld_single_last_update = Upstudy::setting( 'ld_single_last_update' ); $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $ld_header_color = ( $ld_single_page_layout == '4' ) ? 'light' : 'dark' ; $header_title_tag = Upstudy::setting( 'header_title_tag' ); $header_page_title_align = Upstudy::setting( 'header_page_title_align' ); $ld_course_header_style = ''; $ld_single_breadcrumb = Upstudy::setting( 'ld_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; if ( $ld_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '
'; echo '<'.$header_title_tag.' class="page-title has-text-align-'.$header_page_title_align.'">'; the_title(); echo ''; echo '
'; if ( $ld_single_excerpt) : echo '
'; echo '

'; echo esc_html($short_description); echo '

'; echo '
'; endif; upstudy_breadcrumb_shapes(); get_template_part( 'learndash/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; // ===== upstudy_ld_course_page_title_section_04 ==== if ( ! function_exists( 'upstudy_ld_course_page_title_section_04' ) ) : function upstudy_ld_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_'; //$ld_course_header_image = get_post_meta( get_the_ID(), '_upstudy_ld_course_header_image', 1 ); $ld_cg_short_description = get_post_meta( $post_id, '_learndash_course_grid_short_description', true ); $mb_short_description = get_post_meta( $post_id, '_upstudy_ld_excerpt', true ); $short_description = ($ld_cg_short_description) ? $ld_cg_short_description : $mb_short_description; $ld_single_excerpt = Upstudy::setting( 'ld_single_excerpt' ); $ld_single_review = Upstudy::setting( 'ld_single_review' ); $ld_single_last_update = Upstudy::setting( 'ld_single_last_update' ); $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $ld_header_color = ( $ld_single_page_layout == '4' ) ? 'light' : 'dark' ; $page_header_img = get_post_meta($post_id, $prefix . 'header_img', true); $ld_intro_video_position = Upstudy::setting( 'ld_intro_video_position' ); $ld_single_social_shear = Upstudy::setting( 'ld_single_social_shear ' ); $breadcrumb_show = Upstudy::setting( 'breadcrumb_show' ); $shortcode_breadcrumb = Upstudy::setting( 'shortcode_breadcrumb' ); $ld_single_breadcrumb = Upstudy::setting( 'ld_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $ld_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '

'; the_title(); echo '

'; if ( $ld_single_excerpt) : echo '
'; echo '

'; echo esc_html($short_description); echo '

'; echo '
'; endif; get_template_part( 'learndash/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; // End upstudy-col-lg-8 echo '
'; if ( $ld_single_page_layout == '5' ) { get_template_part( 'learndash/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; // ===== upstudy_ld_course_page_title_section_06 if ( ! function_exists( 'upstudy_ld_course_page_title_section_06' ) ) : function upstudy_ld_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 ); $ld_single_excerpt = Upstudy::setting( 'ld_single_excerpt' ); $ld_single_review = Upstudy::setting( 'ld_single_review' ); $ld_single_last_update = Upstudy::setting( 'ld_single_last_update' ); $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $ld_course_header_style = ''; $ld_single_breadcrumb = Upstudy::setting( 'ld_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '

'; echo the_title(); echo '

'; echo '
'; echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; get_template_part( 'learndash/tpl-part/single/meta', 'top' ); echo '
'; echo '
'; echo '
'; } endif; /** * Course page title section upstudy_ld_course_page_title_section_08 */ if ( ! function_exists( 'upstudy_ld_course_page_title_section_08' ) ) : function upstudy_ld_course_page_title_section_08( $title = null, $has_bg_image = null, $extra_style = null ) { $ld_single_excerpt = Upstudy::setting( 'ld_single_excerpt' ); $ld_single_review = Upstudy::setting( 'ld_single_review' ); $ld_single_last_update = Upstudy::setting( 'ld_single_last_update' ); $ld_single_page_layout = Upstudy::setting( 'ld_single_page_layout' ); $ld_header_color = 'upstudy-dark-header'; $header_title_tag = Upstudy::setting( 'header_title_tag' ); $header_page_title_align = 'left'; $ld_course_header_style = Upstudy::setting( 'ld_course_header_style' ); $ld_single_breadcrumb = Upstudy::setting( 'ld_single_breadcrumb' ); echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; if ( $ld_single_breadcrumb ) { echo '
'; do_action( 'upstudy_breadcrumb' ); echo '
'; } echo '

'; the_title(); echo '

'; if ( $ld_single_excerpt) : echo '
'; the_excerpt(); echo '
'; endif; get_template_part( 'ld/tpl-part/single/meta', 'top' ); echo '
'; // End upstudy-single-course-lead-info echo '
'; echo '
'; echo '
'; $course_id = learndash_get_course_id(); if ( $course_id && function_exists( 'learndash_payment_buttons' ) ) { echo learndash_payment_buttons( $course_id ); } echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } endif; if ( ! function_exists( 'upstudy_get_ld_course_meta' ) ) { /** * Get course meta * * @param array $key meta key * @return string */ function upstudy_get_ld_course_meta( $key = '', $course_id = null ) { if ( empty( $course_id ) ) { $course_id = get_the_ID(); } if ( empty( $key ) ) { return get_post_meta( $course_id, '_ld_custom_meta', true ); } $meta_data = get_post_meta( $course_id, '_ld_custom_meta', true ); return isset( $meta_data[$key] ) ? $meta_data[$key] : ''; } } if ( ! function_exists( 'upstudy_get_ld_loop_course_meta' ) ) { /** * Get course meta html * * @param array $meta meta to show * @param array $data meta data * @return string */ function upstudy_get_ld_loop_course_meta( $meta, $data = array() ) { if ( empty( $meta ) ) { return ''; } $out = ''; if ( empty( $data ) ) { $data = get_post_meta( get_the_ID(), '_ld_custom_meta', true ); } $meta = apply_filters( 'upstudy_loop_course_meta', $meta ); $data = apply_filters( 'upstudy_loop_course_meta_data', $data ); if ( in_array( 'duration', $meta ) && ! empty( $data['duration'] ) ) { $out .= '
  • ' . esc_html( $data['duration'] ) . '
  • '; } if ( in_array( 'level', $meta ) && ! empty( $data['level'] ) ) { if ( function_exists( 'ldcm_get_course_level_label' ) ) { $level = ldcm_get_course_level_label( $data['level'] ); } else { $level = $data['level']; } $out .= '
  • ' . esc_html( $level ) . '
  • '; } if ( in_array( 'language', $meta ) && ! empty( $data['language'] ) ) { $out .= '
  • ' . esc_html( $data['language'] ) . '
  • '; } if ( in_array( 'enrolled', $meta ) ) { $enrolled = ! empty( $data['enrolled'] ) ? $data['enrolled'] : 0; switch ( get_post_type( get_the_ID() ) ) { case 'sfwd-courses': $count = upstudy_get_ld_course_student_count( get_the_ID(), $enrolled ); break; case 'groups': $count = upstudy_get_ld_group_student_count( get_the_ID(), $enrolled ); break; } $out .= '
  • ' . $count . '
  • '; } /** Add custom meta items here */ $html = apply_filters( 'upstudy_loop_course_meta_items', $out ); if ( ! empty( $html ) ) { $html = ''; } return $html; } } if ( ! function_exists( 'upstudy_get_ld_course_student_count' ) ) { /** * Get LearnDash course student count * @param integer $course_id course id * @param integer $base_count base count * @return integer student count */ function upstudy_get_ld_course_student_count( $course_id, $base_count = 0 ) { $course_access_users = learndash_get_course_users_access_from_meta( $course_id ); if ( ! empty( $course_access_users ) ) { $course_access_users = learndash_convert_course_access_list( $course_access_users, true ); $count = count( $course_access_users ); } else { $course_access_list = learndash_get_course_meta_setting( $course_id, 'course_access_list' ); if ( ! empty( $course_access_list ) && is_array( $course_access_list ) ) { $course_access_users = explode( ',', $course_access_list ); $count = count( $course_access_users ); } else { $count = 0; } } return $count + absint( $base_count ); } } if ( ! function_exists( 'upstudy_get_ld_group_student_count' ) ) { /** * Get LearnDash group student count * @param integer $post_id post id * @param integer $base_count base count * @return integer student count */ function upstudy_get_ld_group_student_count( $post_id, $base_count = 0 ) { $group_users = learndash_get_groups_user_ids( $post_id ); if ( ( empty( $group_users ) ) || ( ! is_array( $group_users ) ) ) { $group_users = array(); } $count = count( $group_users ); return $count + absint( $base_count ); } }