Ticket #18785: 18785.diff
File 18785.diff, 9.8 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/screen.php
18 18 if ( is_string( $screen ) ) 19 19 $screen = convert_to_screen( $screen ); 20 20 21 global $_wp_column_headers;21 static $column_headers = array(); 22 22 23 if ( !isset( $_wp_column_headers[ $screen->id ] ) ) { 24 $_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 25 } 23 if ( ! isset( $column_headers[ $screen->id ] ) ) 24 $column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 26 25 27 return $ _wp_column_headers[ $screen->id ];26 return $column_headers[ $screen->id ]; 28 27 } 29 28 30 29 /** … … 49 48 * 50 49 * @param unknown_type $screen 51 50 */ 52 function meta_box_prefs( $screen) {51 function meta_box_prefs( $screen ) { 53 52 global $wp_meta_boxes; 54 53 55 54 if ( is_string($screen) ) … … 232 231 $screen .= '-user'; 233 232 234 233 $screen = (string) apply_filters( 'screen_meta_screen', $screen ); 235 $screen = (object) array('id' => $screen, 'base' => $screen);234 $screen = new WP_Screen( $screen ); 236 235 return $screen; 237 236 } 238 237 … … 248 247 * 249 248 * @todo: deprecate? 250 249 */ 251 function add_contextual_help($screen, $help) { 252 global $_wp_contextual_help; 250 function add_contextual_help( $screen, $help ) { 251 if ( is_string( $screen ) ) 252 $screen = convert_to_screen( $screen ); 253 253 254 if ( is_string($screen) ) 255 $screen = convert_to_screen($screen); 256 257 if ( !isset($_wp_contextual_help) ) 258 $_wp_contextual_help = array(); 259 260 $_wp_contextual_help[$screen->id] = $help; 254 $screen->add_old_compat_help( $help ); 261 255 } 262 256 263 257 /** … … 441 435 442 436 /** 443 437 * The help tab data associated with the screen, if any. 438 * 439 * @since 3.3.0 440 * @var array 441 * @access private 442 */ 443 private static $_help_tabs = array(); 444 445 /** 446 * The help sidebar data associated with screens, if any. 444 447 * 445 448 * @since 3.3.0 446 * @var array449 * @var string 447 450 * @access private 448 */449 private $_help_tabs= array();451 */ 452 private static $_help_sidebar = array(); 450 453 451 454 /** 452 * The help sidebar data associated with the screen, if any. 453 * 454 * @since 3.3.0 455 * @var string 456 * @access private 455 * Stores old string-based help. 457 456 */ 458 private $_help_sidebar = '';457 private static $_old_compat_help = array(); 459 458 460 459 /** 461 * The screen options associated with the screen, if any.460 * The screen options associated with screens, if any. 462 461 * 463 462 * @since 3.3.0 464 463 * @var array 465 464 * @access private 466 465 */ 467 private $_options = array();466 private static $_options = array(); 468 467 469 470 468 /** 471 469 * Stores the result of the public show_screen_options function. 472 470 * … … 553 551 $this->base .= '-user'; 554 552 $this->id .= '-user'; 555 553 } 554 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(); 556 561 } 557 562 563 function add_old_compat_help( $help ) { 564 self::$_old_compat_help[ $this->id ] = $help; 565 } 566 558 567 /** 559 568 * Set the parent information for the screen. 560 569 * This is called in admin-header.php after the menu parent for the screen has been determined. … … 579 588 * @param mixed $args Option-dependent arguments. 580 589 */ 581 590 public function add_option( $option, $args = array() ) { 582 $this->_options[ $option ] = $args;591 self::$_options[ $this->id ][ $option ] = $args; 583 592 } 584 593 585 594 /** 595 * Gets the arguments for an option for the screen. 596 * 597 * @since 3.3.0 598 * 599 * @param string 600 */ 601 public function get_option( $option, $key = false ) { 602 if ( ! isset( self::$_options[ $this->id ][ $option ] ) ) 603 return null; 604 if ( $key ) { 605 if ( isset( self::$_options[ $this->id ][ $option ][ $key ] ) ) 606 return self::$_options[ $this->id ][ $option ][ $key ]; 607 return null; 608 } 609 return self::$_options[ $this->id ][ $option ]; 610 } 611 612 /** 586 613 * Add a help tab to the contextual help for the screen. 587 614 * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add contextual help tabs. 588 615 * … … 610 637 if ( ! $args['id'] || ! $args['title'] ) 611 638 return; 612 639 613 $this->_help_tabs[] = $args;640 self::$_help_tabs[ $this->id ][] = $args; 614 641 } 615 642 616 643 /** … … 622 649 * @param string $content Sidebar content in plain text or HTML. 623 650 */ 624 651 public function add_help_sidebar( $content ) { 625 $this->_help_sidebar= $content;652 self::$_help_sidebar[ $screen->id ] = $content; 626 653 } 627 654 628 655 /** … … 633 660 * @since 3.3.0 634 661 */ 635 662 public function render_screen_meta() { 636 global $_wp_contextual_help;637 663 638 664 // Call old contextual_help_list filter. 639 if ( ! isset( $_wp_contextual_help ) ) 640 $_wp_contextual_help = array(); 641 $_wp_contextual_help = apply_filters( 'contextual_help_list', $_wp_contextual_help, $this ); 665 self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help ); 642 666 643 if ( isset( $_wp_contextual_help[ $this->id ] ) || ! $this->_help_tabs) {667 if ( isset( self::$_old_compat_help[ $this->id ] ) || empty(self::$_help_tabs[ $this->id ] ) ) { 644 668 // Call old contextual_help filter. 645 if ( isset( $_wp_contextual_help[ $this->id ] ) )646 $contextual_help = apply_filters( 'contextual_help', $_wp_contextual_help[ $this->id ], $this->id, $this);669 if ( isset( self::$_old_compat_help[ $this->id ] ) ) 670 $contextual_help = apply_filters( 'contextual_help', self::$_old_compat_help[ $this->id ], $this->id ); 647 671 648 672 if ( empty( $contextual_help ) ) { 649 673 $default_help = __( '<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>' ); … … 666 690 'title' => __('Screen Options'), 667 691 'callback' => array( $this, 'render_screen_options' ), 668 692 ) ); 669 $_options_tab = array_pop( $this->_help_tabs);670 array_unshift( $this->_help_tabs, $_options_tab );693 $_options_tab = array_pop( self::$_help_tabs[ $this->id ] ); 694 array_unshift( self::$_help_tabs[ $this->id ], $_options_tab ); 671 695 } 672 696 673 697 // Time to render! … … 677 701 <div id="contextual-help-wrap" class="hidden"> 678 702 <div class="contextual-help-tabs"> 679 703 <ul> 680 <?php foreach ( $this->_help_tabsas $i => $tab ):704 <?php foreach ( self::$_help_tabs[ $this->id ] as $i => $tab ): 681 705 $link_id = "tab-link-{$tab['id']}"; 682 706 $panel_id = "tab-panel-{$tab['id']}"; 683 707 $classes = ( $i == 0 ) ? 'active' : ''; … … 692 716 </ul> 693 717 </div> 694 718 719 <?php if ( ! empty( self::$_help_sidebar[ $this->id ] ) ) : ?> 695 720 <div class="contextual-help-sidebar"> 696 <?php echo $this->_help_sidebar; ?>721 <?php echo self::$_help_sidebar[ $this->id ]; ?> 697 722 </div> 723 <?php endif; ?> 698 724 699 725 <div class="contextual-help-tabs-wrap"> 700 <?php foreach ( $this->_help_tabsas $i => $tab ):726 <?php foreach ( self::$_help_tabs[ $this->id ] as $i => $tab ): 701 727 $panel_id = "tab-panel-{$tab['id']}"; 702 728 $classes = ( $i == 0 ) ? 'active' : ''; 703 729 $classes .= ' help-tab-content'; … … 733 759 $show_screen = true; 734 760 735 761 // Check if there are per-page options. 736 $show_screen = $show_screen || isset( $this->_options['per_page']);762 $show_screen = $show_screen || $this->get_option('per_page'); 737 763 738 764 $this->_screen_settings = apply_filters( 'screen_settings', '', $this ); 739 765 … … 747 773 if ( ! empty( $this->_screen_settings ) ) 748 774 $show_screen = true; 749 775 750 if ( ! empty( $this->_options) )776 if ( ! empty( self::$_options[ $this->id ] ) ) 751 777 $show_screen = true; 752 778 753 779 $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); … … 768 794 ?> 769 795 <form id="adv-settings" action="" method="post"> 770 796 <?php 771 if ( isset( $this->_options['overview']) )772 echo $this-> _options['overview'];797 if ( $this->get_option('overview') ) 798 echo $this->get_option('overview'); 773 799 if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> 774 800 <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5> 775 801 <div class="metabox-prefs"> … … 826 852 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) 827 853 $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); 828 854 829 if ( ! isset( $this->_options['layout_columns']) ) {855 if ( ! $this->get_option('layout_columns') ) { 830 856 $screen_layout_columns = 0; 831 857 return; 832 858 } 833 859 834 860 $screen_layout_columns = get_user_option("screen_layout_$this->id"); 835 $num = $this-> _options['layout_columns']['max'];861 $num = $this->get_option( 'layout_columns', 'max' ); 836 862 837 863 if ( ! $screen_layout_columns || 'auto' == $screen_layout_columns ) { 838 if ( isset( $this->_options['layout_columns']['default']) )839 $screen_layout_columns = $this-> _options['layout_columns']['default'];864 if ( $this->get_option( 'layout_columns', 'default' ) ) 865 $screen_layout_columns = $this->get_option( 'layout_columns', 'default' ); 840 866 } 841 867 842 868 ?> … … 862 888 * @since 3.3.0 863 889 */ 864 890 function render_per_page_options() { 865 if ( ! isset( $this->_options['per_page']) )891 if ( ! $this->get_option( 'per_page' ) ) 866 892 return; 867 893 868 $per_page_label = $this-> _options['per_page']['label'];894 $per_page_label = $this->get_option( 'per_page', 'label' ); 869 895 870 if ( empty( $this->_options['per_page']['option'] ) ) { 896 $option = $this->get_option( 'per_page', 'option' ); 897 if ( ! $option ) 871 898 $option = str_replace( '-', '_', "{$this->id}_per_page" ); 872 } else {873 $option = $this->_options['per_page']['option'];874 }875 899 876 900 $per_page = (int) get_user_option( $option ); 877 901 if ( empty( $per_page ) || $per_page < 1 ) { 878 if ( isset($this->_options['per_page']['default']) ) 879 $per_page = $this->_options['per_page']['default']; 880 else 902 $per_page = $this->get_option( 'per_page', 'default' ); 903 if ( ! $per_page ) 881 904 $per_page = 20; 882 905 } 883 906