PluginProbe
Gutenberg / 11.2.1
Gutenberg v11.2.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 / navigation-page.php

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

75 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bootstrapping 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 $settings = array_merge(
36 gutenberg_get_default_block_editor_settings(),
37 array(
38 'blockNavMenus' => get_theme_support( 'block-nav-menus' ),
39 )
40 );
41 $settings = gutenberg_experimental_global_styles_settings( $settings );
42
43 gutenberg_initialize_editor(
44 'navigation_editor',
45 'edit-navigation',
46 array(
47 'initializer_name' => 'initialize',
48 'editor_settings' => $settings,
49 )
50 );
51
52 wp_enqueue_script( 'wp-edit-navigation' );
53 wp_enqueue_style( 'wp-edit-navigation' );
54 wp_enqueue_script( 'wp-format-library' );
55 wp_enqueue_style( 'wp-format-library' );
56 do_action( 'enqueue_block_editor_assets' );
57 }
58 add_action( 'admin_enqueue_scripts', 'gutenberg_navigation_init' );
59
60 /**
61 * Tells the script loader to load the scripts and styles of custom block on navigation editor screen.
62 *
63 * @param bool $is_block_editor_screen Current decision about loading block assets.
64 * @return bool Filtered decision about loading block assets.
65 */
66 function gutenberg_navigation_editor_load_block_editor_scripts_and_styles( $is_block_editor_screen ) {
67 if ( is_callable( 'get_current_screen' ) && get_current_screen() && 'gutenberg_page_gutenberg-navigation' === get_current_screen()->base ) {
68 return true;
69 }
70
71 return $is_block_editor_screen;
72 }
73
74 add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_navigation_editor_load_block_editor_scripts_and_styles' );
75