Home › Forums › Legacy Support › Support queries › Setup issues › How do I display the course deadline in hours
- This topic has 4 replies, 2 voices, and was last updated 3 years ago by Ada.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
April 14, 2021 at 12:52 am #352241danibuuParticipantHey guys, How do I display the course deadline in hours?April 14, 2021 at 12:53 am #352242danibuuParticipantThis reply has been marked as private.April 14, 2021 at 10:33 am #352361AdaParticipantHi, You need to redefine the course_info shortcode for this. So please use this code in wplms-customizer.php in wplms-customizer plugin.
You can get this plugin from here https://wplms.io/support/knowledge-base/wplms-customizer-plugin/add_Action('init',function(){ if(class_exists('Vibe_Define_Shortcodes')){ $init = new Vibe_Define_Shortcodes; remove_shortcode('course_info',array($init,'course_info')); add_shortcode('course_info','new_course_info'); } }); function new_course_info($atts,$content=null){ extract(shortcode_atts(array( 'info' => 0, ), $atts)); $id = apply_filters('elementor_course_block_id',''); if(empty($id)) return; switch($info){ case 'title': $html = '<a href="'.get_permalink($id).'">'.get_the_title($id).'</a>'; break; case 'excerpt': $html = get_the_excerpt($id); break; case 'description': global $post; $old_post = $post; $post = get_post($id); $html = do_shortcode($post->post_content); $post = $old_post; break; case 'average_rating': $rating = get_post_meta($id,'average_rating',true); $html = bp_course_display_rating($rating); break; case 'average_rating_count': $rating = get_post_meta($id,'average_rating',true); $html = '<span>'.$rating.'</span>'; break; case 'review_count': $html = get_post_meta($id,'rating_count',true); break; case 'student_count': $html = get_post_meta($id,'vibe_students',true); break; case 'last_update': $html = get_the_modified_time(get_option( 'date_format' ),$id); break; case 'instructor_name': $author = get_post_field('post_author',$id); $authors=array($author); $authors = apply_filters('wplms_course_instructors',$authors,$id); $html ='<div class="course_instructors">'; foreach($authors as $instructor_id){ $html .='<a href="'.bp_core_get_user_domain($instructor_id).'" class="course_instructor">'.bp_core_get_user_displayname($instructor_id).'</a>'; } $html .='</div>'; break; case 'course_duration': $duration = bp_course_get_course_duration($id); $duration = intval($duration); if($duration >= (9999*86400)){ $html = _x('Unlimited Duration','','wplms'); }else{ $html = $duration/(60*60) . ' Hours'; } break; case 'course-cat': $post_terms = wp_get_object_terms( $id,'course-cat',array( 'fields' => 'ids' )); if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) { $term_ids = implode( ',' , $post_terms ); $terms = wp_list_categories( array( 'title_li' => '', 'style' => 'none', 'echo' => false, 'taxonomy' => 'course-cat', 'include' => $term_ids ) ); $separator = ''; $terms = str_replace( '<br />', $separator, $terms ); // Display post categories. return '<div class="wplms_course_categories">'.$terms.'</div>'; } return ''; break; case 'level': case 'location': $post_terms = wp_get_object_terms( $id,$info,array( 'fields' => 'ids' )); if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) { $term_ids = implode( ',' , $post_terms ); $terms = wp_list_categories( array( 'title_li' => '', 'style' => 'none', 'echo' => false, 'taxonomy' => $info, 'include' => $term_ids ) ); $separator = ''; $terms = str_replace( '<br />', $separator, $terms ); // Display post categories. return '<div class="wplms_course_'.$info.'">'.$terms.'</div>'; } return ''; break; case 'curriculum_item_count': $curriculum = bp_course_get_curriculum_units($id); $html = is_array($curriculum)?count($curriculum):0; //bp_course_get_post_type break; case 'cumulative_time': $course_curriculum = bp_course_get_curriculum($id); $duration = 0; if(!empty($course_curriculum)){ foreach($course_curriculum as $key => $item){ if(is_numeric($item)){ $post_type = get_post_type($item); if( $post_type == 'unit' && function_exists('bp_course_get_unit_duration')){ $duration += bp_course_get_unit_duration($item); }else if($post_type == 'quiz' && function_exists('bp_course_get_quiz_duration')){ $duration += bp_course_get_quiz_duration($item); } } } if(function_exists('tofriendlytime')){ $html = apply_filters('wplms_cs_get_course_unit_durations',tofriendlytime($duration),$duration); } } //bp_course_get_post_type break; case 'pre-required-courses': $precourse=get_post_meta($id,'vibe_pre_course',true); $pre_course_html = ''; if(!empty($precourse)){ if(is_numeric($precourse)){ $pre_course_html = '<a href="'.get_permalink($precourse).'">'.get_the_title($precourse).'</a>'; }else if(is_array($precourse)){ foreach($precourse as $k => $pre_course_id){ $pre_course_html .= (empty($k)?'':' , ').'<a href="'.get_permalink($pre_course_id).'">'.get_the_title($pre_course_id).'</a>'; } } } if(!empty($pre_course_html)){ $html = $pre_course_html; }else{ $html = __('None','wplms'); } break; case 'certificate': $link =bp_get_course_certificate(array('course_id'=>$id)); $html ='<a href="'.$link.'" class="bp_course_certificate_link">'.__('Preview Certificate','wplms').'</a>'; break; case 'badge': $link =bp_get_course_certificate(array('course_id'=>$id)); $b=bp_get_course_badge($id); $badge=wplms_plugin_wp_get_attachment_info($b); $size = apply_filters('bp_course_badge_thumbnail_size','thumbnail'); $badge_url=wp_get_attachment_image_src($b,$size); $b_title = get_post_meta($id,'vibe_course_badge_title',true); $html ='<a class="tip ajax-badge" data-course="'.get_the_title($id).'" title="'.$b_title.'"><img src="'.$badge_url[0].'" title="'.$b_title.'" width="32px" /></a>'; break; default: ob_start(); do_action('wplms_course_info_content',$id,$info); $html = ob_get_clean(); break; } return $html; }
April 15, 2021 at 12:12 am #352493danibuuParticipantIt worked. ThanksApril 15, 2021 at 4:54 am #352514AdaParticipantThank-you for confirming. Closing this topic. -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- The topic ‘How do I display the course deadline in hours’ is closed to new replies.