コード例 #1
1
 function save_post_action()
 {
     if ($post_id = $this->get('ID')) {
         $post_data = isset($_POST[LP()->question_post_type]) ? $_POST[LP()->question_post_type] : array();
         $post_answers = array();
         $post_explain = $post_data[$post_id]['explaination'];
         if (isset($post_data[$post_id]) && ($post_data = $post_data[$post_id])) {
             //if( LP()->question_post_type != get_post_type( $post_id ) ){
             try {
                 $ppp = wp_update_post(array('ID' => $post_id, 'post_title' => $post_data['text'], 'post_type' => LP()->question_post_type));
             } catch (Exception $ex) {
                 echo "ex:";
                 print_r($ex);
             }
             // }else{
             // }
             $index = 0;
             foreach ($post_data['answer']['text'] as $k => $txt) {
                 $post_answers[$index++] = array('text' => $txt, 'is_true' => $post_data['answer']['is_true'][$k]);
             }
         }
         $post_data['answer'] = $post_answers;
         $post_data['type'] = $this->get_type();
         $post_data['explaination'] = $post_explain;
         update_post_meta($post_id, '_lpr_question', $post_data);
         //print_r($post_data);
     }
     return $post_id;
     // die();
 }
コード例 #2
0
 static function save_quiz_questions($post_id)
 {
     learn_press_debug($_POST);
     die;
     static $has_updated;
     $questions = isset($_POST[LP()->question_post_type]) ? $_POST[LP()->question_post_type] : null;
     if (!$questions) {
         return;
     }
     $postmeta = array();
     // prevent infinite loop with save_post action
     if ($has_updated) {
         return;
     }
     $has_updated = true;
     foreach ($questions as $question_id => $options) {
         $question = LP_Question::instance($question_id);
         if ($question) {
             $question_id = $question->save_post_action();
             if ($question_id) {
                 $postmeta[$question_id] = array('toggle' => $options['toggle']);
                 if (!empty($options['type'])) {
                     $post_data = get_post_meta($question_id, '_lpr_question', true);
                     $post_data['type'] = $options['type'];
                     update_post_meta($question_id, '_lpr_question', $post_data);
                 }
             }
         }
     }
     update_post_meta($post_id, '_lpr_quiz_questions', $postmeta);
 }
コード例 #3
0
 /**
  * Add course to cart
  *
  * @param int $course_id
  * @param int $quantity
  * @param     array
  */
 function add_to_cart($course_id, $quantity = 1, $item_data = array())
 {
     if (!learn_press_is_enable_cart()) {
         $this->empty_cart();
     }
     $course = learn_press_get_course($course_id);
     /*
     		if ( !empty( $this->_cart_content['items'][$course_id] ) ) {
     			$quantity += $this->_cart_content['items'][$course_id]['quantity'];
     		}*/
     $quantity = 1;
     $this->_cart_content['items'][$course_id] = apply_filters('learn_press_add_cart_item', array('item_id' => $course_id, 'quantity' => $quantity, 'subtotal' => $course->get_price() * $quantity, 'total' => $course->get_price() * $quantity, 'data' => $item_data));
     do_action('learn_press_add_to_cart', $course_id, $quantity, $item_data, $this);
     $button = '';
     if (learn_press_is_enable_cart()) {
         if (LP()->settings->get('redirect_after_add') == 'yes') {
             $redirect = learn_press_get_page_link('cart');
             $button = sprintf('<a href="%s">%s</a>', get_the_permalink($course_id), __('Back to class', 'learn_press'));
         } else {
             $redirect = get_the_permalink($course_id);
             $button = sprintf('<a href="%s">%s</a>', learn_press_get_page_link('cart'), __('View cart', 'learn_press'));
         }
     } else {
         $redirect = learn_press_get_page_link('checkout');
     }
     $redirect = apply_filters('learn_press_add_to_cart_redirect', $redirect, $course_id);
     learn_press_add_notice(sprintf(__('<strong>%s</strong> has been added to your cart. %s', 'learn_press'), get_the_title($course_id), $button));
     if (is_ajax()) {
         learn_press_send_json(array('redirect' => $redirect, 'result' => 'success', 'messages' => learn_press_get_notices(true)));
     } else {
         wp_redirect($redirect);
         die;
     }
 }
コード例 #4
0
 /**
  * @param $default_message
  */
 function message_editor($default_message)
 {
     $settings = LP()->settings;
     $content = stripslashes($settings->get($this->section['id'] . '.message', $default_message));
     $editor_id = 'email_message';
     wp_editor(stripslashes($content), $editor_id, array('textarea_rows' => 10, 'wpautop' => false, 'textarea_name' => "lpr_settings[{$this->id}][message]"));
 }
コード例 #5
0
 function include_update()
 {
     // Update LearnPress from 0.9.x to 1.0
     if (version_compare(LP()->db_version, '1.0', '<')) {
         learn_press_include('updates/learnpress-update-1.0.php');
     }
 }
コード例 #6
0
 function notify_new_course()
 {
     global $menu;
     $current_user = wp_get_current_user();
     if (!in_array('administrator', $current_user->roles)) {
         return;
     }
     $count_courses = wp_count_posts(LP()->course_post_type);
     $awaiting_mod = $count_courses->pending;
     $menu['3.14'][0] .= " <span class='awaiting-mod count-{$awaiting_mod}'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>";
 }
コード例 #7
0
 function __construct()
 {
     $this->id = 'new_course';
     $this->title = __('New course', 'learn_press');
     $this->template_html = 'emails/new-course.php';
     $this->template_plain = 'emails/plain/new-course.php';
     $this->default_subject = __('[{site_title}] New course has submitted for review ({course_name})', 'learn_press');
     $this->default_heading = __('New course', 'learn_press');
     $this->recipient = LP()->settings->get('emails_new_course.recipient');
     parent::__construct();
 }
コード例 #8
0
 public function __construct()
 {
     LP()->_include('emails/class-lp-email.php');
     $this->emails['LP_Email_New_Course'] = (include 'emails/class-lp-email-new-course.php');
     $this->emails['LP_Email_Rejected_Course'] = (include 'emails/class-lp-email-rejected-course.php');
     $this->emails['LP_Email_Published_Course'] = (include 'emails/class-lp-email-published-course.php');
     $this->emails['LP_Email_Enrolled_Course'] = (include 'emails/class-lp-email-enrolled-course.php');
     $this->emails['LP_Email_Finished_Course'] = (include 'emails/class-lp-email-finished-course.php');
     $this->emails['LP_Email_New_Order'] = (include 'emails/class-lp-email-new-order.php');
     add_action('learn_press_course_submitted_notification', array($this, 'course_submitted'), 5, 2);
     add_action('learn_press_course_rejected_notification', array($this, 'course_rejected'), 5, 2);
     add_action('learn_press_course_approved_notification', array($this, 'course_approved'), 5, 2);
     add_action('learn_press_email_header', array($this, 'email_header'));
     add_action('learn_press_email_footer', array($this, 'email_footer'));
     do_action('learn_press_emails_init', $this);
 }
コード例 #9
0
 /**
  * Load assets for admin
  */
 static function load_scripts()
 {
     $screen = get_current_screen();
     $screen_id = $screen->id;
     if (in_array($screen_id, learn_press_get_screens())) {
         self::add_style('learn-press-global', learn_press_plugin_url('assets/css/global-style.css'));
         self::add_style('learn-press-admin', learn_press_plugin_url('assets/css/admin/admin.css'), array('learn-press-global'));
         self::add_style('learn-press-icons', learn_press_plugin_url('assets/css/icons.css'));
         //self::add_script( 'learn-press-ui', learn_press_plugin_url( 'assets/js/ui.js' ) );
         self::add_script('learn-press-admin', learn_press_plugin_url('assets/js/admin/admin.js'));
         self::add_script('modal-search-items', LearnPress()->plugin_url('assets/js/admin/modal-search-items.js'), array('jquery'));
     }
     if (in_array($screen_id, array('lp_order', 'order'))) {
         self::add_style('learn-press-order', learn_press_plugin_url('assets/css/admin/meta-box-order.css'));
         self::add_script('learn-press-order', LP()->plugin_url('assets/js/admin/meta-box-order.js'), array('backbone', 'wp-util'));
     }
 }
