title( esc_html__( 'Jetpack Search', 'jetpack' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'login_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'enqueue_embed_scripts', array( $this, 'enqueue_scripts' ) ); } /** * Returns the singleton instance of Jetpack_Search_Debug_Bar * * @return Jetpack_Search_Debug_Bar */ public static function instance() { if ( is_null( self::$instance ) ) { self::$instance = new Jetpack_Search_Debug_Bar(); } return self::$instance; } /** * Enqueues styles for our panel in the debug bar * * @return void */ public function enqueue_scripts() { // Do not enqueue scripts if we haven't already enqueued Debug Bar or Query Monitor styles. if ( ! wp_style_is( 'debug-bar' ) && ! wp_style_is( 'query-monitor' ) ) { return; } wp_enqueue_style( 'jetpack-search-debug-bar', plugins_url( '3rd-party/debug-bar/debug-bar.css', JETPACK__PLUGIN_FILE ) ); wp_enqueue_script( 'jetpack-search-debug-bar', plugins_url( '3rd-party/debug-bar/debug-bar.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ) ); } /** * Should the Jetpack Search Debug Bar show? * * Since we've previously done a check for the search module being activated, let's just return true. * Later on, we can update this to only show when `is_search()` is true. * * @return boolean */ public function is_visible() { return true; } /** * Renders the panel content * * @return void */ public function render() { if ( ! class_exists( 'Jetpack_Search' ) ) { return; } $jetpack_search = Jetpack_Search::instance(); $last_query_info = $jetpack_search->get_last_query_info(); // If not empty, let's reshuffle the order of some things. if ( ! empty( $last_query_info ) ) { $args = $last_query_info['args']; $response = $last_query_info['response']; $response_code = $last_query_info['response_code']; unset( $last_query_info['args'] ); unset( $last_query_info['response'] ); unset( $last_query_info['response_code'] ); if ( is_null( $last_query_info['es_time'] ) ) { $last_query_info['es_time'] = esc_html_x( 'cache hit', 'displayed in search results when results are cached', 'jetpack' ); } $temp = array_merge( array( 'response_code' => $response_code ), array( 'args' => $args ), $last_query_info, array( 'response' => $response ) ); $last_query_info = $temp; } ?>

$info ) : ?>

render_json_toggle( $info ); endif; ?>
 &).
				// If any entities are part of the JSON blob, we want to re-encoode them
				// (double-encode them) so that they are displayed correctly in the debug
				// bar.
				// Use _wp_specialchars() "manually" to ensure entities are encoded correctly.
				echo _wp_specialchars(
					wp_json_encode( $value ),
					ENT_NOQUOTES, // Don't need to encode quotes (output is for a text node).
					'UTF-8',      // wp_json_encode() outputs UTF-8 (really just ASCII), not the blog's charset.
					true          // Do "double-encode" existing HTML entities
				);
			?>