Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active November 21, 2018 21:23
Show Gist options
  • Save jchristopher/98a774e7c5c9d6328d7a181ce922849c to your computer and use it in GitHub Desktop.
Save jchristopher/98a774e7c5c9d6328d7a181ce922849c to your computer and use it in GitHub Desktop.
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search..." value="<?php echo esc_attr( get_search_query() ); ?>" name="s" title="Search for:" />
</label>
<?php
$engines = SWP()->settings['engines'];
$current_engine = isset( $_GET['swpengine'] ) ? esc_attr( $_GET['swpengine'] ) : 'default';
?>
<select name="swpengine" id="swpengine">
<?php foreach ( $engines as $engine => $engine_settings ) : ?>
<option value="<?php echo esc_attr( $engine ); ?>"
<?php selected( $current_engine, $engine ); ?>>
<?php echo isset( $engine_settings['searchwp_engine_label'] ) ? esc_html( $engine_settings['searchwp_engine_label'] ) : 'Default'; ?>
</option>
<?php endforeach; ?>
</select>
<input type="submit" class="search-submit" value="Search" />
</form>
@BBZRK
Copy link

BBZRK commented Nov 21, 2018

This works awesome, but switching the engine via the dropdown and then making a search doesn't seem to update the search stats or the metrics extension stats for that engine? Is there a way for this to happen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment