wp/wp-admin/includes/class-wp-screen.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
--- a/wp/wp-admin/includes/class-wp-screen.php	Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-admin/includes/class-wp-screen.php	Mon Oct 14 18:28:13 2019 +0200
@@ -108,6 +108,7 @@
 	/**
 	 * The taxonomy associated with the screen, if any.
 	 * The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.
+	 *
 	 * @since 3.3.0
 	 * @var string
 	 */
@@ -129,7 +130,7 @@
 	 */
 	private $_help_sidebar = '';
 
- 	/**
+	/**
 	 * The accessible hidden headings and text associated with the screen, if any.
 	 *
 	 * @since 4.4.0
@@ -140,8 +141,6 @@
 	/**
 	 * Stores old string-based help.
 	 *
-	 * @static
-	 *
 	 * @var array
 	 */
 	private static $_old_compat_help = array();
@@ -159,8 +158,6 @@
 	 *
 	 * @since 3.3.0
 	 *
-	 * @static
-	 *
 	 * @var array
 	 */
 	private static $_registry = array();
@@ -182,16 +179,22 @@
 	private $_screen_settings;
 
 	/**
+	 * Whether the screen is using the block editor.
+	 *
+	 * @since 5.0.0
+	 * @var bool
+	 */
+	public $is_block_editor = false;
+
+	/**
 	 * Fetches a screen object.
 	 *
 	 * @since 3.3.0
 	 *
-	 * @static
-	 *
 	 * @global string $hook_suffix
 	 *
 	 * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
-	 * 	                                  Defaults to the current $hook_suffix global.
+	 *                                    Defaults to the current $hook_suffix global.
 	 * @return WP_Screen Screen object.
 	 */
 	public static function get( $hook_name = '' ) {
@@ -199,35 +202,38 @@
 			return $hook_name;
 		}
 
-		$post_type = $taxonomy = null;
-		$in_admin = false;
-		$action = '';
+		$post_type       = $taxonomy = null;
+		$in_admin        = false;
+		$action          = '';
+		$is_block_editor = false;
 
-		if ( $hook_name )
+		if ( $hook_name ) {
 			$id = $hook_name;
-		else
+		} else {
 			$id = $GLOBALS['hook_suffix'];
+		}
 
 		// For those pesky meta boxes.
 		if ( $hook_name && post_type_exists( $hook_name ) ) {
 			$post_type = $id;
-			$id = 'post'; // changes later. ends up being $base.
+			$id        = 'post'; // changes later. ends up being $base.
 		} else {
-			if ( '.php' == substr( $id, -4 ) )
+			if ( '.php' == substr( $id, -4 ) ) {
 				$id = substr( $id, 0, -4 );
+			}
 
 			if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) {
-				$id = substr( $id, 0, -4 );
+				$id     = substr( $id, 0, -4 );
 				$action = 'add';
 			}
 		}
 
 		if ( ! $post_type && $hook_name ) {
 			if ( '-network' == substr( $id, -8 ) ) {
-				$id = substr( $id, 0, -8 );
+				$id       = substr( $id, 0, -8 );
 				$in_admin = 'network';
 			} elseif ( '-user' == substr( $id, -5 ) ) {
-				$id = substr( $id, 0, -5 );
+				$id       = substr( $id, 0, -5 );
 				$in_admin = 'user';
 			}
 
@@ -235,58 +241,75 @@
 			if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) {
 				$maybe = substr( $id, 5 );
 				if ( taxonomy_exists( $maybe ) ) {
-					$id = 'edit-tags';
+					$id       = 'edit-tags';
 					$taxonomy = $maybe;
 				} elseif ( post_type_exists( $maybe ) ) {
-					$id = 'edit';
+					$id        = 'edit';
 					$post_type = $maybe;
 				}
 			}
 
