Skip to content
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

Page Attributes: Fix: Parent-Dropdown missing for custom post-type. #8087

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,15 @@ function gutenberg_handle_early_callback_checks( $response, $handler, $request )
*
* @see https://core.trac.wordpress.org/ticket/43998
*
* @param array $query_params JSON Schema-formatted collection parameters.
* @param string $post_type Post type being accessed.
* @param array $query_params JSON Schema-formatted collection parameters.
* @param WP_Post_Type $post_type Post type object being accessed.
* @return array
*/
function gutenberg_filter_post_collection_parameters( $query_params, $post_type ) {
$post_types = array( 'page', 'wp_block' );
if ( in_array( $post_type->name, $post_types, true )
&& isset( $query_params['per_page'] ) ) {
if (
isset( $query_params['per_page'] ) &&
( $post_type->hierarchical || 'wp_block' === $post_type->name )
) {
// Change from '1' to '-1', which means unlimited.
$query_params['per_page']['minimum'] = -1;
// Default sanitize callback is 'absint', which won't work in our case.
Expand All @@ -513,8 +514,10 @@ function gutenberg_filter_post_collection_parameters( $query_params, $post_type
* @return array
*/
function gutenberg_filter_post_query_arguments( $prepared_args, $request ) {
$post_types = array( 'page', 'wp_block' );
if ( in_array( $prepared_args['post_type'], $post_types, true ) ) {
if (
is_post_type_hierarchical( $prepared_args['post_type'] ) ||
'wp_block' === $prepared_args['post_type']
) {
// Avoid triggering 'rest_post_invalid_page_number' error
// which will need to be addressed in https://core.trac.wordpress.org/ticket/43998.
if ( -1 === $prepared_args['posts_per_page'] ) {
Expand Down