Created
June 6, 2017 13:17
-
-
Save jchristopher/4592111b77675ba0dc2c9e0aea5fcbd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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