-			if ( ! $in_admin )
+			if ( ! $in_admin ) {
 				$in_admin = 'site';
+			}
 		} else {
-			if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
+			if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) {
 				$in_admin = 'network';
-			elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
+			} elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) {
 				$in_admin = 'user';
-			else
+			} else {
 				$in_admin = 'site';
+			}
 		}
 
-		if ( 'index' == $id )
+		if ( 'index' == $id ) {
 			$id = 'dashboard';
-		elseif ( 'front' == $id )
+		} elseif ( 'front' == $id ) {
 			$in_admin = false;
+		}
 
 		$base = $id;
 
 		// If this is the current screen, see if we can be more accurate for post types and taxonomies.
 		if ( ! $hook_name ) {
-			if ( isset( $_REQUEST['post_type'] ) )
+			if ( isset( $_REQUEST['post_type'] ) ) {
 				$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
-			if ( isset( $_REQUEST['taxonomy'] ) )
+			}
+			if ( isset( $_REQUEST['taxonomy'] ) ) {
 				$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
+			}
 
 			switch ( $base ) {
-				case 'post' :
-					if ( isset( $_GET['post'] ) )
+				case 'post':
+					if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
+						wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 );
+					} elseif ( isset( $_GET['post'] ) ) {
 						$post_id = (int) $_GET['post'];
-					elseif ( isset( $_POST['post_ID'] ) )
+					} elseif ( isset( $_POST['post_ID'] ) ) {
 						$post_id = (int) $_POST['post_ID'];
-					else
+					} else {
 						$post_id = 0;
+					}
 
 					if ( $post_id ) {
 						$post = get_post( $post_id );
-						if ( $post )
+						if ( $post ) {
 							$post_type = $post->post_type;
+
+							/** This filter is documented in wp-admin/post.php */
+							$replace_editor = apply_filters( 'replace_editor', false, $post );
+
+							if ( ! $replace_editor ) {
+								$is_block_editor = use_block_editor_for_post( $post );
+							}
+						}
 					}
 					break;
-				case 'edit-tags' :
-				case 'term' :
-					if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
+				case 'edit-tags':
+				case 'term':
+					if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
 						$post_type = 'post';
+					}
 					break;
 				case 'upload':
 					$post_type = 'attachment';
@@ -295,25 +318,35 @@
 		}
 
 		switch ( $base ) {
-			case 'post' :
-				if ( null === $post_type )
+			case 'post':
+				if ( null === $post_type ) {
 					$post_type = 'post';
+				}
+
+				// When creating a new post, use the default block editor support value for the post type.
+				if ( empty( $post_id ) ) {
+					$is_block_editor = use_block_editor_for_post_type( $post_type );
+				}
+
 				$id = $post_type;
 				break;
-			case 'edit' :
-				if ( null === $post_type )
+			case 'edit':
+				if ( null === $post_type ) {
 					$post_type = 'post';
+				}
 				$id .= '-' . $post_type;
 				break;
-			case 'edit-tags' :
-			case 'term' :
-				if ( null === $taxonomy )
+			case 'edit-tags':
+			case 'term':
+				if ( null === $taxonomy ) {
 					$taxonomy = 'post_tag';
+				}
 				// The edit-tags ID does not contain the post type. Look for it in the request.
 				if ( null === $post_type ) {
 					$post_type = 'post';
-					if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
+					if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
 						$post_type = $_REQUEST['post_type'];
+					}
 				}
 
 				$id = 'edit-' . $taxonomy;
@@ -330,20 +363,22 @@
 
 		if ( isset( self::$_registry[ $id ] ) ) {
 			$screen = self::$_registry[ $id ];
-			if ( $screen === get_current_screen() )
+			if ( $screen === get_current_screen() ) {
 				return $screen;
+			}
 		} else {
-			$screen = new WP_Screen();
-			$screen->id     = $id;
+			$screen     = new WP_Screen();
+			$screen->id = $id;
 		}
 