コード例 #10
0
 /**
  * Get the question class name
  *
  * @param  WP_Post $the_question
  * @param  array   $args (default: array())
  * @return string
  */
 public static function get_question_class($the_question, $args = array())
 {
     $question_id = absint($the_question->ID);
     $post_type = $the_question->post_type;
     if (LP()->question_post_type === $post_type) {
         if (isset($args['question_type'])) {
             $question_type = $args['question_type'];
         } else {
             $question_type = false;
         }
     } else {
         $question_type = false;
     }
     $class_name = self::get_class_name_from_question_type($question_type);
     // Filter class name so that the class can be overridden if extended.
     return apply_filters('learn_press_question_class', $class_name, $question_type, $post_type, $question_id);
 }
コード例 #11
0
 /**
  * Get the course class name
  *
  * @param  WP_Post $the_course
  * @param  array   $args (default: array())
  *
  * @return string
  */
 private static function get_course_class($the_course, $args = array())
 {
     $course_id = absint($the_course->ID);
     $post_type = $the_course->post_type;
     if (LP()->course_post_type === $post_type) {
         if (isset($args['course_type'])) {
             $course_type = $args['course_type'];
         } else {
             /*$terms          = get_the_terms( $course_id, 'course_type' );
             		$course_type    = ! empty( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple';
             		*/
             $course_type = 'simple';
         }
     } else {
         $course_type = false;
     }
     $class_name = self::get_class_name_from_course_type($course_type);
     // Filter class name so that the class can be overridden if extended.
     return apply_filters('learn_press_course_class', $class_name, $course_type, $post_type, $course_id);
 }
コード例 #12
0
function learn_press_get_course_order($course_id, $user_id = null)
{
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    global $wpdb;
    $order = false;
    $query = $wpdb->prepare("\n        SELECT ID, pm2.meta_value\n        FROM {$wpdb->posts} p INNER JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id\n        INNER JOIN {$wpdb->postmeta} pm2 ON p.ID = pm2.post_id AND pm2.meta_key = %s\n        WHERE p.post_type = %s AND pm.meta_key = %s AND pm.meta_value = %d\n    ", '_learn_press_order_items', LP()->order_post_type, '_learn_press_customer_id', $user_id);
    if ($orders = $wpdb->get_results($query)) {
        foreach ($orders as $order_data) {
            $order_id = $order_data->ID;
            $order_data = maybe_unserialize($order_data->meta_value);
            if ($order_data && !empty($order_data->products)) {
                if (isset($order_data->products[$course_id])) {
                    $order = $order_id;
                    // a user only can take a course one time
                    // so it should be existing in one and only one order
                    break;
                }
            }
        }
    }
    return $order;
}
コード例 #13
0
ファイル: history.php プロジェクト: thonysmith/LearnPress
$view_id = !empty($_REQUEST['history_id']) ? $_REQUEST['history_id'] : 0;
?>

<?php 
if ($heading) {
    ?>
	<h4><?php 
    echo $heading;
    ?>
</h4>
<?php 
}
?>

