diff --git a/wp-admin/includes/screen.php b/wp-admin/includes/screen.php index 39ba1f81bd..37cb8b8759 100644 --- a/wp-admin/includes/screen.php +++ b/wp-admin/includes/screen.php @@ -11,7 +11,7 @@ * * @since 2.7.0 * - * @param string|object $screen The screen you want the headers for + * @param string|WP_Screen $screen The screen you want the headers for * @return array Containing the headers in the format id => UI String */ function get_column_headers( $screen ) { @@ -31,7 +31,7 @@ function get_column_headers( $screen ) { * * @since 2.7.0 * - * @param string|object $screen The screen you want the hidden columns for + * @param string|WP_Screen $screen The screen you want the hidden columns for * @return array */ function get_hidden_columns( $screen ) { @@ -42,17 +42,17 @@ function get_hidden_columns( $screen ) { } /** - * {@internal Missing Short Description}} + * Prints the meta box preferences for screen meta. * * @since 2.7.0 * - * @param unknown_type $screen + * @param string|WP_Screen $screen */ function meta_box_prefs( $screen ) { global $wp_meta_boxes; - if ( is_string($screen) ) - $screen = convert_to_screen($screen); + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); if ( empty($wp_meta_boxes[$screen->id]) ) return; @@ -81,7 +81,7 @@ function meta_box_prefs( $screen ) { * * @since 2.7.0 * - * @param string|object $screen Screen identifier + * @param string|WP_Screen $screen Screen identifier * @return array Hidden Meta Boxes */ function get_hidden_meta_boxes( $screen ) { @@ -112,11 +112,11 @@ function get_hidden_meta_boxes( $screen ) { * * @since 3.0.0 * - * @param string $screen The name of the screen + * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen. * @return object An object containing the safe screen name and id */ -function convert_to_screen( $screen ) { - $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); +function convert_to_screen( $hook_suffix ) { + $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $hook_suffix); if ( is_network_admin() ) $screen .= '-network'; @@ -144,7 +144,7 @@ function add_contextual_help( $screen, $help ) { if ( is_string( $screen ) ) $screen = convert_to_screen( $screen ); - WP_Screen::add_old_compat_help( $screen->id, $help ); + WP_Screen::add_old_compat_help( $screen, $help ); } /** @@ -165,52 +165,63 @@ function add_screen_option( $option, $args = array() ) { return $current_screen->add_option( $option, $args ); } +/** + * Displays a screen icon. + * + * @uses get_screen_icon() + * @since 2.7.0 + * + * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) + * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. + */ function screen_icon( $screen = '' ) { echo get_screen_icon( $screen ); } +/** + * Gets a screen icon. + * + * @since 3.2.0 + * + * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) + * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. + * @return string HTML for the screen icon. + */ function get_screen_icon( $screen = '' ) { - global $current_screen, $typenow; - - if ( empty($screen) ) - $screen = $current_screen; - elseif ( is_string($screen) ) - $name = $screen; + if ( empty( $screen ) ) + $screen = get_current_screen(); + elseif ( is_string( $screen ) ) + $icon_id = $screen; $class = 'icon32'; - if ( empty($name) ) { - if ( !empty($screen->parent_base) ) - $name = $screen->parent_base; + if ( empty( $icon_id ) ) { + if ( ! empty( $screen->parent_base ) ) + $icon_id = $screen->parent_base; else - $name = $screen->base; + $icon_id = $screen->base; - if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type ) - $name = 'edit-pages'; + if ( ! empty( $screen->post_type ) && 'page' == $screen->post_type ) + $icon_id = 'edit-pages'; - $post_type = ''; - if ( isset( $screen->post_type ) ) - $post_type = $screen->post_type; - elseif ( $current_screen == $screen ) - $post_type = $typenow; - if ( $post_type ) - $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); + if ( ! empty( $screen->post_type ) ) + $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type ); } - return '
' . __('Enable accessibility mode') . '' . __('Disable accessibility mode') . "
\n"; - $show_screen = true; break; } - if ( ! empty( $this->_screen_settings ) ) - $show_screen = true; - - if ( ! empty( self::$_options[ $this->id ] ) ) + if ( $this->_screen_settings || self::$_options[ $this->id ] ) $show_screen = true; $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );