/** * Start session if it is not started * and init global session used by LearnPress * * @access private * @return array */ static function init() { if (!session_id() && !headers_sent()) { session_start(); } if (!session_id()) { LP_Debug::instance()->add('Session start failed!'); return false; } if (empty($_SESSION['learn_press'])) { $_SESSION['learn_press'] = array(); } do_action('learn_press_session_init'); return $_SESSION['learn_press']; }
function trigger($order_id) { if (!$this->enable) { return; } $this->find['site_title'] = '{site_title}'; $this->find['course_name'] = '{course_name}'; $this->find['course_date'] = '{course_date}'; //$this->replace['site_title'] = $this->get_blogname(); //$this->replace['course_name'] = get_the_title( $course_id ); //$this->replace['course_date'] = get_the_date( null, $course_id ); $this->object = array('order' => $order_id); $return = $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); LP_Debug::instance()->add(array('action' => learn_press_get_order($order_id))); return $return; }
function _evaluate_course_by_lesson($user_id) { global $wpdb; $course_lessons = $this->get_lessons(); LP_Debug::instance()->add($course_lessons); if (!$course_lessons) { return 1; } $query = $wpdb->prepare("\n\t\t\tSELECT count(user_id)\n\t\t\tFROM {$wpdb->prefix}learnpress_user_lessons ul\n\t\t\tINNER JOIN {$wpdb->posts} l ON l.ID = ul.lesson_id\n\t\t\tWHERE ul.user_id = %d\n\t\t\tAND status = %s\n\t\t", $user_id, 'completed'); $completed_lessons = $wpdb->get_var($query); return apply_filters('learn_press_evaluation_course_lesson', $completed_lessons / sizeof($course_lessons), $this->id, $user_id); }
static function save($post) { LP_Debug::instance()->add('Save quiz ' . $post); }
public function send($to, $subject, $message, $headers, $attachments) { add_filter('wp_mail_from', array($this, 'get_from_address')); add_filter('wp_mail_from_name', array($this, 'get_from_name')); add_filter('wp_mail_content_type', array($this, 'get_content_format')); $message = apply_filters('learn_press_mail_content', $this->apply_style_inline($message)); $return = wp_mail($to, $subject, $message, $headers, $attachments); //$return = LP_Emails::instance()->send( $this->get_from_address(), $to, $subject, $message, $headers, $attachments ); remove_filter('wp_mail_from', array($this, 'get_from_address')); remove_filter('wp_mail_from_name', array($this, 'get_from_name')); remove_filter('wp_mail_content_type', array($this, 'get_content_format')); LP_Debug::instance()->add(func_get_args()); return $return; }
/** * Updates order to new status if needed * * @param mixed $new_status * * @return bool * @throws Exception */ function update_status($new_status = 'pending') { // Standardise status names. $new_status = 'lp-' === substr($new_status, 0, 3) ? substr($new_status, 3) : $new_status; $old_status = $this->get_status(); if ($new_status !== $old_status && in_array($new_status, array_keys(learn_press_get_order_statuses(false)))) { // Update the order global $wpdb; $updated = $wpdb->update($wpdb->posts, array('post_status' => 'lp-' . $new_status), array('ID' => $this->id), array('%s')); if ($updated === false) { throw new Exception(__('Error! Update order failed', 'learn_press')); return false; } LP_Debug::instance()->add('Update order ' . $updated . ' status from ' . $old_status . ' to ' . $new_status); LP_Debug::instance()->add(get_post($updated)); $this->post_status = 'lp-' . $new_status; // Status was changed do_action('learn_press_order_status_' . $new_status, $this->id); do_action('learn_press_order_status_' . $old_status . '_to_' . $new_status, $this->id); do_action('learn_press_order_status_changed', $this->id, $old_status, $new_status); switch ($new_status) { case 'completed': break; case 'processing': break; } // backward compatible do_action('learn_press_update_order_status', $new_status, $this->id); } }