<?php 
$history = LP()->user->get_quiz_history($quiz->id);
if ($history) {
    $position = 0;
    ?>
	<table class="quiz-history">
		<thead>
			<tr>
				<th width="50" align="right">#</th>
				<th><?php 
    _e('Time', 'learn_press');
    ?>
</th>
				<th><?php 
    _e('Result', 'learn_press');
    ?>
</th>
コード例 #14
0
 /**
  * Get all items in a course
  *
  * @param array $args {
  *                    force       bool    Force to get curriculum items that does not care for it is already existing in memory or not
  *                    group        bool    Group the items returned by type of each item
  *                    field        string  The fields want to get
  *                    }
  *
  * @return array
  */
 function get_curriculum_items($args = array())
 {
     // default value for $args
     $force = false;
     $group = false;
     $field = '';
     $args = wp_parse_args($args, array('force' => false, 'group' => false, 'field' => ''));
     $lessons = array();
     $quizzes = array();
     // overwrite default values with params passed
     extract($args);
     $items = array();
     if (!$this->_curriculum_items || $force) {
         $curriculum = $this->get_curriculum($force);
         $index = 0;
         if (!empty($field)) {
             if (is_string($field)) {
                 $field = explode('![\\s]+!', $field);
             }
             settype($field, 'array');
         } else {
             $field = false;
         }
         //if( is_array( $field ) ) $field = array_map( $field, 'strtolower' );
         if ($curriculum) {
             foreach ($curriculum as $section) {
                 if (empty($section->items)) {
                     continue;
                 }
                 foreach ($section->items as $loop_item) {
                     if ($field) {
                         $item = null;
                         $item_array = (array) $loop_item;
                         foreach ($field as $field_name) {
                             if (array_key_exists($field_name, $item_array)) {
                                 $item = $item_array[$field_name];
                                 break;
                             }
                         }
                     } else {
                         $item = $loop_item;
                     }
                     if ($loop_item->post_type == LP()->lesson_post_type) {
                         $lessons[$index] = $item;
                     } else {
                         $quizzes[$index] = $item;
                     }
                     $index++;
                 }
             }
         }
         // group
         if ($group) {
             $items = array('quizzes' => $quizzes, 'lessons' => $lessons);
         } else {
             // combine lessons and quizzes as it should be in curriculum
             for ($i = 0, $n = sizeof($quizzes) + sizeof($lessons); $i < $n; $i++) {
                 if (!empty($quizzes[$i])) {
                     $items[] = $quizzes[$i];
                 } elseif (!empty($lessons[$i])) {
                     $items[] = $lessons[$i];
                 }
             }
         }
     }
     return apply_filters('learn_press_get_course_items', $items, $this);
 }
コード例 #15
0
 function get_icon()
 {
     return '<img src="' . apply_filters('learn_press_question_icon', LP()->plugin_url('assets/images/question.png'), $this) . '">';
 }
コード例 #16
0
ファイル: profile.php プロジェクト: hernanimattos/LearnPress
<?php

/**
 * Display settings for profile
 *
 * @author  ThimPress
 * @package LearnPress/Admin/Views
 * @version 1.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
$settings = LP()->settings;
?>
	<table class="form-table">
		<tbody>
		<?php 
do_action('learn_press_before_' . $this->id . '_settings_fields', $this);
?>
		<?php 
foreach ($this->get_settings() as $field) {
    ?>
			<?php 
    $this->output_field($field);
    ?>
		<?php 
}
?>
		<?php 
if (1 == 0) {
コード例 #17
0
 function get_questions()
 {
     if (empty($this->questions)) {
         global $wpdb;
         $query = $wpdb->prepare("\n\t\t\t\tSELECT q.*, qq.params\n\t\t\t\tFROM {$wpdb->posts} q\n\t\t\t\tINNER JOIN {$wpdb->learnpress_quiz_questions} qq ON qq.question_id = q.ID\n\t\t\t\tAND q.post_type = %s\n\t\t\t\tAND qq.quiz_id = %d\n\t\t\t", LP()->question_post_type, $this->id);
         if ($this->questions = $wpdb->get_results($query, OBJECT_K)) {
             foreach ($this->questions as $id => $question) {
                 $question->params = maybe_unserialize($question->params);
                 $this->questions[$id] = $question;
             }
         }
     }
     return apply_filters('learn_press_quiz_questions', $this->questions);
 }
コード例 #18
0
			-->
			<button class="button hide-if-js" type="button" data-action="cancel"><?php 
_e('Cancel', 'learn_press');
?>
</button>
			<!--<div class="button lp-check-all-items">
				<input type="checkbox" class="" />
				<span>&dtrif;</span>
			</div>-->
		</div>
		<table class="curriculum-section-items">
			<?php 
echo $content_items;
?>
			<?php 
learn_press_admin_view('meta-boxes/course/loop-item.php', array('item' => learn_press_post_object(array('post_type' => LP()->lesson_post_type))));
?>
		</table>
		<?php 
do_action('learn_press_after_section_items', $section);
?>
		<?php 
if ($buttons = apply_filters('learn_press_loop_section_buttons', array())) {
    ?>
			<br />
			<div class="lp-add-buttons">
				<input type="text" class="regular-text no-submit" name="lp-new-item-name" placeholder="<?php 
    _e('The name of new question or quiz and hit enter', 'learn_press');
    ?>
" />
				<div class="button lp-button-dropdown lp-button-add-item disabled">
コード例 #19
0
/**
 * Return true if a course is required review before submit
 *
 * @param null $course_id
 * @param null $user_id
 *
 * @return bool
 */
function learn_press_course_is_required_review($course_id = null, $user_id = null)
{
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    if (!$course_id) {
        global $post;
        $course_id = $post->ID;
    }
    if (get_post_type($course_id) != 'lp_course') {
        return false;
    }
    $user = learn_press_get_user($user_id);
    if ($user->is_admin() || ($user_course = learn_press_get_user(get_post_field('post_author', $course_id))) && $user_course->is_admin()) {
        return false;
    }
    $required_review = LP()->settings->get('required_review') == 'yes';
    $enable_edit_published = LP()->settings->get('enable_edit_published') == 'yes';
    $is_publish = get_post_status($course_id) == 'publish';
    return !(!$required_review || $required_review && $enable_edit_published && $is_publish);
}
コード例 #20
0
<?php

$settings = LP()->settings;
global $wp_post_types;
if (!empty($wp_post_types[LP()->course_post_type])) {
    $course_type = $wp_post_types[LP()->course_post_type];
    $default_courses_slug = $course_type->rewrite['slug'];
} else {
    $default_courses_slug = '';
}
$course_permalink = $settings->get('course_base');
$courses_page_id = learn_press_get_page_id('courses');
$base_slug = urldecode($courses_page_id > 0 && get_post($courses_page_id) ? get_page_uri($courses_page_id) : _x('courses', 'default-slug', 'learn_press'));
$course_base = _x('course', 'default-slug', 'learn_press');
$structures = array(0 => array('value' => '', 'text' => __('Default', 'learn_press'), 'code' => esc_html(home_url()) . '/?lp_course=sample-course'), 1 => array('value' => '/' . trailingslashit($course_base), 'text' => __('Course', 'learn_press'), 'code' => esc_html(sprintf('%s/%s/sample-course/', home_url(), $course_base))), 2 => array('value' => '/' . trailingslashit($base_slug), 'text' => __('Courses base', 'learn_press'), 'code' => esc_html(sprintf('%s/%s/sample-course/', home_url(), $base_slug))), 3 => array('value' => '/' . trailingslashit($base_slug) . trailingslashit('%course_category%'), 'text' => __('Courses base with category', 'learn_press'), 'code' => esc_html(sprintf('%s/%s/course-category/sample-course/', home_url(), $base_slug))));
$is_custom = true;
foreach ($structures as $k => $structure) {
    ?>
	<tr<?php 
    if ($k == 2 || $k == 3) {
        echo ' class="learn-press-courses-page-id';
        echo !$courses_page_id ? ' hide-if-js"' : '""';
    }
    ?>
 >
		<th>
			<?php 
    $is_checked = checked($course_permalink == '' && $structure['value'] == '' || $structure['value'] == trailingslashit($course_permalink), true, false);
    if ($is_custom && $is_checked) {
        $is_custom = false;
    }
コード例 #21
0
 /**
  * Load assets for frontend
  */
 static function load_scripts()
 {
     // global
     self::add_style('learn-press-icon', learn_press_plugin_url('assets/css/style.css'));
     self::add_script('learn-press-global', learn_press_plugin_url('assets/js/global.js'));
     self::add_script('learn-press-block-ui', learn_press_plugin_url('assets/js/jquery.block-ui.js'));
     // admin
     self::add_style('learn-press-admin', learn_press_plugin_url('assets/css/learnpress-admin.css'));
     // frontend
     self::add_style('learn-press', learn_press_plugin_url('assets/css/learnpress.css'));
     self::add_script('learn-press-js', learn_press_plugin_url('assets/js/frontend/learnpress.js'), array('learn-press-global'));
     // single course
     self::add_script('single-course', learn_press_plugin_url('assets/js/frontend/single-course.js'), array('backbone', 'utils'));
     if (LP()->settings->get('ajax_add_to_cart') == 'yes') {
         self::add_script('learn-press-add-to-cart', learn_press_plugin_url('assets/js/frontend/add-to-cart.js'));
     }
     // single quiz
     self::add_script('learn-press-timer', learn_press_plugin_url('assets/js/jquery.timer.js'));
     self::add_script('single-quiz', learn_press_plugin_url('assets/js/frontend/single-quiz.js'), array('backbone', 'utils'));
     // checkout page
     self::add_script('checkout', learn_press_plugin_url('assets/js/frontend/checkout.js'));
     //self::add_script( 'lpr-alert-js', LP_JS_URL . 'jquery.alert.js' );
     /*self::enqueue_style( 'lpr-learnpress-css' );
     		self::enqueue_style( 'lpr-time-circle-css' );
     
     		self::enqueue_script( 'learn-press-js' );
     		self::enqueue_script( 'lpr-alert-js' );
     		self::enqueue_script( 'lpr-time-circle-js' );
     		self::enqueue_script( 'block-ui' );
     */
 }
コード例 #22
0
ファイル: nav.php プロジェクト: thonysmith/LearnPress
/**
 * Template for displaying the questions navigation
 *
 * @author  ThimPress
 * @package LearnPress
 * @version 1.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
global $quiz;
if (!$quiz->has('questions')) {
    return;
}
$status = LP()->user->get_quiz_status($quiz->id);
?>

<div class="quiz-question-nav-buttons">

	<?php 
if ($status != 'completed') {
    ?>

	<button type="button" data-nav="prev" class="prev-question" data-url="<?php 
    echo $prev;
    ?>
">
		<?php 
    echo apply_filters('learn_press_quiz_question_nav_button_back_title', __('Back', 'learn_press'));
    ?>
コード例 #23
0
if ($gateway instanceof LP_Gateway_Abstract) {
    ?>

	<?php 
    if (apply_filters('learn_press_display_payment_method', true, $gateway->id)) {
        ?>
		<li>
			<label>
				<input id="payment_method_<?php 
        echo $gateway->id;
        ?>
" type="radio" class="input-radio" name="payment_method" value="<?php 
        echo esc_attr($gateway->id);
        ?>
" <?php 
        checked(LP()->session->get('chosen_payment_method') == $gateway->id, true);
        ?>
 data-order_button_text="<?php 
        echo esc_attr($gateway->order_button_text);
        ?>
" />
				<?php 
        echo $gateway->get_title();
        ?>
			</label>
			<?php 
        if (($payment_form = $gateway->get_payment_form()) || ($payment_form = $gateway->get_description())) {
            ?>
				<div class="payment-method-form payment_method_<?php 
            echo $gateway->id;
            ?>
コード例 #24
0
ファイル: ipn.php プロジェクト: thonysmith/LearnPress
environment it is better to have that log file outside of the web root.
*/
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__) . '/ipn_errors.log');
// instantiate the IpnListener class
ob_start();
print_r($_REQUEST);
file_put_contents('ipn.txt', ob_get_clean());
die;
if (isset($_POST)) {
    return;
    $post_password = substr('lpr_order_' . $_POST['txn_id'], 0, 20);
    $date = gmdate('Y-m-d H:i:s', strtotime($_POST['payment_date']) + get_option('gmt_offset') * HOUR_IN_SECONDS);
    $purchased_items = array();
    $purchased_items[] = array('course_id' => $_POST['item_number'], 'cost' => $_POST['mc_gross']);
    $order_data = array('ID' => $order_id, 'post_author' => $_POST['custom'], 'post_date' => $date, 'post_type' => LP()->order_post_type, 'post_password' => $post_password, 'post_title' => __('Order on ', 'learn_press') . ' ' . date("l jS F Y h:i:s A", strtotime($date)));
    $order_meta = array('lpr_cost' => $_POST['mc_gross'], 'lpr_methods' => 'paypal', 'lpr_items' => $purchased_items, 'lpr_status' => 0, 'lpr_courses' => $_POST['item_number'], 'lpr_information' => $_POST);
    learn_press_update_order($order_data, $order_meta, $purchased_items);
}
include 'ipnlistener.php';
$listener = new IpnListener();
/*
When you are testing your IPN script you should be using a PayPal "Sandbox"
account: https://developer.paypal.com
When you are ready to go live change use_sandbox to false.
*/
$listener->use_sandbox = true;
/*
By default the IpnListener object is going  going to post the data back to PayPal
using cURL over a secure SSL connection. This is the recommended way to post
the data back, however, some people may have connections problems using this
コード例 #25
0
 function get_option($option_name, $default = null)
 {
     if (strstr($option_name, '[')) {
         parse_str($option_name, $option_array);
         // Option name is first key
         $option_name = current(array_keys($option_array));
         // Get value
         $option_values = get_option($option_name, '');
         $key = key($option_array[$option_name]);
         if (isset($option_values[$key])) {
             $option_value = $option_values[$key];
         } else {
             $option_value = null;
         }
         // Single value
     } else {
         $option_value = LP()->settings->get(preg_replace('!^learn_press_!', '', $option_name), null);
     }
     if (is_array($option_value)) {
         $option_value = array_map('stripslashes', $option_value);
     } elseif (!is_null($option_value)) {
         $option_value = stripslashes($option_value);
     }
     return $option_value === null ? $default : $option_value;
 }
コード例 #26
0
?>
</th>
		<td><?php 
echo LP()->cart->get_subtotal();
?>
</td>
	</tr>

	<?php 
do_action('learn_press_review_order_before_order_total');
?>

	<tr class="order-total">
		<th><?php 
_e('Total', 'learn_press');
?>
</th>
		<td><?php 
echo LP()->cart->get_total();
?>
</td>
	</tr>

	<?php 
do_action('learn_press_review_order_after_order_total');
?>

	</tfoot>

</table>
コード例 #27
0
 function save_post_action()
 {
     if ($post_id = $this->get('ID')) {
         $post_data = isset($_POST[LP()->question_post_type]) ? $_POST[LP()->question_post_type] : array();
         $post_answers = array();
         $post_explain = $post_data[$post_id]['explaination'];
         if (isset($post_data[$post_id]) && ($post_data = $post_data[$post_id])) {
             wp_update_post(array('ID' => $post_id, 'post_title' => $post_data['text'], 'post_type' => LP()->question_post_type));
             $index = 0;
             foreach ($post_data['answer']['text'] as $k => $txt) {
                 if (!$txt) {
                     continue;
                 }
                 $post_answers[$index++] = array('text' => $txt, 'is_true' => $post_data['answer']['is_true'][$k]);
             }
         }
         $post_data['answer'] = $post_answers;
         $post_data['type'] = $this->get_type();
         $post_data['explaination'] = $post_explain;
         update_post_meta($post_id, '_lpr_question', $post_data);
     }
     return $post_id;
 }
コード例 #28
0
				<?php 
                learn_press_display_message(apply_filters('learn_press_user_can_not_enroll_course_message', __('You have already purchased this course. Please wait for approve', 'learn_press'), $course, $user));
                ?>

			<?php 
            }
            ?>
		<?php 
        }
        ?>
	<?php 
    } elseif ($user->can('purchase-course', $course->id)) {
        ?>

		<?php 
        if (LP()->cart->has_item($course->id)) {
            ?>
			<?php 
            learn_press_display_message(sprintf(__('This course is already added to your cart <a href="%s" class="button view-cart-button">%s</a>', 'learn_press'), learn_press_get_page_link('cart'), __('View Cart', 'learn_press')));
            ?>
		<?php 
        } else {
            ?>

			<form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
				<?php 
            do_action('learn_press_before_purchase_button');
            ?>
				<input type="hidden" name="_wp_http_referer" value="<?php 
            echo get_the_permalink();
            ?>
コード例 #29
0
function learn_press_current_user_can_view_profile_section($section, $user)
{
    $current_user = wp_get_current_user();
    $view = true;
    if ($user->user_login != $current_user->user_login && $section == LP()->settings->get('profile_endpoints.profile-orders', 'profile-orders')) {
        $view = false;
    }
    return apply_filters('learn_press_current_user_can_view_profile_section', $view, $section, $user);
}
コード例 #30
0
			</ul>
		</div>
		-OR-
		<button id="learn-press-button-add-question" class="button" type="button"><?php 
_e('Add Existing Question', 'learn_press');
?>
</button>
	</div>
	<!--
	<div class="question-actions">
		<div id="learn-press-dropdown-questions">
			<input type="text" name="question" id="learn-press-question-name" />
			<button id="learn-press-toggle-questions" type="button" class="dashicons dashicons-arrow-down"></button>
			<ul>
				<?php 
$query_args = array('post_type' => LP()->question_post_type, 'post_status' => 'publish', 'author' => $current_user, 'posts_per_page' => -1);
$query = new WP_Query($query_args);
if ($query->have_posts()) {
    while ($query->have_posts()) {
        $p = $query->next_post();
        ?>
						<li class="question<?php 
        echo in_array($p->ID, $exclude_ids) ? ' added' : '';
        ?>
">
							<a href="" data-id="<?php 
        echo $p->ID;
        ?>
"><?php 
        echo $p->post_title;
        ?>