Make WordPress Core


Ignore:
Timestamp:
01/13/2011 11:19:51 PM (14 years ago)
Author:
westi
Message:

The old methods are good enough in alot of cases where plugins want to extend simply. So un deprecate for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/list-table.php

    r17070 r17293  
    6464}
    6565
     66/**
     67 * Register column headers for a particular screen.
     68 *
     69 * @since 2.7.0
     70 *
     71 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
     72 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
     73 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
     74 */
     75function register_column_headers($screen, $columns) {
     76    $wp_list_table = new _WP_List_Table_Compat($screen, $columns);
     77}
     78
     79/**
     80 * Prints column headers for a particular screen.
     81 *
     82 * @since 2.7.0
     83 */
     84function print_column_headers($screen, $id = true) {
     85    $wp_list_table = new _WP_List_Table_Compat($screen);
     86
     87    $wp_list_table->print_column_headers($id);
     88}
     89
     90/**
     91 * Helper class to be used only by back compat functions
     92 *
     93 * @since 3.1.0
     94 */
     95class _WP_List_Table_Compat extends WP_List_Table {
     96    var $_screen;
     97    var $_columns;
     98
     99    function _WP_List_Table_Compat( $screen, $columns = array() ) {
     100        if ( is_string( $screen ) )
     101            $screen = convert_to_screen( $screen );
     102
     103        $this->_screen = $screen;
     104
     105        if ( !empty( $columns ) ) {
     106            $this->_columns = $columns;
     107            add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
     108        }
     109    }
     110
     111    function get_column_info() {
     112        $columns = get_column_headers( $this->_screen );
     113        $hidden = get_hidden_columns( $this->_screen );
     114        $sortable = array();
     115
     116        return array( $columns, $hidden, $sortable );
     117    }
     118
     119    function get_columns() {
     120        return $this->_columns;
     121    }
     122}
    66123?>
Note: See TracChangeset for help on using the changeset viewer.