Skip to content

Commit 893f17b

Browse files
committed
Docs: Improve docblocks and types for WP_Screen properties.
* Correctly hint that `WP_Screen::$_show_screen_options` is null before being instantiated. * Correctly hint that `::get_option()`, `get_help_tab()` and `get_screen_reader_text()` can return null. * Ensure `$this->columns` is an `int`, by casting `$this->get_option( 'layout_columns', 'default' )` from its numeric string. Developed in WordPress/wordpress-develop#8860 Props justlevine, peterwilsoncc, westonruter. See #64238, #64224. Built from https://develop.svn.wordpress.org/trunk@61300 git-svn-id: http://core.svn.wordpress.org/trunk@60612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 76ee0ab commit 893f17b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

wp-admin/includes/class-wp-screen.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ final class WP_Screen {
175175
/**
176176
* Stores the result of the public show_screen_options function.
177177
*
178+
* Set when calling {@see self::show_screen_options()} for the first time.
179+
*
178180
* @since 3.3.0
179-
* @var bool
181+
* @var ?bool
180182
*/
181183
private $_show_screen_options;
182184

@@ -545,7 +547,7 @@ public function get_options() {
545547
* @param string $option Option name.
546548
* @param string|false $key Optional. Specific array key for when the option is an array.
547549
* Default false.
548-
* @return string The option value if set, null otherwise.
550+
* @return ?string The option value if set, null otherwise.
549551
*/
550552
public function get_option( $option, $key = false ) {
551553
if ( ! isset( $this->_options[ $option ] ) ) {
@@ -598,7 +600,7 @@ public function get_help_tabs() {
598600
* @since 3.4.0
599601
*
600602
* @param string $id Help Tab ID.
601-
* @return array Help tab arguments.
603+
* @return ?array Help tab arguments, or null if no help tabs added.
602604
*/
603605
public function get_help_tab( $id ) {
604606
if ( ! isset( $this->_help_tabs[ $id ] ) ) {
@@ -733,7 +735,7 @@ public function get_screen_reader_content() {
733735
* @since 4.4.0
734736
*
735737
* @param string $key Screen reader text array named key.
736-
* @return string Screen reader text string.
738+
* @return ?string Screen reader text string, or null if no text is associated with the key.
737739
*/
738740
public function get_screen_reader_text( $key ) {
739741
if ( ! isset( $this->_screen_reader_content[ $key ] ) ) {
@@ -949,8 +951,9 @@ public function render_screen_meta() {
949951
if ( $this->get_option( 'layout_columns' ) ) {
950952
$this->columns = (int) get_user_option( "screen_layout_$this->id" );
951953

952-
if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) {
953-
$this->columns = $this->get_option( 'layout_columns', 'default' );
954+
$layout_columns = (int) $this->get_option( 'layout_columns', 'default' );
955+
if ( ! $this->columns && $layout_columns ) {
956+
$this->columns = $layout_columns;
954957
}
955958
}
956959
$GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat.

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-alpha-61299';
19+
$wp_version = '7.0-alpha-61300';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)