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


PHP Sensei函数代码示例

本文整理汇总了PHP中Sensei函数的典型用法代码示例。如果您正苦于以下问题:PHP Sensei函数的具体用法?PHP Sensei怎么用?PHP Sensei使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: possibly_load_supported_theme_wrappers

 /**
  * Remove default Sensei wrappers and load
  * supported wrappers if the current theme is
  * a theme we have an integration for within core.
  *
  * @since 1.9.0
  */
 private function possibly_load_supported_theme_wrappers()
 {
     if (in_array($this->active_theme, $this->themes)) {
         // setup file and class names
         $supported_theme_class_file = trailingslashit(Sensei()->plugin_path) . 'includes/theme-integrations/' . $this->active_theme . '.php';
         $supported_theme_class_name = 'Sensei_' . ucfirst($this->active_theme);
         // load the file or exit if there is no file for this theme
         if (!file_exists($supported_theme_class_file)) {
             return;
         }
         include_once $supported_theme_class_file;
         include_once 'twentytwelve.php';
         //initialize the class or exit if there is no class for this theme
         if (!class_exists($supported_theme_class_name)) {
             return;
         }
         $supported_theme = new $supported_theme_class_name();
         // remove default wrappers
         remove_action('sensei_before_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper'), 10);
         remove_action('sensei_after_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper_end'), 10);
         // load the supported theme wrappers
         add_action('sensei_before_main_content', array($supported_theme, 'wrapper_start'), 10);
         add_action('sensei_after_main_content', array($supported_theme, 'wrapper_end'), 10);
     }
 }
开发者ID:pra85,项目名称:sensei,代码行数:32,代码来源:theme-integration-loader.php

示例2: testClassInstance

 /**
  * Testing the quiz class to make sure it is loaded
  * @since 1.8.0
  */
 public function testClassInstance()
 {
     //test if the class exists
     $this->assertTrue(class_exists('WooThemes_Sensei_Lesson'), 'Sensei Lesson class does not exist');
     //test if the global sensei lesson class is loaded
     $this->assertTrue(isset(Sensei()->lesson), 'Sensei lesson class is not loaded on the global sensei Object');
 }
开发者ID:pra85,项目名称:sensei,代码行数:11,代码来源:test-class-lesson.php

示例3: activate_sensei

/**
 * Activate_sensei
 *
 * All the activation checks needed to ensure Sensei is ready for use
 * @since 1.8.0
 */
function activate_sensei()
{
    // create the teacher role on activation and ensure that it has all the needed capabilities
    Sensei()->teacher->create_role();
    //Load the Welcome Screen
    add_action('activated_plugin', array('Sensei_Welcome', 'redirect'));
}
开发者ID:ragulka,项目名称:sensei,代码行数:13,代码来源:woothemes-sensei.php

示例4: trigger

 /**
  * trigger function.
  *
  * @access public
  * @param integer $message_id
  * @return void
  */
 function trigger($message_id = 0)
 {
     global $sensei_email_data;
     $this->message = get_post($message_id);
     $learner_username = get_post_meta($message_id, '_sender', true);
     $this->learner = get_user_by('login', $learner_username);
     $teacher_username = get_post_meta($message_id, '_receiver', true);
     $this->teacher = get_user_by('login', $teacher_username);
     $content_type = get_post_meta($message_id, '_posttype', true);
     $content_id = get_post_meta($message_id, '_post', true);
     $content_title = get_the_title($content_id);
     // setup the post type parameter
     $content_type = get_post_type($content_id);
     if (!$content_type) {
         $content_type = '';
     }
     // Construct data array
     $sensei_email_data = apply_filters('sensei_email_data', array('template' => $this->template, $content_type . '_id' => $content_id, 'heading' => $this->heading, 'teacher_id' => $this->teacher->ID, 'learner_id' => $this->learner->ID, 'learner_name' => $this->learner->display_name, 'message_id' => $message_id, 'message' => $this->message->post_content, 'content_title' => $content_title, 'content_type' => $content_type), $this->template);
     // Set recipient (teacher)
     $this->recipient = stripslashes($this->teacher->user_email);
     // Send mail
     Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
     wp_safe_redirect(esc_url_raw(add_query_arg(array('send' => 'complete'))));
     exit;
 }
开发者ID:pra85,项目名称:sensei,代码行数:32,代码来源:class-woothemes-sensei-email-teacher-new-message.php

示例5: testVersionNumber

 /**
  * Testing the version numbers before releasing the plugin.
  *
  * The version number in the plugin information block should match the version number specified in the code.
  */
 function testVersionNumber()
 {
     // make sure the version number was set on the new sensei instance
     $this->assertTrue(isset(Sensei()->version), 'The version number is not set on the global Sensei object');
     // read the plugin and get the version number
     //--> use  built in wp function
     // load an instance of the main class and check the version number
     //--> this should be loaded in global $woothemes_sensei.
     //test if the lesson object is loaded
     //$this->assertTrue( false , 'The plugin listings version and the code variable version numbers do not match'  );
 }
开发者ID:ragulka,项目名称:sensei,代码行数:16,代码来源:test-class-sensei.php

示例6: activate_sensei

/**
 * Activate_sensei
 *
 * All the activation checks needed to ensure Sensei is ready for use
 * @since 1.8.0
 */
function activate_sensei()
{
    // create the teacher role on activation and ensure that it has all the needed capabilities
    Sensei()->teacher->create_role();
    //Setup all the role capabilities needed
    Sensei()->updates->add_sensei_caps();
    Sensei()->updates->add_editor_caps();
    Sensei()->updates->assign_role_caps();
    //Load the Welcome Screen
    add_action('activated_plugin', array('Sensei_Welcome', 'redirect'));
}
开发者ID:RiaanKnoetze,项目名称:sensei,代码行数:17,代码来源:woothemes-sensei.php

示例7: trigger

 /**
  * trigger function.
  *
  * @param int $learner_id
  * @param int $course_id
  *
  * @return void
  */
 function trigger($learner_id = 0, $course_id = 0)
 {
     global $sensei_email_data;
     // Get learner user object
     $this->learner = new WP_User($learner_id);
     // Get teacher ID and user object
     $teacher_id = get_post_field('post_author', $course_id, 'raw');
     $this->teacher = new WP_User($teacher_id);
     // Construct data array
     $sensei_email_data = apply_filters('sensei_email_data', array('template' => $this->template, 'heading' => $this->heading, 'teacher_id' => $teacher_id, 'learner_id' => $learner_id, 'learner_name' => $this->learner->display_name, 'course_id' => $course_id), $this->template);
     // Set recipient (learner)
     $this->recipient = stripslashes($this->teacher->user_email);
     // Send mail
     Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
 }
开发者ID:pra85,项目名称:sensei,代码行数:23,代码来源:class-woothemes-sensei-email-teacher-started-course.php

示例8: render

 /**
  * Rendering the shortcode this class is responsible for.
  *
  * @return string $content
  */
 public function render()
 {
     if (empty($this->messages_query)) {
         return '';
     }
     //set the wp_query to the current messages query
     global $wp_query;
     $wp_query = $this->messages_query;
     ob_start();
     Sensei()->frontend->sensei_get_template_part('loop', 'message');
     $shortcode_output = ob_get_clean();
     // set back the global query
     wp_reset_query();
     return $shortcode_output;
 }
开发者ID:RiaanKnoetze,项目名称:sensei,代码行数:20,代码来源:class-sensei-shortcode-user-messages.php

示例9: trigger

 /**
  * trigger function.
  *
  * @access public
  * @param $teacher_id
  * @param $course_id
  * @return void
  */
 function trigger($teacher_id = 0, $course_id = 0)
 {
     global $sensei_email_data;
     $this->teacher = new WP_User($teacher_id);
     $this->recipient = stripslashes($this->teacher->user_email);
     $this->subject = __('New course assigned to you', 'woothemes-sensei');
     //course edit link
     $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit');
     // Course name
     $course = get_post($course_id);
     // Construct data array
     $sensei_email_data = apply_filters('sensei_email_data', array('template' => $this->template, 'heading' => $this->heading, 'teacher_id' => $teacher_id, 'course_id' => $course_id, 'course_name' => $course->post_title, 'course_edit_link' => $course_edit_link), $this->template);
     // Send mail
     Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
 }
开发者ID:mattytemple,项目名称:YTC-Sensei,代码行数:23,代码来源:class-woothemes-sensei-teacher-new-course-assignment.php

示例10: trigger

 /**
  * trigger function.
  *
  * @access public
  *
  * @param int $user_id
  * @param int $course_id
  *
  * @return void
  */
 function trigger($user_id = 0, $course_id = 0)
 {
     global $sensei_email_data;
     // Get learner user object
     $this->user = new WP_User($user_id);
     // Get passed status
     $passed = __('passed', 'woothemes-sensei');
     if (!Sensei_Utils::sensei_user_passed_course($course_id, $user_id)) {
         $passed = __('failed', 'woothemes-sensei');
     }
     // Construct data array
     $sensei_email_data = apply_filters('sensei_email_data', array('template' => $this->template, 'heading' => $this->heading, 'user_id' => $user_id, 'course_id' => $course_id, 'passed' => $passed), $this->template);
     // Set recipient (learner)
     $this->recipient = stripslashes($this->user->user_email);
     // Send mail
     Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
 }
开发者ID:pra85,项目名称:sensei,代码行数:27,代码来源:class-woothemes-sensei-email-learner-completed-course.php

示例11: testGetQuestionType

 /**
  * This tests Woothemes_Sensei()->quiz->get_question_type
  */
 public function testGetQuestionType()
 {
     // doe this method exist on the quiz class?
     $this->assertTrue(method_exists('WooThemes_Sensei_Quiz', 'submit_answers_for_grading'), 'The method get_question_type does not exist ');
     // does this method return false for the wrong data?
     $should_be_false = Sensei()->question->get_question_type('');
     $this->assertFalse($should_be_false, 'The method get_question_type should return false for an empty string parameter');
     // does this method return false for the wrong data?
     $should_be_false = Sensei()->question->get_question_type('');
     $this->assertFalse($should_be_false, 'The method get_question_type should return false for an empty string parameter');
     $should_be_false = Sensei()->question->get_question_type(2000);
     $this->assertFalse($should_be_false, 'The method get_question_type should return false for an empty string parameter');
     // does this method return a string for a valid question id
     $questions = get_posts('post_type=question');
     $should_be_question_type = Sensei()->question->get_question_type($questions[array_rand($questions)]->ID);
     $sensei_question_types = array_keys(Sensei()->question->question_types());
     $this->assertTrue(in_array($should_be_question_type, $sensei_question_types), 'The method get_question_type should return false for an empty string parameter');
 }
开发者ID:pra85,项目名称:sensei,代码行数:21,代码来源:test-class-question.php

示例12: render

 /**
  * Rendering the shortcode this class is responsible for.
  *
  * @return string $content
  */
 public function render()
 {
     if (empty($this->id)) {
         return __('Please supply a course ID for this shortcode.', 'woothemes-sensei');
     }
     //set the wp_query to the current courses query
     global $wp_query;
     $wp_query = $this->course_page_query;
     if (have_posts()) {
         the_post();
     } else {
         return __('No posts found.', 'woothemes-sensei');
     }
     ob_start();
     Sensei()->frontend->sensei_get_template('content-single-course.php');
     $shortcode_output = ob_get_clean();
     // set back the global query
     wp_reset_query();
     return $shortcode_output;
 }
