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: http://svn.automattic.com/wordpress/trunk@20100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3b9133ef4a
commit
1fed7c5c11
|
@ -903,7 +903,7 @@ class WP_List_Table {
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _js_vars() {
|
function _js_vars( $extra_args = array() ) {
|
||||||
$current_screen = get_current_screen();
|
$current_screen = get_current_screen();
|
||||||
|
|
||||||
$args = array(
|
$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 ) );
|
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||||
* @uses $type Global; type of search.
|
* @uses $type Global; type of search.
|
||||||
*/
|
*/
|
||||||
function _js_vars() {
|
function _js_vars() {
|
||||||
global $tab, $type;
|
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() ) {
|
function _js_vars( $extra_args = array() ) {
|
||||||
$search_string = isset( $_REQUEST['s'] ) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
|
$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(
|
$args = array(
|
||||||
'search' => $search_string,
|
'search' => $search_string,
|
||||||
'features' => $this->features,
|
'features' => $this->features,
|
||||||
'paged' => $this->get_pagenum(),
|
'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 ) )
|
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( $args );
|
||||||
parent::_js_vars();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue