Skip to content

Commit

Permalink
Validate the postType query arg in list page (#36706)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Nov 23, 2021
1 parent 69db0e3 commit ae2be61
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/full-site-editing/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ function gutenberg_edit_site_list_init( $settings ) {
wp_enqueue_style( 'wp-edit-site' );
wp_enqueue_media();

$template_type = $_GET['postType'];
$post_type = get_post_type_object( $template_type );
$post_type = get_post_type_object( $_GET['postType'] );

if ( ! $post_type ) {
wp_die( __( 'Invalid post type.', 'gutenberg' ) );
}

$preload_data = array_reduce(
array(
'/',
"/wp/v2/types/$template_type?context=edit",
"/wp/v2/types/$post_type->name?context=edit",
'/wp/v2/types?context=edit',
"/wp/v2/$post_type->rest_base?context=edit",
),
Expand All @@ -116,7 +119,7 @@ function gutenberg_edit_site_list_init( $settings ) {
wp.editSite.initializeList( "%s", "%s", %s );
} );',
'edit-site-editor',
$template_type,
$post_type->name,
wp_json_encode( $settings )
)
);
Expand Down

0 comments on commit ae2be61

Please sign in to comment.