本文整理汇总了PHP中Unit::get_unit_time_estimation方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::get_unit_time_estimation方法的具体用法?PHP Unit::get_unit_time_estimation怎么用?PHP Unit::get_unit_time_estimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::get_unit_time_estimation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
?>
" 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>
示例2: extract
/**
* 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) {
?>
//.........这里部分代码省略.........
示例3: get_course_time_estimation
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;
}