Allow WP_List_Table::_js_vars() to take an array of additional args to add. Allows us to have a single variable printing data when child classes need more data. Also, fix compact() call in [20094]. see #19815.

git-svn-id: https://develop.svn.wordpress.org/trunk@20100 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-03-02 23:06:31 +00:00
parent 153b1ef591
commit b6b4d37fcb
3 changed files with 9 additions and 11 deletions

View File

@ -903,7 +903,7 @@ class WP_List_Table {
*
* @access private
*/
function _js_vars() {
function _js_vars( $extra_args = array() ) {
$current_screen = get_current_screen();
$args = array(
@ -914,6 +914,9 @@ class WP_List_Table {
)
);
if ( is_array( $extra_args ) )
$args = array_merge( $args, $extra_args );
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
}
}

View File

@ -170,7 +170,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
* @uses $type Global; type of search.
*/
function _js_vars() {
global $tab, $type;
parent::_js_vars( compact( $tab, $type ) );
global $tab, $type;
parent::_js_vars( compact( 'tab', 'type' ) );
}
}

View File

@ -217,21 +217,16 @@ class WP_Themes_List_Table extends WP_List_Table {
function _js_vars( $extra_args = array() ) {
$search_string = isset( $_REQUEST['s'] ) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
$total_pages = 1;
if ( ! empty( $this->_pagination_args['total_pages'] ) )
$total_pages = $this->_pagination_args['total_pages'];
$args = array(
'search' => $search_string,
'features' => $this->features,
'paged' => $this->get_pagenum(),
'total_pages' => $total_pages,
'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1,
);
if ( is_array( $extra_args ) )
$args = array_merge( $args, $extra_args );
$args = array_merge( $args, $extra_args );
printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", json_encode( $args ) );
parent::_js_vars();
parent::_js_vars( $args );
}
}