PluginProbe
Gutenberg / 5.3.0
Gutenberg v5.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 5.3.0, at gutenberg.php

165 lines 4.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 * Version: 5.3.0
7 * Author: Gutenberg Team
8 * Text Domain: gutenberg
9 *
10 * @package gutenberg
11 */
12
13 ### BEGIN AUTO-GENERATED DEFINES
14 define( 'GUTENBERG_VERSION', '5.3.0' );
15 define( 'GUTENBERG_GIT_COMMIT', '0563f6f8f9cc2912b67ed6d9ba4a3c910b70e71b' );
16 ### END AUTO-GENERATED DEFINES
17
18 gutenberg_pre_init();
19
20 /**
21 * Project.
22 *
23 * The main entry point for the Gutenberg editor. Renders the editor on the
24 * wp-admin page for the plugin.
25 *
26 * @since 0.1.0
27 * @deprecated 5.3.0
28 */
29 function the_gutenberg_project() {
30 _deprecated_function( __FUNCTION__, '5.3.0' );
31 }
32
33 /**
34 * Gutenberg's Menu.
35 *
36 * Adds a new wp-admin menu page for the Gutenberg editor.
37 *
38 * @since 0.1.0
39 */
40 function gutenberg_menu() {
41 global $submenu;
42
43 add_menu_page(
44 'Gutenberg',
45 'Gutenberg',
46 'edit_posts',
47 'gutenberg',
48 '',
49 'dashicons-edit'
50 );
51
52 add_submenu_page(
53 'gutenberg',
54 __( 'Demo', 'gutenberg' ),
55 __( 'Demo', 'gutenberg' ),
56 'edit_posts',
57 'gutenberg'
58 );
59
60 add_submenu_page(
61 'gutenberg',
62 __( 'Widgets (beta)', 'gutenberg' ),
63 __( 'Widgets (beta)', 'gutenberg' ),
64 'edit_theme_options',
65 'gutenberg-widgets',
66 'the_gutenberg_widgets'
67 );
68
69 if ( current_user_can( 'edit_posts' ) ) {
70 $submenu['gutenberg'][] = array(
71 __( 'Support', 'gutenberg' ),
72 'edit_posts',
73 __( 'https://wordpress.org/support/plugin/gutenberg', 'gutenberg' ),
74 );
75
76 $submenu['gutenberg'][] = array(
77 __( 'Documentation', 'gutenberg' ),
78 'edit_posts',
79 'https://wordpress.org/gutenberg/handbook/',
80 );
81 }
82 }
83 add_action( 'admin_menu', 'gutenberg_menu' );
84
85 /**
86 * Checks whether we're currently loading a Gutenberg page
87 *
88 * @since 3.1.0
89 * @deprecated 5.3.0 WP_Screen::is_block_editor
90 *
91 * @return boolean Whether Gutenberg is being loaded.
92 */
93 function is_gutenberg_page() {
94 _deprecated_function( __FUNCTION__, '5.3.0', 'WP_Screen::is_block_editor' );
95
96 require_once ABSPATH . 'wp-admin/includes/screen.php';
97 return get_current_screen()->is_block_editor();
98 }
99
100 /**
101 * Display a version notice and deactivate the Gutenberg plugin.
102 *
103 * @since 0.1.0
104 */
105 function gutenberg_wordpress_version_notice() {
106 echo '<div class="error"><p>';
107 /* translators: %s: Minimum required version */
108 printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.0.0' );
109 echo '</p></div>';
110
111 deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
112 }
113
114 /**
115 * Display a build notice.
116 *
117 * @since 0.1.0
118 */
119 function gutenberg_build_files_notice() {
120 echo '<div class="error"><p>';
121 _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/CONTRIBUTING.md">contributing</a> file for more information.', 'gutenberg' );
122 echo '</p></div>';
123 }
124
125 /**
126 * Verify that we can initialize the Gutenberg editor , then load it.
127 *
128 * @since 1.5.0
129 */
130 function gutenberg_pre_init() {
131 if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build/blocks' ) ) {
132 add_action( 'admin_notices', 'gutenberg_build_files_notice' );
133 return;
134 }
135
136 // Get unmodified $wp_version.
137 include ABSPATH . WPINC . '/version.php';
138
139 // Strip '-src' from the version string. Messes up version_compare().
140 $version = str_replace( '-src', '', $wp_version );
141
142 if ( version_compare( $version, '5.0.0', '<' ) ) {
143 add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
144 return;
145 }
146
147 require_once dirname( __FILE__ ) . '/lib/load.php';
148 }
149
150 /**
151 * Initialize Gutenberg.
152 *
153 * Load API functions, register scripts and actions, etc.
154 *
155 * @deprecated 5.3.0
156 *
157 * @return bool Whether Gutenberg was initialized.
158 */
159 function gutenberg_init() {
160 _deprecated_function( __FUNCTION__, '5.3.0' );
161
162 require_once ABSPATH . 'wp-admin/includes/screen.php';
163 return get_current_screen()->is_block_editor();
164 }
165