PluginProbe
Gutenberg / 5.8.0
Gutenberg v5.8.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 / widgets-page.php

widgets-page.php in Gutenberg 5.8.0, at lib/widgets-page.php

74 lines 1.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 widgets page.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * The main entry point for the Gutenberg widgets page.
10 *
11 * @since 5.2.0
12 */
13 function the_gutenberg_widgets() {
14 ?>
15 <div id="widgets-editor" class="blocks-widgets-container">
16 </div>
17 <?php
18 }
19
20 /**
21 * Initialize the Gutenberg widgets page.
22 *
23 * @since 5.2.0
24 *
25 * @param string $hook Page.
26 */
27 function gutenberg_widgets_init( $hook ) {
28 if ( 'gutenberg_page_gutenberg-widgets' !== $hook ) {
29 return;
30 }
31
32 // Media settings.
33 $max_upload_size = wp_max_upload_size();
34 if ( ! $max_upload_size ) {
35 $max_upload_size = 0;
36 }
37
38 $settings = array_merge(
39 array(
40 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
41 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
42 'maxUploadFileSize' => $max_upload_size,
43 ),
44 gutenberg_get_legacy_widget_settings()
45 );
46
47 list( $color_palette, ) = (array) get_theme_support( 'editor-color-palette' );
48 list( $font_sizes, ) = (array) get_theme_support( 'editor-font-sizes' );
49
50 if ( false !== $color_palette ) {
51 $settings['colors'] = $color_palette;
52 }
53
54 if ( false !== $font_sizes ) {
55 $settings['fontSizes'] = $font_sizes;
56 }
57
58 wp_add_inline_script(
59 'wp-edit-widgets',
60 sprintf(
61 'wp.editWidgets.initialize( "widgets-editor", %s );',
62 wp_json_encode( $settings )
63 )
64 );
65 // Preload server-registered block schemas.
66 wp_add_inline_script(
67 'wp-blocks',
68 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
69 );
70 wp_enqueue_script( 'wp-edit-widgets' );
71 wp_enqueue_style( 'wp-edit-widgets' );
72 }
73 add_action( 'admin_enqueue_scripts', 'gutenberg_widgets_init' );
74