Ticket #18785: 18785.5.diff
| File 18785.5.diff, 24.0 KB (added by , 14 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; … … 108 108 } 109 109 110 110 /** 111 * {@internal Missing Short Description}}112 *113 * @since 2.7.0114 */115 function favorite_actions( $screen = null ) {116 $default_action = false;117 118 if ( is_string($screen) )119 $screen = convert_to_screen($screen);120 121 if ( $screen->is_user )122 return;123 124 if ( isset($screen->post_type) ) {125 $post_type_object = get_post_type_object($screen->post_type);126 if ( 'add' != $screen->action )127 $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));128 else129 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));130 }131 132 if ( !$default_action ) {133 if ( $screen->is_network ) {134 $default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));135 } else {136 switch ( $screen->id ) {137 case 'upload':138 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));139 break;140 case 'media':141 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));142 break;143 case 'link-manager':144 case 'link':145 if ( 'add' != $screen->action )146 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));147 else148 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));149 break;150 case 'users':151 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));152 break;153 case 'user':154 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));155 break;156 case 'plugins':157 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));158 break;159 case 'plugin-install':160 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));161 break;162 case 'themes':163 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));164 break;165 case 'theme-install':166 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));167 break;168 default:169 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));170 break;171 }172 }173 }174 175 if ( !$screen->is_network ) {176 $actions = array(177 'post-new.php' => array(__('New Post'), 'edit_posts'),178 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),179 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),180 'media-new.php' => array(__('Upload'), 'upload_files'),181 'edit-comments.php' => array(__('Comments'), 'moderate_comments')182 );183 } else {184 $actions = array(185 'sites.php' => array( __('Sites'), 'manage_sites'),186 'users.php' => array( __('Users'), 'manage_network_users')187 );188 }189 190 $default_key = array_keys($default_action);191 $default_key = $default_key[0];192 if ( isset($actions[$default_key]) )193 unset($actions[$default_key]);194 $actions = array_merge($default_action, $actions);195 $actions = apply_filters( 'favorite_actions', $actions, $screen );196 197 $allowed_actions = array();198 foreach ( $actions as $action => $data ) {199 if ( current_user_can($data[1]) )200 $allowed_actions[$action] = $data[0];201 }202 203 if ( empty($allowed_actions) )204 return;205 206 $first = array_keys($allowed_actions);207 $first = $first[0];208 echo '<div id="favorite-actions">';209 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';210 echo '<div id="favorite-inside">';211 212 array_shift($allowed_actions);213 214 foreach ( $allowed_actions as $action => $label) {215 echo "<div class='favorite-action'><a href='$action'>";216 echo $label;217 echo "</a></div>\n";218 }219 echo "</div></div>\n";220 }221 222 /**223 111 * Convert a screen string to a screen object 224 112 * 225 113 * @since 3.0.0 226 114 * 227 * @param string $ screen The name of the screen228 * @return object An object containing the safe screen name and id115 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen. 116 * @return WP_Screen Screen object. 229 117 */ 230 function convert_to_screen( $screen ) { 231 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); 232 233 if ( is_network_admin() ) 234 $screen .= '-network'; 235 elseif ( is_user_admin() ) 236 $screen .= '-user'; 237 238 $screen = (string) apply_filters( 'screen_meta_screen', $screen ); 239 $screen = (object) array( 'id' => $screen, 'base' => $screen ); 240 return $screen; 118 function convert_to_screen( $hook_name ) { 119 return WP_Screen::get( $hook_name ); 241 120 } 242 121 243 122 /** … … 256 135 if ( is_string( $screen ) ) 257 136 $screen = convert_to_screen( $screen ); 258 137 259 WP_Screen::add_old_compat_help( $screen ->id, $help );138 WP_Screen::add_old_compat_help( $screen, $help ); 260 139 } 261 140 262 141 /** … … 277 156 return $current_screen->add_option( $option, $args ); 278 157 } 279 158 159 /** 160 * Displays a screen icon. 161 * 162 * @uses get_screen_icon() 163 * @since 2.7.0 164 * 165 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) 166 * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. 167 */ 280 168 function screen_icon( $screen = '' ) { 281 169 echo get_screen_icon( $screen ); 282 170 } 283 171 172 /** 173 * Gets a screen icon. 174 * 175 * @since 3.2.0 176 * 177 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object) 178 * which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID. 179 * @return string HTML for the screen icon. 180 */ 284 181 function get_screen_icon( $screen = '' ) { 285 global $current_screen, $typenow; 182 if ( empty( $screen ) ) 183 $screen = get_current_screen(); 184 elseif ( is_string( $screen ) ) 185 $icon_id = $screen; 286 186 287 if ( empty($screen) )288 $screen = $current_screen;289 elseif ( is_string($screen) )290 $name = $screen;291 292 187 $class = 'icon32'; 293 188 294 if ( empty( $name) ) {295 if ( !empty($screen->parent_base))296 $ name= $screen->parent_base;189 if ( empty( $icon_id ) ) { 190 if ( $screen->parent_base ) 191 $icon_id = $screen->parent_base; 297 192 else 298 $ name= $screen->base;193 $icon_id = $screen->base; 299 194 300 if ( ' edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type )301 $ name= 'edit-pages';195 if ( 'page' == $screen->post_type ) 196 $icon_id = 'edit-pages'; 302 197 303 $post_type = ''; 304 if ( isset( $screen->post_type ) ) 305 $post_type = $screen->post_type; 306 elseif ( $current_screen == $screen ) 307 $post_type = $typenow; 308 if ( $post_type ) 309 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 198 if ( $screen->post_type ) 199 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type ); 310 200 } 311 201 312 return '<div id="icon-' . esc_attr( $ name) . '" class="' . $class . '"><br /></div>';202 return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>'; 313 203 } 314 204 315 205 /** 316 * Get the current screen object206 * Get the current screen object 317 207 * 318 * @since 3.1.0208 * @since 3.1.0 319 209 * 320 * @return objectCurrent screen object210 * @return WP_Screen Current screen object 321 211 */ 322 212 function get_current_screen() { 323 213 global $current_screen; 324 214 325 if ( ! isset($current_screen) )215 if ( ! isset( $current_screen ) ) 326 216 return null; 327 217 328 218 return $current_screen; … … 335 225 * 336 226 * @uses $current_screen 337 227 * 338 * @param string $id Screen id, optional. 228 * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, 229 * or an existing screen object. 339 230 */ 340 function set_current_screen( $id = '' ) { 341 global $current_screen; 342 343 $current_screen = new WP_Screen( $id ); 344 345 $current_screen = apply_filters('current_screen', $current_screen); 231 function set_current_screen( $hook_name = '' ) { 232 WP_Screen::get( $hook_name )->set_current_screen(); 346 233 } 347 234 348 235 /** 349 * A class representing the currentadmin screen.236 * A class representing the admin screen. 350 237 * 351 238 * @since 3.3.0 352 239 * @access public 353 240 */ 354 241 final class WP_Screen { 355 242 /** 356 * Any action associated with the screen. 'add' for *-add.php and *-new.php screens.Empty otherwise.243 * Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise. 357 244 * 358 245 * @since 3.3.0 359 246 * @var string … … 422 309 /** 423 310 * The post type associated with the screen, if any. 424 311 * The 'edit.php?post_type=page' screen has a post type of 'page'. 312 * The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'. 425 313 * 426 314 * @since 3.3.0 427 315 * @var string … … 445 333 * @var array 446 334 * @access private 447 335 */ 448 private static$_help_tabs = array();449 336 private $_help_tabs = array(); 337 450 338 /** 451 339 * The help sidebar data associated with screens, if any. 452 340 * … … 454 342 * @var string 455 343 * @access private 456 344 */ 457 private static $_help_sidebar = array();345 private $_help_sidebar = ''; 458 346 459 347 /** 460 348 * Stores old string-based help. … … 468 356 * @var array 469 357 * @access private 470 358 */ 471 private static$_options = array();359 private $_options = array(); 472 360 473 361 /** 362 * The screen object registry. 363 * 364 * @since 3.3.0 365 * @var array 366 * @access private 367 */ 368 private static $_registry = array(); 369 370 /** 474 371 * Stores the result of the public show_screen_options function. 475 372 * 476 373 * @since 3.3.0 … … 489 386 private $_screen_settings; 490 387 491 388 /** 492 * Constructor389 * Fetches a screen object. 493 390 * 494 391 * @since 3.3.0 392 * @access public 495 393 * 496 * @param string $id A screen id. If empty, the $hook_suffix global is used to derive the ID. 394 * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. 395 * Defaults to the current $hook_suffix global. 396 * @return WP_Screen Screen object. 497 397 */ 498 public function __construct( $id = '' ) { 499 global $hook_suffix, $typenow, $taxnow; 398 public function get( $hook_name = '' ) { 500 399 501 $action = ''; 400 if ( is_a( $hook_name, 'WP_Screen' ) ) 401 return $hook_name; 502 402 503 if ( empty( $id ) ) { 504 $screen = $hook_suffix; 505 $screen = str_replace('.php', '', $screen); 506 if ( preg_match('/-add|-new$/', $screen) ) 507 $action = 'add'; 508 $screen = str_replace('-new', '', $screen); 509 $screen = str_replace('-add', '', $screen); 510 $this->id = $this->base = $screen; 511 } else { 512 $id = sanitize_key( $id ); 513 if ( false !== strpos($id, '-') ) { 514 list( $id, $typenow ) = explode('-', $id, 2); 515 if ( taxonomy_exists( $typenow ) ) { 403 $action = $post_type = $taxonomy = ''; 404 405 if ( $hook_name ) { 406 if ( '-network' == substr( $hook_name, -8 ) ) 407 $hook_name = str_replace( '-network', '', $hook_name ); 408 elseif ( '-user' == substr( $hook_name, -5 ) ) 409 $hook_name = str_replace( '-user', '', $hook_name ); 410 $id = sanitize_key( $hook_name ); 411 if ( false !== strpos( $id, '-' ) ) { 412 list( $id, $second ) = explode( '-', $id, 2 ); 413 if ( taxonomy_exists( $second ) ) { 516 414 $id = 'edit-tags'; 517 $taxnow = $typenow; 518 $typenow = ''; 415 $taxonomy = $second; 416 } elseif ( post_type_exists( $second ) ) { 417 $post_type = $second; 418 } else { 419 $id .= '-' . $second; 519 420 } 520 421 } 521 $this->id = $this->base = $id; 422 } else { 423 $id = $GLOBALS['hook_suffix']; 424 $id = str_replace( '.php', '', $id ); 425 if ( in_array( substr( $id, -4 ), array( '-add', '-new' ) ) ) 426 $action = 'add'; 427 $id = str_replace( array( '-new', '-add' ), '', $id ); 522 428 } 523 429 524 $this->action = $action; 430 if ( 'index' == $id ) 431 $id = 'dashboard'; 525 432 526 // Map index to dashboard 527 if ( 'index' == $this->base ) 528 $this->base = 'dashboard'; 529 if ( 'index' == $this->id ) 530 $this->id = 'dashboard'; 433 $base = $id; 531 434 532 if ( 'edit' == $this->id ) { 533 if ( empty($typenow) ) 534 $typenow = 'post'; 535 $this->id .= '-' . $typenow; 536 $this->post_type = $typenow; 537 } elseif ( 'post' == $this->id ) { 538 if ( empty($typenow) ) 539 $typenow = 'post'; 540 $this->id = $typenow; 541 $this->post_type = $typenow; 542 } elseif ( 'edit-tags' == $this->id ) { 543 if ( empty($taxnow) ) 544 $taxnow = 'post_tag'; 545 $this->id = 'edit-' . $taxnow; 546 $this->taxonomy = $taxnow; 435 // If this is the current screen, see if we can be more accurate for post types and taxonomies. 436 if ( ! $hook_name ) { 437 switch ( $base ) { 438 case 'post' : 439 if ( isset( $_GET['post'] ) ) 440 $post_id = (int) $_GET['post']; 441 elseif ( isset( $_POST['post_ID'] ) ) 442 $post_id = (int) $_POST['post_ID']; 443 else 444 $post_id = 0; 445 446 if ( $post_id ) { 447 $post = get_post( $post_id ); 448 if ( $post ) 449 $post_type = $post->post_type; 450 } elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) ) { 451 $post_type = $_GET['post_type']; 452 } elseif ( $action == 'add' && isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) { 453 $post_type = $_GET['post_type']; 454 } 455 break; 456 case 'edit' : 457 if ( isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) 458 $post_type = $_GET['post_type']; 459 break; 460 case 'edit-tags' : 461 if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) 462 $taxonomy = $_REQUEST['taxonomy']; 463 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) 464 $post_type = $_REQUEST['post_type']; 465 else 466 $post_type = 'post'; 467 break; 468 } 547 469 } 548 470 549 $this->is_network = is_network_admin(); 550 $this->is_user = is_user_admin(); 471 switch ( $base ) { 472 case 'post' : 473 if ( ! $post_type ) 474 $post_type = 'post'; 475 $id = $post_type; 476 break; 477 case 'edit' : 478 if ( ! $post_type ) 479 $post_type = 'post'; 480 $id .= '-' . $post_type; 481 break; 482 case 'edit-tags' : 483 if ( ! $taxonomy ) 484 $taxonomy = 'post_tag'; 485 $id = 'edit-' . $taxonomy; 486 break; 487 } 551 488 552 if ( $this->is_network) {553 $ this->base.= '-network';554 $ this->id.= '-network';555 } elseif ( $this->is_user) {556 $ this->base.= '-user';557 $ this->id.= '-user';489 if ( is_network_admin() ) { 490 $id .= '-network'; 491 $base .= '-network'; 492 } elseif ( is_user_admin() ) { 493 $id .= '-user'; 494 $base .= '-user'; 558 495 } 559 496 560 if ( ! isset( self::$_help_tabs[ $this->id ] ) ) 561 self::$_help_tabs[ $this->id ] = array(); 562 if ( ! isset( self::$_help_sidebar[ $this->id ] ) ) 563 self::$_help_sidebar[ $this->id ] = ''; 564 if ( ! isset( self::$_options[ $this->id ] ) ) 565 self::$_options[ $this->id ] = array(); 497 if ( isset( self::$_registry[ $id ] ) ) 498 return self::$_registry[ $id ]; 499 500 $screen = new WP_Screen(); 501 $screen->id = $id; 502 $screen->base = $base; 503 $screen->action = $action; 504 $screen->post_type = $post_type; 505 $screen->taxonomy = $taxonomy; 506 $screen->is_user = is_user_admin(); 507 $screen->is_network = is_network_admin(); 508 509 self::$_registry[ $id ] = $screen; 510 511 return $screen; 566 512 } 567 513 514 /** 515 * Makes the screen object the current screen. 516 * 517 * @see set_current_screen() 518 * @since 3.3.0 519 */ 520 function set_current_screen() { 521 global $current_screen, $taxnow, $typenow; 522 $current_screen = $this; 523 $taxnow = $this->taxonomy; 524 $typenow = $this->post_type; 525 $current_screen = apply_filters( 'current_screen', $current_screen ); 526 } 527 528 /** 529 * Constructor 530 * 531 * @since 3.3.0 532 * @access private 533 */ 534 private function __construct() {} 535 536 /** 537 * Sets the old string-based contextual help for the screen. 538 * 539 * For backwards compatibility. 540 * 541 * @since 3.3.0 542 * 543 * @param WP_Screen $screen A screen object. 544 * @param string $help Help text. 545 */ 568 546 static function add_old_compat_help( $screen, $help ) { 569 self::$_old_compat_help[ $screen ] = $help;547 self::$_old_compat_help[ $screen->id ] = $help; 570 548 } 571 549 572 550 /** … … 579 557 */ 580 558 function set_parentage( $parent_file ) { 581 559 $this->parent_file = $parent_file; 582 $this->parent_base = preg_replace('/\?.*$/', '', $parent_file);560 list( $this->parent_base ) = explode( '?', $parent_file ); 583 561 $this->parent_base = str_replace('.php', '', $this->parent_base); 584 562 } 585 563 … … 593 571 * @param mixed $args Option-dependent arguments. 594 572 */ 595 573 public function add_option( $option, $args = array() ) { 596 self::$_options[ $this->id ][ $option ] = $args;574 $this->_options[ $option ] = $args; 597 575 } 598 576 599 577 /** … … 601 579 * 602 580 * @since 3.3.0 603 581 * 604 * @param string 582 * @param string 605 583 */ 606 584 public function get_option( $option, $key = false ) { 607 if ( ! isset( self::$_options[ $this->id ][ $option ] ) )585 if ( ! isset( $this->_options[ $option ] ) ) 608 586 return null; 609 587 if ( $key ) { 610 if ( isset( self::$_options[ $this->id ][ $option ][ $key ] ) )611 return self::$_options[ $this->id ][ $option ][ $key ];588 if ( isset( $this->_options[ $option ][ $key ] ) ) 589 return $this->_options[ $option ][ $key ]; 612 590 return null; 613 591 } 614 return self::$_options[ $this->id ][ $option ];592 return $this->_options[ $option ]; 615 593 } 616 594 617 595 /** … … 642 620 if ( ! $args['id'] || ! $args['title'] ) 643 621 return; 644 622 645 self::$_help_tabs[ $this->id ][] = $args;623 $this->_help_tabs[] = $args; 646 624 } 647 625 648 626 /** … … 654 632 * @param string $content Sidebar content in plain text or HTML. 655 633 */ 656 634 public function add_help_sidebar( $content ) { 657 self::$_help_sidebar[ $this->id ]= $content;635 $this->_help_sidebar = $content; 658 636 } 659 637 660 638 /** … … 669 647 // Call old contextual_help_list filter. 670 648 self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this ); 671 649 672 if ( isset( self::$_old_compat_help[ $this->id ] ) || empty( self::$_help_tabs[ $this->id ]) ) {650 if ( isset( self::$_old_compat_help[ $this->id ] ) || empty( $this->_help_tabs ) ) { 673 651 // Call old contextual_help filter. 674 652 if ( isset( self::$_old_compat_help[ $this->id ] ) ) 675 653 $contextual_help = apply_filters( 'contextual_help', self::$_old_compat_help[ $this->id ], $this->id, $this ); … … 695 673 'title' => __('Screen Options'), 696 674 'callback' => array( $this, 'render_screen_options' ), 697 675 ) ); 698 $_options_tab = array_pop( self::$_help_tabs[ $this->id ]);699 array_unshift( self::$_help_tabs[ $this->id ], $_options_tab );676 $_options_tab = array_pop( $this->_help_tabs ); 677 array_unshift( $this->_help_tabs, $_options_tab ); 700 678 } 701 679 702 680 // Time to render! … … 706 684 <div id="contextual-help-wrap" class="hidden"> 707 685 <div class="contextual-help-tabs"> 708 686 <ul> 709 <?php foreach ( self::$_help_tabs[ $this->id ]as $i => $tab ):687 <?php foreach ( $this->_help_tabs as $i => $tab ): 710 688 $link_id = "tab-link-{$tab['id']}"; 711 689 $panel_id = "tab-panel-{$tab['id']}"; 712 690 $classes = ( $i == 0 ) ? 'active' : ''; … … 721 699 </ul> 722 700 </div> 723 701 724 <?php if ( ! empty( self::$_help_sidebar[ $this->id ]) ) : ?>702 <?php if ( ! empty( $this->_help_sidebar ) ) : ?> 725 703 <div class="contextual-help-sidebar"> 726 <?php echo self::$_help_sidebar[ $this->id ]; ?>704 <?php echo $this->_help_sidebar; ?> 727 705 </div> 728 706 <?php endif; ?> 729 707 730 708 <div class="contextual-help-tabs-wrap"> 731 <?php foreach ( self::$_help_tabs[ $this->id ]as $i => $tab ):709 <?php foreach ( $this->_help_tabs as $i => $tab ): 732 710 $panel_id = "tab-panel-{$tab['id']}"; 733 711 $classes = ( $i == 0 ) ? 'active' : ''; 734 712 $classes .= ' help-tab-content'; … … 752 730 } 753 731 754 732 public function show_screen_options() { 755 global $wp_meta_boxes , $wp_list_table;733 global $wp_meta_boxes; 756 734 757 735 if ( is_bool( $this->_show_screen_options ) ) 758 736 return $this->_show_screen_options; … … 764 742 $show_screen = true; 765 743 766 744 // Check if there are per-page options. 767 $show_screen = $show_screen || $this->get_option('per_page'); 745 if ( $this->get_option( 'per_page' ) ) 746 $show_screen = true; 768 747 769 748 $this->_screen_settings = apply_filters( 'screen_settings', '', $this ); 770 749 771 750 switch ( $this->id ) { 772 751 case 'widgets': 773 752 $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"; 774 $show_screen = true;775 753 break; 776 754 } 777 755 778 if ( ! empty( $this->_screen_settings ))756 if ( $this->_screen_settings || $this->_options ) 779 757 $show_screen = true; 780 758 781 if ( ! empty( self::$_options[ $this->id ] ) )782 $show_screen = true;783 784 759 $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); 785 760 return $this->_show_screen_options; 786 761 } … … 791 766 * @since 3.3.0 792 767 */ 793 768 public function render_screen_options() { 794 global $wp_meta_boxes , $wp_list_table;769 global $wp_meta_boxes; 795 770 796 771 $columns = get_column_headers( $this ); 797 772 $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 /**