Edit File by line
/home/barbar84/www/wp-admin
File: edit-form-blocks.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* The block editor page.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 5.0.0
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Administration
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
// Don't load directly.
[10] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[11] Fix | Delete
die( '-1' );
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* @global string $post_type
[16] Fix | Delete
* @global WP_Post_Type $post_type_object
[17] Fix | Delete
* @global WP_Post $post Global post object.
[18] Fix | Delete
* @global string $title
[19] Fix | Delete
* @global array $editor_styles
[20] Fix | Delete
* @global array $wp_meta_boxes
[21] Fix | Delete
*/
[22] Fix | Delete
global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes;
[23] Fix | Delete
[24] Fix | Delete
// Flag that we're loading the block editor.
[25] Fix | Delete
$current_screen = get_current_screen();
[26] Fix | Delete
$current_screen->is_block_editor( true );
[27] Fix | Delete
[28] Fix | Delete
/*
[29] Fix | Delete
* Emoji replacement is disabled for now, until it plays nicely with React.
[30] Fix | Delete
*/
[31] Fix | Delete
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
[32] Fix | Delete
[33] Fix | Delete
/*
[34] Fix | Delete
* Block editor implements its own Options menu for toggling Document Panels.
[35] Fix | Delete
*/
[36] Fix | Delete
add_filter( 'screen_options_show_screen', '__return_false' );
[37] Fix | Delete
[38] Fix | Delete
wp_enqueue_script( 'heartbeat' );
[39] Fix | Delete
wp_enqueue_script( 'wp-edit-post' );
[40] Fix | Delete
wp_enqueue_script( 'wp-format-library' );
[41] Fix | Delete
[42] Fix | Delete
$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
[43] Fix | Delete
[44] Fix | Delete
// Preload common data.
[45] Fix | Delete
$preload_paths = array(
[46] Fix | Delete
'/',
[47] Fix | Delete
'/wp/v2/types?context=edit',
[48] Fix | Delete
'/wp/v2/taxonomies?per_page=-1&context=edit',
[49] Fix | Delete
'/wp/v2/themes?status=active',
[50] Fix | Delete
sprintf( '/wp/v2/%s/%s?context=edit', $rest_base, $post->ID ),
[51] Fix | Delete
sprintf( '/wp/v2/types/%s?context=edit', $post_type ),
[52] Fix | Delete
sprintf( '/wp/v2/users/me?post_type=%s&context=edit', $post_type ),
[53] Fix | Delete
array( '/wp/v2/media', 'OPTIONS' ),
[54] Fix | Delete
array( '/wp/v2/blocks', 'OPTIONS' ),
[55] Fix | Delete
sprintf( '/wp/v2/%s/%d/autosaves?context=edit', $rest_base, $post->ID ),
[56] Fix | Delete
);
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Preload common data by specifying an array of REST API paths that will be preloaded.
[60] Fix | Delete
*
[61] Fix | Delete
* Filters the array of paths that will be preloaded.
[62] Fix | Delete
*
[63] Fix | Delete
* @since 5.0.0
[64] Fix | Delete
*
[65] Fix | Delete
* @param string[] $preload_paths Array of paths to preload.
[66] Fix | Delete
* @param WP_Post $post Post being edited.
[67] Fix | Delete
*/
[68] Fix | Delete
$preload_paths = apply_filters( 'block_editor_preload_paths', $preload_paths, $post );
[69] Fix | Delete
[70] Fix | Delete
/*
[71] Fix | Delete
* Ensure the global $post remains the same after API data is preloaded.
[72] Fix | Delete
* Because API preloading can call the_content and other filters, plugins
[73] Fix | Delete
* can unexpectedly modify $post.
[74] Fix | Delete
*/
[75] Fix | Delete
$backup_global_post = clone $post;
[76] Fix | Delete
[77] Fix | Delete
$preload_data = array_reduce(
[78] Fix | Delete
$preload_paths,
[79] Fix | Delete
'rest_preload_api_request',
[80] Fix | Delete
array()
[81] Fix | Delete
);
[82] Fix | Delete
[83] Fix | Delete
// Restore the global $post as it was before API preloading.
[84] Fix | Delete
$post = $backup_global_post;
[85] Fix | Delete
[86] Fix | Delete
wp_add_inline_script(
[87] Fix | Delete
'wp-api-fetch',
[88] Fix | Delete
sprintf( 'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );', wp_json_encode( $preload_data ) ),
[89] Fix | Delete
'after'
[90] Fix | Delete
);
[91] Fix | Delete
[92] Fix | Delete
wp_add_inline_script(
[93] Fix | Delete
'wp-blocks',
[94] Fix | Delete
sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ),
[95] Fix | Delete
'after'
[96] Fix | Delete
);
[97] Fix | Delete
[98] Fix | Delete
/*
[99] Fix | Delete
* Assign initial edits, if applicable. These are not initially assigned to the persisted post,
[100] Fix | Delete
* but should be included in its save payload.
[101] Fix | Delete
*/
[102] Fix | Delete
$initial_edits = null;
[103] Fix | Delete
$is_new_post = false;
[104] Fix | Delete
if ( 'auto-draft' === $post->post_status ) {
[105] Fix | Delete
$is_new_post = true;
[106] Fix | Delete
// Override "(Auto Draft)" new post default title with empty string, or filtered value.
[107] Fix | Delete
$initial_edits = array(
[108] Fix | Delete
'title' => $post->post_title,
[109] Fix | Delete
'content' => $post->post_content,
[110] Fix | Delete
'excerpt' => $post->post_excerpt,
[111] Fix | Delete
);
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
// Preload server-registered block schemas.
[115] Fix | Delete
wp_add_inline_script(
[116] Fix | Delete
'wp-blocks',
[117] Fix | Delete
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
[118] Fix | Delete
);
[119] Fix | Delete
[120] Fix | Delete
// Get admin url for handling meta boxes.
[121] Fix | Delete
$meta_box_url = admin_url( 'post.php' );
[122] Fix | Delete
$meta_box_url = add_query_arg(
[123] Fix | Delete
array(
[124] Fix | Delete
'post' => $post->ID,
[125] Fix | Delete
'action' => 'edit',
[126] Fix | Delete
'meta-box-loader' => true,
[127] Fix | Delete
'meta-box-loader-nonce' => wp_create_nonce( 'meta-box-loader' ),
[128] Fix | Delete
),
[129] Fix | Delete
$meta_box_url
[130] Fix | Delete
);
[131] Fix | Delete
wp_add_inline_script(
[132] Fix | Delete
'wp-editor',
[133] Fix | Delete
sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ),
[134] Fix | Delete
'before'
[135] Fix | Delete
);
[136] Fix | Delete
[137] Fix | Delete
[138] Fix | Delete
/*
[139] Fix | Delete
* Initialize the editor.
[140] Fix | Delete
*/
[141] Fix | Delete
[142] Fix | Delete
$align_wide = get_theme_support( 'align-wide' );
[143] Fix | Delete
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
[144] Fix | Delete
$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
[145] Fix | Delete
$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
[146] Fix | Delete
$custom_line_height = get_theme_support( 'custom-line-height' );
[147] Fix | Delete
$custom_units = get_theme_support( 'custom-units' );
[148] Fix | Delete
$custom_spacing = get_theme_support( 'custom-spacing' );
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Filters the allowed block types for the editor, defaulting to true (all
[152] Fix | Delete
* block types supported).
[153] Fix | Delete
*
[154] Fix | Delete
* @since 5.0.0
[155] Fix | Delete
*
[156] Fix | Delete
* @param bool|array $allowed_block_types Array of block type slugs, or
[157] Fix | Delete
* boolean to enable/disable all.
[158] Fix | Delete
* @param WP_Post $post The post resource data.
[159] Fix | Delete
*/
[160] Fix | Delete
$allowed_block_types = apply_filters( 'allowed_block_types', true, $post );
[161] Fix | Delete
[162] Fix | Delete
/*
[163] Fix | Delete
* Get all available templates for the post/page attributes meta-box.
[164] Fix | Delete
* The "Default template" array element should only be added if the array is
[165] Fix | Delete
* not empty so we do not trigger the template select element without any options
[166] Fix | Delete
* besides the default value.
[167] Fix | Delete
*/
[168] Fix | Delete
$available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) );
[169] Fix | Delete
$available_templates = ! empty( $available_templates ) ? array_merge(
[170] Fix | Delete
array(
[171] Fix | Delete
/** This filter is documented in wp-admin/includes/meta-boxes.php */
[172] Fix | Delete
'' => apply_filters( 'default_page_template_title', __( 'Default template' ), 'rest-api' ),
[173] Fix | Delete
),
[174] Fix | Delete
$available_templates
[175] Fix | Delete
) : $available_templates;
[176] Fix | Delete
[177] Fix | Delete
// Media settings.
[178] Fix | Delete
$max_upload_size = wp_max_upload_size();
[179] Fix | Delete
if ( ! $max_upload_size ) {
[180] Fix | Delete
$max_upload_size = 0;
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
// Editor Styles.
[184] Fix | Delete
$styles = array(
[185] Fix | Delete
array(
[186] Fix | Delete
'css' => file_get_contents(
[187] Fix | Delete
is_rtl()
[188] Fix | Delete
? ABSPATH . WPINC . '/css/dist/editor/editor-styles-rtl.css'
[189] Fix | Delete
: ABSPATH . WPINC . '/css/dist/editor/editor-styles.css'
[190] Fix | Delete
),
[191] Fix | Delete
),
[192] Fix | Delete
);
[193] Fix | Delete
[194] Fix | Delete
$styles[] = array(
[195] Fix | Delete
'css' => 'body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif }',
[196] Fix | Delete
);
[197] Fix | Delete
[198] Fix | Delete
if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) {
[199] Fix | Delete
foreach ( $editor_styles as $style ) {
[200] Fix | Delete
if ( preg_match( '~^(https?:)?//~', $style ) ) {
[201] Fix | Delete
$response = wp_remote_get( $style );
[202] Fix | Delete
if ( ! is_wp_error( $response ) ) {
[203] Fix | Delete
$styles[] = array(
[204] Fix | Delete
'css' => wp_remote_retrieve_body( $response ),
[205] Fix | Delete
);
[206] Fix | Delete
}
[207] Fix | Delete
} else {
[208] Fix | Delete
$file = get_theme_file_path( $style );
[209] Fix | Delete
if ( is_file( $file ) ) {
[210] Fix | Delete
$styles[] = array(
[211] Fix | Delete
'css' => file_get_contents( $file ),
[212] Fix | Delete
'baseURL' => get_theme_file_uri( $style ),
[213] Fix | Delete
);
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
// Default editor styles.
[220] Fix | Delete
$default_editor_styles = array(
[221] Fix | Delete
array(
[222] Fix | Delete
'css' => file_get_contents(
[223] Fix | Delete
is_rtl()
[224] Fix | Delete
? ABSPATH . WPINC . '/css/dist/editor/editor-styles-rtl.css'
[225] Fix | Delete
: ABSPATH . WPINC . '/css/dist/editor/editor-styles.css'
[226] Fix | Delete
),
[227] Fix | Delete
),
[228] Fix | Delete
);
[229] Fix | Delete
[230] Fix | Delete
// Image sizes.
[231] Fix | Delete
[232] Fix | Delete
/** This filter is documented in wp-admin/includes/media.php */
[233] Fix | Delete
$image_size_names = apply_filters(
[234] Fix | Delete
'image_size_names_choose',
[235] Fix | Delete
array(
[236] Fix | Delete
'thumbnail' => __( 'Thumbnail' ),
[237] Fix | Delete
'medium' => __( 'Medium' ),
[238] Fix | Delete
'large' => __( 'Large' ),
[239] Fix | Delete
'full' => __( 'Full Size' ),
[240] Fix | Delete
)
[241] Fix | Delete
);
[242] Fix | Delete
[243] Fix | Delete
$available_image_sizes = array();
[244] Fix | Delete
foreach ( $image_size_names as $image_size_slug => $image_size_name ) {
[245] Fix | Delete
$available_image_sizes[] = array(
[246] Fix | Delete
'slug' => $image_size_slug,
[247] Fix | Delete
'name' => $image_size_name,
[248] Fix | Delete
);
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
$image_dimensions = array();
[252] Fix | Delete
$all_sizes = wp_get_registered_image_subsizes();
[253] Fix | Delete
foreach ( $available_image_sizes as $size ) {
[254] Fix | Delete
$key = $size['slug'];
[255] Fix | Delete
if ( isset( $all_sizes[ $key ] ) ) {
[256] Fix | Delete
$image_dimensions[ $key ] = $all_sizes[ $key ];
[257] Fix | Delete
}
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
// Lock settings.
[261] Fix | Delete
$user_id = wp_check_post_lock( $post->ID );
[262] Fix | Delete
if ( $user_id ) {
[263] Fix | Delete
$locked = false;
[264] Fix | Delete
[265] Fix | Delete
/** This filter is documented in wp-admin/includes/post.php */
[266] Fix | Delete
if ( apply_filters( 'show_post_locked_dialog', true, $post, $user_id ) ) {
[267] Fix | Delete
$locked = true;
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
$user_details = null;
[271] Fix | Delete
if ( $locked ) {
[272] Fix | Delete
$user = get_userdata( $user_id );
[273] Fix | Delete
$user_details = array(
[274] Fix | Delete
'name' => $user->display_name,
[275] Fix | Delete
);
[276] Fix | Delete
$avatar = get_avatar_url( $user_id, array( 'size' => 64 ) );
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
$lock_details = array(
[280] Fix | Delete
'isLocked' => $locked,
[281] Fix | Delete
'user' => $user_details,
[282] Fix | Delete
);
[283] Fix | Delete
} else {
[284] Fix | Delete
// Lock the post.
[285] Fix | Delete
$active_post_lock = wp_set_post_lock( $post->ID );
[286] Fix | Delete
if ( $active_post_lock ) {
[287] Fix | Delete
$active_post_lock = esc_attr( implode( ':', $active_post_lock ) );
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
$lock_details = array(
[291] Fix | Delete
'isLocked' => false,
[292] Fix | Delete
'activePostLock' => $active_post_lock,
[293] Fix | Delete
);
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
/**
[297] Fix | Delete
* Filters the body placeholder text.
[298] Fix | Delete
*
[299] Fix | Delete
* @since 5.0.0
[300] Fix | Delete
*
[301] Fix | Delete
* @param string $text Placeholder text. Default 'Start writing or type / to choose a block'.
[302] Fix | Delete
* @param WP_Post $post Post object.
[303] Fix | Delete
*/
[304] Fix | Delete
$body_placeholder = apply_filters( 'write_your_story', __( 'Start writing or type / to choose a block' ), $post );
[305] Fix | Delete
[306] Fix | Delete
$editor_settings = array(
[307] Fix | Delete
'alignWide' => $align_wide,
[308] Fix | Delete
'availableTemplates' => $available_templates,
[309] Fix | Delete
'allowedBlockTypes' => $allowed_block_types,
[310] Fix | Delete
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
[311] Fix | Delete
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
[312] Fix | Delete
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
[313] Fix | Delete
'disablePostFormats' => ! current_theme_supports( 'post-formats' ),
[314] Fix | Delete
/** This filter is documented in wp-admin/edit-form-advanced.php */
[315] Fix | Delete
'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ),
[316] Fix | Delete
'bodyPlaceholder' => $body_placeholder,
[317] Fix | Delete
'isRTL' => is_rtl(),
[318] Fix | Delete
'autosaveInterval' => AUTOSAVE_INTERVAL,
[319] Fix | Delete
'maxUploadFileSize' => $max_upload_size,
[320] Fix | Delete
'allowedMimeTypes' => get_allowed_mime_types(),
[321] Fix | Delete
'styles' => $styles,
[322] Fix | Delete
'defaultEditorStyles' => $default_editor_styles,
[323] Fix | Delete
'imageSizes' => $available_image_sizes,
[324] Fix | Delete
'imageDimensions' => $image_dimensions,
[325] Fix | Delete
'richEditingEnabled' => user_can_richedit(),
[326] Fix | Delete
'postLock' => $lock_details,
[327] Fix | Delete
'postLockUtils' => array(
[328] Fix | Delete
'nonce' => wp_create_nonce( 'lock-post_' . $post->ID ),
[329] Fix | Delete
'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ),
[330] Fix | Delete
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
[331] Fix | Delete
),
[332] Fix | Delete
'__experimentalBlockPatterns' => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),
[333] Fix | Delete
'__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),
[334] Fix | Delete
[335] Fix | Delete
// Whether or not to load the 'postcustom' meta box is stored as a user meta
[336] Fix | Delete
// field so that we're not always loading its assets.
[337] Fix | Delete
'enableCustomFields' => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
[338] Fix | Delete
'enableCustomLineHeight' => $custom_line_height,
[339] Fix | Delete
'enableCustomUnits' => $custom_units,
[340] Fix | Delete
'enableCustomSpacing' => $custom_spacing,
[341] Fix | Delete
);
[342] Fix | Delete
[343] Fix | Delete
$autosave = wp_get_post_autosave( $post_ID );
[344] Fix | Delete
if ( $autosave ) {
[345] Fix | Delete
if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
[346] Fix | Delete
$editor_settings['autosave'] = array(
[347] Fix | Delete
'editLink' => get_edit_post_link( $autosave->ID ),
[348] Fix | Delete
);
[349] Fix | Delete
} else {
[350] Fix | Delete
wp_delete_post_revision( $autosave->ID );
[351] Fix | Delete
}
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
if ( false !== $color_palette ) {
[355] Fix | Delete
$editor_settings['colors'] = $color_palette;
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
if ( false !== $font_sizes ) {
[359] Fix | Delete
$editor_settings['fontSizes'] = $font_sizes;
[360] Fix | Delete
}
[361] Fix | Delete
[362] Fix | Delete
if ( false !== $gradient_presets ) {
[363] Fix | Delete
$editor_settings['gradients'] = $gradient_presets;
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
if ( ! empty( $post_type_object->template ) ) {
[367] Fix | Delete
$editor_settings['template'] = $post_type_object->template;
[368] Fix | Delete
$editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
// If there's no template set on a new post, use the post format, instead.
[372] Fix | Delete
if ( $is_new_post && ! isset( $editor_settings['template'] ) && 'post' === $post->post_type ) {
[373] Fix | Delete
$post_format = get_post_format( $post );
[374] Fix | Delete
if ( in_array( $post_format, array( 'audio', 'gallery', 'image', 'quote', 'video' ), true ) ) {
[375] Fix | Delete
$editor_settings['template'] = array( array( "core/$post_format" ) );
[376] Fix | Delete
}
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
/**
[380] Fix | Delete
* Scripts
[381] Fix | Delete
*/
[382] Fix | Delete
wp_enqueue_media(
[383] Fix | Delete
array(
[384] Fix | Delete
'post' => $post->ID,
[385] Fix | Delete
)
[386] Fix | Delete
);
[387] Fix | Delete
wp_tinymce_inline_scripts();
[388] Fix | Delete
wp_enqueue_editor();
[389] Fix | Delete
[390] Fix | Delete
[391] Fix | Delete
/**
[392] Fix | Delete
* Styles
[393] Fix | Delete
*/
[394] Fix | Delete
wp_enqueue_style( 'wp-edit-post' );
[395] Fix | Delete
wp_enqueue_style( 'wp-format-library' );
[396] Fix | Delete
[397] Fix | Delete
/**
[398] Fix | Delete
* Fires after block assets have been enqueued for the editing interface.
[399] Fix | Delete
*
[400] Fix | Delete
* Call `add_action` on any hook before 'admin_enqueue_scripts'.
[401] Fix | Delete
*
[402] Fix | Delete
* In the function call you supply, simply use `wp_enqueue_script` and
[403] Fix | Delete
* `wp_enqueue_style` to add your functionality to the block editor.
[404] Fix | Delete
*
[405] Fix | Delete
* @since 5.0.0
[406] Fix | Delete
*/
[407] Fix | Delete
do_action( 'enqueue_block_editor_assets' );
[408] Fix | Delete
[409] Fix | Delete
// In order to duplicate classic meta box behaviour, we need to run the classic meta box actions.
[410] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
[411] Fix | Delete
register_and_do_post_meta_boxes( $post );
[412] Fix | Delete
[413] Fix | Delete
// Check if the Custom Fields meta box has been removed at some point.
[414] Fix | Delete
$core_meta_boxes = $wp_meta_boxes[ $current_screen->id ]['normal']['core'];
[415] Fix | Delete
if ( ! isset( $core_meta_boxes['postcustom'] ) || ! $core_meta_boxes['postcustom'] ) {
[416] Fix | Delete
unset( $editor_settings['enableCustomFields'] );
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
/**
[420] Fix | Delete
* Filters the settings to pass to the block editor.
[421] Fix | Delete
*
[422] Fix | Delete
* @since 5.0.0
[423] Fix | Delete
*
[424] Fix | Delete
* @param array $editor_settings Default editor settings.
[425] Fix | Delete
* @param WP_Post $post Post being edited.
[426] Fix | Delete
*/
[427] Fix | Delete
$editor_settings = apply_filters( 'block_editor_settings', $editor_settings, $post );
[428] Fix | Delete
[429] Fix | Delete
$init_script = <<<JS
[430] Fix | Delete
( function() {
[431] Fix | Delete
window._wpLoadBlockEditor = new Promise( function( resolve ) {
[432] Fix | Delete
wp.domReady( function() {
[433] Fix | Delete
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, %s, %s ) );
[434] Fix | Delete
} );
[435] Fix | Delete
} );
[436] Fix | Delete
} )();
[437] Fix | Delete
JS;
[438] Fix | Delete
[439] Fix | Delete
$script = sprintf(
[440] Fix | Delete
$init_script,
[441] Fix | Delete
$post->post_type,
[442] Fix | Delete
$post->ID,
[443] Fix | Delete
wp_json_encode( $editor_settings ),
[444] Fix | Delete
wp_json_encode( $initial_edits )
[445] Fix | Delete
);
[446] Fix | Delete
wp_add_inline_script( 'wp-edit-post', $script );
[447] Fix | Delete
[448] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[449] Fix | Delete
?>
[450] Fix | Delete
[451] Fix | Delete
<div class="block-editor">
[452] Fix | Delete
<h1 class="screen-reader-text hide-if-no-js"><?php echo esc_html( $title ); ?></h1>
[453] Fix | Delete
<div id="editor" class="block-editor__container hide-if-no-js"></div>
[454] Fix | Delete
<div id="metaboxes" class="hidden">
[455] Fix | Delete
<?php the_block_editor_meta_boxes(); ?>
[456] Fix | Delete
</div>
[457] Fix | Delete
[458] Fix | Delete
<?php // JavaScript is disabled. ?>
[459] Fix | Delete
<div class="wrap hide-if-js block-editor-no-js">
[460] Fix | Delete
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
[461] Fix | Delete
<div class="notice notice-error notice-alt">
[462] Fix | Delete
<p>
[463] Fix | Delete
<?php
[464] Fix | Delete
$message = sprintf(
[465] Fix | Delete
/* translators: %s: A link to install the Classic Editor plugin. */
[466] Fix | Delete
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
[467] Fix | Delete
esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
[468] Fix | Delete
);
[469] Fix | Delete
[470] Fix | Delete
/**
[471] Fix | Delete
* Filters the message displayed in the block editor interface when JavaScript is
[472] Fix | Delete
* not enabled in the browser.
[473] Fix | Delete
*
[474] Fix | Delete
* @since 5.0.3
[475] Fix | Delete
*
[476] Fix | Delete
* @param string $message The message being displayed.
[477] Fix | Delete
* @param WP_Post $post The post being edited.
[478] Fix | Delete
*/
[479] Fix | Delete
echo apply_filters( 'block_editor_no_javascript_message', $message, $post );
[480] Fix | Delete
?>
[481] Fix | Delete
</p>
[482] Fix | Delete
</div>
[483] Fix | Delete
</div>
[484] Fix | Delete
</div>
[485] Fix | Delete
[486] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function