LLMS_View_Manager::should_display()
Determine whether or not the view manager should be added to the WP Admin Bar
Description Description
The view manager is only displayed when the following criteria is met:
- The current user must have a role that is allowed to bypass LifterLMS restrictions
- Must be viewing one of the following:
- a single course, lesson, membership, or quiz
- LifterLMS checkout page
- LifterLMS student dashboard page
Return Return
(boolean)
Source Source
File: includes/class.llms.view.manager.php
protected function should_display() { $display = false; global $post; $is_restricted_post = $post && ( is_llms_checkout() || is_llms_account_page() || in_array( $post->post_type, array( 'course', 'lesson', 'llms_membership', 'llms_quiz' ), true ) ); $post_id = $is_restricted_post ? $post->ID : null; if ( llms_can_user_bypass_restrictions( get_current_user_id(), $post_id ) ) { $display = is_admin() || is_post_type_archive() || ! $post || ! $is_restricted_post ? false : true; } /** * Filters whether or not the "View As..." menu item should be displayed in the WP Admin Bar * * @since 4.5.1 * * @param boolean $display Whether or not the menu item should be displayed. */ return apply_filters( 'llms_view_manager_should_display', $display ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.9.0 | When possible, pass the post ID to llms_can_user_bypass_restrictions() . |
4.5.1 | |
4.16.0 | Introduced. |