Changeset 18943
- Timestamp:
- 10/11/2011 09:32:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/screen.php
r18941 r18943 19 19 $screen = convert_to_screen( $screen ); 20 20 21 global $_wp_column_headers; 22 23 if ( !isset( $_wp_column_headers[ $screen->id ] ) ) { 24 $_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 25 } 26 27 return $_wp_column_headers[ $screen->id ]; 21 static $column_headers = array(); 22 23 if ( ! isset( $column_headers[ $screen->id ] ) ) 24 $column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 25 26 return $column_headers[ $screen->id ]; 28 27 } 29 28 … … 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 … … 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 } … … 249 248 * @todo: deprecate? 250 249 */ 251 function add_contextual_help($screen, $help) { 252 global $_wp_contextual_help; 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; 250 function add_contextual_help( $screen, $help ) { 251 if ( is_string( $screen ) ) 252 $screen = convert_to_screen( $screen ); 253 254 $screen->add_old_compat_help( $help ); 261 255 } 262 256 … … 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. 447 * 448 * @since 3.3.0 449 * @var string 450 * @access private 451 */ 452 private static $_help_sidebar = array(); 453 454 /** 455 * Stores old string-based help. 456 */ 457 private static $_old_compat_help = array(); 458 459 /** 460 * The screen options associated with screens, if any. 444 461 * 445 462 * @since 3.3.0 … … 447 464 * @access private 448 465 */ 449 private $_help_tabs = array(); 450 451 /** 452 * The help sidebar data associated with the screen, if any. 453 * 454 * @since 3.3.0 455 * @var string 456 * @access private 457 */ 458 private $_help_sidebar = ''; 459 460 /** 461 * The screen options associated with the screen, if any. 462 * 463 * @since 3.3.0 464 * @var array 465 * @access private 466 */ 467 private $_options = array(); 468 466 private static $_options = array(); 469 467 470 468 /** … … 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(); 561 } 562 563 function add_old_compat_help( $help ) { 564 self::$_old_compat_help[ $this->id ] = $help; 556 565 } 557 566 … … 580 589 */ 581 590 public function add_option( $option, $args = array() ) { 582 $this->_options[ $option ] = $args; 591 self::$_options[ $this->id ][ $option ] = $args; 592 } 593 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 ]; 583 610 } 584 611 … … 611 638 return; 612 639 613 $this->_help_tabs[] = $args;640 self::$_help_tabs[ $this->id ][] = $args; 614 641 } 615 642 … … 623 650 */ 624 651 public function add_help_sidebar( $content ) { 625 $this->_help_sidebar= $content;652 self::$_help_sidebar[ $this->id ] = $content; 626 653 } 627 654 … … 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 ); 642 643 if ( isset( $_wp_contextual_help[ $this->id ] ) || ! $this->_help_tabs ) { 665 self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help ); 666 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 ) ) { … … 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 … … 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']}"; … … 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' : ''; … … 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 ); … … 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 … … 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> … … 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; … … 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 … … 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']; 869 870 if ( empty( $this->_options['per_page']['option'] ) ) { 894 $per_page_label = $this->get_option( 'per_page', 'label' ); 895 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 }
Note: See TracChangeset
for help on using the changeset viewer.