浏览代码

Blockbase: Switch logic for enabling Site Editor (#4219)

* Blockbase: Switch logic for enabling Site Editor

* Always add legacy admin links

Co-authored-by: Jason Crist <jcrist@pbking.com>
Ben Dwyer 4 年之前
父节点
当前提交
b0ecd1084d
共有 1 个文件被更改,包括 10 次插入7 次删除
  1. 10 7
      blockbase/inc/disable-site-editor.php

+ 10 - 7
blockbase/inc/disable-site-editor.php

@@ -15,19 +15,22 @@ function add_disable_site_editor_setting() {
 		'gutenberg-experiments',
 		'gutenberg_experiments_section',
 		array(
-			'label' => __( 'Disable Site Editor', 'gutenberg' ),
+			'label' => __( 'Enable Site Editor', 'gutenberg' ),
 			'id'    => 'universal-theme-disable-site-editor',
 		)
 	);
 
-	if ( get_option( 'gutenberg-experiments' ) ) {
-		if ( array_key_exists( 'universal-theme-disable-site-editor', get_option( 'gutenberg-experiments' ) ) ) {
-			readd_legacy_admin_links();
-			remove_site_editor_admin_link();
-		}
+	readd_legacy_admin_links();
+
+	if ( ! site_editor_enabled() ) {
+		remove_site_editor_admin_link();
 	}
 }
 
+function site_editor_enabled() {
+	return get_option( 'gutenberg-experiments' ) && array_key_exists( 'universal-theme-disable-site-editor', get_option( 'gutenberg-experiments' ) );
+}
+
 /**
  * Adds the Customizer and Widgets menu links back to the Dashboard under themes.
  */
@@ -39,7 +42,7 @@ function readd_legacy_admin_links() {
 		$submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
 
 		if (
-			function_exists( 'gutenberg_use_widgets_block_editor') &&
+			function_exists( 'gutenberg_use_widgets_block_editor' ) &&
 			gutenberg_use_widgets_block_editor() &&
 			! function_exists( 'wp_use_widgets_block_editor' ) &&
 			current_theme_supports( 'widgets' )