static function update_version_10() { $update = false; if (!self::_has_new_table()) { self::_create_tables(); $update = true; } if (!get_option('learnpress_version')) { self::_create_options(); $update = true; } $ask = get_transient('learn_press_upgrade_courses_ask_again'); if (version_compare(LEARNPRESS_VERSION, '1.0') === 0 && self::_need_to_update() || $update) { // Notify for administrator if (empty($ask) && learn_press_current_user_is('administrator')) { LP_Admin_Assets::enqueue_style('learn-press-upgrade', LP()->plugin_url('assets/css/admin/upgrade.css')); LP_Admin_Assets::enqueue_script('learn-press-upgrade', LP()->plugin_url('assets/js/admin/upgrade.js')); $upgrade_url = wp_nonce_url(admin_url('options-general.php?page=learn_press_upgrade_10'), 'learn-press-upgrade'); $message = sprintf('<p>%s</p>', __('It seem to be you have updated LearnPress from old version and there are some courses or data is out of date and need to upgrade.', 'learn_press')); $message .= sprintf('<div id="learn-press-confirm-abort-upgrade-course"><p><label><input type="checkbox" id="learn-press-ask-again-abort-upgrade" /> %s</label></p><p><button href="" class="button disabled" data-action="yes">%s</button> <button href="" class="button" data-action="no">%s</button> </p></div>', __('Do not ask again.', 'learn_press'), __('Ok', 'learn_press'), __('Cancel', 'learn_press')); $message .= sprintf('<p id="learn-press-upgrade-course-actions"><a href="%s" class="button" data-action="upgrade">%s</a> <button class="button disabled" data-action="abort">%s</button></p>', $upgrade_url, __('Upgrade now', 'learn_press'), __('No, thank!', 'learn_press')); LP_Admin_Notice::add($message, 'error'); } // Notify for instructor if (learn_press_current_user_is('instructor')) { LP_Admin_Notice::add(sprintf('<p>%s</p>', __('LearnPress has upgraded and need to upgrade the database before you can work with it. Please notify the site administrator.', 'learn_press')), 'error'); } } }
function enqueue_script() { if (LP()->lesson_post_type != get_post_type()) { return; } LP_Admin_Assets::enqueue_script('select2', LP_PLUGIN_URL . '/lib/meta-box/js/select2/select2.min.js'); LP_Admin_Assets::enqueue_style('select2', LP_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); }
static function admin_enqueue_scripts() { /*$q = new LP_Question(); $q->admin_script();*/ LP_Admin_Assets::enqueue_style('select2', RWMB_CSS_URL . 'select2/select2.css'); LP_Admin_Assets::enqueue_script('select2', RWMB_JS_URL . 'select2/select2.min.js'); LP_Admin_Assets::enqueue_script('lpr-quiz-question', LearnPress()->plugin_url('inc/admin/meta-boxes/js/quiz-question.js')); }
static function admin_enqueue_scripts() { /*$q = new LP_Question(); $q->admin_script();*/ LP_Admin_Assets::enqueue_style('select2', RWMB_CSS_URL . 'select2/select2.css'); LP_Admin_Assets::enqueue_script('select2', RWMB_JS_URL . 'select2/select2.min.js'); LP_Admin_Assets::enqueue_script('lpr-quiz-question', learn_press_plugin_url('assets/js/admin/meta-box-quiz.js')); wp_enqueue_script('modal-search-items'); }
/** * Enqueue scripts * * @static */ static function admin_scripts() { LP_Admin_Assets::add_localize(array('notice_remove_section_item' => __('Are you sure you want to remove this item?', 'learn_press')), null, 'admin-course'); if (in_array(get_post_type(), array(LP()->course_post_type, LP()->lesson_post_type))) { wp_enqueue_style('lp-meta-boxes', LP()->plugin_url('assets/css/meta-boxes.css')); wp_enqueue_script('jquery-caret', LP()->plugin_url('assets/js/jquery.caret.js', 'jquery')); wp_enqueue_script('lp-meta-boxes', LP()->plugin_url('assets/js/meta-boxes.js', 'jquery', 'backbone', 'util')); wp_localize_script('lp-meta-boxes', 'lp_course_params', self::admin_params()); } }
/** * Enqueue scripts and styles * * @return void */ static function admin_enqueue_scripts() { LP_Admin_Assets::enqueue_style('meta-box-course', LP()->plugin_url('assets/css/admin/meta-box-course.css')); LP_Admin_Assets::enqueue_style('select2', RWMB_CSS_URL . 'select2/select2.css'); LP_Admin_Assets::enqueue_style('toastr', LP_CSS_URL . 'toastr.css'); //LP_Admin_Assets::enqueue_style( 'thim-course', LearnPress()->plugin_url( 'inc/admin/meta-boxes/css/course.css' ) ); LP_Admin_Assets::enqueue_script('select2', RWMB_JS_URL . 'select2/select2.min.js'); LP_Admin_Assets::enqueue_script('toastr', LP_JS_URL . 'toastr.js'); LP_Admin_Assets::enqueue_script('tojson', LP_JS_URL . 'toJSON.js'); LP_Admin_Assets::enqueue_script('meta-box-course', LearnPress()->plugin_url('assets/js/admin/meta-box-course.js'), array('jquery', 'toastr', 'tojson')); LP_Admin_Assets::add_localize(array('confirm_remove_section_lesson' => __('Do you want to remove this lesson permanently?', 'learn_press'), 'confirm_remove_section_quiz' => __('Do you want to remove this quiz permanently?', 'learn_press'), 'confirm_remove_section' => __('Do you want to remove this section permanently?', 'learn_press'), 'add_new_quiz' => __('New quiz added', 'learn_press'), 'add_new_lesson' => __('New lesson added', 'learn_press'), 'add_new_section' => __('New section added', 'learn_press'), 'remove_section_lesson' => __('The lesson removed', 'learn_press'), 'remove_section_quiz' => __('The quiz removed', 'learn_press'), 'remove_section' => __('The section removed', 'learn_press'), 'section_ordered' => __('The ordering completed', 'learn_press'), 'add_lesson_to_section' => __('Lesson added to section complete!', 'learn_press'), 'add_quiz_to_section' => __('Quiz added to section complete!', 'learn_press'), 'update_lesson_quiz' => __('%s updated', 'learn_press'), 'quick_edit_name' => __('Click to quick edit name', 'learn_press'), 'confirm_remove_section_assignment' => __('Do you want to remove this assignment permanently', 'learn_press'), 'add_new_assignment' => __('New assignment added', 'learn_press'), 'remove_section_assignment' => __('The assignment removed', 'learn_press'), 'add_assignment_to_section' => __('Assignment added to section complete!', 'learn_press')), null, 'meta-box-course'); }
/** * Enqueue admin scripts */ public function admin_scripts() { /** * Tipsy tooltip assets */ LP_Admin_Assets::enqueue_style('jquery-tipsy', LP_CSS_URL . 'tipsy.css'); LP_Admin_Assets::enqueue_script('jquery-tipsy', LP_JS_URL . 'jquery.tipsy.js'); }
static function admin_assets() { LP_Admin_Assets::enqueue_style('learnpress-question', learn_press_plugin_url('assets/css/admin/meta-box-question.css')); LP_Admin_Assets::enqueue_script('learnpress-question', learn_press_plugin_url('assets/js/admin/meta-box-question.js'), array('jquery', 'jquery-ui-sortable')); }
/** * Translate javascript text */ function learn_press_admin_localize_script() { if (defined('DOING_AJAX') || !is_admin()) { return; } $translate = array('quizzes_is_not_available' => __('Quiz is not available', 'learn_press'), 'lessons_is_not_available' => __('Lesson is not available', 'learn_press')); LP_Admin_Assets::add_localize($translate); }
* Load assets for admin */ static function load_scripts() { $screen = get_current_screen(); $screen_id = $screen->id; $page_id = !empty($_REQUEST['page']) ? $_REQUEST['page'] : ''; if (in_array($screen_id, learn_press_get_screens()) || in_array($page_id, learn_press_get_admin_pages())) { 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', learn_press_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', learn_press_plugin_url('assets/js/admin/meta-box-order.js'), array('backbone', 'wp-util')); } } static function _print_assets() { self::enqueue_style('learn-press-icons'); self::enqueue_style('learn-press-admin'); self::enqueue_style('learn-press-order'); self::enqueue_script('learn-press-order'); self::enqueue_script('learn-press-admin'); } } LP_Admin_Assets::init();