Skip to content

Commit

Permalink
Infinite Scroll: Fatal error when calling protected method from WP_Query
Browse files Browse the repository at this point in the history
Since we already have wp_query() we can use its query_vars['search_terms'] property instead of calling parse_search_terms().
It gets populated on https://github.com/WordPress/WordPress/blob/4.3.1/wp-includes/query.php#L2075 with the same data.

Merges #2827
Fixes #2255
Props osiux

https://[private link]

Merges r132544-wpcom.
  • Loading branch information
jeherve authored and georgestephanis committed Feb 1, 2017
1 parent 69612b1 commit d8f2cb0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/infinite-scroll/infinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ function has_only_title_matching_posts() {

//code inspired by WP_Query class
if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', self::wp_query()->get( 's' ), $matches ) ) {
$search_terms = self::wp_query()->parse_search_terms( $matches[0] );
$search_terms = self::wp_query()->query_vars['search_terms'];
// if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence
if ( empty( $search_terms ) || count( $search_terms ) > 9 ) {
$search_terms = array( self::wp_query()->get( 's' ) );
Expand Down

0 comments on commit d8f2cb0

Please sign in to comment.