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

gutenberg.php in Gutenberg 9.1.0, at gutenberg.php

189 lines 5.1 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.1.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.1.0' );
17 define( 'GUTENBERG_GIT_COMMIT', 'd21c8048b7a6e0100976809f1488b428dc0f57c1' );
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 * Display a version notice and deactivate the Gutenberg plugin.
111 *
112 * @since 0.1.0
113 */
114 function gutenberg_wordpress_version_notice() {
115 echo '<div class="error"><p>';
116 /* translators: %s: Minimum required version */
117 printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.3.0' );
118 echo '</p></div>';
119
120 deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
121 }
122
123 /**
124 * Display a build notice.
125 *
126 * @since 0.1.0
127 */
128 function gutenberg_build_files_notice() {
129 echo '<div class="error"><p>';
130 _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' );
131 echo '</p></div>';
132 }
133
134 /**
135 * Verify that we can initialize the Gutenberg editor , then load it.
136 *
137 * @since 1.5.0
138 */
139 function gutenberg_pre_init() {
140 global $wp_version;
141 if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build/blocks' ) ) {
142 add_action( 'admin_notices', 'gutenberg_build_files_notice' );
143 return;
144 }
145
146 // Get unmodified $wp_version.
147 include ABSPATH . WPINC . '/version.php';
148
149 // Strip '-src' from the version string. Messes up version_compare().
150 $version = str_replace( '-src', '', $wp_version );
151
152 if ( version_compare( $version, '5.3.0', '<' ) ) {
153 add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
154 return;
155 }
156
157 require_once dirname( __FILE__ ) . '/lib/load.php';
158 }
159
160 /**
161 * Outputs a WP REST API nonce.
162 */
163 function gutenberg_rest_nonce() {
164 exit( wp_create_nonce( 'wp_rest' ) );
165 }
166 add_action( 'wp_ajax_gutenberg_rest_nonce', 'gutenberg_rest_nonce' );
167
168
169 /**
170 * Exposes the site icon url to the Gutenberg editor through the WordPress REST
171 * API. The site icon url should instead be fetched from the wp/v2/settings
172 * endpoint when https://github.com/WordPress/gutenberg/pull/19967 is complete.
173 *
174 * @since 8.2.1
175 *
176 * @param WP_REST_Response $response Response data served by the WordPress REST index endpoint.
177 * @return WP_REST_Response
178 */
179 function register_site_icon_url( $response ) {
180 $data = $response->data;
181 $data['site_icon_url'] = get_site_icon_url();
182 $response->set_data( $data );
183 return $response;
184 }
185
186 add_filter( 'rest_index', 'register_site_icon_url' );
187
188 add_theme_support( 'widgets-block-editor' );
189