开发者ID:RiaanKnoetze,项目名称:sensei,代码行数:25,代码来源:class-sensei-shortcode-course-page.php

示例13: render

 /**
  * Rendering the shortcode this class is responsible for.
  *
  * @return string $content
  */
 public function render()
 {
     if (!is_user_logged_in()) {
         Sensei()->notices->add_notice(__('Please login to view your messages.', 'woothemes-sensei'), 'alert');
     } elseif (0 == $this->messages_query->post_count) {
         Sensei()->notices->add_notice(__('You do not have any messages.', 'woothemes-sensei'), 'alert');
     }
     $messages_disabled_in_settings = !(!isset(Sensei()->settings->settings['messages_disable']) || !Sensei()->settings->settings['messages_disable']);
     // don't show anything if messages are disable
     if ($messages_disabled_in_settings) {
         return '';
     }
     //set the wp_query to the current messages query
     global $wp_query;
     $wp_query = $this->messages_query;
     ob_start();
     Sensei()->notices->print_notices();
     Sensei_Templates::get_part('loop', 'message');
     $messages_html = ob_get_clean();
     // set back the global query
     wp_reset_query();
     return $messages_html;
 }
开发者ID:pra85,项目名称:sensei,代码行数:28,代码来源:class-sensei-shortcode-user-messages.php

示例14: trigger

 /**
  * trigger function.
  *
  * @param int $user_id
  * @param int $quiz_id
  * @param int $grade
  * @param int $passmark
  *
  * @return void
  */
 function trigger($user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0)
 {
     global $sensei_email_data;
     // Get learner user object
     $this->user = new WP_User($user_id);
     // Get passed flag
     $passed = __('failed', 'woothemes-sensei');
     if ($grade >= $passmark) {
         $passed = __('passed', 'woothemes-sensei');
     }
     // Get grade tye (auto/manual)
     $grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true);
     if ('auto' == $grade_type) {
         $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have completed a quiz', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
         $this->heading = apply_filters('sensei_email_heading', __('You have completed a quiz', 'woothemes-sensei'), $this->template);
     }
     $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
     // Construct data array
     $sensei_email_data = apply_filters('sensei_email_data', array('template' => $this->template, 'heading' => $this->heading, 'user_id' => $user_id, 'user_name' => stripslashes($this->user->display_name), 'lesson_id' => $lesson_id, 'quiz_id' => $quiz_id, 'grade' => $grade, 'passmark' => $passmark, 'passed' => $passed, 'grade_type' => $grade_type), $this->template);
     // Set recipient (learner)
     $this->recipient = stripslashes($this->user->user_email);
     // Send mail
     Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
 }
开发者ID:pra85,项目名称:sensei,代码行数:34,代码来源:class-woothemes-sensei-email-learner-graded-quiz.php

示例15: get_currentuserinfo

// Get User Meta
get_currentuserinfo();
// exit if no lessons exist
if (!($total_lessons > 0)) {
    return;
}
$html .= '<section class="course-lessons">';
$html .= '<header>';
$html .= '<h2>' . apply_filters('sensei_lessons_text', __('Lessons', 'woothemes-sensei')) . '</h2>';
$html .= '</header>';
$lesson_count = 1;
$lessons_completed = count(Sensei()->course->get_completed_lesson_ids($post->ID, $current_user->ID));
$show_lesson_numbers = false;
foreach ($course_lessons as $lesson_item) {
    //skip lesson that are already in the modules
    if (false != Sensei()->modules->get_lesson_module($lesson_item->ID)) {
        continue;
    }
    $single_lesson_complete = false;
    $post_classes = array('course', 'post');
    $user_lesson_status = false;
    if (is_user_logged_in()) {
        // Check if Lesson is complete
        $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
开发者ID:drumchannel,项目名称:drumchannel-dev,代码行数:31,代码来源:course-lessons.php


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