WP_Themes_List_Table::_js_vars() WordPress Method

The WP_Themes_List_Table::_js_vars() method is used to enqueue the JavaScript file for the theme list table. This method is called from the WP_Themes_List_Table::prepare_items() method.

WP_Themes_List_Table::_js_vars( array $extra_args = array() ) #

Send required variables to JavaScript land


Parameters

$extra_args

(array)(Optional)

Default value: array()


Top ↑

Source

File: wp-admin/includes/class-wp-themes-list-table.php

	public function _js_vars( $extra_args = array() ) {
		$search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';

		$args = array(
			'search'      => $search_string,
			'features'    => $this->features,
			'paged'       => $this->get_pagenum(),
			'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", wp_json_encode( $args ) );
		parent::_js_vars();
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.