wp-admin/edit-form-blocks.php


Lines:

1 to 100 of 358
<?php

/**
 * The block editor page.
 *
 * @since 5.0.0
 *
 * @package WordPress
 * @subpackage Administration
 */

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
  die( '-1' );
}


/**
 * @global string       $post_type
 * @global WP_Post_Type $post_type_object
 * @global WP_Post      $post             Global post object.
 * @global string       $title
 * @global array        $wp_meta_boxes
 */
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' ),
  sprintf( '%s/autosaves?context=edit', $rest_path ),
  '/wp/v2/settings',
);

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;
  }

 View on GitHub View on Trac

Called by

    Invoked by

      API Letters: ,,,,