mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55845 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -6031,7 +6031,7 @@ function get_pages( $args = array() ) {
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
$pages = $query->get_posts();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user