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 +180 -2 23.1.112.1.0 View file →
@@ -13,10 +13,10 @@
13 13 * @since 0.1.0
14 14 */
15 15 function gutenberg_menu() {
16 16 add_menu_page(
17 - __( 'Gutenberg', 'gutenberg' ),
18 - __( 'Gutenberg', 'gutenberg' ),
17 + 'Gutenberg',
18 + 'Gutenberg',
19 19 'edit_posts',
20 20 'gutenberg',
21 21 '',
22 22 'dashicons-edit'
@@ -29,8 +29,36 @@
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 +
49 + if ( get_option( 'gutenberg-experiments' ) ) {
50 + if ( array_key_exists( 'gutenberg-navigation', get_option( 'gutenberg-experiments' ) ) ) {
51 + add_submenu_page(
52 + 'gutenberg',
53 + __( 'Navigation (beta)', 'gutenberg' ),
54 + __( 'Navigation (beta)', 'gutenberg' ),
55 + 'edit_theme_options',
56 + 'gutenberg-navigation',
57 + 'gutenberg_navigation_page'
58 + );
59 + }
60 + }
33 61 if ( current_user_can( 'edit_posts' ) ) {
34 62 add_submenu_page(
35 63 'gutenberg',
36 64 __( 'Support', 'gutenberg' ),
@@ -45,6 +73,156 @@
45 73 'edit_posts',
46 74 'https://developer.wordpress.org/block-editor/'
47 75 );
48 76 }
77 +
78 + add_submenu_page(
79 + 'gutenberg',
80 + __( 'Experiments Settings', 'gutenberg' ),
81 + __( 'Experiments', 'gutenberg' ),
82 + 'edit_posts',
83 + 'gutenberg-experiments',
84 + 'the_gutenberg_experiments'
85 + );
49 86 }
50 87 add_action( 'admin_menu', 'gutenberg_menu', 9 );
88 +
89 +/**
90 + * Site editor's Menu.
91 + *
92 + * Adds a new wp-admin menu item for the Site editor.
93 + *
94 + * @since 9.4.0
95 + */
96 +function gutenberg_site_editor_menu() {
97 + if ( gutenberg_experimental_is_site_editor_available() ) {
98 + add_theme_page(
99 + __( 'Editor (beta)', 'gutenberg' ),
100 + sprintf(
101 + /* translators: %s: "beta" label. */
102 + __( 'Editor %s', 'gutenberg' ),
103 + '<span class="awaiting-mod">' . __( 'beta', 'gutenberg' ) . '</span>'
104 + ),
105 + 'edit_theme_options',
106 + 'gutenberg-edit-site',
107 + 'gutenberg_edit_site_page'
108 + );
109 + }
110 +}
111 +add_action( 'admin_menu', 'gutenberg_site_editor_menu', 9 );
112 +
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 +/**
163 + * Outputs a WP REST API nonce.
164 + */
165 +function gutenberg_rest_nonce() {
166 + exit( wp_create_nonce( 'wp_rest' ) );
167 +}
168 +add_action( 'wp_ajax_gutenberg_rest_nonce', 'gutenberg_rest_nonce' );
169 +
170 +
171 +/**
172 + * Exposes the site icon url to the Gutenberg editor through the WordPress REST
173 + * API. The site icon url should instead be fetched from the wp/v2/settings
174 + * endpoint when https://github.com/WordPress/gutenberg/pull/19967 is complete.
175 + *
176 + * @since 8.2.1
177 + *
178 + * @param WP_REST_Response $response Response data served by the WordPress REST index endpoint.
179 + * @return WP_REST_Response
180 + */
181 +function register_site_icon_url( $response ) {
182 + $data = $response->data;
183 + $data['site_icon_url'] = get_site_icon_url();
184 + $response->set_data( $data );
185 + return $response;
186 +}
187 +
188 +add_filter( 'rest_index', 'register_site_icon_url' );
189 +
190 +/**
191 + * Exposes the site logo to the Gutenberg editor through the WordPress REST
192 + * API. This is used for fetching this information when user has no rights
193 + * to update settings.
194 + *
195 + * @since 10.9
196 + *
197 + * @param WP_REST_Response $response Response data served by the WordPress REST index endpoint.
198 + * @return WP_REST_Response
199 + */
200 +function register_site_logo_to_rest_index( $response ) {
201 + $site_logo_id = get_theme_mod( 'custom_logo' );
202 + $response->data['site_logo'] = $site_logo_id;
203 + if ( $site_logo_id ) {
204 + $response->add_link(
205 + 'https://api.w.org/featuredmedia',
206 + rest_url( 'wp/v2/media/' . $site_logo_id ),
207 + array(
208 + 'embeddable' => true,
209 + )
210 + );
211 + }
212 + return $response;
213 +}
214 +
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' );