PluginProbe
Gutenberg / 9.1.1
Gutenberg v9.1.1
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 9.1.1, at lib/widgets-page.php

106 lines 2.5 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
16 id="widgets-editor"
17 class="blocks-widgets-container"
18 >
19 </div>
20 <?php
21 }
22
23 /**
24 * Initialize the Gutenberg widgets page.
25 *
26 * @since 5.2.0
27 *
28 * @param string $hook Page.
29 */
30 function gutenberg_widgets_init( $hook ) {
31 if ( 'widgets.php' === $hook ) {
32 wp_enqueue_style( 'wp-block-library' );
33 wp_enqueue_style( 'wp-block-library-theme' );
34 wp_add_inline_style(
35 'wp-block-library-theme',
36 '.block-widget-form .widget-control-save { display: none; }'
37 );
38 return;
39 }
40 if ( ! in_array( $hook, array( 'appearance_page_gutenberg-widgets' ), true ) ) {
41 return;
42 }
43
44 $initializer_name = 'initialize';
45
46 // Media settings.
47 $max_upload_size = wp_max_upload_size();
48 if ( ! $max_upload_size ) {
49 $max_upload_size = 0;
50 }
51
52 /** This filter is documented in wp-admin/includes/media.php */
53 $image_size_names = apply_filters(
54 'image_size_names_choose',
55 array(
56 'thumbnail' => __( 'Thumbnail', 'gutenberg' ),
57 'medium' => __( 'Medium', 'gutenberg' ),
58 'large' => __( 'Large', 'gutenberg' ),
59 'full' => __( 'Full Size', 'gutenberg' ),
60 )
61 );
62
63 $available_image_sizes = array();
64 foreach ( $image_size_names as $image_size_slug => $image_size_name ) {
65 $available_image_sizes[] = array(
66 'slug' => $image_size_slug,
67 'name' => $image_size_name,
68 );
69 }
70
71 $settings = array_merge(
72 array(
73 'imageSizes' => $available_image_sizes,
74 'isRTL' => is_rtl(),
75 'maxUploadFileSize' => $max_upload_size,
76 ),
77 gutenberg_get_legacy_widget_settings()
78 );
79
80 $settings = gutenberg_experimental_global_styles_settings( $settings );
81
82 wp_add_inline_script(
83 'wp-edit-widgets',
84 sprintf(
85 'wp.domReady( function() {
86 wp.editWidgets.%s( "widgets-editor", %s );
87 } );',
88 $initializer_name,
89 wp_json_encode( gutenberg_experiments_editor_settings( $settings ) )
90 )
91 );
92
93 // Preload server-registered block schemas.
94 wp_add_inline_script(
95 'wp-blocks',
96 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
97 );
98
99 wp_enqueue_script( 'wp-edit-widgets' );
100 wp_enqueue_script( 'admin-widgets' );
101 wp_enqueue_script( 'wp-format-library' );
102 wp_enqueue_style( 'wp-edit-widgets' );
103 wp_enqueue_style( 'wp-format-library' );
104 }
105 add_action( 'admin_enqueue_scripts', 'gutenberg_widgets_init' );
106