wp/wp-admin/includes/class-wp-screen.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   375 			$screen = self::$_registry[ $id ];
   375 			$screen = self::$_registry[ $id ];
   376 			if ( get_current_screen() === $screen ) {
   376 			if ( get_current_screen() === $screen ) {
   377 				return $screen;
   377 				return $screen;
   378 			}
   378 			}
   379 		} else {
   379 		} else {
   380 			$screen     = new WP_Screen();
   380 			$screen     = new self();
   381 			$screen->id = $id;
   381 			$screen->id = $id;
   382 		}
   382 		}
   383 
   383 
   384 		$screen->base            = $base;
   384 		$screen->base            = $base;
   385 		$screen->action          = $action;
   385 		$screen->action          = $action;
   537 	/**
   537 	/**
   538 	 * Gets the arguments for an option for the screen.
   538 	 * Gets the arguments for an option for the screen.
   539 	 *
   539 	 *
   540 	 * @since 3.3.0
   540 	 * @since 3.3.0
   541 	 *
   541 	 *
   542 	 * @param string $option Option name.
   542 	 * @param string       $option Option name.
   543 	 * @param string $key    Optional. Specific array key for when the option is an array.
   543 	 * @param string|false $key    Optional. Specific array key for when the option is an array.
   544 	 *                       Default false.
   544 	 *                             Default false.
   545 	 * @return string The option value if set, null otherwise.
   545 	 * @return string The option value if set, null otherwise.
   546 	 */
   546 	 */
   547 	public function get_option( $option, $key = false ) {
   547 	public function get_option( $option, $key = false ) {
   548 		if ( ! isset( $this->_options[ $option ] ) ) {
   548 		if ( ! isset( $this->_options[ $option ] ) ) {
   549 			return null;
   549 			return null;
   792 		 * @since 2.7.0
   792 		 * @since 2.7.0
   793 		 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
   793 		 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
   794 		 *                   {@see get_current_screen()->remove_help_tab()} instead.
   794 		 *                   {@see get_current_screen()->remove_help_tab()} instead.
   795 		 *
   795 		 *
   796 		 * @param array     $old_compat_help Old contextual help.
   796 		 * @param array     $old_compat_help Old contextual help.
   797 		 * @param WP_Screen $this            Current WP_Screen instance.
   797 		 * @param WP_Screen $screen          Current WP_Screen instance.
   798 		 */
   798 		 */
   799 		self::$_old_compat_help = apply_filters_deprecated(
   799 		self::$_old_compat_help = apply_filters_deprecated(
   800 			'contextual_help_list',
   800 			'contextual_help_list',
   801 			array( self::$_old_compat_help, $this ),
   801 			array( self::$_old_compat_help, $this ),
   802 			'3.3.0',
   802 			'3.3.0',
   812 		 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
   812 		 * @deprecated 3.3.0 Use {@see get_current_screen()->add_help_tab()} or
   813 		 *                   {@see get_current_screen()->remove_help_tab()} instead.
   813 		 *                   {@see get_current_screen()->remove_help_tab()} instead.
   814 		 *
   814 		 *
   815 		 * @param string    $old_help  Help text that appears on the screen.
   815 		 * @param string    $old_help  Help text that appears on the screen.
   816 		 * @param string    $screen_id Screen ID.
   816 		 * @param string    $screen_id Screen ID.
   817 		 * @param WP_Screen $this      Current WP_Screen instance.
   817 		 * @param WP_Screen $screen    Current WP_Screen instance.
   818 		 */
   818 		 */
   819 		$old_help = apply_filters_deprecated(
   819 		$old_help = apply_filters_deprecated(
   820 			'contextual_help',
   820 			'contextual_help',
   821 			array( $old_help, $this->id, $this ),
   821 			array( $old_help, $this->id, $this ),
   822 			'3.3.0',
   822 			'3.3.0',
   933 		 *
   933 		 *
   934 		 * @since 2.8.0
   934 		 * @since 2.8.0
   935 		 *
   935 		 *
   936 		 * @param array     $empty_columns Empty array.
   936 		 * @param array     $empty_columns Empty array.
   937 		 * @param string    $screen_id     Screen ID.
   937 		 * @param string    $screen_id     Screen ID.
   938 		 * @param WP_Screen $this          Current WP_Screen instance.
   938 		 * @param WP_Screen $screen        Current WP_Screen instance.
   939 		 */
   939 		 */
   940 		$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
   940 		$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
   941 
   941 
   942 		if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) {
   942 		if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) {
   943 			$this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) );
   943 			$this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) );
  1085 		 *
  1085 		 *
  1086 		 * @since 4.4.0
  1086 		 * @since 4.4.0
  1087 		 *
  1087 		 *
  1088 		 * @param bool      $show_button Whether to show Screen Options submit button.
  1088 		 * @param bool      $show_button Whether to show Screen Options submit button.
  1089 		 *                               Default false.
  1089 		 *                               Default false.
  1090 		 * @param WP_Screen $this        Current WP_Screen instance.
  1090 		 * @param WP_Screen $screen      Current WP_Screen instance.
  1091 		 */
  1091 		 */
  1092 		$show_button = apply_filters( 'screen_options_show_submit', false, $this );
  1092 		$show_button = apply_filters( 'screen_options_show_submit', false, $this );
  1093 
  1093 
  1094 		if ( $show_button ) {
  1094 		if ( $show_button ) {
  1095 			submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
  1095 			submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
  1111 		if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) {
  1111 		if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) {
  1112 			return;
  1112 			return;
  1113 		}
  1113 		}
  1114 		?>
  1114 		?>
  1115 		<fieldset class="metabox-prefs">
  1115 		<fieldset class="metabox-prefs">
  1116 		<legend><?php _e( 'Boxes' ); ?></legend>
  1116 		<legend><?php _e( 'Screen elements' ); ?></legend>
       
  1117 		<p>
       
  1118 			<?php _e( 'Some screen elements can be shown or hidden by using the checkboxes.' ); ?>
       
  1119 			<?php _e( 'They can be expanded and collapsed by clickling on their headings, and arranged by dragging their headings or by clicking on the up and down arrows.' ); ?>
       
  1120 		</p>
  1117 		<?php
  1121 		<?php
  1118 			meta_box_prefs( $this );
  1122 
       
  1123 		meta_box_prefs( $this );
  1119 
  1124 
  1120 		if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
  1125 		if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
  1121 			if ( isset( $_GET['welcome'] ) ) {
  1126 			if ( isset( $_GET['welcome'] ) ) {
  1122 				$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
  1127 				$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
  1123 				update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
  1128 				update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );