コード例 #1
0
 /**
  * Clean all items from cart
  *
  * @return $this
  */
 function empty_cart()
 {
     do_action('learn_press_before_empty_cart');
     LP_Session::set('cart', $this->get_default_cart_content());
     $this->get_cart_from_session();
     do_action('learn_press_emptied_cart');
     return $this;
 }
コード例 #2
0
/**
 * Display a message immediately with out push into queue
 *
 * @param        $message
 * @param string $type
 */
function learn_press_display_message($message, $type = 'success')
{
    // get all notices added into queue
    $notices = LP_Session::get('notices');
    LP_Session::set('notices', null);
    // add new notice and display
    learn_press_add_notice($message, $type);
    echo learn_press_get_notices(true);
    // store back notices
    LP_Session::set('notices', $notices);
}
コード例 #3
0
ファイル: learnpress.php プロジェクト: taibeo1905/LearnPress
 function get_session()
 {
     if (!$this->session) {
         $this->session = LP_Session::instance();
     }
     return $this->session;
 }
コード例 #4
0
 /**
  * Get unique instance object of the class
  *
  * @return LP_Session|object
  */
 static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #5
0
/**
 * Display all notices from queue and clear queue if required
 *
 * @param bool|true $clear
 */
function learn_press_print_notices($clear = true)
{
    if ($notices = LP_Session::get('notices')) {
        // Allow to reorder the position of notices
        $notice_types = apply_filters('learn_press_notice_types', array('error', 'success', 'notice'));
        foreach ($notice_types as $notice_type) {
            if (!empty($notices[$notice_type])) {
                learn_press_get_template("notices/{$notice_type}.php", array('messages' => $notices[$notice_type]));
            }
        }
        // clear queue if required
        if ($clear) {
            learn_press_clear_notices();
        }
    }
}
コード例 #6
0
 /**
  * Quiz for anonymous users
  *
  * @param boolean
  * @param int
  * @param int
  * @return boolean
  */
 function do_quiz_for_anonymous_user($continue, $quiz_id, $user_id)
 {
     $course_id = learn_press_get_course_by_quiz($quiz_id);
     if ($this->is_public_quiz($course_id)) {
         $session = LP_Session::instance();
         $session->set('anonymous_quiz', array('questions' => array_values(learn_press_get_quiz_questions($quiz_id)), 'finished' => 0, 'answers' => array(), 'start' => time(), 'end' => null));
         $continue = false;
         do_action('learn_press_user_start_quiz', $quiz_id, $user_id);
     }
     return $continue;
 }