Ticket #18785: 18785.2.diff
File 18785.2.diff, 24.0 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/deprecated.php
805 805 $current_screen->render_screen_meta(); 806 806 } 807 807 808 /** 809 * Favorite actions were deprecated in version 3.2. Use the admin bar instead. 810 * 811 * @since 2.7.0 812 * @deprecated 3.2.0 813 */ 814 function favorite_actions() { 815 _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' ); 816 } 817 808 818 function media_upload_image() { 809 819 __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' ); 810 820 return wp_media_upload_handler(); -
wp-admin/includes/screen.php
11 11 * 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 */ 17 17 function get_column_headers( $screen ) { … … 31 31 * 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 */ 37 37 function get_hidden_columns( $screen ) { … … 42 42 } 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]) ) 58 58 return; … … 81 81 * 82 82 * @since 2.7.0 83 83 * 84 * @param string| object $screen Screen identifier84 * @param string|WP_Screen $screen Screen 85 85 * @return array Hidden Meta Boxes 86 86 */ 87 87 function get_hidden_meta_boxes( $screen ) { … … 90 90 91 91 $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); 92 92 93 $defaults = ! is_array( $hidden ); 94 93 95 // Hide slug boxes by default 94 if ( !is_array( $hidden )) {96 if ( $defaults ) { 95 97 if ( 'post' == $screen->base || 'page' == $screen->base ) 96 98 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); 97 99 else … … 99 101 $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); 100 102 } 101 103 102 return $hidden;104 return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $defaults ); 103 105 } 104 106 105 107 /** 106 * {@internal Missing Short Description}}107 *108 * @since 2.7.0109 */110 function favorite_actions( $screen = null ) {111 $default_action = false;112 113 if ( is_string($screen) )114 $screen = convert_to_screen($screen);115 116 if ( $screen->is_user )117 return;118 119 if ( isset($screen->post_type) ) {120 $post_type_object = get_post_type_object($screen->post_type);121 if ( 'add' != $screen->action )122 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));123 else124 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));125 }126 127 if ( !$default_action ) {128 if ( $screen->is_network ) {129 $default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));130 } else {131 switch ( $screen->id ) {132 case 'upload':133 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));134 break;135 case 'media':136 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));137 break;138 case 'link-manager':139 case 'link':140 if ( 'add' != $screen->action )141 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));142 else143 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));144 break;145 case 'users':146 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));147 break;148 case 'user':149 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));150 break;151 case 'plugins':152 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));153 break;154 case 'plugin-install':155 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));156 break;157 case 'themes':158 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));159 break;160 case 'theme-install':161 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));162 break;163 default:164 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));165 break;166 }167 }168 }169 170 if ( !$screen->is_network ) {171 $actions = array(172 'post-new.php' => array(__('New Post'), 'edit_posts'),173 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),174 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),175 'media-new.php' => array(__('Upload'), 'upload_files'),176 'edit-comments.php' => array(__('Comments'), 'moderate_comments')177 );178 } else {179 $actions = array(180 'sites.php' => array( __('Sites'), 'manage_sites'),181 'users.php' => array( __('Users'), 'manage_network_users')182 );183 }184 185 $default_key = array_keys($default_action);186 $default_key = $default_key[0];187 if ( isset($actions[$default_key]) )188 unset($actions[$default_key]);189 $actions = array_merge($default_action, $actions);190 $actions = apply_filters( 'favorite_actions', $actions, $screen );191 192 $allowed_actions = array();193 foreach ( $actions as $action => $data ) {194 if ( current_user_can($data[1]) )195 $allowed_actions[$action] = $data[0];196 }197 198 if ( empty($allowed_actions) )199 return;200 201 $first = array_keys($allowed_actions);202 $first = $first[0];203 echo '<div id="favorite-actions">';204 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';205 echo '<div id="favorite-inside">';206 207 array_shift($allowed_actions);208 209 foreach ( $allowed_actions as $action => $label) {210 echo "<div class='favorite-action'><a href='$action'>";211 echo $label;212 echo "</a></div>\n";213 }214 echo "</div></div>\n";215 }216 217 /**218 108 * Convert a screen string to a screen object 219 109 * 220 110 * @since 3.0.0 221 111 * 222 * @param string $ screen The name of the screen223 * @return object An object containing the safe screen name and id112 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen. 113 * @return WP_Screen Screen object. 224 114 */ 225 function convert_to_screen( $screen ) { 226 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); 227 228 if ( is_network_admin() ) 229 $screen .= '-network'; 230 elseif ( is_user_admin() ) 231 $screen .= '-user'; 232 233 $screen = (string) apply_filters( 'screen_meta_screen', $screen ); 234 $screen = (object) array( 'id' => $screen, 'base' => $screen ); 235 return $screen; 115 function convert_to_screen( $hook_name ) { 116 return WP_Screen::get( $hook_name ); 236 117 } 237 118 238 119 /** … … 251 132 if ( is_string( $screen ) ) 252 133 $screen = convert_to_screen( $screen ); 253 134 254 WP_Screen::add_old_compat_help( $screen ->id, $help );135 WP_Screen::add_old_compat_help( $screen, $help ); 255 136 } 256 137 257 138 /** … … 272 153 return $current_screen->add_option( $option, $args ); 273 154 } 274 155 156 /** 157 * Displays a screen icon. 158 * 159 * @uses get_screen_icon() 160 * @since 2.7.0 161 * 162 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) 163 * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. 164 */ 275 165 function screen_icon( $screen = '' ) { 276 166 echo get_screen_icon( $screen ); 277 167 } 278 168 169 /** 170 * Gets a screen icon. 171 * 172 * @since 3.2.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 * @return string HTML for the screen icon. 177 */ 279 178 function get_screen_icon( $screen = '' ) { 280 global $current_screen, $typenow; 179 if ( empty( $screen ) ) 180 $screen = get_current_screen(); 181 elseif ( is_string( $screen ) ) 182 $icon_id = $screen; 281 183 282 if ( empty($screen) )283 $screen = $current_screen;284 elseif ( is_string($screen) )285 $name = $screen;286 287 184 $class = 'icon32'; 288 185 289 if ( empty( $name) ) {290 if ( !empty($screen->parent_base))291 $ name= $screen->parent_base;186 if ( empty( $icon_id ) ) { 187 if ( $screen->parent_base ) 188 $icon_id = $screen->parent_base; 292 189 else 293 $ name= $screen->base;190 $icon_id = $screen->base; 294 191 295 if ( 'edit' == $ name && isset($screen->post_type)&& 'page' == $screen->post_type )296 $ name= 'edit-pages';192 if ( 'edit' == $icon_id && $screen->post_type && 'page' == $screen->post_type ) 193 $icon_id = 'edit-pages'; 297 194 298 $post_type = ''; 299 if ( isset( $screen->post_type ) ) 300 $post_type = $screen->post_type; 301 elseif ( $current_screen == $screen ) 302 $post_type = $typenow; 303 if ( $post_type ) 304 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 195 if ( $screen->post_type ) 196 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type ); 305 197 } 306 198 307 return '<div id="icon-' . esc_attr( $ name) . '" class="' . $class . '"><br /></div>';199 return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>'; 308 200 } 309 201 310 202 /** 311 * 203 * Get the current screen object 312 204 * 313 * 205 * @since 3.1.0 314 206 * 315 * @return objectCurrent screen object207 * @return WP_Screen Current screen object 316 208 */ 317 209 function get_current_screen() { 318 210 global $current_screen; 319 211 320 if ( ! isset($current_screen) )212 if ( ! isset( $current_screen ) ) 321 213 return null; 322 214 323 215 return $current_screen; … … 330 222 * 331 223 * @uses $current_screen 332 224 * 333 * @param string $id Screen id, optional. 225 * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, 226 * or an existing screen object. 334 227 */ 335 function set_current_screen( $id = '' ) { 336 global $current_screen; 337 338 $current_screen = new WP_Screen( $id ); 339 340 $current_screen = apply_filters('current_screen', $current_screen); 228 function set_current_screen( $hook_name = '' ) { 229 $screen = WP_Screen::get( $hook_name ); 230 $screen->set_current_screen(); 341 231 } 342 232 343 233 /** 344 * A class representing the currentadmin screen.234 * A class representing the admin screen. 345 235 * 346 236 * @since 3.3.0 347 237 * @access public 348 238 */ 349 239 final class WP_Screen { 350 240 /** 351 * Any action associated with the screen. 241 * Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise. 352 242 * 353 243 * @since 3.3.0 354 244 * @var string … … 440 330 * @var array 441 331 * @access private 442 332 */ 443 private static$_help_tabs = array();333 private $_help_tabs = array(); 444 334 445 335 /** 446 336 * The help sidebar data associated with screens, if any. … … 449 339 * @var string 450 340 * @access private 451 341 */ 452 private static $_help_sidebar = array();342 private $_help_sidebar = ''; 453 343 454 344 /** 455 345 * Stores old string-based help. … … 463 353 * @var array 464 354 * @access private 465 355 */ 466 private static$_options = array();356 private $_options = array(); 467 357 468 358 /** 359 * The screen object registry. 360 * 361 * @since 3.3.0 362 * @var array 363 * @access private 364 */ 365 private static $_registry = array(); 366 367 /** 469 368 * Stores the result of the public show_screen_options function. 470 369 * 471 370 * @since 3.3.0 … … 484 383 private $_screen_settings; 485 384 486 385 /** 487 * Constructor386 * Fetches a screen object. 488 387 * 489 388 * @since 3.3.0 389 * @access public 490 390 * 491 * @param string $id A screen id. If empty, the $hook_suffix global is used to derive the ID. 391 * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. 392 * Defaults to the current $hook_suffix global. 393 * @return WP_Screen Screen object. 492 394 */ 493 public function __construct( $id = '' ) { 494 global $hook_suffix, $typenow, $taxnow; 395 public function get( $hook_name = '' ) { 495 396 496 $action = ''; 397 if ( is_a( $hook_name, 'WP_Screen' ) ) 398 return $hook_name; 497 399 498 if ( empty( $id ) ) { 499 $screen = $hook_suffix; 500 $screen = str_replace('.php', '', $screen); 501 if ( preg_match('/-add|-new$/', $screen) ) 502 $action = 'add'; 503 $screen = str_replace('-new', '', $screen); 504 $screen = str_replace('-add', '', $screen); 505 $this->id = $this->base = $screen; 506 } else { 507 $id = sanitize_key( $id ); 508 if ( false !== strpos($id, '-') ) { 509 list( $id, $typenow ) = explode('-', $id, 2); 510 if ( taxonomy_exists( $typenow ) ) { 400 $action = $post_type = $taxonomy = ''; 401 402 if ( $hook_name ) { 403 if ( '-network' == substr( $hook_name, -8 ) ) 404 $hook_name = str_replace( '-network', '', $hook_name ); 405 elseif ( '-user' == substr( $hook_name, -5 ) ) 406 $hook_name = str_replace( '-user', '', $hook_name ); 407 $id = sanitize_key( $hook_name ); 408 if ( false !== strpos( $id, '-' ) ) { 409 list( $id, $second ) = explode( '-', $id, 2 ); 410 if ( taxonomy_exists( $second ) ) { 511 411 $id = 'edit-tags'; 512 $taxnow = $typenow; 513 $typenow = ''; 412 $taxonomy = $second; 413 } elseif ( post_type_exists( $second ) ) { 414 $post_type = $second; 415 } else { 416 $id .= '-' . $second; 514 417 } 515 418 } 516 $this->id = $this->base = $id; 419 } else { 420 $id = $GLOBALS['hook_suffix']; 421 $id = str_replace( '.php', '', $id ); 422 if ( in_array( substr( $id, -4 ), array( '-add', '-new' ) ) ) 423 $action = 'add'; 424 $id = str_replace( array( '-new', '-add' ), '', $id ); 517 425 } 518 426 519 $this->action = $action; 427 if ( 'index' == $id ) 428 $id = 'dashboard'; 520 429 521 // Map index to dashboard 522 if ( 'index' == $this->base ) 523 $this->base = 'dashboard'; 524 if ( 'index' == $this->id ) 525 $this->id = 'dashboard'; 430 $base = $id; 526 431 527 if ( 'edit' == $this->id ) { 528 if ( empty($typenow) ) 529 $typenow = 'post'; 530 $this->id .= '-' . $typenow; 531 $this->post_type = $typenow; 532 } elseif ( 'post' == $this->id ) { 533 if ( empty($typenow) ) 534 $typenow = 'post'; 535 $this->id = $typenow; 536 $this->post_type = $typenow; 537 } elseif ( 'edit-tags' == $this->id ) { 538 if ( empty($taxnow) ) 539 $taxnow = 'post_tag'; 540 $this->id = 'edit-' . $taxnow; 541 $this->taxonomy = $taxnow; 432 // If this is the current screen, see if we can be more accurate for post types and taxonomies. 433 if ( ! $hook_name ) { 434 switch ( $base ) { 435 case 'post' : 436 if ( isset( $_GET['post'] ) ) 437 $post_id = (int) $_GET['post']; 438 elseif ( isset( $_POST['post_ID'] ) ) 439 $post_id = (int) $_POST['post_ID']; 440 else 441 $post_id = 0; 442 443 if ( $post_id ) { 444 $post = get_post( $post_id ); 445 if ( $post ) 446 $post_type = $post->post_type; 447 } elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) ) { 448 $post_type = $_GET['post_type']; 449 } elseif ( $action == 'add' && isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) { 450 $post_type = $_GET['post_type']; 451 } 452 break; 453 case 'edit' : 454 if ( isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) 455 $post_type = $_GET['post_type']; 456 break; 457 case 'edit-tags' : 458 if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) 459 $taxonomy = $_REQUEST['taxonomy']; 460 break; 461 } 542 462 } 543 463 544 $this->is_network = is_network_admin(); 545 $this->is_user = is_user_admin(); 464 switch ( $id ) { 465 case 'post' : 466 if ( ! $post_type ) 467 $post_type = 'post'; 468 $id = $post_type; 469 break; 470 case 'edit' : 471 if ( ! $post_type ) 472 $post_type = 'post'; 473 $id .= '-' . $post_type; 474 break; 475 case 'edit-tags' : 476 if ( ! $taxonomy ) 477 $taxonomy = 'post_tag'; 478 $id = 'edit-' . $taxonomy; 479 break; 480 } 546 481 547 if ( $this->is_network) {548 $ this->base.= '-network';549 $ this->id.= '-network';550 } elseif ( $this->is_user) {551 $ this->base.= '-user';552 $ this->id.= '-user';482 if ( is_network_admin() ) { 483 $id .= '-network'; 484 $base .= '-network'; 485 } elseif ( is_user_admin() ) { 486 $id .= '-user'; 487 $base .= '-user'; 553 488 } 554 489 555 if ( ! isset( self::$_help_tabs[ $this->id ] ) ) 556 self::$_help_tabs[ $this->id ] = array(); 557 if ( ! isset( self::$_help_sidebar[ $this->id ] ) ) 558 self::$_help_sidebar[ $this->id ] = ''; 559 if ( ! isset( self::$_options[ $this->id ] ) ) 560 self::$_options[ $this->id ] = array(); 490 if ( isset( self::$_registry[ $id ] ) ) 491 return self::$_registry[ $id ]; 492 493 $screen = new WP_Screen(); 494 $screen->id = $id; 495 $screen->base = $base; 496 $screen->action = $action; 497 $screen->post_type = $post_type; 498 $screen->taxonomy = $taxonomy; 499 $screen->is_user = is_user_admin(); 500 $screen->is_network = is_network_admin(); 501 502 self::$_registry[ $id ] = $screen; 503 504 return $screen; 561 505 } 562 506 507 /** 508 * Makes the screen object the current screen. 509 * 510 * @see set_current_screen() 511 * @since 3.3.0 512 */ 513 function set_current_screen() { 514 global $current_screen, $taxnow, $typenow; 515 $current_screen = $this; 516 $taxnow = $this->taxonomy; 517 $typenow = $this->post_type; 518 $current_screen = apply_filters( 'current_screen', $current_screen ); 519 } 520 521 /** 522 * Constructor 523 * 524 * @since 3.3.0 525 * @access private 526 */ 527 private function __construct() {} 528 529 /** 530 * Sets the old string-based contextual help for the screen. 531 * 532 * For backwards compatibility. 533 * 534 * @since 3.3.0 535 * 536 * @param WP_Screen $screen A screen object. 537 * @param string $help Help text. 538 */ 563 539 static function add_old_compat_help( $screen, $help ) { 564 self::$_old_compat_help[ $screen ] = $help;540 self::$_old_compat_help[ $screen->id ] = $help; 565 541 } 566 542 567 543 /** … … 588 564 * @param mixed $args Option-dependent arguments. 589 565 */ 590 566 public function add_option( $option, $args = array() ) { 591 self::$_options[ $this->id ][ $option ] = $args;567 $this->_options[ $option ] = $args; 592 568 } 593 569 594 570 /** … … 599 575 * @param string 600 576 */ 601 577 public function get_option( $option, $key = false ) { 602 if ( ! isset( self::$_options[ $this->id ][ $option ] ) )578 if ( ! isset( $this->_options[ $option ] ) ) 603 579 return null; 604 580 if ( $key ) { 605 if ( isset( self::$_options[ $this->id ][ $option ][ $key ] ) )606 return self::$_options[ $this->id ][ $option ][ $key ];581 if ( isset( $this->_options[ $option ][ $key ] ) ) 582 return $this->_options[ $option ][ $key ]; 607 583 return null; 608 584 } 609 return self::$_options[ $this->id ][ $option ];585 return $this->_options[ $option ]; 610 586 } 611 587 612 588 /** … … 637 613 if ( ! $args['id'] || ! $args['title'] ) 638 614 return; 639 615 640 self::$_help_tabs[ $this->id ][] = $args;616 $this->_help_tabs[] = $args; 641 617 } 642 618 643 619 /** … … 649 625 * @param string $content Sidebar content in plain text or HTML. 650 626 */ 651 627 public function add_help_sidebar( $content ) { 652 self::$_help_sidebar[ $this->id ]= $content;628 $this->_help_sidebar = $content; 653 629 } 654 630 655 631 /** … … 664 640 // Call old contextual_help_list filter. 665 641 self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this ); 666 642 667 if ( isset( self::$_old_compat_help[ $this->id ] ) || empty( self::$_help_tabs[ $this->id ]) ) {643 if ( isset( self::$_old_compat_help[ $this->id ] ) || empty( $this->_help_tabs ) ) { 668 644 // Call old contextual_help filter. 669 645 if ( isset( self::$_old_compat_help[ $this->id ] ) ) 670 646 $contextual_help = apply_filters( 'contextual_help', self::$_old_compat_help[ $this->id ], $this->id, $this ); … … 690 666 'title' => __('Screen Options'), 691 667 'callback' => array( $this, 'render_screen_options' ), 692 668 ) ); 693 $_options_tab = array_pop( self::$_help_tabs[ $this->id ]);694 array_unshift( self::$_help_tabs[ $this->id ], $_options_tab );669 $_options_tab = array_pop( $this->_help_tabs ); 670 array_unshift( $this->_help_tabs, $_options_tab ); 695 671 } 696 672 697 673 // Time to render! … … 701 677 <div id="contextual-help-wrap" class="hidden"> 702 678 <div class="contextual-help-tabs"> 703 679 <ul> 704 <?php foreach ( self::$_help_tabs[ $this->id ]as $i => $tab ):680 <?php foreach ( $this->_help_tabs as $i => $tab ): 705 681 $link_id = "tab-link-{$tab['id']}"; 706 682 $panel_id = "tab-panel-{$tab['id']}"; 707 683 $classes = ( $i == 0 ) ? 'active' : ''; … … 716 692 </ul> 717 693 </div> 718 694 719 <?php if ( ! empty( self::$_help_sidebar[ $this->id ]) ) : ?>695 <?php if ( ! empty( $this->_help_sidebar ) ) : ?> 720 696 <div class="contextual-help-sidebar"> 721 <?php echo self::$_help_sidebar[ $this->id ]; ?>697 <?php echo $this->_help_sidebar; ?> 722 698 </div> 723 699 <?php endif; ?> 724 700 725 701 <div class="contextual-help-tabs-wrap"> 726 <?php foreach ( self::$_help_tabs[ $this->id ]as $i => $tab ):702 <?php foreach ( $this->_help_tabs as $i => $tab ): 727 703 $panel_id = "tab-panel-{$tab['id']}"; 728 704 $classes = ( $i == 0 ) ? 'active' : ''; 729 705 $classes .= ' help-tab-content'; … … 747 723 } 748 724 749 725 public function show_screen_options() { 750 global $wp_meta_boxes , $wp_list_table;726 global $wp_meta_boxes; 751 727 752 728 if ( is_bool( $this->_show_screen_options ) ) 753 729 return $this->_show_screen_options; … … 759 735 $show_screen = true; 760 736 761 737 // Check if there are per-page options. 762 $show_screen = $show_screen || $this->get_option('per_page'); 738 if ( $this->get_option( 'per_page' ) ) 739 $show_screen = true; 763 740 764 741 $this->_screen_settings = apply_filters( 'screen_settings', '', $this ); 765 742 766 743 switch ( $this->id ) { 767 744 case 'widgets': 768 745 $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"; 769 $show_screen = true;770 746 break; 771 747 } 772 748 773 if ( ! empty( $this->_screen_settings ))749 if ( $this->_screen_settings || $this->_options ) 774 750 $show_screen = true; 775 751 776 if ( ! empty( self::$_options[ $this->id ] ) )777 $show_screen = true;778 779 752 $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); 780 753 return $this->_show_screen_options; 781 754 } … … 786 759 * @since 3.3.0 787 760 */ 788 761 public function render_screen_options() { 789 global $wp_meta_boxes , $wp_list_table;762 global $wp_meta_boxes; 790 763 791 764 $columns = get_column_headers( $this ); 792 765 $hidden = get_hidden_columns( $this ); -
wp-admin/post.php
16 16 17 17 wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); 18 18 19 if ( isset( $_GET['post']) )19 if ( isset( $_GET['post'] ) ) 20 20 $post_id = (int) $_GET['post']; 21 elseif ( isset( $_POST['post_ID']) )21 elseif ( isset( $_POST['post_ID'] ) ) 22 22 $post_id = (int) $_POST['post_ID']; 23 23 else 24 24 $post_id = 0; 25 25 26 $post_ID = $post_id; 26 $post = null; 27 $post_type_object = null; 28 $post_type = null; 29 if ( $post_id ) { 30 $post = get_post($post_id); 31 if ( $post ) { 32 $post_type_object = get_post_type_object($post->post_type); 33 if ( $post_type_object ) { 34 $post_type = $post->post_type; 35 $current_screen->post_type = $post->post_type; 36 $current_screen->id = $current_screen->post_type; 37 } 38 } 39 } elseif ( isset($_POST['post_type']) ) { 40 $post_type_object = get_post_type_object($_POST['post_type']); 41 if ( $post_type_object ) { 42 $post_type = $post_type_object->name; 43 $current_screen->post_type = $post_type; 44 $current_screen->id = $current_screen->post_type; 45 } 27 $post = $post_type = $post_type_object = null; 28 29 if ( $post_id ) 30 $post = get_post( $post_id ); 31 32 if ( $post ) { 33 $post_type = $post->post_type; 34 $post_type_object = get_post_type_object( $post_type ); 46 35 } 47 36 48 37 /**