PluginProbe
Gutenberg / 12.1.0
Gutenberg v12.1.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
← All changes | lib/init.php +79 -1 12.6.012.1.0 View file →
@@ -29,8 +29,24 @@
29 29 'edit_posts',
30 30 'gutenberg'
31 31 );
32 32
33 + if (
34 + gutenberg_use_widgets_block_editor() &&
35 + ! function_exists( 'wp_use_widgets_block_editor' ) &&
36 + current_theme_supports( 'widgets' )
37 + ) {
38 + add_theme_page(
39 + __( 'Widgets', 'gutenberg' ),
40 + __( 'Widgets', 'gutenberg' ),
41 + 'edit_theme_options',
42 + 'gutenberg-widgets',
43 + 'the_gutenberg_widgets',
44 + 2
45 + );
46 + remove_submenu_page( 'themes.php', 'widgets.php' );
47 + }
48 +
33 49 if ( get_option( 'gutenberg-experiments' ) ) {
34 50 if ( array_key_exists( 'gutenberg-navigation', get_option( 'gutenberg-experiments' ) ) ) {
35 51 add_submenu_page(
36 52 'gutenberg',
@@ -77,9 +93,9 @@
77 93 *
78 94 * @since 9.4.0
79 95 */
80 96 function gutenberg_site_editor_menu() {
81 - if ( wp_is_block_theme() ) {
97 + if ( gutenberg_experimental_is_site_editor_available() ) {
82 98 add_theme_page(
83 99 __( 'Editor (beta)', 'gutenberg' ),
84 100 sprintf(
85 101 /* translators: %s: "beta" label. */
@@ -94,8 +110,57 @@
94 110 }
95 111 add_action( 'admin_menu', 'gutenberg_site_editor_menu', 9 );
96 112
97 113 /**
114 + * Modify WP admin bar.
115 + *
116 + * @param WP_Admin_Bar $wp_admin_bar Core class used to implement the Toolbar API.
117 + */
118 +function modify_admin_bar( $wp_admin_bar ) {
119 + if (
120 + gutenberg_use_widgets_block_editor() &&
121 + ! function_exists( 'wp_use_widgets_block_editor' ) &&
122 + $wp_admin_bar->get_node( 'widgets' ) !== null
123 + ) {
124 + $wp_admin_bar->add_menu(
125 + array(
126 + 'id' => 'widgets',
127 + 'href' => admin_url( 'themes.php?page=gutenberg-widgets' ),
128 + )
129 + );
130 + }
131 +}
132 +add_action( 'admin_bar_menu', 'modify_admin_bar', 40 );
133 +
134 +
135 +remove_action( 'welcome_panel', 'wp_welcome_panel' );
136 +/**
137 + * Modify Dashboard welcome panel.
138 + *
139 + * When widgets are merged in core this should go into `wp-admin/includes/dashboard.php`
140 + * and replace the widgets link in the `wp_welcome_panel` checking for the same condition,
141 + * because then `gutenberg_use_widgets_block_editor` will exist in core.
142 + */
143 +function modify_welcome_panel() {
144 + ob_start();
145 + wp_welcome_panel();
146 + $welcome_panel = ob_get_clean();
147 + if (
148 + gutenberg_use_widgets_block_editor() &&
149 + ! function_exists( 'wp_use_widgets_block_editor' )
150 + ) {
151 + echo str_replace(
152 + admin_url( 'widgets.php' ),
153 + admin_url( 'themes.php?page=gutenberg-widgets' ),
154 + $welcome_panel
155 + );
156 + } else {
157 + echo $welcome_panel;
158 + }
159 +}
160 +add_action( 'welcome_panel', 'modify_welcome_panel', 40 );
161 +
162 +/**
98 163 * Outputs a WP REST API nonce.
99 164 */
100 165 function gutenberg_rest_nonce() {
101 166 exit( wp_create_nonce( 'wp_rest' ) );
@@ -147,4 +212,17 @@
147 212 return $response;
148 213 }
149 214
150 215 add_filter( 'rest_index', 'register_site_logo_to_rest_index' );
216 +
217 +add_theme_support( 'widgets-block-editor' );
218 +
219 +/**
220 + * Enable block templates (editor mode) for themes with theme.json.
221 + */
222 +function gutenberg_enable_block_templates() {
223 + if ( WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ) {
224 + add_theme_support( 'block-templates' );
225 + }
226 +}
227 +
228 +add_action( 'setup_theme', 'gutenberg_enable_block_templates' );