PluginProbe
Gutenberg / 9.3.0
Gutenberg v9.3.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.3.0, at gutenberg.php

211 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.3.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.3.0' );
17 define( 'GUTENBERG_GIT_COMMIT', 'ab1a60f1429877e940e3a1946d2493b652387d24' );
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 }
70
71 if ( gutenberg_is_fse_theme() ) {
72 add_menu_page(
73 __( 'Site Editor (beta)', 'gutenberg' ),
74 sprintf(
75 /* translators: %s: "beta" label. */
76 __( 'Site Editor %s', 'gutenberg' ),
77 '<span class="awaiting-mod">' . __( 'beta', 'gutenberg' ) . '</span>'
78 ),
79 'edit_theme_options',
80 'gutenberg-edit-site',
81 'gutenberg_edit_site_page',
82 'dashicons-layout'
83 );
84 }
85
86 if ( current_user_can( 'edit_posts' ) ) {
87 add_submenu_page(
88 'gutenberg',
89 __( 'Support', 'gutenberg' ),
90 __( 'Support', 'gutenberg' ),
91 'edit_posts',
92 __( 'https://wordpress.org/support/plugin/gutenberg/', 'gutenberg' )
93 );
94 add_submenu_page(
95 'gutenberg',
96 __( 'Documentation', 'gutenberg' ),
97 __( 'Documentation', 'gutenberg' ),
98 'edit_posts',
99 'https://developer.wordpress.org/block-editor/'
100 );
101 }
102
103 add_submenu_page(
104 'gutenberg',
105 __( 'Experiments Settings', 'gutenberg' ),
106 __( 'Experiments', 'gutenberg' ),
107 'edit_posts',
108 'gutenberg-experiments',
109 'the_gutenberg_experiments'
110 );
111 }
112 add_action( 'admin_menu', 'gutenberg_menu', 9 );
113
114 /**
115 * Modify WP admin bar.
116 *
117 * @param WP_Admin_Bar $wp_admin_bar Core class used to implement the Toolbar API.
118 */
119 function modify_admin_bar( $wp_admin_bar ) {
120 if ( gutenberg_use_widgets_block_editor() ) {
121 $wp_admin_bar->add_menu(
122 array(
123 'id' => 'widgets',
124 'href' => admin_url( 'themes.php?page=gutenberg-widgets' ),
125 )
126 );
127 }
128 }
129 add_action( 'admin_bar_menu', 'modify_admin_bar', 40 );
130
131 /**
132 * Display a version notice and deactivate the Gutenberg plugin.
133 *
134 * @since 0.1.0
135 */
136 function gutenberg_wordpress_version_notice() {
137 echo '<div class="error"><p>';
138 /* translators: %s: Minimum required version */
139 printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.3.0' );
140 echo '</p></div>';
141
142 deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
143 }
144
145 /**
146 * Display a build notice.
147 *
148 * @since 0.1.0
149 */
150 function gutenberg_build_files_notice() {
151 echo '<div class="error"><p>';
152 _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' );
153 echo '</p></div>';
154 }
155
156 /**
157 * Verify that we can initialize the Gutenberg editor , then load it.
158 *
159 * @since 1.5.0
160 */
161 function gutenberg_pre_init() {
162 global $wp_version;
163 if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build/blocks' ) ) {
164 add_action( 'admin_notices', 'gutenberg_build_files_notice' );
165 return;
166 }
167
168 // Get unmodified $wp_version.
169 include ABSPATH . WPINC . '/version.php';
170
171 // Strip '-src' from the version string. Messes up version_compare().
172 $version = str_replace( '-src', '', $wp_version );
173
174 if ( version_compare( $version, '5.3.0', '<' ) ) {
175 add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
176 return;
177 }
178
179 require_once dirname( __FILE__ ) . '/lib/load.php';
180 }
181
182 /**
183 * Outputs a WP REST API nonce.
184 */
185 function gutenberg_rest_nonce() {
186 exit( wp_create_nonce( 'wp_rest' ) );
187 }
188 add_action( 'wp_ajax_gutenberg_rest_nonce', 'gutenberg_rest_nonce' );
189
190
191 /**
192 * Exposes the site icon url to the Gutenberg editor through the WordPress REST
193 * API. The site icon url should instead be fetched from the wp/v2/settings
194 * endpoint when https://github.com/WordPress/gutenberg/pull/19967 is complete.
195 *
196 * @since 8.2.1
197 *
198 * @param WP_REST_Response $response Response data served by the WordPress REST index endpoint.
199 * @return WP_REST_Response
200 */
201 function register_site_icon_url( $response ) {
202 $data = $response->data;
203 $data['site_icon_url'] = get_site_icon_url();
204 $response->set_data( $data );
205 return $response;
206 }
207
208 add_filter( 'rest_index', 'register_site_icon_url' );
209
210 add_theme_support( 'widgets-block-editor' );
211