LLMS_Admin_Post_Table_Instructors::pre_get_posts( obj $query )
Handle course & membership queries for searching by llms_instructors rather than author
Parameters Parameters
- $query
-
(obj) (Required) WP_Query
Return Return
(void)
Source Source
File: includes/admin/post-types/post-tables/class.llms.admin.post.table.instructors.php
public function pre_get_posts( $query ) { if ( ! is_admin() ) { return; } if ( ! $query->is_main_query() ) { return; } // Don't run duplicates. if ( $query->get( 'llms_instructor_query' ) ) { return; } // phpcs:ignore -- commented out code // var_dump( $query->query_vars ); if ( isset( $query->query_vars['post_type'] ) && in_array( $query->query_vars['post_type'], $this->post_types ) && ! empty( $query->query_vars['author'] ) ) { // Get the query or a default to work with. $meta_query = $query->get( 'meta_query' ); if ( ! $meta_query ) { $meta_query = array(); } /** * Set an and relation for our filters * if other filters already exist, we'll ensure we obey them as well this way. */ $meta_query['relation'] = 'AND'; $meta_query[] = array( 'compare' => 'LIKE', 'key' => '_llms_instructors', 'value' => $this->get_serialized_id( $query->query_vars['author'] ), ); $query->set( 'meta_query', $meta_query ); $query->set( 'llms_instructor_query', true ); $query->set( 'author', '' ); } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.13.0 | Introduced. |