PluginProbe
Gutenberg / 8.3.0
Gutenberg v8.3.0
24.0.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 All 403 releases
gutenberg / lib / navigation-page.php

navigation-page.php in Gutenberg 8.3.0, at lib/navigation-page.php

102 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 Navigation page.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * The main entry point for the Gutenberg Navigation page.
10 *
11 * @since 7.8.0
12 */
13 function gutenberg_navigation_page() {
14 ?>
15 <div
16 id="navigation-editor"
17 class="edit-navigation"
18 >
19 </div>
20 <?php
21 }
22
23 /**
24 * Initialize the Gutenberg Navigation page.
25 *
26 * @since 7.8.0
27 *
28 * @param string $hook Page.
29 */
30 function gutenberg_navigation_init( $hook ) {
31 if ( 'gutenberg_page_gutenberg-navigation' !== $hook ) {
32 return;
33 }
34
35 // Media settings.
36 $max_upload_size = wp_max_upload_size();
37 if ( ! $max_upload_size ) {
38 $max_upload_size = 0;
39 }
40
41 /** This filter is documented in wp-admin/includes/media.php */
42 $image_size_names = apply_filters(
43 'image_size_names_choose',
44 array(
45 'thumbnail' => __( 'Thumbnail', 'gutenberg' ),
46 'medium' => __( 'Medium', 'gutenberg' ),
47 'large' => __( 'Large', 'gutenberg' ),
48 'full' => __( 'Full Size', 'gutenberg' ),
49 )
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
71 if ( false !== $color_palette ) {
72 $settings['colors'] = $color_palette;
73 }
74
75 if ( false !== $font_sizes ) {
76 $settings['fontSizes'] = $font_sizes;
77 }
78
79 wp_add_inline_script(
80 'wp-edit-navigation',
81 sprintf(
82 'wp.domReady( function() {
83 wp.editNavigation.initialize( "navigation-editor", %s );
84 } );',
85 wp_json_encode( gutenberg_experiments_editor_settings( $settings ) )
86 )
87 );
88
89 // Preload server-registered block schemas.
90 wp_add_inline_script(
91 'wp-blocks',
92 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
93 );
94
95 wp_enqueue_script( 'wp-edit-navigation' );
96 wp_enqueue_style( 'wp-edit-navigation' );
97 wp_enqueue_style( 'wp-block-library' );
98 wp_enqueue_script( 'wp-format-library' );
99 wp_enqueue_style( 'wp-format-library' );
100 }
101 add_action( 'admin_enqueue_scripts', 'gutenberg_navigation_init' );
102