Changeset 12235 for sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/search.php
- Timestamp:
- 11/10/2022 09:02:49 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/search.php
r12203 r12235 16 16 add_action( 'pre_get_posts', [ __CLASS__, 'default_search_to_only_photos' ] ); 17 17 add_filter( 'posts_join', [ __CLASS__, 'tag_join_for_search' ], 10, 2 ); 18 add_filter( 'posts_search', [ __CLASS__, 'limit_partial_matching' ], 9, 2 ); 18 19 add_filter( 'posts_search', [ __CLASS__, 'tag_where_for_search' ], 10, 2 ); 19 20 add_filter( 'posts_groupby', [ __CLASS__, 'tag_groupby_for_search' ], 10, 2 ); … … 93 94 94 95 /** 96 * Limits partial matching of search terms to at least being at the start of 97 * a matching term. 98 * 99 * @param string $where Search SQL for WHERE clause. 100 * @param WP_Query $query The current WP_Query object. 101 * @return string 102 */ 103 public static function limit_partial_matching( $where, $query ) { 104 global $wpdb; 105 106 if ( ! is_admin() && $query->is_search() && $query->is_main_query() ) { 107 $where = preg_replace( 108 "/LIKE '(\{\w+\})([^\{]+)(\{\w+\})'/", 109 "LIKE '$2$1'", 110 $where 111 ); 112 } 113 114 return $where; 115 } 116 117 /** 95 118 * Customizes the WHERE clause for frontend searches. 96 119 *
Note: See TracChangeset
for help on using the changeset viewer.