Changeset 19051
- Timestamp:
- 10/24/2011 06:40:15 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/screen.php
r19050 r19051 12 12 * @since 2.7.0 13 13 * 14 * @param string| object$screen The screen you want the headers for14 * @param string|WP_Screen $screen The screen you want the headers for 15 15 * @return array Containing the headers in the format id => UI String 16 16 */ … … 32 32 * @since 2.7.0 33 33 * 34 * @param string| object$screen The screen you want the hidden columns for34 * @param string|WP_Screen $screen The screen you want the hidden columns for 35 35 * @return array 36 36 */ … … 43 43 44 44 /** 45 * {@internal Missing Short Description}}45 * Prints the meta box preferences for screen meta. 46 46 * 47 47 * @since 2.7.0 48 48 * 49 * @param unknown_type$screen49 * @param string|WP_Screen $screen 50 50 */ 51 51 function meta_box_prefs( $screen ) { 52 52 global $wp_meta_boxes; 53 53 54 if ( is_string( $screen) )55 $screen = convert_to_screen( $screen);54 if ( is_string( $screen ) ) 55 $screen = convert_to_screen( $screen ); 56 56 57 57 if ( empty($wp_meta_boxes[$screen->id]) ) … … 82 82 * @since 2.7.0 83 83 * 84 * @param string| object$screen Screen identifier84 * @param string|WP_Screen $screen Screen identifier 85 85 * @return array Hidden Meta Boxes 86 86 */ … … 113 113 * @since 3.0.0 114 114 * 115 * @param string $ screen The name of the screen115 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen. 116 116 * @return object An object containing the safe screen name and id 117 117 */ 118 function convert_to_screen( $ screen) {119 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $ screen);118 function convert_to_screen( $hook_suffix ) { 119 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $hook_suffix); 120 120 121 121 if ( is_network_admin() ) … … 145 145 $screen = convert_to_screen( $screen ); 146 146 147 WP_Screen::add_old_compat_help( $screen ->id, $help );147 WP_Screen::add_old_compat_help( $screen, $help ); 148 148 } 149 149 … … 166 166 } 167 167 168 /** 169 * Displays a screen icon. 170 * 171 * @uses get_screen_icon() 172 * @since 2.7.0 173 * 174 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) 175 * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. 176 */ 168 177 function screen_icon( $screen = '' ) { 169 178 echo get_screen_icon( $screen ); 170 179 } 171 180 181 /** 182 * Gets a screen icon. 183 * 184 * @since 3.2.0 185 * 186 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) 187 * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. 188 * @return string HTML for the screen icon. 189 */ 172 190 function get_screen_icon( $screen = '' ) { 173 global $current_screen, $typenow; 174 175 if ( empty($screen) ) 176 $screen = $current_screen; 177 elseif ( is_string($screen) ) 178 $name = $screen; 191 if ( empty( $screen ) ) 192 $screen = get_current_screen(); 193 elseif ( is_string( $screen ) ) 194 $icon_id = $screen; 179 195 180 196 $class = 'icon32'; 181 197 182 if ( empty( $name) ) {183 if ( ! empty($screen->parent_base) )184 $ name= $screen->parent_base;198 if ( empty( $icon_id ) ) { 199 if ( ! empty( $screen->parent_base ) ) 200 $icon_id = $screen->parent_base; 185 201 else 186 $name = $screen->base; 187 188 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type ) 189 $name = 'edit-pages'; 190 191 $post_type = ''; 192 if ( isset( $screen->post_type ) ) 193 $post_type = $screen->post_type; 194 elseif ( $current_screen == $screen ) 195 $post_type = $typenow; 196 if ( $post_type ) 197 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 198 } 199 200 return '<div id="icon-' . esc_attr( $name ) . '" class="' . $class . '"><br /></div>'; 201 } 202 203 /** 204 * Get the current screen object 205 * 206 * @since 3.1.0 202 $icon_id = $screen->base; 203 204 if ( ! empty( $screen->post_type ) && 'page' == $screen->post_type ) 205 $icon_id = 'edit-pages'; 206 207 if ( ! empty( $screen->post_type ) ) 208 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type ); 209 } 210 211 return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>'; 212 } 213 214 /** 215 * Get the current screen object 216 * 217 * @since 3.1.0 207 218 * 208 219 * @return object Current screen object … … 211 222 global $current_screen; 212 223 213 if ( ! isset($current_screen) )224 if ( ! isset( $current_screen ) ) 214 225 return null; 215 226 … … 221 232 * 222 233 * @since 3.0.0 223 *224 234 * @uses $current_screen 225 235 * 226 * @param string $ id Screen id, optional.227 */ 228 function set_current_screen( $ id= '' ) {236 * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. 237 */ 238 function set_current_screen( $hook_name = '' ) { 229 239 global $current_screen; 230 240 231 $current_screen = new WP_Screen( $ id);241 $current_screen = new WP_Screen( $hook_name ); 232 242 233 243 $current_screen = apply_filters('current_screen', $current_screen); … … 235 245 236 246 /** 237 * A class representing the currentadmin screen.247 * A class representing the admin screen. 238 248 * 239 249 * @since 3.3.0 … … 242 252 final class WP_Screen { 243 253 /** 244 * Any action associated with the screen. 254 * Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise. 245 255 * 246 256 * @since 3.3.0 … … 454 464 } 455 465 466 /** 467 * Sets the old string-based contextual help for the screen. 468 * 469 * For backwards compatibility. 470 * 471 * @since 3.3.0 472 * 473 * @param WP_Screen $screen A screen object. 474 * @param string $help Help text. 475 */ 456 476 static function add_old_compat_help( $screen, $help ) { 457 self::$_old_compat_help[ $screen ] = $help;477 self::$_old_compat_help[ $screen->id ] = $help; 458 478 } 459 479 … … 468 488 function set_parentage( $parent_file ) { 469 489 $this->parent_file = $parent_file; 470 $this->parent_base = preg_replace('/\?.*$/', '', $parent_file);471 $this->parent_base = str_replace( '.php', '', $this->parent_base);490 list( $this->parent_base ) = explode( '?', $parent_file ); 491 $this->parent_base = str_replace( '.php', '', $this->parent_base ); 472 492 } 473 493 … … 490 510 * @since 3.3.0 491 511 * 492 * @param string 512 * @param string 493 513 */ 494 514 public function get_option( $option, $key = false ) { … … 641 661 642 662 public function show_screen_options() { 643 global $wp_meta_boxes , $wp_list_table;663 global $wp_meta_boxes; 644 664 645 665 if ( is_bool( $this->_show_screen_options ) ) … … 648 668 $columns = get_column_headers( $this ); 649 669 650 $show_screen = false; 651 if ( ! empty( $wp_meta_boxes[ $this->id ] ) || ! empty( $columns ) ) 652 $show_screen = true; 653 654 // Check if there are per-page options. 655 $show_screen = $show_screen || $this->get_option('per_page'); 670 $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' ); 656 671 657 672 $this->_screen_settings = apply_filters( 'screen_settings', '', $this ); … … 660 675 case 'widgets': 661 676 $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; 662 $show_screen = true;663 677 break; 664 678 } 665 679 666 if ( ! empty( $this->_screen_settings ) ) 667 $show_screen = true; 668 669 if ( ! empty( self::$_options[ $this->id ] ) ) 680 if ( $this->_screen_settings || self::$_options[ $this->id ] ) 670 681 $show_screen = true; 671 682
Note: See TracChangeset
for help on using the changeset viewer.