This document outlines the main functions and classes that form the backbone of the LearnPress LMS plugin.
Core Classes
1. LP_Course
class LP_Course extends LP_Abstract_Course
File Location: inc/course/class-lp-course.php
Purpose:
Manages all information and behaviors related to courses in the system.
Significance:
This is a core class of the system, handling operations related to courses such as retrieving information, managing students, managing content, calculating progress, and more.
2. LP_User
class LP_User extends LP_Abstract_User
File Location: inc/user/class-lp-user.php
Purpose:
Manages user information and behaviors within the learning system.
Significance:
Handles operations related to users such as course enrollment, tracking learning progress, managing access permissions, and more.
3. LP_Page_Controller
class LP_Page_Controller
File Location: inc/class-lp-page-controller.php
Purpose:
Controls the display of pages within the system.
Significance:
Processes page display requests, URL routing, and manages display templates.
4. LP_Query
class LP_Query
File Location: inc/class-lp-query.php
Purpose:
Handles custom queries for LearnPress.
Significance:
Extends WP_Query to support special queries for courses, lessons, quizzes, and other LearnPress content types.
5. LP_Course_DB
class LP_Course_DB
File Location: inc/Databases/class-lp-course-db.php
Purpose:
Handles database operations related to courses.
Significance:
Provides methods to query, add, edit, and delete course data in the database.
6. LP_User_Items_DB
class LP_User_Items_DB
File Location: inc/Databases/class-lp-user-items-db.php
Purpose:
Manages data about users’ learning progress.
Significance:
Stores and retrieves information about user participation in courses, lessons, quizzes, and other learning items.
7. FilterCourseTemplate
class FilterCourseTemplate
File Location: inc/TemplateHooks/Course/FilterCourseTemplate.php
Purpose:
Processes course filters in the user interface.
Significance:
Provides methods to display and process course filters according to various criteria, including the new online/offline filter.
8. CourseModel
class CourseModel extends PostModel
File Location: inc/Models/CourseModel.php
Purpose:
Modern implementation of course data model.
Significance:
Provides a structured way to interact with course data, replacing some functionality of the older LP_Course class.
9. UserModel
class UserModel
File Location: inc/Models/UserModel.php
Purpose:
Modern implementation of user data model.
Significance:
Provides structured access to user data and learning progress, including the new pagination for quizzes.
Core Functions
1. learn_press_get_course()
function learn_press_get_course($course_id = 0)
File Location: inc/lp-core-functions.php
Purpose:
Retrieves a course object from an ID.
Significance:
Basic function to access course information throughout the system.
2. learn_press_get_user()
function learn_press_get_user($user_id = 0)
File Location: inc/lp-core-functions.php
Purpose:
Retrieves a LearnPress user object from an ID.
Significance:
Basic function to access user information throughout the system.
3. learn_press_get_page_id()
function learn_press_get_page_id($name)
File Location: inc/lp-core-functions.php
Purpose:
Gets the ID of system pages (courses, checkout, profile, etc.).
Significance:
Helps identify important pages in the system.
4. learn_press_is_course()
function learn_press_is_course()
File Location: inc/lp-core-functions.php
Purpose:
Checks if the current page is a course page.
Significance:
Supports conditional display of appropriate content.
5. learn_press_is_learning_course()
function learn_press_is_learning_course()
File Location: inc/lp-core-functions.php
Purpose:
Checks if the user is currently viewing a learning course page.
Significance:
Used to determine if specific learning interface elements should be displayed.
6. learn_press_get_course_item_link()
function learn_press_get_course_item_link($course_id, $item_id)
File Location: inc/course/lp-course-functions.php
Purpose:
Generates a URL to a specific item within a course.
Significance:
Essential for navigation within course content.
7. learn_press_get_user_item_status()
function learn_press_get_user_item_status($user_id, $item_id, $course_id)
File Location: inc/user/lp-user-functions.php
Purpose:
Gets the status of a user’s progress on a specific course item.
Significance:
Used to display progress indicators and determine access permissions.
8. learn_press_get_courses()
function learn_press_get_courses($args = array())
File Location: inc/course/lp-course-functions.php
Purpose:
Retrieves a list of courses based on specified criteria.
Significance:
Used for displaying course listings, including filtered results by type (online/offline).