From 65206ec0d700d0edb2c0c0d5cf891c4d82babb75 Mon Sep 17 00:00:00 2001 From: scribu Date: Sat, 21 Aug 2010 18:08:42 +0000 Subject: [PATCH] Make deprecated functions work. See #14651 git-svn-id: http://svn.automattic.com/wordpress/trunk@15517 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/admin.php | 3 + wp-admin/includes/default-list-tables.php | 2 - wp-admin/includes/deprecated.php | 73 +++++++++++++++++++++-- wp-admin/includes/list-table.php | 2 + 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php index 23c9ee2b7c..dde7a881c5 100644 --- a/wp-admin/includes/admin.php +++ b/wp-admin/includes/admin.php @@ -39,6 +39,9 @@ require_once(ABSPATH . 'wp-admin/includes/taxonomy.php'); /** WordPress Template Administration API */ require_once(ABSPATH . 'wp-admin/includes/template.php'); +/** WordPress List Table Administration API */ +require_once(ABSPATH . 'wp-admin/includes/list-table.php'); + /** WordPress Theme Administration API */ require_once(ABSPATH . 'wp-admin/includes/theme.php'); diff --git a/wp-admin/includes/default-list-tables.php b/wp-admin/includes/default-list-tables.php index 0fc31630a1..de51929597 100644 --- a/wp-admin/includes/default-list-tables.php +++ b/wp-admin/includes/default-list-tables.php @@ -1,7 +1,5 @@ id] = $columns; +} + +/** + * Get the column headers for a screen + * + * @since 2.7.0 + * @deprecated 3.1.0 + * @deprecated Use WP_List_Table + * + * @param string|object $screen The screen you want the headers for + * @return array Containing the headers in the format id => UI String + */ +function get_column_headers($screen) { + _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' ); + + $table = new _WP_List_Table_Compat($screen); + list( $columns ) = $table->get_column_headers(); + + return $columns; } /** @@ -215,19 +248,49 @@ function register_column_headers() { * @deprecated 3.1.0 * @deprecated Use WP_List_Table */ -function print_column_headers() { +function print_column_headers($screen, $id = true) { _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' ); + + $table = new _WP_List_Table_Compat($screen); + + $table->print_column_headers($id); } /** * Gets hidden column names for a particular screen. * - * @since unknown + * @since 2.7.0 * @deprecated 3.1.0 * @deprecated Use WP_List_Table + * + * @param string $screen + * @return array */ -function get_hidden_columns() { +function get_hidden_columns($screen) { _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' ); - return array(); + + $table = new _WP_List_Table_Compat($screen); + + return $table->get_hidden_columns(); +} + +// Helper class to be used only by deprecated functions +class _WP_List_Table_Compat extends WP_List_Table { + + function _WP_List_Table_Compat( $screen) { + parent::WP_List_Table( array( + 'screen' => $screen, + 'ajax' => false + ) ); + } + + function get_columns() { + global $_wp_column_headers; + + if ( isset($_wp_column_headers[$this->_screen->id]) ) + return $_wp_column_headers[$this->_screen->id]; + + return array(); + } } diff --git a/wp-admin/includes/list-table.php b/wp-admin/includes/list-table.php index 2a2200e350..089e248677 100644 --- a/wp-admin/includes/list-table.php +++ b/wp-admin/includes/list-table.php @@ -458,6 +458,8 @@ class WP_List_Table { * * @since 3.1.0 * @access protected + * + * @param bool $with_id Wether to set the id attribute or not */ function print_column_headers( $with_id = true ) { $screen = $this->_screen;