Making WordPress.org


Ignore:
Timestamp:
09/05/2022 05:14:31 AM (3 years ago)
Author:
dufresnesteven
Message:

wporg-developer: Sync with https://github.com/WordPress/wporg-developer/commit/790d402933d2725374de0d19e6bf6a576c8b15d2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php

    r9866 r12050  
    6969    public static function pre_get_posts( $query ) {
    7070        // Don't modify anything if not a non-admin main search query.
    71         if ( ! ( ! is_admin() && $query->is_main_query() && $query->is_search() ) ) {
     71        if (
     72            (
     73                // Not the admin
     74                is_admin() ||
     75                // Not non-main queries / non-searches
     76                ( ! $query->is_main_query() || ! $query->is_search() )
     77            ) &&
     78            // but yes if it's the autocomplete search (which is admin, and not the main query).
     79            ! $query->get( '_autocomplete_search' )
     80        ) {
    7281            return;
    7382        }
     
    8695            // If user has '()' at end of a search string, assume they want a specific function/method.
    8796            $s = htmlentities( $query->get( 's' ) );
    88             if ( '()' === substr( $s, -2 ) ) {
     97            if ( '()' === substr( $s, -2 ) || '(' == substr( $s, -1 ) ) {
    8998                // Enable exact search.
    9099                $query->set( 'exact',     true );
    91100                // Modify the search query to omit the parentheses.
    92                 $query->set( 's',         substr( $s, 0, -2 ) ); // remove '()'
     101                $query->set( 's',         trim( $s, '()' ) );
    93102                // Restrict search to function-like content.
    94103                $query->set( 'post_type', array( 'wp-parser-function', 'wp-parser-method' ) );
Note: See TracChangeset for help on using the changeset viewer.