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


PHP LP函数代码示例

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


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

示例1: save_post_action

 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();
 }
开发者ID:taibeo1905,项目名称:LearnPress,代码行数:30,代码来源:class-lp-question-true-or-false.php

示例2: save_quiz_questions

 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);
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:31,代码来源:class-quiz-questions-field.php

示例3: add_to_cart

 /**
  * 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;
     }
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:41,代码来源:class-lp-cart.php

示例4: message_editor

 /**
  * @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]"));
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:10,代码来源:class-lp-settings-emails.php

示例5: include_update

 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');
     }
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:7,代码来源:class-lp-admin.php

示例6: notify_new_course

 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>";
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:11,代码来源:class-lp-admin-menu.php

示例7: __construct

 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();
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:11,代码来源:class-lp-email-new-course.php

示例8: __construct

 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);
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:16,代码来源:class-lp-emails.php

示例9: load_scripts

 /**
  * 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'));
     }
 }
开发者ID:taibeo1905,项目名称:LearnPress,代码行数:20,代码来源:class-lp-admin-assets.php

示例10: get_question_class

 /**
  * 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);
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:24,代码来源:class-lp-question-factory.php

示例11: get_course_class

 /**
  * 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);
 }
开发者ID:thonysmith,项目名称:LearnPress,代码行数:28,代码来源:class-lp-course.php

示例12: learn_press_get_course_order

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;
}
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:24,代码来源:lp-order-functions.php

示例13: LP

$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>
开发者ID:thonysmith,项目名称:LearnPress,代码行数:31,代码来源:history.php

示例14: get_curriculum_items

 /**
  * 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);
 }
开发者ID:taibeo1905,项目名称:LearnPress,代码行数:78,代码来源:abstract-lp-course.php

示例15: get_icon

 function get_icon()
 {
     return '<img src="' . apply_filters('learn_press_question_icon', LP()->plugin_url('assets/images/question.png'), $this) . '">';
 }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:4,代码来源:abstract-lp-question.php


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