PluginProbe
Gutenberg / 7.0.0
Gutenberg v7.0.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 7.0.0, at gutenberg.php

141 lines 3.7 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: 7.0.0
7 * Author: Gutenberg Team
8 * Text Domain: gutenberg
9 *
10 * @package gutenberg
11 */
12
13 ### BEGIN AUTO-GENERATED DEFINES
14 define( 'GUTENBERG_VERSION', '7.0.0' );
15 define( 'GUTENBERG_GIT_COMMIT', '3534dee58ca76da57a3f5c4b1d9c5898b9f3489a' );
16 ### END AUTO-GENERATED DEFINES
17
18 gutenberg_pre_init();
19
20 /**
21 * Gutenberg's Menu.
22 *
23 * Adds a new wp-admin menu page for the Gutenberg editor.
24 *
25 * @since 0.1.0
26 */
27 function gutenberg_menu() {
28 global $submenu;
29
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 ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-widget-experiments', get_option( 'gutenberg-experiments' ) ) ) {
48 add_submenu_page(
49 'gutenberg',
50 __( 'Widgets (beta)', 'gutenberg' ),
51 __( 'Widgets (beta)', 'gutenberg' ),
52 'edit_theme_options',
53 'gutenberg-widgets',
54 'the_gutenberg_widgets'
55 );
56 }
57
58 if ( current_user_can( 'edit_posts' ) ) {
59 $submenu['gutenberg'][] = array(
60 __( 'Support', 'gutenberg' ),
61 'edit_posts',
62 __( 'https://wordpress.org/support/plugin/gutenberg', 'gutenberg' ),
63 );
64
65 $submenu['gutenberg'][] = array(
66 __( 'Documentation', 'gutenberg' ),
67 'edit_posts',
68 'https://developer.wordpress.org/block-editor/',
69 );
70 }
71
72 add_submenu_page(
73 'gutenberg',
74 __( 'Experiments Settings', 'gutenberg' ),
75 __( 'Experiments', 'gutenberg' ),
76 'edit_posts',
77 'gutenberg-experiments',
78 'the_gutenberg_experiments'
79 );
80 }
81 add_action( 'admin_menu', 'gutenberg_menu' );
82
83 /**
84 * Display a version notice and deactivate the Gutenberg plugin.
85 *
86 * @since 0.1.0
87 */
88 function gutenberg_wordpress_version_notice() {
89 echo '<div class="error"><p>';
90 /* translators: %s: Minimum required version */
91 printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.2.0' );
92 echo '</p></div>';
93
94 deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
95 }
96
97 /**
98 * Display a build notice.
99 *
100 * @since 0.1.0
101 */
102 function gutenberg_build_files_notice() {
103 echo '<div class="error"><p>';
104 _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' );
105 echo '</p></div>';
106 }
107
108 /**
109 * Verify that we can initialize the Gutenberg editor , then load it.
110 *
111 * @since 1.5.0
112 */
113 function gutenberg_pre_init() {
114 global $wp_version;
115 if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build/blocks' ) ) {
116 add_action( 'admin_notices', 'gutenberg_build_files_notice' );
117 return;
118 }
119
120 // Get unmodified $wp_version.
121 include ABSPATH . WPINC . '/version.php';
122
123 // Strip '-src' from the version string. Messes up version_compare().
124 $version = str_replace( '-src', '', $wp_version );
125
126 if ( version_compare( $version, '5.2.0', '<' ) ) {
127 add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
128 return;
129 }
130
131 require_once dirname( __FILE__ ) . '/lib/load.php';
132 }
133
134 /**
135 * Outputs a WP REST API nonce.
136 */
137 function gutenberg_rest_nonce() {
138 exit( wp_create_nonce( 'wp_rest' ) );
139 }
140 add_action( 'wp_ajax_gutenberg_rest_nonce', 'gutenberg_rest_nonce' );
141