Not authenticated. Please go to the Wordpress's admin panel → {$boostfab_name} Panel to authenticate."; } $query_str = http_build_query($query); return " "; } function boostfab_register_admin_menu_item() { global $boostfab_name; $badge = ""; $api_token = get_option("boostfab_api_token", ''); if (!is_signedin_or_trying()) { $badge = '!'; } add_menu_page("{$boostfab_name} Panel", "{$boostfab_name} Panel {$badge}", "manage_options", "boostfab-panel", "boostfab_print_admin_panel", "dashicons-cart"); } function is_signedin_or_trying() { return $api_token = get_option("boostfab_api_token", '') != '' || !empty($_POST["api_token"]); } function boostfab_print_admin_panel() { global $boostfab_api_url_from_backend; $api_token = get_option("boostfab_api_token", ''); $can_signin = current_user_can('edit_posts') || current_user_can('edit_pages'); if (isset($_POST["api_token"]) && $can_signin) { check_admin_referer('signin'); $api_token_input = sanitize_text_field($_POST["api_token"]); if (preg_match('/^[a-zA-Z0-9-_\.]+$/', $api_token_input)) { update_option("boostfab_api_token", $api_token_input); $api_token = $api_token_input; $response = wp_remote_get($boostfab_api_url_from_backend . "/organizations", [ 'headers' => [ 'Authorization' => "Bearer {$api_token}" ] ]); if (is_wp_error($response)) { $error_message = $response->get_error_message(); echo esc_html("Something went wrong: " . $error_message); } else { $json = json_decode($response['body']); $organizations = $json->items; if (count($organizations) > 0) { $organization = $organizations[0]; update_option("boostfab_organization_slug", $organization->slug); } } } else { echo esc_html("The API token does not seem to be valid: " . $api_token_input); } } $signedIn = $api_token !== ''; if ($signedIn) { boostfab_print_admin_panel_authenticated(); } else { boostfab_print_admin_panel_unauthenticated(); } ?>


[%2s] to embed %3s in your pages or posts."), esc_html($boostfab_name), esc_html(BOOSTFAB_SHORTCODE), esc_html($boostfab_name), get_admin_url(null, 'edit.php?post_type=page'), get_admin_url(null, 'edit.php') ), 'post' ) ?>

send us a message. We will answer you as soon as possible."), "https://tawk.to/quotify" ), 'post' ) ?>


Boostfab.com account"), esc_url($boostfab_public_url) ), 'post' ) ?>

create an account in a few seconds."), esc_url($boostfab_public_url) . "/signup" ), 'post' ) ?>

_("You are not allowed to update the settings.") ]); die(); } if (isset($_POST['color'])) { check_ajax_referer('update-settings'); if ($_POST['color'] == 'null') { delete_option("boostfab_primary_color"); } else { $sanitized_color = sanitize_hex_color($_POST['color']); if (preg_match('/^#[0-9a-fA-F]{6}$/', $sanitized_color)) { update_option("boostfab_primary_color", substr($sanitized_color, 1)); } else { http_response_code(400); wp_send_json([ "message" => _("The color does not seem to be valid.") ]); die(); } } } wp_die(); } function boostfab_create_sample_page() { $post_name = _("Get a quotation!"); $page_id = wp_insert_post( array( 'comment_status' => 'close', 'ping_status' => 'close', 'post_author' => get_current_user_id(), 'post_title' => $post_name, 'post_name' => strtolower(str_replace(' ', '-', trim($post_name))), 'post_status' => 'publish', 'post_content' => "
[" . BOOSTFAB_SHORTCODE . "]
", 'post_type' => 'page', ) ); if (!get_option('boostfab_sample_quotation_page_created')) { add_option('boostfab_sample_quotation_page_created', '1'); } http_response_code(201); wp_send_json([ "url" => get_permalink($page_id) ]); die(); }