?>
" name='meta_preview_unit[<?php 
                echo $unit->ID;
                ?>
]' <?php 
                if (isset($preview_unit[$unit->ID])) {
                    echo $preview_unit[$unit->ID] == 'on' ? 'checked' : '';
                }
                ?>
 <?php 
                echo $unit->post_status == 'publish' ? 'enabled' : 'disabled';
                ?>
 />

																									<span><?php 
                echo $unit_class->get_unit_time_estimation($unit->ID);
                ?>
</span>
																								</div>
																							</label>
																							<input type="checkbox" id="unit_<?php 
                echo $unit->ID;
                ?>
" class="hidden_checkbox"/>


																							<ol>
																								<?php 
                if ($unit_pages == 0) {
                    ?>
																									<li>
        /**
         * Shows the course structure.
         *
         * @since 1.0.0
         */
        function course_structure($atts)
        {
            extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'course' => false, 'free_text' => __('Free', 'cp'), 'free_show' => 'true', 'show_title' => 'no', 'show_label' => 'no', 'label_delimeter' => ': ', 'label_tag' => 'h2', 'show_divider' => 'yes', 'label' => __('Course Structure', 'cp'), 'class' => ''), $atts, 'course_structure'));
            $course_id = (int) $course_id;
            $free_text = sanitize_text_field($free_text);
            $free_show = sanitize_text_field($free_show);
            $free_show = 'true' == $free_show ? true : false;
            $show_title = sanitize_html_class($show_title);
            $show_label = sanitize_html_class($show_label);
            $label_delimeter = sanitize_html_class($label_delimeter);
            $label_tag = sanitize_html_class($label_tag);
            $show_divider = sanitize_html_class($show_divider);
            $label = sanitize_text_field($label);
            $class = sanitize_html_class($class);
            // Saves some overhead by not loading the post again if we don't need to.
            $course = empty($course) ? new Course($course_id) : object_decode($course, 'Course');
            $class = sanitize_html_class($class);
            $label_tag = sanitize_html_class($label_tag);
            $label_delimeter = sanitize_html_class($label_delimeter);
            if ($course->details->course_structure_options == 'on') {
                $content = '';
                $student = new Student(get_current_user_id());
                $existing_student = $student->has_access_to_course($course_id);
                $show_unit = $course->details->show_unit_boxes;
                $preview_unit = $course->details->preview_unit_boxes;
                $show_page = $course->details->show_page_boxes;
                $preview_page = $course->details->preview_page_boxes;
                $current_time = date('Y-m-d', current_time('timestamp', 0));
                $course_start_date = $course->details->course_start_date;
                $enable_links = false;
                if ($current_time >= $course_start_date) {
                    $enable_links = true;
                }
                $units = $course->get_units();
                $content .= '<div class="course-structure-block course-structure-block-' . $course_id . '">';
                if (!empty($label)) {
                    $content .= '<' . $label_tag . ' class="label">' . $label . $label_delimeter . '</' . $label_tag . '>';
                }
                $content .= 'yes' == $show_title ? '<label>' . $this->details->post_title . '</label>' : '';
                if ($units) {
                    ob_start();
                    ?>
					<ul class="tree">
						<li>
							<ul>
								<?php 
                    foreach ($units as $unit) {
                        $unit_class = new Unit($unit->ID);
                        $unit_pagination = cp_unit_uses_new_pagination($unit->ID);
                        if ($unit_pagination) {
                            $unit_pages = coursepress_unit_pages($unit->ID, $unit_pagination);
                        } else {
                            $unit_pages = coursepress_unit_pages($unit->ID);
                        }
                        //$unit_pages	 = $unit_class->get_number_of_unit_pages();
                        //									$modules = Unit_Module::get_modules( $unit->ID );
                        $unit_permalink = Unit::get_permalink($unit->ID);
                        if (isset($show_unit[$unit->ID]) && $show_unit[$unit->ID] == 'on' && $unit->post_status == 'publish') {
                            ?>
										<li>
											<label for="unit_<?php 
                            echo $unit->ID;
                            ?>
" class="course_structure_unit_label <?php 
                            echo $existing_student ? 'single_column' : '';
                            ?>
">
												<?php 
                            $title = '';
                            if ($existing_student && $enable_links) {
                                $title = '<a href="' . $unit_permalink . '">' . $unit->post_title . '</a>';
                            } else {
                                $title = $unit->post_title;
                            }
                            ?>
												<div class="tree-unit-left"><?php 
                            echo $title;
                            ?>
</div>
												<div class="tree-unit-right">

													<?php 
                            if ($course->details->course_structure_time_display == 'on') {
                                ?>
														<span><?php 
                                echo $unit_class->get_unit_time_estimation($unit->ID);
                                ?>
</span>
													<?php 
                            }
                            ?>

													<?php 
                            if (isset($preview_unit[$unit->ID]) && $preview_unit[$unit->ID] == 'on' && $unit_permalink && !$existing_student) {
                                ?>
														<a href="<?php 
                                echo $unit_permalink;
                                ?>
?try" class="preview_option"><?php 
                                echo $free_text;
                                ?>
</a>
													<?php 
                            }
                            ?>
												</div>
											</label>

											<ul>
												<?php 
                            for ($i = 1; $i <= $unit_pages; $i++) {
                                if (isset($show_page[$unit->ID . '_' . $i]) && $show_page[$unit->ID . '_' . $i] == 'on') {
                                    ?>
														<li class="course_structure_page_li <?php 
                                    echo $existing_student ? 'single_column' : '';
                                    ?>
">
															<?php 
                                    $pages_num = 1;
                                    $page_title = $unit_class->get_unit_page_name($i);
                                    ?>

															<label for="page_<?php 
                                    echo $unit->ID . '_' . $i;
                                    ?>
">
																<?php 
                                    $title = '';
                                    if ($existing_student && $enable_links) {
                                        $p_title = isset($page_title) && $page_title !== '' ? $page_title : __('Untitled Page', 'cp');
                                        $title = '<a href="' . trailingslashit($unit_permalink) . trailingslashit('page') . trailingslashit($i) . '">' . $p_title . '</a>';
                                    } else {
                                        $title = isset($page_title) && $page_title !== '' ? $page_title : __('Untitled Page', 'cp');
                                    }
                                    ?>

																<div class="tree-page-left">
																	<?php 
                                    echo $title;
                                    ?>
																</div>
																<div class="tree-page-right">

																	<?php 
                                    if ($course->details->course_structure_time_display == 'on') {
                                        ?>
																		<span><?php 
                                        echo $unit_class->get_unit_page_time_estimation($unit->ID, $i);
                                        ?>
</span>
																	<?php 
                                    }
                                    ?>

																	<?php 
                                    if (isset($preview_page[$unit->ID . '_' . $i]) && $preview_page[$unit->ID . '_' . $i] == 'on' && $unit_permalink && !$existing_student) {
                                        ?>
																		<a href="<?php 
                                        echo $unit_permalink;
                                        ?>
page/<?php 
                                        echo $i;
                                        ?>
?try" class="preview_option"><?php 
                                        echo $free_text;
                                        ?>
</a>
																	<?php 
                                    }
                                    ?>

																</div>
															</label>

															<?php 
                                    ?>
														</li>
													<?php 
                                }
                            }
                            //page visible
                            ?>

											</ul>
										</li>
									<?php 
                        }
                        //unit visible
                    }
                    // foreach
                    ?>
							</ul>
						</li>
					</ul>

					<?php 
                    if ($show_divider == 'yes') {
                        ?>
						<div class="divider"></div>
					<?php 
                    }
                    ?>

					<?php 
                    $content .= trim(ob_get_clean());
                } else {
                }
                $content .= '</div>';
                return $content;
            }
        }
 public static function get_course_time_estimation($course_id, $status = 'any')
 {
     $course_time = '';
     $course_seconds = 0;
     $units = Unit::get_units_from_course($course_id, $status, false);
     foreach ($units as $unit) {
         $unit_details = new Unit($unit->ID);
         $unit_time = $unit_details->get_unit_time_estimation($unit->ID);
         $min_sec = explode(':', $unit_time);
         if (isset($min_sec[0])) {
             $course_seconds += intval($min_sec[0]) * 60;
         }
         if (isset($min_sec[1])) {
             $course_seconds += intval(substr($min_sec[1], 0, 2));
         }
     }
     $total_seconds = round($course_seconds);
     $formatted_time = sprintf('%02d:%02d:%02d', $total_seconds / 3600, $total_seconds / 60 % 60, $total_seconds % 60);
     $course_time = apply_filters('coursepress_course_get_time_estimation', $formatted_time, $total_seconds, $course_id);
     return $course_time;
 }