| 1 |
<?php |
| 2 |
/** |
| 3 |
* Define common constants used by LearnPress |
| 4 |
*/ |
| 5 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 6 |
$upload_dir = wp_upload_dir(); |
| 7 |
$plugin_info = get_plugin_data( LP_PLUGIN_FILE ); |
| 8 |
|
| 9 |
// version. |
| 10 |
define( 'LEARNPRESS_VERSION', $plugin_info['Version'] ); |
| 11 |
const LP_KEY_DB_VERSION = 'learnpress_db_version'; |
| 12 |
|
| 13 |
// Plugin paths and urls. |
| 14 |
define( 'LP_PLUGIN_PATH', plugin_dir_path( LP_PLUGIN_FILE ) ); |
| 15 |
define( 'LP_PLUGIN_BASENAME', plugin_basename( LP_PLUGIN_FILE ) ); |
| 16 |
define( 'LP_PLUGIN_FOLDER_NAME', str_replace( array( '/', basename( LP_PLUGIN_FILE ) ), '', LP_PLUGIN_BASENAME ) ); |
| 17 |
const LP_TEMPLATE_PATH = LP_PLUGIN_PATH . 'templates/'; |
| 18 |
define( 'LP_PLUGIN_URL', trailingslashit( plugins_url( '/', LP_PLUGIN_FILE ) ) ); |
| 19 |
const LP_JS_URL = LP_PLUGIN_URL . 'assets/js/'; |
| 20 |
const LP_CSS_URL = LP_PLUGIN_URL . 'assets/css/'; |
| 21 |
|
| 22 |
// Log path. |
| 23 |
define( 'LP_LOG_PATH', $upload_dir['basedir'] . '/learn-press-logs/' ); |
| 24 |
|
| 25 |
// Turn on/off cart. |
| 26 |
const LP_ENABLE_CART = false; |
| 27 |
|
| 28 |
// Cache group id. |
| 29 |
const LP_SESSION_CACHE_GROUP = 'learn_press_session_id'; |
| 30 |
|
| 31 |
// Table prefix. |
| 32 |
const LP_TABLE_PREFIX = 'learnpress_'; |
| 33 |
|
| 34 |
// Define constants for custom post types. |
| 35 |
const LP_COURSE_CPT = 'lp_course'; |
| 36 |
const LP_LESSON_CPT = 'lp_lesson'; |
| 37 |
const LP_QUESTION_CPT = 'lp_question'; |
| 38 |
const LP_QUIZ_CPT = 'lp_quiz'; |
| 39 |
const LP_ORDER_CPT = 'lp_order'; |
| 40 |
|
| 41 |
// Role of user . |
| 42 |
const LP_TEACHER_ROLE = 'lp_teacher'; |
| 43 |
const ADMIN_ROLE = 'administrator'; |
| 44 |
|
| 45 |
// Options. |
| 46 |
const LP_USE_ATTRIBUTES = false; |
| 47 |
|
| 48 |
// Error codes. |
| 49 |
const LP_REQUIRE_LOGIN = 120; |
| 50 |
const LP_INVALID_QUIZ_OR_COURSE = 140; |
| 51 |
const LP_COURSE_IS_FINISHED = 150; |
| 52 |
const LP_QUIZ_HAS_STARTED_OR_COMPLETED = 160; |
| 53 |
const LP_ERROR_NO_PAYMENT_METHOD_SELECTED = 1000; |
| 54 |
const LP_COMPLETE_ITEM_FAIL = 170; |
| 55 |
|
| 56 |
// Pages. |
| 57 |
const LP_PAGE_CHECKOUT = 'lp_page_checkout'; |
| 58 |
const LP_PAGE_COURSES = 'lp_page_courses'; |
| 59 |
const LP_PAGE_SINGLE_COURSE = 'lp_page_single_course'; |
| 60 |
const LP_PAGE_QUIZ = 'lp_page_quiz'; |
| 61 |
const LP_PAGE_QUESTION = 'lp_page_question'; |
| 62 |
const LP_PAGE_PROFILE = 'lp_page_profile'; |
| 63 |
const LP_PAGE_BECOME_A_TEACHER = 'lp_page_become_a_teacher'; |
| 64 |
const LP_PAGE_SINGLE_COURSE_CURRICULUM = 'lp_page_single_course_curriculum'; |
| 65 |
|
| 66 |
// Key block course's item. |
| 67 |
const LP_BLOCK_COURSE_FINISHED = 'block_course_finished'; |
| 68 |
const LP_BLOCK_COURSE_DURATION_EXPIRE = 'block_course_duration_expire'; |
| 69 |
const LP_BLOCK_COURSE_PURCHASE = 'block_course_purchased'; |
| 70 |
|
| 71 |
// Status user item course. |
| 72 |
const LP_COURSE_ENROLLED = 'enrolled'; |
| 73 |
const LP_COURSE_FINISHED = 'finished'; |
| 74 |
const LP_COURSE_PURCHASED = 'purchased'; |
| 75 |
const LP_ITEM_COMPLETED = 'completed'; |
| 76 |
const LP_ITEM_STARTED = 'started'; |
| 77 |
|
| 78 |
// Graduation user item course |
| 79 |
const LP_COURSE_GRADUATION_IN_PROGRESS = 'in-progress'; |
| 80 |
const LP_COURSE_GRADUATION_PASSED = 'passed'; |
| 81 |
const LP_COURSE_GRADUATION_FAILED = 'failed'; |
| 82 |
|
| 83 |
// Enable lazy-load animation placeholder. |
| 84 |
const LP_LAZY_LOAD_ANIMATION = true; |
| 85 |
|