Making WordPress.org

Changeset 11591


Ignore:
Timestamp:
02/22/2022 03:46:33 AM (3 years ago)
Author:
dd32
Message:

Openverse iframe theme: Do not parse the request URI to generate a WP_Query, do not run FOUND_ROWS().

Parsing the request or trying to select the number of affected rows isn't needed here, as it's all passed to the iframe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse/functions.php

    r11590 r11591  
    5454 * disable those queries by returning an empty SQL
    5555 * query for the main WP_Query instance.
     56 *
     57 * Set no_found_rows to avoid querying for FOUND_ROWS().
    5658 */
    5759function disable_default_query( $sql, $query ) {
    5860    if ( $query->is_main_query() ) {
    5961        $sql = '';
     62        $query->set( 'no_found_rows', true );
    6063    }
    6164
     
    6366}
    6467add_filter( 'posts_request', __NAMESPACE__ . '\disable_default_query', 10, 2 );
     68
     69/**
     70 * Disable request parsing.
     71 *
     72 * This avoids `WP` parsing the requested URI to generate the WP_Query parameters.
     73 * As all URIs will be passed through to the iframe, there's no point in parsing
     74 * this or querying for posts that definitely do not exist within the WordPress site.
     75 */
     76add_filter( 'do_parse_request', '__return_false' );
    6577
    6678/**
Note: See TracChangeset for help on using the changeset viewer.