Posts, Post Types: Add a new filter for query arguments in `get_pages`.
In [55569] `get_pages` was converted to use `WP_Query` internally. But for plugins that were extending the `get_pages` filters and filter `WP_Query` query arguments, this could result in a conflict. Add a filter `get_pages_query_args` to allow developers to change arguments passed to `WP_Query` but also have the context of the original arguments passed to the `get_pages` function. This change also expands test coverage of `get_pages` to ensure no breakages in the future. Props spacedmonkey, westonruter, costdev, flixos90, kenwins, marianne38. See #12821. Built from https://develop.svn.wordpress.org/trunk@55845 git-svn-id: http://core.svn.wordpress.org/trunk@55357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fc3f62f4a2
commit
a88a66b0bd
|
@ -6031,7 +6031,7 @@ function get_pages( $args = array() ) {
|
||||||
}
|
}
|
||||||
$post_author = $post_author->ID;
|
$post_author = $post_author->ID;
|
||||||
}
|
}
|
||||||
$query_args['author__in'][] = $post_author;
|
$query_args['author__in'][] = (int) $post_author;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6060,6 +6060,16 @@ function get_pages( $args = array() ) {
|
||||||
$query_args['posts_per_page'] = $number;
|
$query_args['posts_per_page'] = $number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters query arguments passed to WP_Query in get_pages.
|
||||||
|
*
|
||||||
|
* @since 6.3.0
|
||||||
|
*
|
||||||
|
* @param array $query_args Array of arguments passed to WP_Query.
|
||||||
|
* @param array $parsed_args Array of get_pages() arguments.
|
||||||
|
*/
|
||||||
|
$query_args = apply_filters( 'get_pages_query_args', $query_args, $parsed_args );
|
||||||
|
|
||||||
$query = new WP_Query( $query_args );
|
$query = new WP_Query( $query_args );
|
||||||
$pages = $query->get_posts();
|
$pages = $query->get_posts();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-55844';
|
$wp_version = '6.3-alpha-55845';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue