diff --git a/lib/compat/wordpress-5.9/register-global-styles-cpt.php b/lib/compat/wordpress-5.9/register-global-styles-cpt.php index cb7b21e89014f..0a18bc547fe62 100644 --- a/lib/compat/wordpress-5.9/register-global-styles-cpt.php +++ b/lib/compat/wordpress-5.9/register-global-styles-cpt.php @@ -6,34 +6,44 @@ * @package gutenberg */ -/** - * Registers a Custom Post Type to store the user's origin config. - * - * This has been ported to src/wp-includes/post.php +/* + * If wp_get_global_settings is defined, it means the plugin + * is running on WordPress 5.9, so don't need to register the CPT + * as it was already done by WordPress core. */ -function register_global_styles_custom_post_type() { - $args = array( - 'label' => __( 'Global Styles', 'gutenberg' ), - 'description' => 'CPT to store user design tokens', - 'public' => false, - 'show_ui' => false, - 'show_in_rest' => false, - 'rewrite' => false, - 'capabilities' => array( - 'read' => 'edit_theme_options', - 'create_posts' => 'edit_theme_options', - 'edit_posts' => 'edit_theme_options', - 'edit_published_posts' => 'edit_theme_options', - 'delete_published_posts' => 'edit_theme_options', - 'edit_others_posts' => 'edit_theme_options', - 'delete_others_posts' => 'edit_theme_options', - ), - 'map_meta_cap' => true, - 'supports' => array( - 'title', - 'editor', - 'revisions', - ), - ); - register_post_type( 'wp_global_styles', $args ); +if ( ! function_exists( 'wp_get_global_settings' ) ) { + + /** + * Registers a Custom Post Type to store the user's origin config. + * + * This has been ported to src/wp-includes/post.php + */ + function register_global_styles_custom_post_type() { + $args = array( + 'label' => __( 'Global Styles', 'gutenberg' ), + 'description' => 'Global styles to include in themes.', + 'public' => false, + 'show_ui' => false, + 'show_in_rest' => false, + 'rewrite' => false, + 'capabilities' => array( + 'read' => 'edit_theme_options', + 'create_posts' => 'edit_theme_options', + 'edit_posts' => 'edit_theme_options', + 'edit_published_posts' => 'edit_theme_options', + 'delete_published_posts' => 'edit_theme_options', + 'edit_others_posts' => 'edit_theme_options', + 'delete_others_posts' => 'edit_theme_options', + ), + 'map_meta_cap' => true, + 'supports' => array( + 'title', + 'editor', + 'revisions', + ), + ); + register_post_type( 'wp_global_styles', $args ); + } + + add_action( 'init', 'register_global_styles_custom_post_type' ); } diff --git a/lib/global-styles.php b/lib/global-styles.php index 78802343c5c32..df4d01203ccb7 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -153,26 +153,6 @@ function_exists( 'gutenberg_is_edit_site_page' ) && return $settings; } -/** - * Whether or not the Site Editor is available. - * - * @return boolean - */ -function gutenberg_experimental_is_site_editor_available() { - return wp_is_block_theme(); -} - -/** - * Register CPT to store/access user data. - * - * @return void - */ -function gutenberg_experimental_global_styles_register_user_cpt() { - if ( gutenberg_experimental_is_site_editor_available() ) { - register_global_styles_custom_post_type(); - } -} - /** * Sanitizes global styles user content removing unsafe rules. * @@ -293,7 +273,6 @@ function gutenberg_load_css_custom_properties() { add_filter( 'block_editor_settings', 'gutenberg_experimental_global_styles_settings', PHP_INT_MAX ); } -add_action( 'init', 'gutenberg_experimental_global_styles_register_user_cpt' ); add_action( 'wp_enqueue_scripts', 'gutenberg_experimental_global_styles_enqueue_assets' ); // kses actions&filters. diff --git a/lib/init.php b/lib/init.php index 606401eed7803..4264c4b3c69a1 100644 --- a/lib/init.php +++ b/lib/init.php @@ -94,7 +94,7 @@ function gutenberg_menu() { * @since 9.4.0 */ function gutenberg_site_editor_menu() { - if ( gutenberg_experimental_is_site_editor_available() ) { + if ( wp_is_block_theme() ) { add_theme_page( __( 'Editor (beta)', 'gutenberg' ), sprintf(