Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Callback for SearchWP engine choice dropdown. Swaps out engine config for
* chosen engine at runtime.
*
* @param $settings
* @param $query
*
* @return mixed
*/
function my_searchwp_engine_dropdown_handler( $settings, $query ) {
$engines = SWP()->settings['engines'];
$selected_engine = isset( $_GET['swpengine'] ) ? esc_attr( $_GET['swpengine'] ) : 'default';
if ( isset( $engines[ $selected_engine ] ) ) {
$settings = $engines[ $selected_engine ];
}
return $settings;
}
add_filter( 'searchwp_engine_settings_default', 'my_searchwp_engine_dropdown_handler', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.