'application/json', 'Authorization' => 'Bearer ' . $api_key, ]; $response = wp_remote_get($url, array( 'headers' => $headers, )); if (is_wp_error($response)) { $error_message = $response->get_error_message(); echo esc_html("Something went wrong: $error_message"); } return $response; } public function render_general_settings() { $save_error = false; $saved_successfully = false; // Saves the Api Key and Placements ID in the wp db if ($_SERVER["REQUEST_METHOD"] == "POST") { $nonce = sanitize_text_field(wp_unslash($_POST['_wpnonce'])); // Verify the nonce if (!isset($nonce) || !wp_verify_nonce($nonce, 'adcaptcha_form_action')) { die('Invalid nonce'); } $api_key = sanitize_text_field(wp_unslash($_POST['adcaptcha_option_name']['api_key'])); $placement_id = sanitize_text_field(wp_unslash($_POST['adcaptcha_option_name']['placement_id'])); $response = $this->verify_input_data($api_key, $placement_id); if ($response['response']['code'] === 200) { update_option('adcaptcha_api_key', $api_key); update_option('adcaptcha_placement_id', $placement_id); update_option('adcaptcha_render_captcha', true); $saved_successfully = true; } else { $save_error = true; update_option('adcaptcha_render_captcha', false); } } ?>