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:
parent
153b1ef591
commit
b6b4d37fcb
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,6 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
|||
*/
|
||||
function _js_vars() {
|
||||
global $tab, $type;
|
||||
parent::_js_vars( compact( $tab, $type ) );
|
||||
parent::_js_vars( compact( 'tab', 'type' ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
||||
printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", json_encode( $args ) );
|
||||
parent::_js_vars();
|
||||
parent::_js_vars( $args );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue