static function exception($message) { if (LP_Settings::instance()->get('debug') != 'yes') { return; } throw new Exception($message); }
static function _minify_source() { if (LP_Settings::instance()->get('debug') == 'yes') { return; } $minify = self::$_minify; foreach ($minify as $find => $replace) { self::_create_file($find, $replace); } }
/** * Output common js settings in admin * * @since 0.9.4 */ function plugin_js_settings() { static $did = false; if ($did) { return; } $js = array('ajax' => admin_url('admin-ajax.php'), 'plugin_url' => LearnPress()->plugin_url(), 'siteurl' => home_url()); echo '<script type="text/javascript">var LearnPress_Settings = ' . json_encode($js) . '</script>'; if (LP_Settings::instance()->get('debug') == 'yes') { echo '<script type="text/javascript">var LEARN_PRESS_DEBUG = true;</script>'; } $did = true; }
static function instance() { if (empty(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Includes needed files */ function includes() { require_once 'inc/lp-deprecated.php'; // include core functions require_once 'inc/lp-core-functions.php'; require_once 'inc/lp-add-on-functions.php'; // auto include file for class if class doesn't exists require_once 'inc/class-lp-autoloader.php'; require_once 'inc/class-lp-install.php'; require_once 'inc/lp-webhooks.php'; require_once 'inc/class-lp-request-handler.php'; if (is_admin()) { require_once 'inc/admin/class-lp-admin-notice.php'; if (!class_exists('RWMB_Meta_Box')) { require_once 'inc/libraries/meta-box/meta-box.php'; } require_once 'inc/admin/class-lp-admin.php'; //require_once 'inc/admin/class-lp-admin-settings.php'; require_once 'inc/admin/settings/class-lp-settings-base.php'; require_once 'inc/admin/class-lp-admin-assets.php'; } else { } $this->settings = LP_Settings::instance(); require_once 'inc/class-lp-assets.php'; require_once 'inc/question/abstract-lp-question.php'; require_once 'inc/question/class-lp-question-factory.php'; $this->include_post_types(); // course require_once 'inc/course/lp-course-functions.php'; require_once 'inc/course/abstract-lp-course.php'; require_once 'inc/course/class-lp-course.php'; // quiz require_once 'inc/quiz/lp-quiz-functions.php'; require_once 'inc/quiz/class-lp-quiz.php'; // question //require_once 'inc/question/lp-question.php'; // order require_once 'inc/order/lp-order-functions.php'; require_once 'inc/order/class-lp-order.php'; // user API require_once 'inc/user/lp-user-functions.php'; require_once 'inc/user/abstract-lp-user.php'; require_once 'inc/user/class-lp-user.php'; // others require_once 'inc/class-lp-session.php'; require_once 'inc/admin/class-lp-profile.php'; require_once 'inc/admin/class-lp-email.php'; // assets if (is_admin()) { //Include pointers require_once 'inc/admin/pointers/pointers.php'; } else { // shortcodes require_once 'inc/class-lp-shortcodes.php'; // Include short-code file require_once 'inc/shortcodes/profile-page.php'; require_once 'inc/shortcodes/archive-courses.php'; } // include template functions require_once 'inc/lp-template-functions.php'; require_once 'inc/lp-template-hooks.php'; // settings //require_once 'inc/class-lp-settings.php'; // simple cart require_once 'inc/cart/class-lp-cart.php'; // payment gateways require_once 'inc/gateways/class-lp-gateway-abstract.php'; require_once 'inc/gateways/class-lp-gateways.php'; //add ajax-action require_once 'inc/admin/class-lp-admin-ajax.php'; require_once 'inc/class-lp-ajax.php'; require_once 'inc/class-lp-multi-language.php'; if (!empty($_REQUEST['debug'])) { require_once 'inc/debug.php'; } }
/** * Register course post type */ static function register_post_type() { $settings = LP_Settings::instance(); $labels = array('name' => _x('Courses', 'Post Type General Name', 'learn_press'), 'singular_name' => _x('Course', 'Post Type Singular Name', 'learn_press'), 'menu_name' => __('Courses', 'learn_press'), 'parent_item_colon' => __('Parent Item:', 'learn_press'), 'all_items' => __('Courses', 'learn_press'), 'view_item' => __('View Course', 'learn_press'), 'add_new_item' => __('Add New Course', 'learn_press'), 'add_new' => __('Add New', 'learn_press'), 'edit_item' => __('Edit Course', 'learn_press'), 'update_item' => __('Update Course', 'learn_press'), 'search_items' => __('Search Course', 'learn_press'), 'not_found' => sprintf(__('You have not got any course yet. Click <a href="%s">Add new</a> to start', 'learn_press'), admin_url('post-new.php?post_type=lp_course')), 'not_found_in_trash' => __('No course found in Trash', 'learn_press')); $course_permalink = empty($course_base = $settings->get('course_base')) ? _x('courses', 'slug', 'learn_press') : $course_base; $args = array('labels' => $labels, 'public' => true, 'query_var' => true, 'publicly_queryable' => true, 'show_ui' => true, 'has_archive' => ($page_id = learn_press_get_page_id('courses')) && get_post($page_id) ? get_page_uri($page_id) : 'course', 'capability_type' => LP_COURSE_CPT, 'map_meta_cap' => true, 'show_in_menu' => 'learn_press', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'taxonomies' => array('course_category', 'course_tag'), 'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'comments', 'author'), 'hierarchical' => true, 'rewrite' => array('slug' => $course_permalink, 'hierarchical' => true, 'with_front' => false)); register_post_type(LP_COURSE_CPT, $args); register_taxonomy('course_category', array(LP_COURSE_CPT), array('label' => __('Course Categories', 'learn_press'), 'labels' => array('name' => __('Course Categories', 'learn_press'), 'menu_name' => __('Category', 'learn_press'), 'singular_name' => __('Category', 'learn_press'), 'add_new_item' => __('Add New Course Category', 'learn_press'), 'all_items' => __('All Categories', 'learn_press')), 'query_var' => true, 'public' => true, 'hierarchical' => true, 'show_ui' => true, 'show_in_menu' => 'learn_press', 'show_admin_column' => true, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'rewrite' => array('slug' => empty($category_base = $settings->get('course_category_base')) ? _x('course-category', 'slug', 'learn_press') : $category_base, 'hierarchical' => true, 'with_front' => false))); register_taxonomy('course_tag', array(LP_COURSE_CPT), array('labels' => array('name' => __('Course Tags', 'learn_press'), 'singular_name' => __('Tag', 'learn_press'), 'search_items' => __('Search Course Tags', 'learn_press'), 'popular_items' => __('Popular Course Tags', 'learn_press'), 'all_items' => __('All Course Tags', 'learn_press'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Course Tag', 'learn_press'), 'update_item' => __('Update Course Tag', 'learn_press'), 'add_new_item' => __('Add New Course Tag', 'learn_press'), 'new_item_name' => __('New Course Tag Name', 'learn_press'), 'separate_items_with_commas' => __('Separate tags with commas', 'learn_press'), 'add_or_remove_items' => __('Add or remove tags', 'learn_press'), 'choose_from_most_used' => __('Choose from the most used tags', 'learn_press'), 'menu_name' => __('Tags', 'learn_press')), 'public' => true, 'hierarchical' => false, 'show_ui' => true, 'show_in_menu' => 'learn_press', 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => array('slug' => empty($tag_base = $settings->get('course_tag_base')) ? _x('course-tag', 'slug', 'learn_press') : $tag_base, 'with_front' => false))); /*if ( !is_admin() ) { LP_Assets::enqueue_script( 'tipsy', LP_PLUGIN_URL . '/assets/js/jquery.tipsy.js' ); LP_Assets::enqueue_style( 'tipsy', LP_PLUGIN_URL . '/assets/css/tipsy.css' ); } flush_rewrite_rules();*/ }
function learn_press_init() { if (class_exists('LP_Settings')) { $settings = LP_Settings::instance('general'); if ($settings->get('instructor_registration')) { add_action('register_form', 'learn_press_edit_registration'); add_action('user_register', 'learn_press_registration_save', 10, 1); } } }
<?php /** * Display settings for course * * @author ThimPress * @package LearnPress/Admin/Views * @version 1.0 */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } $settings = LP_Settings::instance(); ?> <h3 class=""><?php echo $this->section['title']; ?> </h3> <table class="form-table"> <tbody> <?php do_action('learn_press_before_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings); ?> <?php foreach ($this->get_settings() as $field) { ?> <?php $this->output_field($field); ?> <?php