| 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.5.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.5.0' ); |
| 15 |
define( 'GUTENBERG_GIT_COMMIT', 'e728c2432aa472b3bae1a3cf727a7c613cc5144c' ); |
| 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 |
add_submenu_page( |
| 48 |
'gutenberg', |
| 49 |
__( 'Widgets (beta)', 'gutenberg' ), |
| 50 |
__( 'Widgets (beta)', 'gutenberg' ), |
| 51 |
'edit_theme_options', |
| 52 |
'gutenberg-widgets', |
| 53 |
'the_gutenberg_widgets' |
| 54 |
); |
| 55 |
|
| 56 |
if ( current_user_can( 'edit_posts' ) ) { |
| 57 |
$submenu['gutenberg'][] = array( |
| 58 |
__( 'Support', 'gutenberg' ), |
| 59 |
'edit_posts', |
| 60 |
__( 'https://wordpress.org/support/plugin/gutenberg', 'gutenberg' ), |
| 61 |
); |
| 62 |
|
| 63 |
$submenu['gutenberg'][] = array( |
| 64 |
__( 'Documentation', 'gutenberg' ), |
| 65 |
'edit_posts', |
| 66 |
'https://wordpress.org/gutenberg/handbook/', |
| 67 |
); |
| 68 |
} |
| 69 |
} |
| 70 |
add_action( 'admin_menu', 'gutenberg_menu' ); |
| 71 |
|
| 72 |
/** |
| 73 |
* Display a version notice and deactivate the Gutenberg plugin. |
| 74 |
* |
| 75 |
* @since 0.1.0 |
| 76 |
*/ |
| 77 |
function gutenberg_wordpress_version_notice() { |
| 78 |
echo '<div class="error"><p>'; |
| 79 |
/* translators: %s: Minimum required version */ |
| 80 |
printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.0.0' ); |
| 81 |
echo '</p></div>'; |
| 82 |
|
| 83 |
deactivate_plugins( array( 'gutenberg/gutenberg.php' ) ); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Display a build notice. |
| 88 |
* |
| 89 |
* @since 0.1.0 |
| 90 |
*/ |
| 91 |
function gutenberg_build_files_notice() { |
| 92 |
echo '<div class="error"><p>'; |
| 93 |
_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' ); |
| 94 |
echo '</p></div>'; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Verify that we can initialize the Gutenberg editor , then load it. |
| 99 |
* |
| 100 |
* @since 1.5.0 |
| 101 |
*/ |
| 102 |
function gutenberg_pre_init() { |
| 103 |
if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build/blocks' ) ) { |
| 104 |
add_action( 'admin_notices', 'gutenberg_build_files_notice' ); |
| 105 |
return; |
| 106 |
} |
| 107 |
|
| 108 |
// Get unmodified $wp_version. |
| 109 |
include ABSPATH . WPINC . '/version.php'; |
| 110 |
|
| 111 |
// Strip '-src' from the version string. Messes up version_compare(). |
| 112 |
$version = str_replace( '-src', '', $wp_version ); |
| 113 |
|
| 114 |
if ( version_compare( $version, '5.0.0', '<' ) ) { |
| 115 |
add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' ); |
| 116 |
return; |
| 117 |
} |
| 118 |
|
| 119 |
require_once dirname( __FILE__ ) . '/lib/load.php'; |
| 120 |
} |
| 121 |
|