-
Notifications
You must be signed in to change notification settings - Fork 3.4k
64250 redirect guess 404 permalink #10975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 17 commits
ae6a847
ce90699
9b52804
4532fae
3da7e89
c420204
7eed5d7
ccc2e39
6021fd9
243ac98
3e8210f
940add6
ff23ab9
07df29a
5bcf66f
cf4de84
eb2f5cd
9b17942
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -660,6 +660,7 @@ public function fill_query_vars( $query_vars ) { | |||||
| * @since 5.3.0 Introduced the `$meta_type_key` parameter. | ||||||
| * @since 6.1.0 Introduced the `$update_menu_item_cache` parameter. | ||||||
| * @since 6.2.0 Introduced the `$search_columns` parameter. | ||||||
| * @since 7.0.0 Introduced the `$starts_with` parameter. | ||||||
| * | ||||||
| * @param string|array $query { | ||||||
| * Optional. Array or string of Query parameters. | ||||||
|
|
@@ -686,6 +687,9 @@ public function fill_query_vars( $query_vars ) { | |||||
| * See WP_Date_Query::__construct(). | ||||||
| * @type int $day Day of the month. Default empty. Accepts numbers 1-31. | ||||||
| * @type bool $exact Whether to search by exact keyword. Default false. | ||||||
| * Cannot be used together with `$search_position`. | ||||||
| * @type bool $search_position Whether to search start, ends or is anywhere within keyword. Default anywhere. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * Cannot be used together with `$exact`. | ||||||
| * @type string $fields Post fields to query for. Accepts: | ||||||
| * - '' Returns an array of complete post objects (`WP_Post[]`). | ||||||
| * - 'ids' Returns an array of post IDs (`int[]`). | ||||||
|
|
@@ -774,7 +778,7 @@ public function fill_query_vars( $query_vars ) { | |||||
| * character used for exclusion can be modified using the | ||||||
| * the 'wp_query_search_exclusion_prefix' filter. | ||||||
| * @type string[] $search_columns Array of column names to be searched. Accepts 'post_title', | ||||||
| * 'post_excerpt' and 'post_content'. Default empty array. | ||||||
| * 'post_excerpt', 'post_content' and 'post_name'. Default empty array. | ||||||
| * @type int $second Second of the minute. Default empty. Accepts numbers 0-59. | ||||||
| * @type bool $sentence Whether to search by phrase. Default false. | ||||||
| * @type bool $suppress_filters Whether to suppress filters. Default false. | ||||||
|
|
@@ -813,6 +817,15 @@ public function parse_query( $query = '' ) { | |||||
| $query_vars = &$this->query_vars; | ||||||
| $this->query_vars_changed = true; | ||||||
|
|
||||||
| if ( ! empty( $query_vars['exact'] ) && ! empty( $query_vars['search_position'] ) ) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| _doing_it_wrong( | ||||||
| __METHOD__, | ||||||
| __( 'The `exact` and `search_position` query parameters are mutually exclusive and cannot be used together.' ), | ||||||
| '7.0.0' | ||||||
| ); | ||||||
| $query_vars['search_position'] = 'anywhere'; | ||||||
| } | ||||||
|
|
||||||
| if ( ! empty( $query_vars['robots'] ) ) { | ||||||
| $this->is_robots = true; | ||||||
| } elseif ( ! empty( $query_vars['favicon'] ) ) { | ||||||
|
|
@@ -1448,20 +1461,35 @@ protected function parse_search( &$query_vars ) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| $n = ! empty( $query_vars['exact'] ) ? '' : '%'; | ||||||
| $start = '%'; | ||||||
| $end = '%'; | ||||||
| if ( ! empty( $query_vars['exact'] ) ) { | ||||||
| $start = ''; | ||||||
| $end = ''; | ||||||
| } elseif ( ! empty( $query_vars['search_position'] ) ) { | ||||||
| if ( 'start' === $query_vars['search_position'] ) { | ||||||
| $start = ''; | ||||||
| } | ||||||
| if ( 'end' === $query_vars['search_position'] ) { | ||||||
| $end = ''; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| $searchand = ''; | ||||||
| $query_vars['search_orderby_title'] = array(); | ||||||
|
|
||||||
| $default_search_columns = array( 'post_title', 'post_excerpt', 'post_content' ); | ||||||
| $search_columns = ! empty( $query_vars['search_columns'] ) ? $query_vars['search_columns'] : $default_search_columns; | ||||||
| $default_search_columns = array( 'post_title', 'post_excerpt', 'post_content' ); | ||||||
| $allowed_search_columns = $default_search_columns; | ||||||
| $allowed_search_columns[] = 'post_name'; | ||||||
| $search_columns = ! empty( $query_vars['search_columns'] ) ? $query_vars['search_columns'] : $default_search_columns; | ||||||
| if ( ! is_array( $search_columns ) ) { | ||||||
| $search_columns = array( $search_columns ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Filters the columns to search in a WP_Query search. | ||||||
| * | ||||||
| * The supported columns are `post_title`, `post_excerpt` and `post_content`. | ||||||
| * The supported columns are `post_title`, `post_excerpt`, `post_content`, and `post_name`. | ||||||
| * They are all included by default. | ||||||
| * | ||||||
| * @since 6.2.0 | ||||||
|
|
@@ -1473,7 +1501,7 @@ protected function parse_search( &$query_vars ) { | |||||
| $search_columns = (array) apply_filters( 'post_search_columns', $search_columns, $query_vars['s'], $this ); | ||||||
|
|
||||||
| // Use only supported search columns. | ||||||
| $search_columns = array_intersect( $search_columns, $default_search_columns ); | ||||||
| $search_columns = array_intersect( $search_columns, $allowed_search_columns ); | ||||||
| if ( empty( $search_columns ) ) { | ||||||
| $search_columns = $default_search_columns; | ||||||
| } | ||||||
|
|
@@ -1500,13 +1528,11 @@ protected function parse_search( &$query_vars ) { | |||||
| $andor_op = 'OR'; | ||||||
| } | ||||||
|
|
||||||
| if ( $n && ! $exclude ) { | ||||||
| $like = '%' . $wpdb->esc_like( $term ) . '%'; | ||||||
| $like = $start . $wpdb->esc_like( $term ) . $end; | ||||||
| if ( $end && ! $exclude ) { | ||||||
| $query_vars['search_orderby_title'][] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $like ); | ||||||
| } | ||||||
|
|
||||||
| $like = $n . $wpdb->esc_like( $term ) . $n; | ||||||
|
|
||||||
| $search_columns_parts = array(); | ||||||
| foreach ( $search_columns as $search_column ) { | ||||||
| $search_columns_parts[ $search_column ] = $wpdb->prepare( "({$wpdb->posts}.$search_column $like_op %s)", $like ); | ||||||
|
|
@@ -1962,6 +1988,10 @@ public function get_posts() { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| if ( ! isset( $query_vars['search_position'] ) || ! in_array( $query_vars['search_position'], array( 'start', 'end', 'anywhere' ), true ) ) { | ||||||
| $query_vars['search_position'] = 'anywhere'; | ||||||
| } | ||||||
|
|
||||||
| if ( ! isset( $query_vars['ignore_sticky_posts'] ) ) { | ||||||
| $query_vars['ignore_sticky_posts'] = false; | ||||||
| } | ||||||
|
|
||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this file there are a few tests to ensure the default colums are used for empty/invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1