当前位置: 首页>>代码示例>>PHP>>正文


PHP WooThemes_Sensei_Utils::is_preview_lesson方法代码示例

本文整理汇总了PHP中WooThemes_Sensei_Utils::is_preview_lesson方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::is_preview_lesson方法的具体用法?PHP WooThemes_Sensei_Utils::is_preview_lesson怎么用?PHP WooThemes_Sensei_Utils::is_preview_lesson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WooThemes_Sensei_Utils的用法示例。


在下文中一共展示了WooThemes_Sensei_Utils::is_preview_lesson方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: single_lesson_handler

 public function single_lesson_handler()
 {
     global $post;
     // Preview Lessons shouldn't ignore this rule.
     if (WooThemes_Sensei_Utils::is_preview_lesson($post->ID)) {
         return;
     }
     $course_id = get_post_meta($post->ID, '_lesson_course', true);
     // User already started this course, so ideally, we shouldn't restrict access.
     if (WooThemes_Sensei_Utils::user_started_course($post->ID, wp_get_current_user()->ID)) {
         return;
     }
     // This happens if the lesson isn't locked itself.
     if (memberful_can_user_access_post(wp_get_current_user()->ID, $post->ID)) {
         if (!memberful_can_user_access_post(wp_get_current_user()->ID, $course_id)) {
             // The user doesn't have access to this post, so he shouldn't have actions on it.
             remove_all_actions('sensei_lesson_single_meta');
             // Now the funky filtering part.
             remove_action('the_content', 'memberful_wp_protect_content');
             add_action('the_content', array($this, 'single_lesson_special_content_filter'), -10);
         }
     } else {
         // The user doesn't have access to this post, so he shouldn't have actions on it.
         remove_all_actions('sensei_lesson_single_meta');
     }
 }
开发者ID:andrewkhunn,项目名称:lancero,代码行数:26,代码来源:woothemes-sensei.php

示例2: check_user_permissions

 /**
  * check_user_permissions function.
  *
  * @access public
  * @param string $page (default: '')
  * @param array $data (default: array())
  * @return void
  */
 public function check_user_permissions($page = '', $data = array())
 {
     // REFACTOR
     global $current_user, $post;
     if (!isset($current_user)) {
         return;
     }
     // Get User Meta
     get_currentuserinfo();
     $user_allowed = false;
     switch ($page) {
         case 'course-single':
             // check for prerequisite course or lesson,
             $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true);
             $update_course = $this->woocommerce_course_update($post->ID);
             // Count completed lessons
             if (0 < absint($course_prerequisite_id)) {
                 $prerequisite_complete = WooThemes_Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID);
             } else {
                 $prerequisite_complete = true;
             }
             // End If Statement
             // Handles restrictions
             if (!$prerequisite_complete && 0 < absint($course_prerequisite_id)) {
                 $this->permissions_message['title'] = get_the_title($post->ID) . ': ' . __('Restricted Access', 'woothemes-sensei');
                 $course_link = '<a href="' . esc_url(get_permalink($course_prerequisite_id)) . '">' . __('course', 'woothemes-sensei') . '</a>';
                 $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link);
             } else {
                 $user_allowed = true;
             }
             // End If Statement
             break;
         case 'lesson-single':
             // Check for WC purchase
             $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true);
             $update_course = $this->woocommerce_course_update($lesson_course_id);
             $is_preview = WooThemes_Sensei_Utils::is_preview_lesson($post->ID);
             if ($this->access_settings() && WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
                 $user_allowed = true;
             } elseif ($this->access_settings() && false == $is_preview) {
                 $user_allowed = true;
             } else {
                 $this->permissions_message['title'] = get_the_title($post->ID) . ': ' . __('Restricted Access', 'woothemes-sensei');
                 $course_link = '<a href="' . esc_url(get_permalink($lesson_course_id)) . '">' . __('course', 'woothemes-sensei') . '</a>';
                 $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true);
                 if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < $wc_post_id) {
                     if ($is_preview) {
                         $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
                     } else {
                         $this->permissions_message['message'] = apply_filters('sensei_please_purchase_course_text', sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link));
                     }
                 } else {
                     if ($is_preview) {
                         $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
                     } else {
                         /** This filter is documented in class-woothemes-sensei-frontend.php */
                         $this->permissions_message['message'] = apply_filters('sensei_please_sign_up_text', sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link));
                     }
                 }
                 // End If Statement
             }
             // End If Statement
             break;
         case 'quiz-single':
             $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true);
             $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
             $update_course = $this->woocommerce_course_update($lesson_course_id);
             if ($this->access_settings() && WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) || sensei_all_access()) {
                 // Check for prerequisite lesson for this quiz
                 $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
                 $user_lesson_prerequisite_complete = WooThemes_Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID);
                 // Handle restrictions
                 if (sensei_all_access()) {
                     $user_allowed = true;
                 } else {
                     if (0 < absint($lesson_prerequisite_id) && !$user_lesson_prerequisite_complete) {
                         $this->permissions_message['title'] = get_the_title($post->ID) . ': ' . __('Restricted Access', 'woothemes-sensei');
                         $lesson_link = '<a href="' . esc_url(get_permalink($lesson_prerequisite_id)) . '">' . __('lesson', 'woothemes-sensei') . '</a>';
                         $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link);
                     } else {
                         $user_allowed = true;
                     }
                     // End If Statement
                 }
                 // End If Statement
             } elseif ($this->access_settings()) {
                 // Check if the user has started the course
                 if (is_user_logged_in() && !WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) && (isset($this->settings->settings['access_permission']) && true == $this->settings->settings['access_permission'])) {
                     $user_allowed = false;
                     $this->permissions_message['title'] = get_the_title($post->ID) . ': ' . __('Restricted Access', 'woothemes-sensei');
                     $course_link = '<a href="' . esc_url(get_permalink($lesson_course_id)) . '">' . __('course', 'woothemes-sensei') . '</a>';
                     $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true);