-		$screen->base       = $base;
-		$screen->action     = $action;
-		$screen->post_type  = (string) $post_type;
-		$screen->taxonomy   = (string) $taxonomy;
-		$screen->is_user    = ( 'user' == $in_admin );
-		$screen->is_network = ( 'network' == $in_admin );
-		$screen->in_admin   = $in_admin;
+		$screen->base            = $base;
+		$screen->action          = $action;
+		$screen->post_type       = (string) $post_type;
+		$screen->taxonomy        = (string) $taxonomy;
+		$screen->is_user         = ( 'user' == $in_admin );
+		$screen->is_network      = ( 'network' == $in_admin );
+		$screen->in_admin        = $in_admin;
+		$screen->is_block_editor = $is_block_editor;
 
 		self::$_registry[ $id ] = $screen;
 
@@ -363,8 +398,8 @@
 	public function set_current_screen() {
 		global $current_screen, $taxnow, $typenow;
 		$current_screen = $this;
-		$taxnow = $this->taxonomy;
-		$typenow = $this->post_type;
+		$taxnow         = $this->taxonomy;
+		$typenow        = $this->post_type;
 
 		/**
 		 * Fires after the current screen has been set.
@@ -393,19 +428,34 @@
 	 * @return bool True if the screen is in the indicated admin, false otherwise.
 	 */
 	public function in_admin( $admin = null ) {
-		if ( empty( $admin ) )
+		if ( empty( $admin ) ) {
 			return (bool) $this->in_admin;
+		}
 
 		return ( $admin == $this->in_admin );
 	}
 
 	/**
+	 * Sets or returns whether the block editor is loading on the current screen.
+	 *
+	 * @since 5.0.0
+	 *
+	 * @param bool $set Optional. Sets whether the block editor is loading on the current screen or not.
+	 * @return bool True if the block editor is being loaded, false otherwise.
+	 */
+	public function is_block_editor( $set = null ) {
+		if ( $set !== null ) {
+			$this->is_block_editor = (bool) $set;
+		}
+
+		return $this->is_block_editor;
+	}
+
+	/**
 	 * Sets the old string-based contextual help for the screen for backward compatibility.
 	 *
 	 * @since 3.3.0
 	 *
-	 * @static
-	 *
 	 * @param WP_Screen $screen A screen object.
 	 * @param string $help Help text.
 	 */
@@ -422,9 +472,9 @@
 	 * @param string $parent_file The parent file of the screen. Typically the $parent_file global.
 	 */
 	public function set_parentage( $parent_file ) {
-		$this->parent_file = $parent_file;
+		$this->parent_file         = $parent_file;
 		list( $this->parent_base ) = explode( '?', $parent_file );
-		$this->parent_base = str_replace( '.php', '', $this->parent_base );
+		$this->parent_base         = str_replace( '.php', '', $this->parent_base );
 	}
 
 	/**
@@ -482,11 +532,13 @@
 	 * @return string The option value if set, null otherwise.
 	 */
 	public function get_option( $option, $key = false ) {
-		if ( ! isset( $this->_options[ $option ] ) )
+		if ( ! isset( $this->_options[ $option ] ) ) {
 			return null;
+		}
 		if ( $key ) {
-			if ( isset( $this->_options[ $option ][ $key ] ) )
+			if ( isset( $this->_options[ $option ][ $key ] ) ) {
 				return $this->_options[ $option ][ $key ];
+			}
 			return null;
 		}
 		return $this->_options[ $option ];
@@ -533,8 +585,9 @@
 	 * @return array Help tab arguments.
 	 */
 	public function get_help_tab( $id ) {
-		if ( ! isset( $this->_help_tabs[ $id ] ) )
+		if ( ! isset( $this->_help_tabs[ $id ] ) ) {
 			return null;
+		}
 		return $this->_help_tabs[ $id ];
 	}
 
@@ -563,13 +616,14 @@
 			'callback' => false,
 			'priority' => 10,
 		);
-		$args = wp_parse_args( $args, $defaults );
+		$args     = wp_parse_args( $args, $defaults );
 
 		$args['id'] = sanitize_html_class( $args['id'] );
 
 		// Ensure we have an ID and title.
-		if ( ! $args['id'] || ! $args['title'] )
+		if ( ! $args['id'] || ! $args['title'] ) {
 			return;
+		}
 
 		// Allows for overriding an existing tab with that ID.
 		$this->_help_tabs[ $args['id'] ] = $args;
@@ -635,7 +689,7 @@
 		return $this->columns;
 	}
 
