PluginProbe
Gutenberg / 9.2.0
Gutenberg v9.2.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
gutenberg / gutenberg.php

gutenberg.php in Gutenberg 9.2.0, at gutenberg.php

206 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Gutenberg
4 * Plugin URI: https://github.com/WordPress/gutenberg
5 * Description: Printing since 1440. This is the development plugin for the new block editor in core.
6 * Requires at least: 5.3
7 * Requires PHP: 5.6
8 * Version: 9.2.0
9 * Author: Gutenberg Team
10 * Text Domain: gutenberg
11 *
12 * @package gutenberg
13 */
14
15 ### BEGIN AUTO-GENERATED DEFINES
16 define( 'GUTENBERG_VERSION', '9.2.0' );
17 define( 'GUTENBERG_GIT_COMMIT', '3a840caf13b6f320bd87087aeccb667fde70df9d' );
18 ### END AUTO-GENERATED DEFINES
19
20 gutenberg_pre_init();
21
22 /**
23 * Gutenberg's Menu.
24 *
25 * Adds a new wp-admin menu page for the Gutenberg editor.
26 *
27 * @since 0.1.0
28 */
29 function gutenberg_menu() {
30 add_menu_page(
31 'Gutenberg',
32 'Gutenberg',
33 'edit_posts',
34 'gutenberg',
35 '',
36 'dashicons-edit'
37 );
38
39 add_submenu_page(
40 'gutenberg',
41 __( 'Demo', 'gutenberg' ),
42 __( 'Demo', 'gutenberg' ),
43 'edit_posts',
44 'gutenberg'
45 );
46
47 if ( gutenberg_use_widgets_block_editor() ) {
48 add_theme_page(
49 __( 'Widgets', 'gutenberg' ),
50 __( 'Widgets', 'gutenberg' ),
51 'edit_theme_options',
52 'gutenberg-widgets',
53 'the_gutenberg_widgets'
54 );
55 remove_submenu_page( 'themes.php', 'widgets.php' );
56 }
57
58 if ( get_option( 'gutenberg-experiments' ) ) {
59 if ( array_key_exists( 'gutenberg-navigation', get_option( 'gutenberg-experiments' ) ) ) {
60 add_submenu_page(
61 'gutenberg',
62 __( 'Navigation (beta)', 'gutenberg' ),
63 __( 'Navigation (beta)', 'gutenberg' ),
64 'edit_theme_options',
65 'gutenberg-navigation',
66 'gutenberg_navigation_page'
67 );
68 }
69 if ( array_key_exists( 'gutenberg-full-site-editing', get_option( 'gutenberg-experiments' ) ) ) {
70 add_menu_page(
71 __( 'Site Editor (beta)', 'gutenberg' ),
72 __( 'Site Editor (beta)', 'gutenberg' ),
73 'edit_theme_options',
74 'gutenberg-edit-site',
75 'gutenberg_edit_site_page',
76 'dashicons-layout'
77 );
78 }
79 }
80
81 if ( current_user_can( 'edit_posts' ) ) {
82 add_submenu_page(
83 'gutenberg',
84 __( 'Support', 'gutenberg' ),
85 __( 'Support', 'gutenberg' ),
86 'edit_posts',
87 __( 'https://wordpress.org/support/plugin/gutenberg/', 'gutenberg' )
88 );
89 add_submenu_page(
90 'gutenberg',
91 __( 'Documentation', 'gutenberg' ),
92 __( 'Documentation', 'gutenberg' ),
93 'edit_posts',
94 'https://developer.wordpress.org/block-editor/'
95 );
96 }
97
98 add_submenu_page(
99 'gutenberg',
100 __( 'Experiments Settings', 'gutenberg' ),
101 __( 'Experiments', 'gutenberg' ),
102 'edit_posts',
103 'gutenberg-experiments',
104 'the_gutenberg_experiments'
105 );
106 }
107 add_action( 'admin_menu', 'gutenberg_menu', 9 );
108
109 /**
110 * Modify WP admin bar.
111 *
112 * @param WP_Admin_Bar $wp_admin_bar Core class used to implement the Toolbar API.
113 */
114 function modify_admin_bar( $wp_admin_bar ) {
115 if ( gutenberg_use_widgets_block_editor() ) {
116 $wp_admin_bar->add_menu(
117 array(
118 'id' => 'widgets',
119 'href' => admin_url( 'themes.php?page=gutenberg-widgets' ),
120 )
121 );
122 }
123 }
124 add_action( 'admin_bar_menu', 'modify_admin_bar', 40 );
125
126 /**
127 * Display a version notice and deactivate the Gutenberg plugin.
128 *
129 * @since 0.1.0
130 */
131 function gutenberg_wordpress_version_notice() {
132 echo '<div class="error"><p>';
133 /* translators: %s: Minimum required version */
134 printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.3.0' );
135 echo '</p></div>';
136
137 deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
138 }
139
140 /**
141 * Display a build notice.
142 *
143 * @since 0.1.0
144 */
145 function gutenberg_build_files_notice() {
146 echo '<div class="error"><p>';
147 _e( 'Gutenberg development mode requires files to be built. Run <code>npm install</code> to install dependencies, <code>npm run build</code> to build the files or <code>npm run dev</code> to build the files and watch for changes. Read the <a href="https://github.com/WordPress/gutenberg/blob/master/docs/contributors/getting-started.md">contributing</a> file for more information.', 'gutenberg' );
148 echo '</p></div>';
149 }
150
151 /**
152 * Verify that we can initialize the Gutenberg editor , then load it.
153 *
154 * @since 1.5.0
155 */
156 function gutenberg_pre_init() {
157 global $wp_version;
158 if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build/blocks' ) ) {
159 add_action( 'admin_notices', 'gutenberg_build_files_notice' );
160 return;
161 }
162
163 // Get unmodified $wp_version.
164 include ABSPATH . WPINC . '/version.php';
165
166 // Strip '-src' from the version string. Messes up version_compare().
167 $version = str_replace( '-src', '', $wp_version );
168
169 if ( version_compare( $version, '5.3.0', '<' ) ) {
170 add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
171 return;
172 }
173
174 require_once dirname( __FILE__ ) . '/lib/load.php';
175 }
176
177 /**
178 * Outputs a WP REST API nonce.
179 */
180 function gutenberg_rest_nonce() {
181 exit( wp_create_nonce( 'wp_rest' ) );
182 }
183 add_action( 'wp_ajax_gutenberg_rest_nonce', 'gutenberg_rest_nonce' );
184
185
186 /**
187 * Exposes the site icon url to the Gutenberg editor through the WordPress REST
188 * API. The site icon url should instead be fetched from the wp/v2/settings
189 * endpoint when https://github.com/WordPress/gutenberg/pull/19967 is complete.
190 *
191 * @since 8.2.1
192 *
193 * @param WP_REST_Response $response Response data served by the WordPress REST index endpoint.
194 * @return WP_REST_Response
195 */
196 function register_site_icon_url( $response ) {
197 $data = $response->data;
198 $data['site_icon_url'] = get_site_icon_url();
199 $response->set_data( $data );
200 return $response;
201 }
202
203 add_filter( 'rest_index', 'register_site_icon_url' );
204
205 add_theme_support( 'widgets-block-editor' );
206