Description
/ global $post_type, $post_type_object, $post, $title, $wp_meta_boxes; $block_editor_context = new WP_Block_Editor_Context( array( 'post' => $post ) ); // Flag that we're loading the block editor. $current_screen = get_current_screen(); $current_screen->is_block_editor( true ); // Default to is-fullscreen-mode to avoid jumps in the UI. add_filter( 'admin_body_class', static function ( $classes ) { return "$classes is-fullscreen-mode"; } ); /* Emoji replacement is disabled for now, until it plays nicely with React. / remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); /* Block editor implements its own Options menu for toggling Document Panels. / add_filter( 'screen_options_show_screen', '__return_false' ); wp_enqueue_script( 'heartbeat' ); wp_enqueue_script( 'wp-edit-post' ); $rest_path = rest_get_route_for_post( $post ); // Preload common data. $preload_paths = array( '/wp/v2/types?context=view', '/wp/v2/taxonomies?context=view', add_query_arg( array( 'context' => 'edit', 'per_page' => -1, ), rest_get_route_for_post_type_items( 'wp_block' ) ), add_query_arg( 'context', 'edit', $rest_path ), sprintf( '/wp/v2/types/%s?context=edit', $post_type ), '/wp/v2/users/me', array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'page' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'wp_block' ), 'OPTIONS' ), array( rest_get_route_for_post_type_items( 'wp_template' ), 'OPTIONS' ), sprintf( '%s/autosaves?context=edit', $rest_path ), '/wp/v2/settings', array( '/wp/v2/settings', 'OPTIONS' ), '/wp/v2/global-styles/themes/' . get_stylesheet(), '/wp/v2/themes?context=edit&status=active', '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit', ); block_editor_rest_api_preload( $preload_paths, $block_editor_context ); wp_add_inline_script( 'wp-blocks', sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ), 'after' ); /* Assign initial edits, if applicable. These are not initially assigned to the persisted post, but should be included in its save payload. / $initial_edits = array(); $is_new_post = false; if ( 'auto-draft' === $post->post_status ) { $is_new_post = true; // Override "(Auto Draft)" new post default title with empty string, or filtered value. if ( post_type_supports( $post->post_type, 'title' ) ) { $initial_edits['title'] = $post->post_title; } if ( post_type_supports( $post->post_type, 'editor' ) ) { $initial_edits['content'] = $post->post_content; } if ( post_type_supports( $post->post_type, 'excerpt' ) ) { $initial_edits['excerpt'] = $post->post_excerpt; } } // Preload server-registered block schemas. wp_add_inline_script( 'wp-blocks', 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' ); // Get admin url for handling meta boxes. $meta_box_url = admin_url( 'post.php' ); $meta_box_url = add_query_arg( array( 'post' => $post->ID, 'action' => 'edit', 'meta-box-loader' => true, 'meta-box-loader-nonce' => wp_create_nonce( 'meta-box-loader' ), ), $meta_box_url ); wp_add_inline_script( 'wp-editor', sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ), 'before' ); /* Get all available templates for the post/page attributes meta-box. The "Default template" array element should only be added if the array is not empty so we do not trigger the template select element without any options besides the default value.
Occurrences
Filename | Line Number |
---|---|
wp-admin/edit-form-blocks.php | 154 |
wp-admin/includes/post.php | 1798 |
PHP Doc
/**
* @global string $post_type Global post type.
* @global WP_Post_Type $post_type_object Global post type object.
* @global WP_Post $post Global post object.
* @global string $title The title of the current screen.
* @global array $wp_meta_boxes Global meta box state.
*/
global $post_type, $post_type_object, $post, $title, $wp_meta_boxes;
$block_editor_context = new WP_Block_Editor_Context( array( 'post' => $post ) );
// Flag that we're loading the block editor.
$current_screen = get_current_screen();
$current_screen->is_block_editor( true );
// Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter(
'admin_body_class',
static function ( $classes ) {
return "$classes is-fullscreen-mode";
}
);
/*
* Emoji replacement is disabled for now, until it plays nicely with React.
*/
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
/*
* Block editor implements its own Options menu for toggling Document Panels.
*/
add_filter( 'screen_options_show_screen', '__return_false' );
wp_enqueue_script( 'heartbeat' );
wp_enqueue_script( 'wp-edit-post' );
$rest_path = rest_get_route_for_post( $post );
// Preload common data.
$preload_paths = array(
'/wp/v2/types?context=view',
'/wp/v2/taxonomies?context=view',
add_query_arg(
array(
'context' => 'edit',
'per_page' => -1,
),
rest_get_route_for_post_type_items( 'wp_block' )
),
add_query_arg( 'context', 'edit', $rest_path ),
sprintf( '/wp/v2/types/%s?context=edit', $post_type ),
'/wp/v2/users/me',
array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ),
array( rest_get_route_for_post_type_items( 'page' ), 'OPTIONS' ),
array( rest_get_route_for_post_type_items( 'wp_block' ), 'OPTIONS' ),
array( rest_get_route_for_post_type_items( 'wp_template' ), 'OPTIONS' ),
sprintf( '%s/autosaves?context=edit', $rest_path ),
'/wp/v2/settings',
array( '/wp/v2/settings', 'OPTIONS' ),
'/wp/v2/global-styles/themes/' . get_stylesheet(),
'/wp/v2/themes?context=edit&status=active',
'/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit',
);
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
wp_add_inline_script(
'wp-blocks',
sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ),
'after'
);
/*
* Assign initial edits, if applicable. These are not initially assigned to the persisted post,
* but should be included in its save payload.
*/
$initial_edits = array();
$is_new_post = false;
if ( 'auto-draft' === $post->post_status ) {
$is_new_post = true;
// Override "(Auto Draft)" new post default title with empty string, or filtered value.
if ( post_type_supports( $post->post_type, 'title' ) ) {
$initial_edits['title'] = $post->post_title;
}
if ( post_type_supports( $post->post_type, 'editor' ) ) {
$initial_edits['content'] = $post->post_content;
}
if ( post_type_supports( $post->post_type, 'excerpt' ) ) {
$initial_edits['excerpt'] = $post->post_excerpt;
}
}
// Preload server-registered block schemas.
wp_add_inline_script(
'wp-blocks',
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
);
// Get admin url for handling meta boxes.
$meta_box_url = admin_url( 'post.php' );
$meta_box_url = add_query_arg(
array(
'post' => $post->ID,
'action' => 'edit',
'meta-box-loader' => true,
'meta-box-loader-nonce' => wp_create_nonce( 'meta-box-loader' ),
),
$meta_box_url
);
wp_add_inline_script(
'wp-editor',
sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ),
'before'
);
/*
* Get all available templates for the post/page attributes meta-box.
* The "Default template" array element should only be added if the array is
* not empty so we do not trigger the template select element without any options
* besides the default value.
*/