- 	/**
+	/**
 	 * Get the accessible hidden headings and text used in the screen.
 	 *
 	 * @since 4.4.0
@@ -685,7 +739,7 @@
 			'heading_pagination' => __( 'Items list navigation' ),
 			'heading_list'       => __( 'Items list' ),
 		);
-		$content = wp_parse_args( $content, $defaults );
+		$content  = wp_parse_args( $content, $defaults );
 
 		$this->_screen_reader_content = $content;
 	}
@@ -734,7 +788,6 @@
 		 * @param string    $old_help  Help text that appears on the screen.
 		 * @param string    $screen_id Screen ID.
 		 * @param WP_Screen $this      Current WP_Screen instance.
-		 *
 		 */
 		$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
 
@@ -751,29 +804,33 @@
 			 * @param string $old_help_default Default contextual help text.
 			 */
 			$default_help = apply_filters( 'default_contextual_help', '' );
-			if ( $default_help )
+			if ( $default_help ) {
 				$old_help = '<p>' . $default_help . '</p>';
+			}
 		}
 
 		if ( $old_help ) {
-			$this->add_help_tab( array(
-				'id'      => 'old-contextual-help',
-				'title'   => __('Overview'),
-				'content' => $old_help,
-			) );
+			$this->add_help_tab(
+				array(
+					'id'      => 'old-contextual-help',
+					'title'   => __( 'Overview' ),
+					'content' => $old_help,
+				)
+			);
 		}
 
 		$help_sidebar = $this->get_help_sidebar();
 
 		$help_class = 'hidden';
-		if ( ! $help_sidebar )
+		if ( ! $help_sidebar ) {
 			$help_class .= ' no-sidebar';
+		}
 
 		// Time to render!
 		?>
 		<div id="screen-meta" class="metabox-prefs">
 
-			<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>">
+			<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e( 'Contextual Help Tab' ); ?>">
 				<div id="contextual-help-back"></div>
 				<div id="contextual-help-columns">
 					<div class="contextual-help-tabs">
@@ -790,7 +847,7 @@
 									<?php echo esc_html( $tab['title'] ); ?>
 								</a>
 							</li>
-						<?php
+							<?php
 							$class = '';
 						endforeach;
 						?>
@@ -806,7 +863,7 @@
 					<div class="contextual-help-tabs-wrap">
 						<?php
 						$classes = 'help-tab-content active';
-						foreach ( $this->get_help_tabs() as $tab ):
+						foreach ( $this->get_help_tabs() as $tab ) :
 							$panel_id = "tab-panel-{$tab['id']}";
 							?>
 
@@ -816,11 +873,12 @@
 								echo $tab['content'];
 
 								// If it exists, fire tab callback.
-								if ( ! empty( $tab['callback'] ) )
+								if ( ! empty( $tab['callback'] ) ) {
 									call_user_func_array( $tab['callback'], array( $this, $tab ) );
+								}
 								?>
 							</div>
-						<?php
+							<?php
 							$classes = 'help-tab-content';
 						endforeach;
 						?>
@@ -844,43 +902,48 @@
 		 */
 		$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
 
-		if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
-			$this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
+		if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) {
+			$this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) );
+		}
 
 		if ( $this->get_option( 'layout_columns' ) ) {
-			$this->columns = (int) get_user_option("screen_layout_$this->id");
+			$this->columns = (int) get_user_option( "screen_layout_$this->id" );
 
-			if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )
+			if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) {
 				$this->columns = $this->get_option( 'layout_columns', 'default' );
+			}
 		}
