PluginProbe
Gutenberg / 7.4.0
Gutenberg v7.4.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / edit-site-page.php

edit-site-page.php in Gutenberg 7.4.0, at lib/edit-site-page.php

106 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bootstraping the Gutenberg Edit Site Page.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * The main entry point for the Gutenberg Edit Site Page.
10 *
11 * @since 7.2.0
12 */
13 function gutenberg_edit_site_page() {
14 ?>
15 <div
16 id="edit-site-editor"
17 class="edit-site"
18 >
19 </div>
20 <?php
21 }
22
23 /**
24 * Initialize the Gutenberg Edit Site Page.
25 *
26 * @since 7.2.0
27 *
28 * @param string $hook Page.
29 */
30 function gutenberg_edit_site_init( $hook ) {
31 global $_wp_current_template_id;
32 if ( 'gutenberg_page_gutenberg-edit-site' !== $hook ) {
33 return;
34 }
35
36 // Get editor settings.
37 $max_upload_size = wp_max_upload_size();
38 if ( ! $max_upload_size ) {
39 $max_upload_size = 0;
40 }
41
42 // This filter is documented in wp-admin/includes/media.php.
43 $image_size_names = apply_filters(
44 'image_size_names_choose',
45 array(
46 'thumbnail' => __( 'Thumbnail', 'gutenberg' ),
47 'medium' => __( 'Medium', 'gutenberg' ),
48 'large' => __( 'Large', 'gutenberg' ),
49 'full' => __( 'Full Size', 'gutenberg' ),
50 )
51 );
52 $available_image_sizes = array();
53 foreach ( $image_size_names as $image_size_slug => $image_size_name ) {
54 $available_image_sizes[] = array(
55 'slug' => $image_size_slug,
56 'name' => $image_size_name,
57 );
58 }
59
60 $settings = array(
61 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
62 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
63 'imageSizes' => $available_image_sizes,
64 'isRTL' => is_rtl(),
65 'maxUploadFileSize' => $max_upload_size,
66 );
67
68 list( $color_palette, ) = (array) get_theme_support( 'editor-color-palette' );
69 list( $font_sizes, ) = (array) get_theme_support( 'editor-font-sizes' );
70 if ( false !== $color_palette ) {
71 $settings['colors'] = $color_palette;
72 }
73 if ( false !== $font_sizes ) {
74 $settings['fontSizes'] = $font_sizes;
75 }
76
77 // Get root template by trigerring `./template-loader.php`'s logic.
78 get_front_page_template();
79 get_index_template();
80 apply_filters( 'template_include', null );
81 $settings['templateId'] = $_wp_current_template_id;
82
83 // Initialize editor.
84 wp_add_inline_script(
85 'wp-edit-site',
86 sprintf(
87 'wp.domReady( function() {
88 wp.editSite.initialize( "edit-site-editor", %s );
89 } );',
90 wp_json_encode( gutenberg_experiments_editor_settings( $settings ) )
91 )
92 );
93
94 // Preload server-registered block schemas.
95 wp_add_inline_script(
96 'wp-blocks',
97 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
98 );
99
100 wp_enqueue_script( 'wp-edit-site' );
101 wp_enqueue_script( 'wp-format-library' );
102 wp_enqueue_style( 'wp-edit-site' );
103 wp_enqueue_style( 'wp-format-library' );
104 }
105 add_action( 'admin_enqueue_scripts', 'gutenberg_edit_site_init' );
106