本文整理汇总了PHP中Unit::is_unit_available方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::is_unit_available方法的具体用法?PHP Unit::is_unit_available怎么用?PHP Unit::is_unit_available使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::is_unit_available方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: module_status
function module_status($atts)
{
ob_start();
extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'unit_id' => false, 'message' => __('%d of %d mandatory elements completed.', 'cp'), 'format' => 'true'), $atts, 'module_status'));
$message = sanitize_text_field($message);
$format = sanitize_text_field($format);
$format = 'true' == $format ? true : false;
if ($course_id) {
$course_id = (int) $course_id;
}
$unit_id = (int) $unit_id;
if (empty($unit_id)) {
return '';
}
$criteria = Unit::get_module_completion_data($unit_id);
$unit_status = Unit::get_unit_availability_status($unit_id);
$unit_available = Unit::is_unit_available($unit_id, $unit_status);
$input_modules_count = count($criteria['all_input_ids']);
$assessable_input_modules_count = count($criteria['gradable_modules']);
$mandatory_input_elements = count($criteria['mandatory_modules']);
$mandatory_responses = Student_Completion::get_mandatory_steps_completed(get_current_user_id(), $course_id, $unit_id);
// $all_responses = do_shortcode( '[course_unit_details field="student_module_responses"]' );
// $is_unit_available = do_shortcode( '[course_unit_details field="is_unit_available"]' );
// $input_modules_count = do_shortcode( '[course_unit_details field="input_modules_count"]' );
// $assessable_input_modules_count = do_shortcode( '[course_unit_details field="assessable_input_modules_count"]' );
// $mandatory_input_elements = do_shortcode( '[course_unit_details field="mandatory_input_modules_count"]' );
// $mandatory_responses = do_shortcode( '[course_unit_details field="student_module_responses" additional="mandatory"]' );
// $all_responses = do_shortcode( '[course_unit_details field="student_module_responses"]' );
$unit = new Unit($unit_id);
$unit->status = $unit_status;
if ($input_modules_count > 0) {
?>
<span class="unit-archive-single-module-status"><?php
if ($unit_available) {
if ($mandatory_input_elements > 0) {
echo sprintf($message, $mandatory_responses, $mandatory_input_elements);
}
} else {
if (isset($unit->status) && $unit->status['mandatory_required']['enabled'] && !$unit->status['mandatory_required']['result'] && !$unit->status['completion_required']['enabled']) {
esc_html_e('All mandatory answers are required in previous unit.', 'cp');
} elseif (isset($unit->status) && $unit->status['completion_required']['enabled'] && !$unit->status['completion_required']['result']) {
esc_html_e('Previous unit must be completed successfully.', 'cp');
}
if (isset($unit->status) && !$unit->status['date_restriction']['result']) {
echo __('Available', 'cp') . ' ' . date_i18n(get_option('date_format'), strtotime(do_shortcode('[course_unit_details field="unit_availability"]')));
}
}
?>
</span>
<?php
} else {
?>
<span class="unit-archive-single-module-status"><?php
if ($unit_available) {
// _e('Read-only','cp');
} else {
if (isset($unit->status) && $unit->status['mandatory_required']['enabled'] && !$unit->status['mandatory_required']['result'] && !$unit->status['completion_required']['enabled']) {
esc_html_e('All mandatory answers are required in previous unit.', 'cp');
} elseif (isset($unit->status) && $unit->status['completion_required']['enabled'] && !$unit->status['completion_required']['result']) {
esc_html_e('Previous unit must be completed successfully.', 'cp');
}
if (isset($unit->status) && !empty($unit->status) && !$unit->status['date_restriction']['result']) {
echo __('Available', 'cp') . ' ' . date_i18n(get_option('date_format'), strtotime(do_shortcode('[course_unit_details field="unit_availability"]')));
}
}
?>
</span>
<?php
}
$content = ob_get_clean();
return $content;
}
示例2: array
<div class="clearfix"></div>
<ul class="units-archive-list">
<?php
if (have_posts()) {
?>
<?php
$args = array('order' => 'ASC', 'post_type' => 'unit', 'post_status' => current_user_can('manage_options') ? 'any' : 'publish', 'meta_key' => 'unit_order', 'orderby' => 'meta_value_num', 'posts_per_page' => '-1', 'meta_query' => array('relation' => 'AND', array('key' => 'course_id', 'value' => $course_id)));
$posts = query_posts($args);
while (have_posts()) {
the_post();
$additional_class = '';
$additional_li_class = '';
$unit_id = get_the_ID();
$is_unit_available = Unit::is_unit_available($unit_id);
if (!$is_unit_available) {
$additional_class = 'locked-unit';
$additional_li_class = 'li-locked-unit';
}
$unit_progress = do_shortcode('[course_unit_percent course_id="' . $course_id . '" unit_id="' . $unit_id . '" format="true" style="extended"]');
?>
<li class="<?php
echo $additional_li_class;
?>
">
<div class='<?php
echo $additional_class;
?>
'></div>
<div class="unit-archive-single">
示例3: while
<?php
if (have_posts()) {
?>
<?php
while (have_posts()) {
the_post();
$draft = get_post_status() !== 'publish';
$show_draft = $draft && cp_can_see_unit_draft();
if ($draft && !$show_draft) {
continue;
}
$additional_class = '';
$additional_li_class = '';
$unit_id = get_the_ID();
$additional_content = '';
if (!Unit::is_unit_available($unit_id)) {
$additional_class = 'locked-unit';
$additional_li_class = 'li-locked-unit';
$additional_content = '<div class="' . esc_attr($additional_class) . '"></div>';
}
$unit_progress = do_shortcode('[course_unit_percent course_id="' . $course_id . '" unit_id="' . $unit_id . '" format="true" style="flat"]');
?>
<li class="<?php
echo esc_attr($additional_li_class);
?>
">
<?php
echo $additional_content;
?>
<?php
echo do_shortcode('[course_unit_title link="yes" last_page="no"]');
示例4: action_parse_request
//.........这里部分代码省略.........
exit;
} else {
$course_id = do_shortcode('[get_parent_course_id]');
// NOTIFICATIONS
$args = array('slug' => $wp->request, 'title' => get_the_title($course_id), 'content' => $this->get_template_details($this->plugin_dir . 'includes/templates/course-notifications-archive.php', $vars), 'type' => 'notifications', 'is_page' => true, 'is_singular' => true, 'is_archive' => false);
$pg = new CoursePress_Virtual_Page($args);
do_shortcode('[course_notifications_loop]');
}
}
if ($units_archive_page) {
$this->units_archive_subpage = 'units';
$theme_file = locate_template(array('archive-unit.php'));
if ($theme_file != '') {
do_shortcode('[course_units_loop]');
require_once $theme_file;
exit;
} else {
$course_id = do_shortcode('[get_parent_course_id]');
// COURSE UNITS
$args = array('slug' => $wp->request, 'title' => get_the_title($course_id), 'content' => $this->get_template_details($this->plugin_dir . 'includes/templates/course-units-archive.php', $vars), 'type' => 'unit', 'is_page' => true, 'is_singular' => true, 'is_archive' => false);
$pg = new CoursePress_Virtual_Page($args);
do_shortcode('[course_units_loop]');
}
$user_id = get_current_user_id();
$this->set_latest_activity($user_id);
$this->upgrade_user_meta($user_id, $course_id);
}
if ($units_archive_grades_page) {
$this->units_archive_subpage = 'grades';
$theme_file = locate_template(array('archive-unit-grades.php'));
if ($theme_file != '') {
do_shortcode('[course_units_loop]');
require_once $theme_file;
exit;
} else {
$course_id = do_shortcode('[get_parent_course_id]');
// COURSE GRADES
$args = array('slug' => $wp->request, 'title' => get_the_title($course_id), 'content' => $this->get_template_details($this->plugin_dir . 'includes/templates/course-units-archive-grades.php', $vars), 'type' => 'unit', 'is_page' => true, 'is_singular' => true, 'is_archive' => false);
$pg = new CoursePress_Virtual_Page($args);
do_shortcode('[course_units_loop]');
}
$this->set_latest_activity(get_current_user_id());
}
if ($units_workbook_page) {
$this->units_archive_subpage = 'workbook';
$theme_file = locate_template(array('archive-unit-workbook.php'));
if ($theme_file != '') {
do_shortcode('[course_units_loop]');
require_once $theme_file;
exit;
} else {
$course_id = do_shortcode('[get_parent_course_id]');
// WORKBOOK
do_shortcode('[course_units_loop]');
$args = array('slug' => $wp->request, 'title' => get_the_title($course_id), 'content' => $this->get_template_details($this->plugin_dir . 'includes/templates/archive-unit-workbook.php', $vars), 'type' => 'unit', 'is_page' => true, 'is_singular' => true, 'is_archive' => false);
$pg = new CoursePress_Virtual_Page($args);
do_shortcode('[course_units_loop]');
}
$this->set_latest_activity(get_current_user_id());
}
}
/* Show Unit single template */
if (array_key_exists('coursename', $wp->query_vars) && array_key_exists('unitname', $wp->query_vars)) {
$this->remove_pre_next_post();
$vars = array();
$unit = new Unit();
$vars['course_id'] = Course::get_course_id_by_name($wp->query_vars['coursename']);
$vars['unit_id'] = $unit->get_unit_id_by_name($wp->query_vars['unitname'], $vars['course_id']);
//$this->set_course_visited( get_current_user_id(), Course::get_course_id_by_name( $wp->query_vars['coursename'] ) );
$unit = new Unit($vars['unit_id']);
$this->set_unit_visited(get_current_user_id(), $vars['unit_id']);
$theme_file = locate_template(array('single-unit.php'));
$forced_previous_completion_template = locate_template(array('single-previous-unit.php'));
if (!Unit::is_unit_available($vars['unit_id']) && (!current_user_can('manage_options') && !CoursePress_Capabilities::can_update_course($vars['course_id']))) {
if ($forced_previous_completion_template != '') {
do_shortcode('[course_unit_single]');
//required for getting unit results
require_once $forced_previous_completion_template;
exit;
} else {
$args = array('slug' => $wp->request, 'title' => $unit->details->post_title, 'content' => __('This Unit is not available at the moment. Please check back later.', 'cp'), 'type' => 'page', 'is_page' => true, 'is_singular' => false, 'is_archive' => false);
$pg = new CoursePress_Virtual_Page($args);
}
} else {
if ($theme_file != '') {
global $wp;
do_shortcode('[course_unit_single unit_id="' . $vars['unit_id'] . '"]');
//required for getting unit results
require_once $theme_file;
do_action('wp');
//fix for gravity
exit;
} else {
$args = array('slug' => $wp->request, 'title' => isset($unit->details) ? get_the_title($unit->details->post_parent) : '', 'content' => $this->get_template_details($this->plugin_dir . 'includes/templates/course-units-single.php', $vars), 'type' => 'unit', 'is_page' => true, 'is_singular' => true, 'is_archive' => false);
$pg = new CoursePress_Virtual_Page($args);
}
$this->set_latest_activity(get_current_user_id());
}
}
}