Skip to content

Commit

Permalink
Backport WP_REST_Pattern_Directory_Controller changes from core (#47409)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored Jan 25, 2023
1 parent 1bf03b6 commit 913db72
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,21 @@ public function get_items( $request ) {

$gutenberg_data = get_plugin_data( dirname( dirname( dirname( __DIR__ ) ) ) . '/gutenberg.php', false );

$valid_query_args = array( 'offset', 'order', 'orderby', 'page', 'per_page', 'search', 'slug' );
$query_args = array_merge(
array_intersect_key( $request->get_params(), array_flip( $valid_query_args ) ),
array(
'locale' => get_user_locale(),
'wp-version' => $wp_version, // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- it's defined in `version.php` above.
'gutenberg-version' => $gutenberg_data['Version'],
)
$valid_query_args = array(
'offset' => true,
'order' => true,
'orderby' => true,
'page' => true,
'per_page' => true,
'search' => true,
'slug' => true,
);

$query_args = array_intersect_key( $request->get_params(), $valid_query_args );

$query_args['locale'] = get_user_locale();
$query_args['wp-version'] = $wp_version; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- it's defined in `version.php` above.
$query_args['gutenberg-version'] = $gutenberg_data['Version'];
$query_args['pattern-categories'] = isset( $request['category'] ) ? $request['category'] : false;
$query_args['pattern-keywords'] = isset( $request['keyword'] ) ? $request['keyword'] : false;

Expand Down

0 comments on commit 913db72

Please sign in to comment.