-		$GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat.
+		$GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat.
 
 		// Add screen options
-		if ( $this->show_screen_options() )
+		if ( $this->show_screen_options() ) {
 			$this->render_screen_options();
+		}
 		?>
 		</div>
 		<?php
-		if ( ! $this->get_help_tabs() && ! $this->show_screen_options() )
+		if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) {
 			return;
+		}
 		?>
 		<div id="screen-meta-links">
-		<?php if ( $this->get_help_tabs() ) : ?>
+		<?php if ( $this->show_screen_options() ) : ?>
+			<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
+			<button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button>
+			</div>
+			<?php
+		endif;
+		if ( $this->get_help_tabs() ) :
+			?>
 			<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
 			<button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></button>
 			</div>
-		<?php endif;
-		if ( $this->show_screen_options() ) : ?>
-			<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
-			<button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button>
-			</div>
 		<?php endif; ?>
 		</div>
 		<?php
 	}
 
 	/**
-	 *
 	 * @global array $wp_meta_boxes
 	 *
 	 * @return bool
@@ -888,27 +951,21 @@
 	public function show_screen_options() {
 		global $wp_meta_boxes;
 
-		if ( is_bool( $this->_show_screen_options ) )
+		if ( is_bool( $this->_show_screen_options ) ) {
 			return $this->_show_screen_options;
+		}
 
 		$columns = get_column_headers( $this );
 
 		$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
 
-		switch ( $this->base ) {
-			case 'widgets':
-				$nonce = wp_create_nonce( 'widgets-access' );
-				$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on&_wpnonce=' . urlencode( $nonce ) . '">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off&_wpnonce=' . urlencode( $nonce ) . '">' . __('Disable accessibility mode') . "</a></p>\n";
-				break;
-			case 'post' :
-				$expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
-				$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
-				$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
-				$this->_screen_settings = $expand;
-				break;
-			default:
-				$this->_screen_settings = '';
-				break;
+		$this->_screen_settings = '';
+
+		if ( 'post' === $this->base ) {
+			$expand                 = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
+			$expand                .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
+			$expand                .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
+			$this->_screen_settings = $expand;
 		}
 
 		/**
@@ -924,8 +981,9 @@
 		 */
 		$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
 
-		if ( $this->_screen_settings || $this->_options )
+		if ( $this->_screen_settings || $this->_options ) {
 			$show_screen = true;
+		}
 
 		/**
 		 * Filters whether to show the Screen Options tab.
@@ -950,22 +1008,25 @@
 	 * }
 	 */
 	public function render_screen_options( $options = array() ) {
-		$options = wp_parse_args( $options, array(
-			'wrap' => true,
-		) );
+		$options = wp_parse_args(
+			$options,
+			array(
+				'wrap' => true,
+			)
+		);
 
 		$wrapper_start = $wrapper_end = $form_start = $form_end = '';
 
 		// Output optional wrapper.
 		if ( $options['wrap'] ) {
 			$wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">';
-			$wrapper_end = '</div>';
+			$wrapper_end   = '</div>';
 		}
 
 		// Don't output the form and nonce for the widgets accessibility mode links.
 		if ( 'widgets' !== $this->base ) {
 			$form_start = "\n<form id='adv-settings' method='post'>\n";
-			$form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
+			$form_end   = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
 		}
 
 		echo $wrapper_start . $form_start;
@@ -1014,41 +1075,20 @@
 		<?php
 			meta_box_prefs( $this );
 
-			if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
-				if ( isset( $_GET['welcome'] ) ) {
-					$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
-					update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
-				} else {
-					$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
-					if ( '' === $welcome_checked ) {
-						$welcome_checked = '1';
-					}
-					if ( '2' === $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
-						$welcome_checked = false;
-					}
+		if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
+			if ( isset( $_GET['welcome'] ) ) {
+				$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
+				update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
+			} else {
+				$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
+				if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
+					$welcome_checked = false;
 				}
-				echo '<label for="wp_welcome_panel-hide">';
-				echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
-				echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
 			}
-
-			if ( 'dashboard' === $this->id && has_action( 'try_gutenberg_panel' ) ) {
-				if ( isset( $_GET['try_gutenberg'] ) ) {
-					$try_gutenberg_checked = empty( $_GET['try_gutenberg'] ) ? 0 : 1;
-					update_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', $try_gutenberg_checked );
-				} else {
-					$try_gutenberg_checked = get_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', true );
-					if ( '' === $try_gutenberg_checked ) {
-						$try_gutenberg_checked = '1';
-					}
-					if ( '2' === $try_gutenberg_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
-						$try_gutenberg_checked = false;
-					}
-				}
-				echo '<label for="wp_try_gutenberg_panel-hide">';
-				echo '<input type="checkbox" id="wp_try_gutenberg_panel-hide"' . checked( (bool) $try_gutenberg_checked, true, false ) . ' />';
-				echo __( 'New Editor' ) . "</label>\n";
-			}
+			echo '<label for="wp_welcome_panel-hide">';
+			echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
+			echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
+		}
 		?>
 		</fieldset>
 		<?php
@@ -1113,20 +1153,22 @@
 		}
 
 		$screen_layout_columns = $this->get_columns();
-		$num = $this->get_option( 'layout_columns', 'max' );
+		$num                   = $this->get_option( 'layout_columns', 'max' );
 
 		?>
 		<fieldset class='columns-prefs'>
-		<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend><?php
-			for ( $i = 1; $i <= $num; ++$i ):
-				?>
-				<label class="columns-prefs-<?php echo $i; ?>">
-					<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
-						<?php checked( $screen_layout_columns, $i ); ?> />
-					<?php printf( _n( '%s column', '%s columns', $i ), number_format_i18n( $i ) ); ?>
+		<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend>
+												<?php
+												for ( $i = 1; $i <= $num; ++$i ) :
+													?>
+													<label class="columns-prefs-<?php echo $i; ?>">
+				<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
+													<?php checked( $screen_layout_columns, $i ); ?> />
+													<?php printf( _n( '%s column', '%s columns', $i ), number_format_i18n( $i ) ); ?>
 				</label>
-				<?php
-			endfor; ?>
+													<?php
+			endfor;
+												?>
 		</fieldset>
 		<?php
 	}
@@ -1210,15 +1252,20 @@
 			return;
 		}
 
-		$view_mode_post_types = get_post_types( array( 'hierarchical' => false, 'show_ui' => true ) );
+		$view_mode_post_types = get_post_types(
+			array(
+				'hierarchical' => false,
+				'show_ui'      => true,
+			)
+		);
 
 		/**
 		 * Filters the post types that have different view mode options.
 		 *
 		 * @since 4.4.0
 		 *
-		 * @param array $view_mode_post_types Array of post types that can change view modes.
-		 *                                    Default non-hierarchical post types with show_ui on.
+		 * @param string[] $view_mode_post_types Array of post types that can change view modes.
+		 *                                       Default non-hierarchical post types with show_ui on.
 		 */
 		$view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types );
 
@@ -1230,7 +1277,7 @@
 
 		// This needs a submit button
 		add_filter( 'screen_options_show_submit', '__return_true' );
-?>
+		?>
 		<fieldset class="metabox-prefs view-mode">
 		<legend><?php _e( 'View Mode' ); ?></legend>
 				<label for="list-view-mode">
@@ -1242,7 +1289,7 @@
 					<?php _e( 'Excerpt View' ); ?>
 				</label>
 		</fieldset>
-<?php
+		<?php
 	}
 
 	/**