本文整理汇总了PHP中learn_press_enqueue_script函数的典型用法代码示例。如果您正苦于以下问题:PHP learn_press_enqueue_script函数的具体用法?PHP learn_press_enqueue_script怎么用?PHP learn_press_enqueue_script使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了learn_press_enqueue_script函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enqueue_script
function enqueue_script()
{
if ('lpr_lesson' != get_post_type()) {
return;
}
LPR_Admin_Assets::enqueue_script('select2', LPR_PLUGIN_URL . '/lib/meta-box/js/select2/select2.min.js');
LPR_Admin_Assets::enqueue_style('select2', LPR_PLUGIN_URL . '/lib/meta-box/css/select2/select2.css');
ob_start();
?>
<script>
var form = $('#post');
form.submit(function (evt) {
var $title = $('#title'),
is_error = false;
if (0 == $title.val().length) {
alert('<?php
_e('Please enter the title of the lesson', 'learn_press');
?>
');
$title.focus();
is_error = true;
}
if (is_error) {
evt.preventDefault();
return false;
}
});
</script>
<?php
$script = ob_get_clean();
$script = preg_replace('!</?script>!', '', $script);
learn_press_enqueue_script($script);
}
示例2: __construct
function __construct()
{
if (self::$loaded) {
return;
}
$this->paypal_live_url = 'https://www.paypal.com/';
$this->paypal_sandbox_url = 'https://www.sandbox.paypal.com/';
$this->paypal_payment_live_url = 'https://www.paypal.com/cgi-bin/webscr';
$this->paypal_payment_sandbox_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$this->paypal_nvp_api_live_url = 'https://api-3t.paypal.com/nvp';
$this->paypal_nvp_api_sandbox_url = 'https://api-3t.sandbox.paypal.com/nvp';
$settings = learn_press_settings('payment');
$this->method = !empty($_REQUEST['learn-press-transaction-method']) ? $_REQUEST['learn-press-transaction-method'] : '';
if ($settings->get('paypal.enable')) {
add_action('init', array($this, 'register_web_hook'));
add_action('learn_press_take_course_paypal', array($this, 'process_payment'));
add_action('learn_press_do_transaction_paypal-standard-secure', array($this, 'process_order_paypal_standard_secure'));
add_action('learn_press_do_transaction_paypal-standard', array($this, 'process_order_paypal_standard'));
//add_action('learn_press_update_order_status', array($this, 'remove_transient'), 5, 2);
//add_action('learn_press_payment_gateway_form_paypal', array($this, 'payment_form'));
add_action('learn_press_web_hook_learn_press_paypal-standard', array($this, 'web_hook_process_paypal_standard'));
add_action('learn_press_web_hook_learn_press_paypal-standard-secure', array($this, 'web_hook_process_paypal_standard_secure'));
add_action('init', array($this, 'parse_ipn'));
add_filter('learn_press_payment_method_from_slug_paypal-standard-secure', array($this, 'payment_method_name'));
add_filter('learn_press_payment_method_from_slug_paypal-standard', array($this, 'payment_method_name'));
}
if (is_admin()) {
ob_start();
?>
<script>
$('#learn_press_paypal_enable').change(function(){
var $rows = $(this).closest('tr').siblings('tr');
if( this.checked ){
$rows.css("display", "");
}else{
$rows.css("display", "none");
}
}).trigger('change');
</script>
<?php
$script = ob_get_clean();
$script = preg_replace('!</?script>!', '', $script);
learn_press_enqueue_script($script);
}
add_filter('learn_press_payment_gateway_available_paypal', array($this, 'paypal_available'), 10, 2);
parent::__construct();
self::$loaded = true;
}
示例3: _admin_enqueue_script
/**
* @param bool $enqueue
*/
private function _admin_enqueue_script($enqueue = true)
{
ob_start();
$key = 'question_' . $this->get('ID');
?>
<script type="text/javascript">
(function ($) {
var $form = $('#post');
$form.unbind('learn_press_question_before_update.<?php
echo $key;
?>
').on('learn_press_question_before_update.<?php
echo $key;
?>
', function () {
var $question = $('.lpr-question-single-choice[data-id="<?php
echo $this->get('ID');
?>
"]');
if ($question.length) {
var $input = $('.lpr-is-true-answer input[type="radio"]:checked', $question);
if (0 == $input.length) {
var message = $('.lpr-question-title input', $question).val();
message += ": " + '<?php
_e('No answer added to question or you must set an answer is correct!', 'learn_press');
?>
'
window.learn_press_before_update_quiz_message.push(message);
return false;
}
}
});
})(jQuery);
</script>
<?php
$script = ob_get_clean();
if ($enqueue) {
$script = preg_replace('!</?script.*>!', '', $script);
learn_press_enqueue_script($script);
} else {
echo $script;
}
}
示例4: enqueue_script
/**
* Enqueue scripts
*/
function enqueue_script()
{
if (!in_array(get_post_type(), array('lpr_question'))) {
return;
}
ob_start();
?>
<script>
var form = $('#post');
form.submit(function (evt) {
var $title = $('#title'),
is_error = false;
if (0 == $title.val().length) {
alert('<?php
_e('Please enter the title of the question', 'learn_press');
?>
');
$title.focus();
is_error = true;
} else if ( $('.lpr-question-types').length && ( 0 == $('.lpr-question-types').val().length ) ) {
alert('<?php
_e('Please a type of question', 'learn_press');
?>
');
$('.lpr-question-types').focus();
is_error = true;
}
if (is_error) {
evt.preventDefault();
return false;
}
});
</script>
<?php
$script = ob_get_clean();
$script = preg_replace('!</?script>!', '', $script);
learn_press_enqueue_script($script);
ob_start();
?>
<script type="text/html" id="tmpl-form-quick-add-question">
<div id="lpr-form-quick-add-question" class="lpr-quick-add-form">
<input type="text">
<select class="lpr-question-types lpr-select2" name="lpr_question[type]" id="lpr-quiz-question-type">
<?php
if ($questions = lpr_get_question_types()) {
?>
<?php
foreach ($questions as $type) {
$question = LPR_Question_Type::instance($type);
if (!$question) {
continue;
}
?>
<option value="<?php
echo $type;
?>
"><?php
echo $question->get_name();
?>
</option>
<?php
}
?>
<?php
}
?>
</select>
<button class="button" data-action="add" type="button"><?php
_e('Add [Enter]', 'learn_press');
?>
</button>
<button data-action="cancel" class="button" type="button"><?php
_e('Cancel [ESC]', 'learn_press');
?>
</button>
<span class="lpr-ajaxload">...</span>
</div>
</script>
<?php
$js_template = ob_get_clean();
learn_press_enqueue_script($js_template, true);
}
示例5: load_scripts
/**
* Load Script
*/
static function load_scripts()
{
self::add_style('lpr-learnpress-css', LPR_CSS_URL . 'learnpress.css');
self::add_style('lpr-time-circle-css', LPR_CSS_URL . 'timer.css');
self::add_script('learn-press-js', LPR_JS_URL . 'learnpress.js', array('jquery'), '', true);
self::add_script('lpr-alert-js', LPR_JS_URL . 'jquery.alert.js', array('jquery'));
self::add_script('lpr-time-circle-js', LPR_JS_URL . 'jquery.timer.js', array('jquery'));
learn_press_enqueue_script("<script>var ajaxurl='" . admin_url('admin-ajax.php') . "';</script>", true);
global $post;
if (!in_array($post->post_type, array('lpr_course', 'lpr_quiz', 'lpr_lesson'))) {
return;
}
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');
}
示例6: enqueue_script
function enqueue_script()
{
if ('lpr_quiz' != get_post_type()) {
return;
}
ob_start();
?>
<script>
var form = $('#post');
form.submit(function(evt){
var $title = $('#title'),
is_error = false;
window.learn_press_before_update_quiz_message = [];
if( 0 == $title.val().length ){
window.learn_press_before_update_quiz_message.push( '<?php
_e('Please enter the title of the quiz', 'learn_press');
?>
' );
$title.focus();
is_error = true;
}
/* hook */
is_error = form.triggerHandler( 'learn_press_question_before_update' ) === false;
if( window.learn_press_before_update_quiz_message.length /*true == is_error*/ ){
if( window.learn_press_before_update_quiz_message.length ){
alert( "Error: \n" + window.learn_press_before_update_quiz_message.join( "\n\n" ) )
}
evt.preventDefault();
return false;
}
});
</script>
<?php
$script = ob_get_clean();
$script = preg_replace('!</?script>!', '', $script);
learn_press_enqueue_script($script);
ob_start();
?>
<script type="text/html" id="tmpl-form-quick-add-question">
<div id="lpr-form-quick-add-question" class="lpr-quick-add-form">
<input type="text">
<select class="lpr-question-types lpr-select2" name="lpr_question[type]" id="lpr-quiz-question-type">
<?php
if ($questions = lpr_get_question_types()) {
?>
<?php
foreach ($questions as $type) {
?>
<option value="<?php
echo $type;
?>
"><?php
echo LPR_Question_Type::instance($type)->get_name();
?>
</option>
<?php
}
?>
<?php
}
?>
</select>
<button class="button" data-action="add" type="button"><?php
_e('Add [Enter]', 'learnpress');
?>
</button>
<button data-action="cancel" class="button" type="button"><?php
_e('Cancel [ESC]', 'learnpress');
?>
</button>
<span class="lpr-ajaxload">...</span>
</div>
</script>
<?php
$js_template = ob_get_clean();
learn_press_enqueue_script($js_template, true);
}
示例7: become_teacher_form
/**
* Display a form let the user can be join as a teacher
*/
static function become_teacher_form($atts)
{
global $current_user;
$user = new WP_User($current_user->ID);
if (in_array(LP()->teacher_role, $user->roles)) {
return __("You are a teacher now", 'learn_press');
}
if (!is_user_logged_in()) {
return __("Please login to fill out this form", 'learn_press');
}
if (!empty($_REQUEST['become-a-teacher-send'])) {
return __('Your request has been sent! We will get in touch with you soon!', 'learn_press');
}
get_currentuserinfo();
$atts = shortcode_atts(array('method' => 'post', 'action' => '', 'title' => __('Become a Teacher', 'learn_press'), 'description' => __('Fill out your information and send to us to become a teacher', 'learn_press'), 'submit_button_text' => __('Submit', 'learn_press')), $atts);
$fields = array('bat_name' => array('title' => __('Name', 'learn_press'), 'type' => 'text', 'placeholder' => __('Your name', 'learn_press'), 'def' => $current_user->display_name), 'bat_email' => array('title' => __('Email', 'learn_press'), 'type' => 'email', 'placeholder' => __('Your email address', 'learn_press'), 'def' => $current_user->user_email), 'bat_phone' => array('title' => __('Phone', 'learn_press'), 'type' => 'text', 'placeholder' => __('Your phone number', 'learn_press')));
$fields = apply_filters('learn_press_become_teacher_form_fields', $fields);
ob_start();
$form_template = learn_press_locate_template('global/become-teacher-form.php');
if (file_exists($form_template)) {
require $form_template;
}
$html = ob_get_clean();
ob_start();
?>
<script>
$('form[name="become_teacher_form"]').submit(function () {
var $form = $(this);
$form.siblings('.error-message').fadeOut('fast', function () {
$(this).remove()
});
if ($form.triggerHandler('become_teacher_send') !== false) {
$.ajax({
url : $form.attr('action'),
data : $form.serialize(),
dataType: 'html',
type : 'post',
success : function (code) {
if (code.indexOf('<!-- LP_AJAX_START -->') >= 0)
code = code.split('<!-- LP_AJAX_START -->')[1];
if (code.indexOf('<!-- LP_AJAX_END -->') >= 0)
code = code.split('<!-- LP_AJAX_END -->')[0];
var result = $.parseJSON(code);
return;
if (!result.error.length) {
var url = window.location.href;
if (url.indexOf('?') != -1) url += '&'
else url += '?';
url += 'become-a-teacher-send=1';
window.location.href = url;
} else {
$.each(result.error, function () {
$('<p class="error-message">' + this + '</p>').insertBefore($form);
})
}
}
});
}
return false;
});
</script>
<?php
$js = preg_replace('!</?script>!', '', ob_get_clean());
//$js = preg_replace( '!\s+|\t+!', ' ', $js );
learn_press_enqueue_script($js);
return $html;
}
示例8: admin_head
function admin_head()
{
global $post, $wp_query;
if ('lpr_order' != get_post_type()) {
return;
}
ob_start();
?>
<script>
$('#update-order-status').click(function(){
var $button = $(this).attr('disabled', 'disabled').html('<?php
_e('Processing...', 'learn_press');
?>
');
$.ajax({
url: ajaxurl,
type: 'POST',
dataType: 'json',
data:{
action: 'update_order_status',
order_id: '<?php
echo $post->ID;
?>
',
status: $('select[name="learn_press_order_status"]').val()
},
success: function (res) {
if (res.status) {
$('.order-data-status')
.removeClass('pending completed')
.html(res.status)
.addClass(res.class);
}
$button.removeAttr('disabled').html('<?php
_e('Apply', 'learn_press');
?>
');
},
error: function(){
$button.removeAttr('disabled').html('<?php
_e('Apply', 'learn_press');
?>
');
}
});
})
</script>
<?php
$js = preg_replace('!</?script>!', '', ob_get_clean());
learn_press_enqueue_script($js);
}
示例9: ob_start
</label>
</p>
</div>
<?php
ob_start();
?>
<script type="text/javascript">
jQuery('#post').submit(function (e) {
var $review = $('textarea[name="review_message"]', this),
$status = $('select#post_status', this),
clicked = $(':focus', this).attr('name');
if (clicked == 'save' && $status.val() != 'publish' && !($review.val() + '').length) {
alert('<?php
_e('Please write your message to Instructor', 'learn_press');
?>
');
$review.focus();
return false;
}
});
jQuery('#learn-press-notice-check').click(function(){
var $review = jQuery('textarea[name="review_message"]').prop('disabled', !this.checked);
this.checked && $review.focus();
});
</script>
<?php
learn_press_enqueue_script(strip_tags(ob_get_clean()));
?>
<?php
}
}
示例10: enqueue_script
function enqueue_script()
{
if ('lpr_course' != get_post_type()) {
return;
}
ob_start();
global $post;
?>
<script>
window.course_id = <?php
echo $post->ID;
?>
, form = $('#post');
form.submit(function (evt) {
var $title = $('#title'),
$curriculum = $('.lpr-curriculum-section:not(.lpr-empty)'),
is_error = false;
if (0 == $title.val().length) {
alert('<?php
_e('Please enter the title of the course', 'learn_press');
?>
');
$title.focus();
is_error = true;
} else if (0 == $curriculum.length) {
alert('<?php
_e('Please add at least one section for the course', 'learn_press');
?>
');
$('.lpr-curriculum-section .lpr-section-name').focus();
is_error = true;
} else {
$curriculum.each(function () {
var $section = $('.lpr-section-name', this);
if (0 == $section.val().length) {
alert('<?php
_e('Please enter the title of the section', 'learn_press');
?>
');
$section.focus();
is_error = true;
return false;
}
});
}
if( $( 'input[name="_lpr_course_payment"]:checked').val() == 'not_free' && $('input[name="_lpr_course_price"]').val() <= 0 ){
alert( '<?php
_e('Please set a price for this course', 'learn_press');
?>
' );
is_error = true;
$('input[name="_lpr_course_price"]').focus();
}
if (true == is_error) {
evt.preventDefault();
return false;
}
});
$('input[name="_lpr_course_final"]').bind('click change', function(){
if( $(this).val() == 'yes' ){
$(this).closest('.rwmb-field').next().show();
}else{
$(this).closest('.rwmb-field').next().hide();
}
}).filter(":checked").trigger('change')
</script>
<?php
$script = ob_get_clean();
$script = preg_replace('!</?script>!', '', $script);
learn_press_enqueue_script($script);
}
示例11: post_review_message_box
/**
* Log the messages between admin and instructor
*/
function post_review_message_box()
{
global $post;
if (!learn_press_course_is_required_review($post->ID, get_current_user_id())) {
//return;
}
$user = learn_press_get_current_user();
if ($user->is_instructor()) {
?>
<div id="learn-press-review-message">
<h4><?php
_e('Your message to Reviewer', 'learn_press');
?>
</h4>
<textarea name="review_message" resize="none" placeholder="<?php
_e('Enter some information here for reviewer', 'learn_press');
?>
"></textarea>
<p>
<label>
<input type="checkbox" />
<?php
_e('Notice to the admin for reviews', 'learn_press');
?>
</label>
</p>
<p class="description submitdelete">
<?php
_e('Warning! Your course will become to Pending Review for admin reviews before it can be published when you update');
?>
</p>
</div>
<?php
ob_start();
?>
<script type="text/javascript">
$('#post').submit(function (e) {
var $review = $('textarea[name="review_message"]');
if (!($review.val() + '').length) {
alert('<?php
_e('Please write your message to Reviewer', 'learn_press');
?>
');
$review.focus();
return false;
}
});
</script>
<?php
learn_press_enqueue_script(strip_tags(ob_get_clean()));
?>
<?php
} else {
if ($user->is_admin()) {
?>
<div id="learn-press-review-message">
<h4><?php
_e('Your message to Instructor', 'learn_press');
?>
</h4>
<textarea name="review_message" resize="none" placeholder="<?php
_e('Enter some information here for instructor. E.g: for reason why the course is rejected etc...', 'learn_press');
?>
"></textarea>
<p>
<label>
<input type="checkbox" />
<?php
_e('Notice to the instructor for changes', 'learn_press');
?>
</label>
</p>
</div>
<?php
ob_start();
?>
<script type="text/javascript">
$('#post').submit(function (e) {
var $review = $('textarea[name="review_message"]', this),
$status = $('select#post_status', this),
clicked = $(':focus', this).attr('name');
if (clicked == 'save' && $status.val() != 'publish' && !($review.val() + '').length) {
alert('<?php
_e('Please write your message to Reviewer', 'learn_press');
?>
');
$review.focus();
return false;
}
});
</script>
<?php
learn_press_enqueue_script(strip_tags(ob_get_clean()));
?>
<?php
}
}
//.........这里部分代码省略.........
示例12: init
function init()
{
if ($this->settings->get('paypal_enable')) {
if ($this->settings->get('paypal_sandbox') == 'no') {
$this->paypal_url = $this->paypal_live_url;
$this->paypal_payment_url = $this->paypal_payment_live_url;
$this->paypal_nvp_api_url = $this->paypal_nvp_api_live_url;
$this->paypal_email = $this->settings->get('paypal_email');
} else {
$this->paypal_url = $this->paypal_sandbox_url;
$this->paypal_payment_url = $this->paypal_payment_sandbox_url;
$this->paypal_nvp_api_url = $this->paypal_nvp_api_sandbox_url;
$this->paypal_email = $this->settings->get('paypal_sandbox_email');
}
if (did_action('init')) {
$this->register_web_hook();
$this->parse_ipn();
} else {
add_action('init', array($this, 'register_web_hook'));
add_action('init', array($this, 'parse_ipn'));
}
//add_action( 'learn_press_take_course_paypal', array( $this, 'process_payment' ) );
//add_action( 'learn_press_do_transaction_paypal-standard-secure', array( $this, 'process_order_paypal_standard_secure' ) );
//add_action( 'learn_press_do_transaction_paypal-standard', array( $this, 'process_order_paypal_standard' ) );
//add_action('learn_press_update_order_status', array($this, 'remove_transient'), 5, 2);
//add_action('learn_press_payment_gateway_form_paypal', array($this, 'payment_form'));
add_action('learn_press_web_hook_learn_press_paypal', array($this, 'web_hook_process_paypal'));
}
if (is_admin()) {
ob_start();
?>
<script>
$('#learn_press_paypal_enable').change(function () {
var $rows = $(this).closest('tr').siblings('tr');
if (this.checked) {
$rows.css("display", "");
} else {
$rows.css("display", "none");
}
}).trigger('change');
</script>
<?php
$script = ob_get_clean();
$script = preg_replace('!</?script>!', '', $script);
learn_press_enqueue_script($script);
}
add_filter('learn_press_payment_gateway_available_paypal', array($this, 'paypal_available'), 10, 2);
}
示例13: learn_press_page_title
/**
* Modify the page title depending on where we are standing in single course
* Page title = COURSE_TITLE::LESSON_TITLE
*
* @param $title
* @param $sep
*
* @return mixed
*/
function learn_press_page_title($title, $sep)
{
if (is_feed() || 'lpr_course' != get_post_type() || empty($_REQUEST['lesson'])) {
return $title;
}
$course_title = get_the_title();
learn_press_enqueue_script('window.learn_press_title_sep=\'' . $sep . '\'');
return preg_replace('!(' . $course_title . ')!', '$1::' . get_the_title($_REQUEST['lesson']), $title);
}
示例14: _e
_e('File was not found.', 'learn_press');
?>
</p>
<?php
}
?>
</div>
<?php
}
?>
</div>
<?php
}
?>
</td>
</tr>
<?php
ob_start();
?>
<script>
jQuery(function($){
$('#learn_press_email_formats').change(function(){
var format = $(this).val();
$('.'+format).show().siblings().hide();
}).change();
});
</script>
<?php
learn_press_enqueue_script(preg_replace('!</?script>!', '', ob_get_clean()));