//.........这里部分代码省略.........
开发者ID:drumchannel,项目名称:drumchannel-dev,代码行数:101,代码来源:class-woothemes-sensei.php

示例3: get_post_meta

     $single_lesson_complete = WooThemes_Sensei_Utils::user_completed_lesson($lesson_item->ID, $current_user->ID);
     if ($single_lesson_complete) {
         $post_classes[] = 'lesson-completed';
     }
     // End If Statement
 }
 // End If Statement
 // Get Lesson data
 $complexity_array = $woothemes_sensei->post_types->lesson->lesson_complexities();
 $lesson_length = get_post_meta($lesson_item->ID, '_lesson_length', true);
 $lesson_complexity = get_post_meta($lesson_item->ID, '_lesson_complexity', true);
 if ('' != $lesson_complexity) {
     $lesson_complexity = $complexity_array[$lesson_complexity];
 }
 $user_info = get_userdata(absint($lesson_item->post_author));
 $is_preview = WooThemes_Sensei_Utils::is_preview_lesson($lesson_item->ID);
 $preview_label = '';
 if ($is_preview && !$is_user_taking_course) {
     $preview_label = $woothemes_sensei->frontend->sensei_lesson_preview_title_text($post->ID);
     $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
     $post_classes[] = 'lesson-preview';
 }
 $html .= '<article class="' . esc_attr(join(' ', get_post_class($post_classes, $lesson_item->ID))) . '">';
 $html .= '<header>';
 $html .= '<h2><a href="' . esc_url(get_permalink($lesson_item->ID)) . '" title="' . esc_attr(sprintf(__('Start %s', 'woothemes-sensei'), $lesson_item->post_title)) . '">';
 if (apply_filters('sensei_show_lesson_numbers', $show_lesson_numbers)) {
     $html .= '<span class="lesson-number">' . $lesson_count . '. </span>';
 }
 $html .= esc_html(sprintf(__('%s', 'woothemes-sensei'), $lesson_item->post_title)) . $preview_label . '</a></h2>';
 $html .= '<p class="lesson-meta">';
 if ('' != $lesson_length) {
开发者ID:drumchannel,项目名称:drumchannel-dev,代码行数:31,代码来源:course-lessons.php

示例4: sensei_course_preview_titles

 public function sensei_course_preview_titles($title, $lesson_id)
 {
     global $post, $current_user, $woothemes_sensei;
     $course_id = $post->ID;
     $title_text = '';
     if (method_exists('WooThemes_Sensei_Utils', 'is_preview_lesson') && WooThemes_Sensei_Utils::is_preview_lesson($lesson_id)) {
         $is_user_taking_course = WooThemes_Sensei_Utils::sensei_check_for_activity(array('post_id' => $course_id, 'user_id' => $current_user->ID, 'type' => 'sensei_course_status'));
         if (!$is_user_taking_course) {
             if (method_exists('WooThemes_Sensei_Frontend', 'sensei_lesson_preview_title_text')) {
                 $title_text = $woothemes_sensei->frontend->sensei_lesson_preview_title_text($course_id);
                 // Remove brackets for display here
                 $title_text = str_replace('(', '', $title_text);
                 $title_text = str_replace(')', '', $title_text);
                 $title_text = '<span class="preview-label">' . $title_text . '</span>';
             }
             $title .= ' ' . $title_text;
         }
     }
     return $title;
 }
开发者ID:drumchannel,项目名称:drumchannel-dev,代码行数:20,代码来源:class-sensei-modules.php

示例5: wp_get_current_user

                <?php 
$view_lesson = true;
wp_get_current_user();
$lesson_prerequisite = absint(get_post_meta($post->ID, '_lesson_prerequisite', true));
if ($lesson_prerequisite > 0) {
    // Check for prerequisite lesson completions
    $view_lesson = WooThemes_Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
}
$lesson_course_id = get_post_meta($post->ID, '_lesson_course', true);
$user_taking_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID);
if (current_user_can('administrator')) {
    $view_lesson = true;
    $user_taking_course = true;
}
$is_preview = false;
if (WooThemes_Sensei_Utils::is_preview_lesson($post->ID)) {
    $is_preview = true;
    $view_lesson = true;
}
if ($view_lesson) {
    ?>

					<section class="entry fix">
					<?php 
    if ($is_preview && !$user_taking_course) {
        ?>
						<div class="sensei-message alert"><?php 
        echo $woothemes_sensei->permissions_message['message'];
        ?>
</div>
					<?php 
开发者ID:ragulka,项目名称:sensei,代码行数:31,代码来源:content-single-lesson.php

示例6: sensei_lesson_preview_title

 public function sensei_lesson_preview_title($title = '', $id = 0)
 {
     global $post, $current_user;
     // Limit to lessons and check if lesson ID matches filtered post ID
     // @see https://github.com/woothemes/sensei/issues/574
     if (isset($post->ID) && $id == $post->ID && 'lesson' == get_post_type($post)) {
         // Limit to main query only
         if (is_main_query()) {
             // Get the course ID
             $course_id = get_post_meta($post->ID, '_lesson_course', true);
             // Check if the user is taking the course
             if (is_singular('lesson') && WooThemes_Sensei_Utils::is_preview_lesson($post->ID) && !WooThemes_Sensei_Utils::user_started_course($course_id, $current_user->ID) && $post->ID == $id) {
                 $title .= ' ' . $this->sensei_lesson_preview_title_text($course_id);
             }
         }
     }
     return $title;
 }
开发者ID:Ezyva2015,项目名称:opendooronline.com.au,代码行数:18,代码来源:class-woothemes-sensei-frontend.php

示例7: widget

    function widget($args, $instance)
    {
        global $woothemes_sensei, $post, $current_user, $view_lesson, $user_taking_course;
        $allmodules = 'off';
        if (isset($instance['allmodules'])) {
            $allmodules = $instance['allmodules'];
        }
        // If not viewing a lesson/quiz, don't display the widget
        if (!(is_singular('lesson') || is_singular('quiz'))) {
            return;
        }
        extract($args);
        if (is_singular('quiz')) {
            $current_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true));
        } else {
            $current_lesson_id = $post->ID;
        }
        // get the course for the current lesson/quiz
        $lesson_course_id = get_post_meta($current_lesson_id, '_lesson_course', true);
        // Check if the user is taking the course
        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID);
        //Check for preview lesson
        $is_preview = false;
        if (method_exists('WooThemes_Sensei_Utils', 'is_preview_lesson')) {
            $is_preview = WooThemes_Sensei_Utils::is_preview_lesson($post->ID);
        }
        $course_title = get_the_title($lesson_course_id);
        $course_url = get_the_permalink($lesson_course_id);
        $in_module = false;
        $lesson_module = '';
        $lesson_array = array();
        if (0 < $current_lesson_id) {
            // get an array of lessons in the module if there is one
            if (isset(Sensei()->modules) && has_term('', Sensei()->modules->taxonomy, $current_lesson_id)) {
                // Get all modules
                $course_modules = Sensei()->modules->get_course_modules($lesson_course_id);
                $lesson_module = Sensei()->modules->get_lesson_module($current_lesson_id);
                $in_module = true;
                $current_module_title = htmlspecialchars($lesson_module->name);
                // Display all modules
                if ('on' == $allmodules) {
                    foreach ($course_modules as $module) {
                        // get all lessons in the module
                        $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($lesson_course_id), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . intval($module->term_id), 'orderby' => 'meta_value_num date', 'order' => 'ASC');
                        $lesson_array = array_merge($lesson_array, get_posts($args));
                    }
                } else {
                    // Only display current module
                    // get all lessons in the current module
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($lesson_course_id), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => $lesson_module)), 'meta_key' => '_order_module_' . intval($lesson_module->term_id), 'orderby' => 'meta_value_num date', 'order' => 'ASC');
                    $lesson_array = get_posts($args);
                }
            } else {
                // if there's no module, get all lessons in the course
                $lesson_array = Sensei()->course->course_lessons($lesson_course_id);
            }
        }
        echo $before_widget;
        ?>

		<header>
			<h2 class="course-title"><a href="<?php 
        echo $course_url;
        ?>
"><?php 
        echo $course_title;
        ?>
</a></h2>

			<?php 
        if ($in_module && 'on' != $allmodules) {
            ?>
				<h3 class="module-title"><?php 
            echo $current_module_title;
            ?>
</h3>
			<?php 
        }
        ?>

		</header>

		<?php 
        $nav_id_array = sensei_get_prev_next_lessons($current_lesson_id);
        $previous_lesson_id = absint($nav_id_array['prev_lesson']);
        $next_lesson_id = absint($nav_id_array['next_lesson']);
        if (0 < $previous_lesson_id || 0 < $next_lesson_id) {
            ?>

			<ul class="course-progress-navigation">
				<?php 
            if (0 < $previous_lesson_id) {
                ?>
<li class="prev"><a href="<?php 
                echo esc_url(get_permalink($previous_lesson_id));
                ?>
" title="<?php 
                echo get_the_title($previous_lesson_id);
                ?>
"><span><?php 
//.........这里部分代码省略.........
开发者ID:mslinnea,项目名称:sensei-course-progress,代码行数:101,代码来源:class-sensei-course-progress-widget.php


注:本文中的WooThemes_Sensei_Utils::is_preview_lesson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。