本文整理汇总了PHP中Unit::get_unit_page_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::get_unit_page_name方法的具体用法?PHP Unit::get_unit_page_name怎么用?PHP Unit::get_unit_page_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::get_unit_page_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
<label><?php
_e('Page Label', 'cp');
?>
<span class="delete_unit_page">
<a class="button button-units button-delete-unit"><i class="fa fa-trash-o"></i> <?php
_e('Delete Page', 'cp');
?>
</a>
</span>
</label>
<div class="description"><?php
_e('The label will be displayed on the Course Overview and Unit page', 'cp');
?>
</div>
<input type="text" value="<?php
echo esc_attr($unit->get_unit_page_name($i));
?>
" name="page_title[page_<?php
echo $i;
?>
]" id="page_title_<?php
echo $i;
?>
" class="page_title" />
<label class="show_page_title">
<input type="checkbox" name="show_page_title[]" value="yes" <?php
echo isset($show_title[$i - 1]) && $show_title[$i - 1] == 'yes' ? 'checked' : !isset($show_title[$i - 1]) ? 'checked' : '';
?>
/>
<input type="hidden" name="show_page_title_field[]" value="<?php
echo isset($show_title[$i - 1]) && $show_title[$i - 1] == 'yes' || !isset($show_title[$i - 1]) ? 'yes' : 'no';
示例2: isset
if ($unit_pages == 0) {
?>
<li>
<label><?php
_e('There are currently no pages to display', 'cp');
?>
</label>
</li>
<?php
} else {
?>
<li class="course_structure_page_li">
<?php
for ($i = 1; $i <= $unit_pages; $i++) {
$pages_num = 1;
$page_title = $unit_class->get_unit_page_name($i);
?>
<label for="page_<?php
echo $unit->ID . '_' . $i;
?>
">
<div class="tree-page-left">
<?php
echo isset($page_title) && $page_title !== '' ? $page_title : __('Untitled Page', 'cp');
?>
</div>
<div class="tree-page-right">
<input type='checkbox' class="module_show" id='show-<?php
echo $unit->ID . '_' . $i;
?>
示例3: extract
function course_unit_details($atts)
{
global $post_id, $wp, $coursepress;
extract(shortcode_atts(apply_filters('shortcode_atts_course_unit_details', array('unit_id' => 0, 'field' => 'post_title', 'format' => 'true', 'additional' => '2', 'style' => 'flat', 'class' => 'course-name-content', 'tooltip_alt' => __('Percent of the unit completion', 'cp'), 'knob_fg_color' => '#24bde6', 'knob_bg_color' => '#e0e6eb', 'knob_data_thickness' => '.35', 'knob_data_width' => '70', 'knob_data_height' => '70', 'unit_title' => '', 'unit_page_title_tag' => 'h3', 'unit_page_title_tag_class' => '', 'last_visited' => 'false', 'parent_course_preceding_content' => __('Course: ', 'cp'), 'student_id' => get_current_user_ID(), 'decimal_places' => '0')), $atts));
$unit_id = (int) $unit_id;
$field = sanitize_html_class($field);
$format = sanitize_text_field($format);
$format = 'true' == $format ? true : false;
$additional = sanitize_text_field($additional);
$style = sanitize_html_class($style);
$tooltip_alt = sanitize_text_field($tooltip_alt);
$knob_fg_color = sanitize_text_field($knob_fg_color);
$knob_bg_color = sanitize_text_field($knob_bg_color);
$knob_data_thickness = sanitize_text_field($knob_data_thickness);
$knob_data_width = (int) $knob_data_width;
$knob_data_height = (int) $knob_data_height;
$unit_title = sanitize_text_field($unit_title);
$unit_page_title_tag = sanitize_html_class($unit_page_title_tag);
$unit_page_title_tag_class = sanitize_html_class($unit_page_title_tag_class);
$parent_course_preceding_content = sanitize_text_field($parent_course_preceding_content);
$student_id = (int) $student_id;
$last_visited = sanitize_text_field($last_visited);
$last_visited = 'true' == $last_visited ? true : false;
$class = sanitize_html_class($class);
$decimal_places = sanitize_text_field($decimal_places);
if ($unit_id == 0) {
$unit_id = get_the_ID();
}
$unit = new Unit($unit_id);
if (!isset($unit->details)) {
$unit->details = new stdClass();
}
$student = new Student(get_current_user_id());
$class = sanitize_html_class($class);
if ($field == 'is_unit_available') {
$unit->details->{$field} = Unit::is_unit_available($unit_id);
}
if ($field == 'unit_page_title') {
$paged = isset($wp->query_vars['paged']) ? absint($wp->query_vars['paged']) : 1;
$page_name = $unit->get_unit_page_name($paged);
if ($unit_title !== '') {
$page_title_prepend = $unit_title . ': ';
} else {
$page_title_prepend = '';
}
$show_title_array = get_post_meta($unit_id, 'show_page_title', true);
$show_title = false;
if (isset($show_title_array[$paged - 1]) && 'yes' == $show_title_array[$paged - 1]) {
$show_title = true;
}
if (!empty($page_name) && $show_title) {
$unit->details->{$field} = '<' . $unit_page_title_tag . '' . ($unit_page_title_tag_class !== '' ? ' class="' . $unit_page_title_tag_class . '"' : '') . '>' . $page_title_prepend . $unit->get_unit_page_name($paged) . '</' . $unit_page_title_tag . '>';
} else {
$unit->details->{$field} = '';
}
}
if ($field == 'parent_course') {
$course = new Course($unit->course_id);
$unit->details->{$field} = $parent_course_preceding_content . '<a href="' . $course->get_permalink() . '" class="' . $class . '">' . $course->details->post_title . '</a>';
}
/* ------------ */
$front_save_count = 0;
$modules = Unit_Module::get_modules($unit_id);
$mandatory_answers = 0;
$mandatory = 'no';
foreach ($modules as $mod) {
$mandatory = get_post_meta($mod->ID, 'mandatory_answer', true);
if ($mandatory == 'yes') {
$mandatory_answers++;
}
$class_name = $mod->module_type;
if (class_exists($class_name)) {
if (constant($class_name . '::FRONT_SAVE')) {
$front_save_count++;
}
}
}
$input_modules_count = $front_save_count;
/* ------------ */
//$input_modules_count = do_shortcode( '[course_unit_details field="input_modules_count" unit_id="' . $unit_id . '"]' );
$responses_count = 0;
$modules = Unit_Module::get_modules($unit_id);
foreach ($modules as $module) {
if (Unit_Module::did_student_respond($module->ID, $student_id)) {
$responses_count++;
}
}
$student_modules_responses_count = $responses_count;
//$student_modules_responses_count = do_shortcode( '[course_unit_details field="student_module_responses" unit_id="' . $unit_id . '"]' );
if ($student_modules_responses_count > 0) {
$percent_value = $mandatory_answers > 0 ? round(100 / $mandatory_answers * $student_modules_responses_count, 0) : 0;
$percent_value = $percent_value > 100 ? 100 : $percent_value;
//in case that student gave answers on all mandatory plus optional questions
} else {
$percent_value = 0;
}
if ($input_modules_count == 0) {
$grade = 0;
$front_save_count = 0;
$assessable_answers = 0;
//.........这里部分代码省略.........
示例4: foreach
/**
* Renders the course structure.
*
* Used in shortcodes on the front end to render the course hierarchy.
*
* @param string $try_title
* @param bool $show_try
* @param bool $hide_title
* @param bool $echo
*/
function course_structure_front($try_title = '', $show_try = true, $hide_title = false, $echo = true)
{
$show_unit = $this->details->show_unit_boxes;
$preview_unit = $this->details->preview_unit_boxes;
$show_page = $this->details->show_page_boxes;
$preview_page = $this->details->preview_page_boxes;
$units = $this->get_units();
$content = '';
if (!$echo) {
ob_start();
}
echo $hide_title ? '' : '<label>' . $this->details->post_title . '</label>';
?>
<ul class="tree">
<li>
<ul>
<?php
foreach ($units as $unit) {
$unit_class = new Unit($unit->ID);
$unit_pages = $unit_class->get_number_of_unit_pages();
// $modules = Unit_Module::get_modules( $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">
<div class="tree-unit-left"><?php
echo $unit->post_title;
?>
</div>
<div class="tree-unit-right">
<?php
if ($this->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') {
?>
<a href="<?php
echo Unit::get_permalink($unit->ID);
?>
?try" class="preview_option"><?php
if ($try_title == '') {
_e('Try Now', 'cp');
} else {
echo $try_title;
}
?>
</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
$pages_num = 1;
$page_title = $unit_class->get_unit_page_name($i);
?>
<label for="page_<?php
echo $unit->ID . '_' . $i;
?>
">
<div class="tree-page-left">
<?php
echo isset($page_title) && $page_title !== '' ? $page_title : __('Untitled Page', 'cp');
?>
</div>
<div class="tree-page-right">
//.........这里部分代码省略.........