Changeset 9316
- Timestamp:
- 12/10/2019 07:23:08 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php
r9185 r9316 22 22 */ 23 23 public static function do_init() { 24 add_action( 'pre_get_posts', array( __CLASS__, 'invalid_post_type_filter_404' ), 9 ); 24 25 add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 20 ); 25 26 add_filter( 'posts_orderby', array( __CLASS__, 'search_posts_orderby' ), 10, 2 ); … … 34 35 if ( is_search() || isset( $_GET[ 'post_type' ] ) ) { 35 36 wp_no_robots(); 37 } 38 } 39 40 /* 41 * Makes request respond as a 404 if request is to filter by an invalid post_type. 42 * 43 * @access public 44 * 45 * @param WP_Query $query WP_Query object 46 */ 47 public static function invalid_post_type_filter_404( $query ) { 48 // If the main query is being filtered by post_type. 49 if ( $query->is_main_query() && isset( $_GET['post_type'] ) ) { 50 // Get list of valid parsed post types specified in query. 51 $valid_post_types = array_intersect( $_GET['post_type'], DevHub\get_parsed_post_types() ); 52 53 // If no valid post types were specified, then request is a 404. 54 if ( ! $valid_post_types ) { 55 $query->set_404(); 56 } 36 57 } 37 58 }
Note: See TracChangeset
for help on using the changeset viewer.