diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/screen.php --- a/wp/wp-admin/includes/screen.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/screen.php Tue Dec 15 13:49:49 2020 +0100 @@ -11,10 +11,8 @@ * * @since 2.7.0 * - * @staticvar array $column_headers - * * @param string|WP_Screen $screen The screen you want the headers for - * @return array Containing the headers in the format id => UI String + * @return string[] The column header labels keyed by column ID. */ function get_column_headers( $screen ) { if ( is_string( $screen ) ) { @@ -24,7 +22,6 @@ static $column_headers = array(); if ( ! isset( $column_headers[ $screen->id ] ) ) { - /** * Filters the column headers for a list table on a specific screen. * @@ -35,7 +32,7 @@ * * @since 3.0.0 * - * @param array $columns An array of column headers. Default empty. + * @param string[] $columns The column header labels keyed by column ID. */ $column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() ); } @@ -49,7 +46,7 @@ * @since 2.7.0 * * @param string|WP_Screen $screen The screen you want the hidden columns for - * @return array + * @return string[] Array of IDs of hidden columns. */ function get_hidden_columns( $screen ) { if ( is_string( $screen ) ) { @@ -68,7 +65,7 @@ * * @since 4.4.0 * - * @param array $hidden An array of columns hidden by default. + * @param string[] $hidden Array of IDs of columns hidden by default. * @param WP_Screen $screen WP_Screen object of the current screen. */ $hidden = apply_filters( 'default_hidden_columns', $hidden, $screen ); @@ -80,8 +77,8 @@ * @since 4.4.0 * @since 4.4.1 Added the `use_defaults` parameter. * - * @param array $hidden An array of hidden columns. - * @param WP_Screen $screen WP_Screen object of the current screen. + * @param string[] $hidden Array of IDs of hidden columns. + * @param WP_Screen $screen WP_Screen object of the current screen. * @param bool $use_defaults Whether to show the default columns. */ return apply_filters( 'hidden_columns', $hidden, $screen, $use_defaults ); @@ -118,8 +115,8 @@ if ( false == $box || ! $box['title'] ) { continue; } - // Submit box cannot be hidden - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) { + // Submit box cannot be hidden. + if ( 'submitdiv' === $box['id'] || 'linksubmitdiv' === $box['id'] ) { continue; } @@ -129,10 +126,12 @@ $widget_title = $box['args']['__widget_basename']; } + $is_hidden = in_array( $box['id'], $hidden, true ); + printf( '', esc_attr( $box['id'] ), - checked( in_array( $box['id'], $hidden ), false, false ), + checked( $is_hidden, false, false ), $widget_title ); } @@ -141,12 +140,12 @@ } /** - * Get Hidden Meta Boxes + * Gets an array of IDs of hidden meta boxes. * * @since 2.7.0 * * @param string|WP_Screen $screen Screen identifier - * @return array Hidden Meta Boxes + * @return string[] IDs of hidden meta boxes. */ function get_hidden_meta_boxes( $screen ) { if ( is_string( $screen ) ) { @@ -157,11 +156,11 @@ $use_defaults = ! is_array( $hidden ); - // Hide slug boxes by default + // Hide slug boxes by default. if ( $use_defaults ) { $hidden = array(); - if ( 'post' == $screen->base ) { - if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) { + if ( 'post' === $screen->base ) { + if ( in_array( $screen->post_type, array( 'post', 'page', 'attachment' ), true ) ) { $hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv' ); } else { $hidden = array( 'slugdiv' ); @@ -173,7 +172,7 @@ * * @since 3.1.0 * - * @param array $hidden An array of meta boxes hidden by default. + * @param string[] $hidden An array of IDs of meta boxes hidden by default. * @param WP_Screen $screen WP_Screen object of the current screen. */ $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); @@ -184,7 +183,7 @@ * * @since 3.3.0 * - * @param array $hidden An array of hidden meta boxes. + * @param string[] $hidden An array of IDs of hidden meta boxes. * @param WP_Screen $screen WP_Screen object of the current screen. * @param bool $use_defaults Whether to show the default meta boxes. * Default true. @@ -198,7 +197,7 @@ * @since 3.1.0 * * @param string $option An option name. - * @param mixed $args Option-dependent arguments. + * @param mixed $args Option-dependent arguments. */ function add_screen_option( $option, $args = array() ) { $current_screen = get_current_screen(); @@ -215,7 +214,7 @@ * * @since 3.1.0 * - * @global WP_Screen $current_screen + * @global WP_Screen $current_screen WordPress current screen object. * * @return WP_Screen|null Current screen object or null when screen not defined. */ @@ -234,8 +233,8 @@ * * @since 3.0.0 * - * @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, - * or an existing screen object. + * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, + * or an existing screen object. */ function set_current_screen( $hook_name = '' ) { WP_Screen::get( $hook_name )->set_current_screen();