llms_get_post( obj|int $post, mixed $error = false )
Retrieve the LLMS Post Model for a give post by ID or WP_Post Object
Description #Description
Parameters #Parameters
- $post
-
(obj|int) (Required) instance of WP_Post or a WP Post ID
- $error
-
(mixed) (Optional) determine what to return if the LLMS class isn't found post = WP_Post falsy = false
Default value: false
Return #Return
(mixed)
Source #Source
File: includes/llms.functions.core.php
function llms_get_post( $post, $error = false ) { $post = get_post( $post ); if ( ! $post ) { return $post; } $post_type = explode( '_', str_replace( 'llms_', '', $post->post_type ) ); $class = 'LLMS'; foreach ( $post_type as $part ) { $class .= '_' . ucfirst( $part ); } if ( class_exists( $class ) ) { return new $class( $post ); } elseif ( 'post' === $error ) { return $post; } return false; }
Expand full source code Collapse full source code View on GitHub
Changelog #Changelog
Version | Description |
---|---|
3.3.0 | Introduced. |
Related #Related
Used By #Used By
Used By | Description |
---|---|
includes/abstracts/llms.abstract.post.data.php: LLMS_Abstract_Post_Data::__construct() |
Constructor. |
includes/controllers/class.llms.controller.orders.php: LLMS_Controller_Orders::on_delete_order() |
Called when a post is permanently deleted. |
includes/admin/reporting/tables/llms.table.memberships.php: LLMS_Table_Memberships::get_data() |
Retrieve data for a cell. |
includes/admin/reporting/tabs/class.llms.admin.reporting.tab.memberships.php: LLMS_Admin_Reporting_Tab_Memberships::breadcrumbs() |
Add breadcrumb links to the tab depending on current view. |
includes/admin/reporting/tabs/class.llms.admin.reporting.tab.memberships.php: LLMS_Admin_Reporting_Tab_Memberships::output() |
Output tab content. |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.enrollment.php: LLMS_Meta_Box_Order_Enrollment::save_delete_enrollment() |
Delete enrollment data based on posted values. |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.enrollment.php: LLMS_Meta_Box_Order_Enrollment::save_update_enrollment() |
Update enrollment data based on posted values. |
includes/class.llms.ajax.handler.php: LLMS_AJAX_Handler::llms_save_membership_autoenroll_courses() |
Save autoenroll courses list for a Membership |
includes/class.llms.course.data.php: LLMS_Course_Data::__construct() |
Constructor |
includes/llms.template.functions.php: lifterlms_course_continue_button() | |
includes/models/model.llms.student.quizzes.php: LLMS_Student_Quizzes::get_attempts_remaining_for_quiz() |
Get the # of attempts remaining by a student for a given quiz |
includes/models/model.llms.question.choice.php: LLMS_Question_Choice::set_question() |
Sets question-related data from constructor |
includes/models/model.llms.post.instructors.php: LLMS_Post_Instructors::__construct() |
Constructor |
includes/models/model.llms.section.php: LLMS_Section::get_previous() |
Retrieve the previous section |
includes/models/model.llms.section.php: LLMS_Section::get_course() |
Retrieve an instance of LLMS_Course for the sections’s parent course |
includes/models/model.llms.section.php: LLMS_Section::get_next() |
Retrieve the previous section |
includes/models/model.llms.order.php: LLMS_Order::get_transactions() |
Retrieve an array of transactions associated with the order according to supplied arguments |
includes/models/model.llms.order.php: LLMS_Order::get_product() |
Retrieve an LLMS_Post_Model object for the associated product |
includes/models/model.llms.lesson.php: LLMS_Lesson::get_section() |
Retrieve an instance of LLMS_Course for the elements’s parent section |
includes/models/model.llms.lesson.php: LLMS_Lesson::get_quiz() |
Retrieve an object for the assigned quiz (if a quiz is assigned ) |
includes/models/model.llms.lesson.php: LLMS_Lesson::get_course() |
Retrieve an instance of LLMS_Course for the element’s parent course |
includes/models/model.llms.quiz.php: LLMS_Quiz::get_lessons() |
Retrieve lessons this quiz is assigned to |
includes/models/model.llms.quiz.php: LLMS_Quiz::get_lesson() |
Retrieve LLMS_Lesson for the quiz’s parent lesson |
includes/models/model.llms.quiz.attempt.question.php: LLMS_Quiz_Attempt_Question::get_question() |
Retrieve an instance of the LLMS_Question |
includes/models/model.llms.user.postmeta.php: LLMS_User_Postmeta::get_link() |
Retrieve a link for the item on the admin panel |
includes/models/model.llms.instructor.php: LLMS_Instructor::get_posts() |
Retrieve instructor’s posts (courses and memberships, mixed) |
includes/models/model.llms.instructor.php: LLMS_Instructor::is_instructor() |
Determine if the user is an instructor on a post |
includes/models/model.llms.user.postmeta.php: LLMS_User_Postmeta::get_description() |
Get a string used to describe the postmeta item |
includes/models/model.llms.student.php: LLMS_Student::update_completion_status() |
Update the completion status of a track, course, section, or lesson for the current student Cascades up to parents and clears progress caches for parents Triggers actions for completion/incompletion Inserts / updates necessary user postmeta data |
includes/models/model.llms.quiz.attempt.php: LLMS_Quiz_Attempt::get_new_questions() |
Retrieve an array of blank questions for insertion into a new attempt during initialization |
includes/models/model.llms.quiz.attempt.php: LLMS_Quiz_Attempt::get_quiz() |
Get an instance of the LLMS_Quiz for the attempt |
includes/models/model.llms.quiz.attempt.php: LLMS_Quiz_Attempt::answer_question() |
Answer a question records the selected option and whether or not the selected option was the correct option Automatically updates & saves the attempt to the database |
includes/processors/class.llms.processor.course.data.php: LLMS_Processor_Course_Data::schedule_from_lesson() |
Schedule recalculation from actions triggered against a lesson |
includes/processors/class.llms.processor.course.data.php: LLMS_Processor_Course_Data::task() |
Execute calculation for each item in the queue until all students in the course have been polled Stores the data in the postmeta table to be accessible via LLMS_Course |
includes/llms.functions.core.php: llms_get_post_parent_course() |
Retrieve the parent course for a section, lesson, or quiz |
includes/abstracts/llms.abstract.notification.view.php: LLMS_Abstract_Notification_View::__construct() |
Constructor |
includes/abstracts/llms.abstract.notification.view.quiz.completion.php: LLMS_Abstract_Notification_View_Quiz_Completion::set_merge_data() |
Replace merge codes with actual values |
includes/class.llms.question.manager.php: LLMS_Question_Manager::get_question() |
Retrieve a question associated with this quiz by question ID |
includes/class-llms-grades.php: LLMS_Grades::get_grade() |
Main grade getter function Uses caching by default and can bypass cache when requested |
includes/class-llms-grades.php: LLMS_Grades::calculate_grade_from_children() |
Calculates the grades for elements that have a list of children which are averaged / weighted to come up with the total grade |
includes/functions/llms.functions.templates.dashboard.php: lifterlms_template_student_dashboard_my_grades() | |
includes/functions/llms.functions.templates.loop.php: lifterlms_loop_featured_video() |
Output a featured video on the course tile in a LifterLMS Loop |
includes/functions/llms-functions-access-plans.php: llms_insert_access_plan() |
Create or update an access plan. |
includes/functions/llms.functions.updates.php: llms_update_3160_ensure_no_lesson_dupe_rels() |
Create duplicates for any quiz attached to multiple lessons |
includes/functions/llms.functions.updates.php: llms_update_3160_update_question_data() |
Update question & choice data to new structure |
includes/functions/llms.functions.updates.php: llms_update_3160_update_attempt_question_data() |
Update question data to new formats & match question choice indexes to new choice IDs |
includes/functions/llms.functions.updates.php: llms_update_3160_update_quiz_to_lesson_rels() |
Ensure quizzes backreference their parent lessons |
includes/functions/llms.functions.updates.php: llms_update_3120_update_order_end_dates() |
Add end dates to LifterLMS Orders which have a length but no saved end date |
includes/functions/llms.functions.updates.php: llms_update_3130_create_default_instructors() |
Setup default instructor data for courses and memberships |
includes/functions/llms.functions.updates.php: llms_update_3160_update_quiz_settings() |
Add yes/no vals for quiz new quiz settings |
includes/functions/llms.functions.updates.php: llms_update_380_set_access_plan_visibility() |
Add visibility settings to all access plans and delete the “featured” meta values for all access plans |
includes/functions/llms.functions.access.php: llms_is_quiz_accessible() |
Determine if a quiz should be accessible by a user |
includes/functions/llms.functions.order.php: llms_setup_pending_order() |
Setup a pending order which can be passed to an LLMS_Payment_Gateway for processing. |
includes/functions/llms.functions.access.php: llms_is_post_restricted_by_drip_settings() |
Determine if a lesson/quiz is restricted by drip settings |
includes/functions/llms.functions.access.php: llms_is_post_restricted_by_prerequisite() |
Determine if a lesson/quiz is restricted by a prerequisite lesson |
includes/functions/llms.functions.access.php: llms_is_post_restricted_by_time_period() |
Determine if a course (or lesson/quiz) is “open” according to course time period settings |
includes/class.llms.ajax.handler.php: LLMS_AJAX_Handler::quiz_start() |
Start a Quiz Attempt |
includes/class.llms.ajax.handler.php: LLMS_AJAX_Handler::quiz_answer_question() |
AJAX Quiz answer question |
includes/class.llms.ajax.handler.php: LLMS_AJAX_Handler::instructors_mb_store() |
Store data for the instructors metabox |
includes/class.llms.quiz.data.php: LLMS_Quiz_Data::__construct() |
Constructor |
includes/controllers/class.llms.controller.orders.php: LLMS_Controller_Orders::switch_payment_source() |
Handle form submission of the “Update Payment Method” form on the student dashboard when viewing a single order |
includes/controllers/class.llms.controller.orders.php: LLMS_Controller_Orders::create_pending_order() |
Handle form submission of the checkout / payment form |
includes/controllers/class.llms.controller.lesson.progression.php: LLMS_Controller_Lesson_Progression::quiz_maybe_prevent_lesson_completion() |
Before a lesson is marked as complete, check if all the lesson’s quiz requirements are met |
includes/forms/controllers/class.llms.controller.account.php: LLMS_Controller_Account::cancel_subscription() |
Lets student cancel recurring access plan subscriptions from the student dashboard view order screen |
includes/shortcodes/class.llms.shortcode.checkout.php: LLMS_Shortcode_Checkout::output() |
Gather a bunch of information and output the actual content for the shortcode |
includes/shortcodes/class.llms.shortcode.course.outline.php: LLMS_Shortcode_Course_Outline::get_output() |
Retrieve the actual content of the shortcode |
includes/shortcodes/class.llms.shortcode.course.author.php: LLMS_Shortcode_Course_Author::get_author_id() |
Retrieve the author ID of th course Lessons and Quizzes cascade up |
includes/shortcodes/class.llms.bbp.shortcode.course.forums.list.php: LLMS_BBP_Shortcode_Course_Forums_List::get_forums() |
Retrieve the forum ids associated with the course |
includes/widgets/class.llms.bbp.widget.course.forums.list.php: LLMS_BBP_Widget_Course_Forums_List::widget() |
Output the widget |
includes/class.llms.template.loader.php: LLMS_Template_Loader::restricted_by_quiz() |
Handle attempts to access quizzes |
includes/class.llms.template.loader.php: LLMS_Template_Loader::maybe_redirect_to_sales_page() |
Handle sales page redirects for courses & memberships |
includes/class.llms.achievements.php: LLMS_Achievements::get_achievements_by_post() |
Get a list of achievement Achievement Template IDs for a given post |
includes/integrations/class.llms.integration.bbpress.php: LLMS_Integration_BBPress::get_course_forum_ids() |
Retrieve course ids restricted to a LifterLMS course |
includes/class.llms.query.user.postmeta.php: LLMS_Query_User_Postmeta::parse_args() |
Parses data passed to $statuses Convert strings to array and ensure resulting array contains only valid statuses If no valid statuses, returns to the default |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::output() |
Output the page content |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::process_detachments() |
Process lesson detachments from the heartbeat data |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::process_trash() |
Delete/trash elements from heartbeat data |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::update_lessons() |
Update lesson from heartbeat data |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::update_quiz() |
Update quizzes during heartbeats |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::update_section() |
Update a section with data from the heartbeat |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::get_existing_posts() |
Retrieve a list of lessons the current user is allowed to clone/attach Used for ajax searching to add existing lessons |
includes/admin/class.llms.admin.builder.php: LLMS_Admin_Builder::handle_ajax() |
A terrible Rest API for the course builder |
includes/admin/reporting/tables/llms.table.courses.php: LLMS_Table_Courses::get_data() |
Retrieve data for a cell |
includes/admin/reporting/tables/llms.table.quizzes.php: LLMS_Table_Quizzes::get_data() |
Retrieve data for a cell |
includes/admin/reporting/widgets/class.llms.analytics.widget.lessoncompletions.php: LLMS_Analytics_Lessoncompletions_Widget::get_lesson_ids() |
Retrieve an array of lesson ids for all the products in the current filter |
includes/admin/reporting/tabs/class.llms.admin.reporting.tab.courses.php: LLMS_Admin_Reporting_Tab_Courses::breadcrumbs() |
Add breadcrumb links to the tab depending on current view |
includes/admin/reporting/tabs/class.llms.admin.reporting.tab.courses.php: LLMS_Admin_Reporting_Tab_Courses::output() |
Output tab content |
includes/admin/reporting/tabs/class.llms.admin.reporting.tab.quizzes.php: LLMS_Admin_Reporting_Tab_Quizzes::breadcrumbs() |
Add breadcrumb links to the tab depending on current view |
includes/admin/reporting/tabs/class.llms.admin.reporting.tab.quizzes.php: LLMS_Admin_Reporting_Tab_Quizzes::output() |
Output tab content |
includes/admin/post-types/post-tables/class.llms.admin.post.table.instructors.php: LLMS_Admin_Post_Table_Instructors::manage_columns() |
Manage content of custom columns |
includes/admin/post-types/post-tables/class.llms.admin.post.table.lessons.php: LLMS_Admin_Post_Table_Lessons::manage_columns() |
Manage content of custom lesson columns |
includes/admin/post-types/meta-boxes/class.llms.meta.box.lesson.php: LLMS_Meta_Box_Lesson::get_fields() |
This function is where extending classes can configure all the fields within the metabox The function must return an array which can be consumed by the “output” function |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.enrollment.php: LLMS_Meta_Box_Order_Enrollment::output() |
Function to field WP::output() method call. |
includes/admin/post-types/meta-boxes/class.llms.meta.box.instructors.php: LLMS_Metabox_Instructors::get_fields() |
Define metabox fields |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.transactions.php: LLMS_Meta_Box_Order_Transactions::resend_receipt() |
Resend a receipt for a transaction |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.details.php: LLMS_Meta_Box_Order_Details::output() |
Function to field WP::output() method call Passes output instruction to parent |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.details.php: LLMS_Meta_Box_Order_Details::save() |
Save method Does nothing because there’s no editable data in this metabox |
includes/admin/post-types/meta-boxes/class.llms.meta.box.order.submit.php: LLMS_Meta_Box_Order_Submit::save() |
Save action, update order status |
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.builder.php: LLMS_Metabox_Course_Builder::output() |
Override the output method to output a button |
includes/admin/post-types/class.llms.post.tables.php: LLMS_Admin_Post_Tables::handle_link_actions() |
Handle events for our custom postrow actions |
includes/class.llms.generator.php: LLMS_Generator::handle_prerequisites() |
Updates course and lesson prerequisites If the prerequisite was included in the import, updates to the new imported version If the prereq is not included but the source matches, leaves the prereq intact as long as the prereq exists Otherwise removes prerequisite data from the new course / lesson |
includes/class.llms.generator.php: LLMS_Generator::create_question() |
Creates a new question |
includes/class.llms.quiz.legacy.php: LLMS_Quiz_Legacy::get_course() |
Retrieve the course associated with the lesson |
includes/notifications/controllers/class.llms.notification.controller.quiz.failed.php: LLMS_Notification_Controller_Quiz_Failed::send_test() |
Send a test notification to the currently logged in users Extending classes should redefine this in order to properly setup the controller with post_id and user_id data |
includes/notifications/controllers/class.llms.notification.controller.payment.retry.php: LLMS_Notification_Controller_Payment_Retry::get_subscriber() |
Takes a subscriber type (student, author, etc) and retrieves a User ID |
includes/notifications/controllers/class.llms.notification.controller.section.complete.php: LLMS_Notification_Controller_Section_Complete::action_callback() |
Callback function called when a section is completed by a student |
includes/notifications/controllers/class.llms.notification.controller.quiz.failed.php: LLMS_Notification_Controller_Quiz_Failed::action_callback() |
Callback function called when a quiz is failed by a student |
includes/notifications/controllers/class.llms.notification.controller.quiz.failed.php: LLMS_Notification_Controller_Quiz_Failed::get_test_settings() |
Get an array of LifterLMS Admin Page settings to send test notifications |
includes/notifications/controllers/class.llms.notification.controller.enrollment.php: LLMS_Notification_Controller_Enrollment::action_callback() |
Callback function, called after enrollment into a course |
includes/notifications/controllers/class.llms.notification.controller.purchase.receipt.php: LLMS_Notification_Controller_Purchase_Receipt::get_subscriber() |
Takes a subscriber type (student, author, etc) and retrieves a User ID |
includes/notifications/controllers/class.llms.notification.controller.purchase.receipt.php: LLMS_Notification_Controller_Purchase_Receipt::get_test_settings() |
Get an array of LifterLMS Admin Page settings to send test notifications |
includes/notifications/controllers/class.llms.notification.controller.purchase.receipt.php: LLMS_Notification_Controller_Purchase_Receipt::send_test() |
Send a test notification to the currently logged in users Extending classes should redefine this in order to properly setup the controller with post_id and user_id data |
includes/notifications/controllers/class.llms.notification.controller.course.complete.php: LLMS_Notification_Controller_Course_Complete::action_callback() |
Callback function called when a course is completed by a student |
includes/notifications/controllers/class.llms.notification.controller.quiz.passed.php: LLMS_Notification_Controller_Quiz_Passed::get_test_settings() |
Get an array of LifterLMS Admin Page settings to send test notifications |
includes/notifications/controllers/class.llms.notification.controller.quiz.passed.php: LLMS_Notification_Controller_Quiz_Passed::send_test() |
Send a test notification to the currently logged in users Extending classes should redefine this in order to properly setup the controller with post_id and user_id data |
includes/notifications/controllers/class.llms.notification.controller.manual.payment.due.php: LLMS_Notification_Controller_Manual_Payment_Due::get_subscriber() |
Takes a subscriber type (student, author, etc) and retrieves a User ID |
includes/notifications/controllers/class.llms.notification.controller.quiz.passed.php: LLMS_Notification_Controller_Quiz_Passed::action_callback() |
Callback function called when a quiz is failed by a student |
includes/notifications/controllers/class.llms.notification.controller.quiz.graded.php: LLMS_Notification_Controller_Quiz_Graded::get_test_settings() |
Get an array of LifterLMS Admin Page settings to send test notifications |
includes/notifications/controllers/class.llms.notification.controller.lesson.complete.php: LLMS_Notification_Controller_Lesson_Complete::action_callback() |
Callback function called when a lesson is completed by a student |
includes/notifications/views/class.llms.notification.view.quiz.graded.php: LLMS_Notification_View_Quiz_Graded::set_merge_data() |
Replace merge codes with actual values |
includes/notifications/controllers/class.llms.notification.controller.subscription.cancelled.php: LLMS_Notification_Controller_Subscription_Cancelled::get_subscriber() |
Takes a subscriber type (student, author, etc) and retrieves a User ID |
vendor/lifterlms/lifterlms-blocks/includes/class-llms-blocks-post-instructors.php: LLMS_Blocks_Post_Instructors::update_callback() |
Update instructor information for a given object. |
vendor/lifterlms/lifterlms-blocks/includes/class-llms-blocks-post-instructors.php: LLMS_Blocks_Post_Instructors::get_callback() |
Retrieve instructor information for a give object. |
User Contributed Notes #User Contributed Notes
Permalink: