Skip to content

Commit

Permalink
Extract to separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Nov 26, 2021
1 parent 6b40260 commit ac5e847
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions lib/full-site-editing/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,7 @@ function gutenberg_get_editor_styles() {
return $styles;
}

/**
* Initialize the Gutenberg Templates List Page.
*
* @param array $settings The editor settings.
*/
function gutenberg_edit_site_list_init( $settings ) {
wp_enqueue_script( 'wp-edit-site' );
wp_enqueue_style( 'wp-edit-site' );
wp_enqueue_media();

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

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

$preload_data = array_reduce(
array(
Expand All @@ -111,6 +97,25 @@ function gutenberg_edit_site_list_init( $settings ) {
),
'after'
);
}

/**
* Initialize the Gutenberg Templates List Page.
*
* @param array $settings The editor settings.
*/
function gutenberg_edit_site_list_init( $settings ) {
wp_enqueue_script( 'wp-edit-site' );
wp_enqueue_style( 'wp-edit-site' );
wp_enqueue_media();

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

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

gutenberg_edit_site_list_preload_data( $post_type );

wp_add_inline_script(
'wp-edit-site',
Expand Down

0 comments on commit ac5e847

Please sign in to comment.