plugin_path = plugin_dir_path( __FILE__ ); $this->plugin_url = plugin_dir_url( __FILE__ ); load_plugin_textdomain( $this->text_domain, FALSE, $this->plugin_path . '\lang' ); add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'register_styles' ] ); add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] ); add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ] ); register_activation_hook( __FILE__, [ $this, 'activation' ] ); register_deactivation_hook( __FILE__, [ $this, 'deactivation' ] ); $this->run_plugin(); } private function run_plugin() { // action hooks add_action( 'admin_menu', 'abbs_bing_search_register_admin_page' ); add_action( 'pre_get_posts', 'abbs_bing_search_check_if_search' ); add_action( 'admin_init', 'abbs_bing_search_register_settings' ); add_action( 'admin_notices', 'abbs_bing_search_notify_user' ); function abbs_bing_search_register_admin_page() { add_submenu_page( "options-general.php", "Bing Search", "Bing Search", "manage_options", "abbs_bing_search_options", "abbs_bing_search_submenu_callback" ); } function abbs_bing_search_register_settings() { register_setting( "abbs_bing_search_options", "abbs_bing_api_key", [ 'type' => 'string', 'description' => __( 'The API Key provided by Bing to use the search functionality', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_bing_search_count", [ 'type' => 'intval', 'description' => __( 'The amount of Search items per page', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_bing_search_market", [ 'type' => 'string', 'description' => __( 'The market that the search will use', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_bing_search_website", [ 'type' => 'string', 'description' => __( 'The website that will be used in the search closure', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_bing_inline_search", [ 'type' => 'string', 'description' => __( 'Set if you would like a inline search on the results column', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_bing_search_custom_css", [ 'type' => 'string', 'description' => __( 'Inject any custom styling here to be used on the plugin theme file', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_custom_search_bool", [ 'type' => 'string', 'description' => __( 'Use the new custom search functionality (currently in preview).', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); register_setting( "abbs_bing_search_options", "abbs_custom_search_string", [ 'type' => 'string', 'description' => __( 'Code given by bing for your custom search.', 'abbs-bing-search' ), 'sanitize_callback' => NULL, 'show_in_rest' => FALSE, ] ); add_settings_section( 'abbs_bing_search_settings_section', __( 'API Settings', 'abbs-bing-search' ), '', 'abbs_bing_search_options' ); add_settings_section( "abbs_bing_inject_css_section", __( "Custom CSS", 'abbs-bing-search' ), '', "abbs_bing_search_options" ); add_settings_field( "abbs_bing_api_key", __( "Bing API Key", 'abbs-bing-search' ), "abbs_bing_api_key_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_bing_website_search", __( "Website", 'abbs-bing-search' ), "abbs_bing_website_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_bing_search_count", __( "Items Per Page", 'abbs-bing-search' ), "abbs_bing_search_count_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_bing_search_market", __( "Country/Market", 'abbs-bing-search' ), "abbs_bing_search_market_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_bing_inline_search", __( "Inline Search field", 'abbs-bing-search' ), "abbs_bing_inline_search_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_custom_search_bool", __( "Use custom search API", 'abbs-bing-search' ), "abbs_custom_search_bool_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_custom_search_string", __( "Custom search Code", 'abbs-bing-search' ), "abbs_custom_search_string_callback", "abbs_bing_search_options", 'abbs_bing_search_settings_section' ); add_settings_field( "abbs_bing_search_custom_css", __( "Custom Styles", 'abbs-bing-search' ), "abbs_bing_search_custom_css_callback", "abbs_bing_search_options", 'abbs_bing_inject_css_section' ); } function abbs_custom_search_bool_callback() { $setting = get_option( 'abbs_custom_search_bool' ); ?>

Setting this to empty will use the default server name.

$endpoint, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "cache-control: no-cache", "ocp-apim-subscription-key: $bing_key", ], ] ); $response = curl_exec( $curl ); $err = curl_error( $curl ); curl_close( $curl ); if ( $err ) { global $bing_query_object; $bing_query_object = "ERROR"; } else { global $bing_query_object; global $bing_query_options; $bing_query_object = json_decode( $response ); if ( ! isset( $bing_query_object->webPages->value ) ) { $bing_query_object = "NORESULTS"; } else { $bing_query_object = $bing_query_object->webPages->value; $bing_query_options = [ "next_page" => "Next Page", "prev_page" => ( $page != 0 ? "Previous Page" : "" ), ]; } } } catch ( Exception $e ) { global $bing_query_object; $bing_query_object = "ERROR"; } return __DIR__ . "/bing-search-template.php"; } function abbs_admin_footer_content() { echo 'Thank you for creating with WordPress. | Plugin Created By Askew Brook'; } function abbs_bing_search_check_if_search( $query ) { if ( $query->is_search ) { add_action( 'template_include', 'abbs_bing_search_fire_search_func' ); } } } public static function get_instance() { // If an instance hasn't been created and set to $instance create an instance and set it to $instance. if ( NULL == self::$instance ) { self::$instance = new self; } return self::$instance; } public function get_plugin_url() { return $this->plugin_url; } public function get_plugin_path() { return $this->plugin_path; } public function activation() { } public function deactivation() { } public function register_scripts() { } public function register_styles() { } } Askew_Brook_Bing_Search::get_instance();