<?php
/**
 * Renders the content of the submenu page for the AI for SEO help page.
 *
 * @since 1.2.1
 */

if (!defined("ABSPATH")) {
    exit;
}

if (!ai4seo_can_manage_this_plugin()) {
    return;
}


// ___________________________________________________________________________________________ \\
// === PREPARE =============================================================================== \\
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ \\

// Variable for the subject-options for the contact form
$ai4seo_contact_subject_options = array(
    "0" => __("Please select", "ai-for-seo"),
    "Request a Feature" => __("Request a Feature", "ai-for-seo"),
    "Report a bug" => __("Report a bug", "ai-for-seo"),
    "Get a quote" => __("Get a quote", "ai-for-seo"),
    "General question" => __("General question", "ai-for-seo"),
    "I need help with my SEO" => __("I need help with my SEO", "ai-for-seo"),
    "Other" => __("Other", "ai-for-seo"),
);

$ai4seo_free_plan_credits = ai4seo_get_plan_credits("free");
$ai4seo_s_plan_credits = ai4seo_get_plan_credits("s");
$ai4seo_m_plan_credits = ai4seo_get_plan_credits("m");
$ai4seo_l_plan_credits = ai4seo_get_plan_credits("l");

$ai4seo_reset_generated_data_tooltip = sprintf(
    /* translators: %1$s plugin name, %2$s plugin name */
    esc_html__('<strong>This will delete all AI-generated data.</strong><br>Use this option to allow *%1$s* to regenerate all previously generated data.<br><br>- <strong>Note:</strong> This does not remove or undo data that has been synced to third-party SEO plugins or written into the media library. However, this data will be considered \"old\" and can be overwritten if the \"Include Complete Entries When Overwriting\" setting is enabled.<br>- No Credits will be refunded.<br>- <strong>Caution:</strong> This action is irreversible and may cause metadata generated by *%2$s* to no longer appear on your website.', 'ai-for-seo'),
    esc_html(AI4SEO_PLUGIN_NAME),
    esc_html(AI4SEO_PLUGIN_NAME)
);
$ai4seo_credits_packs = ai4seo_get_credits_packs();


// ___________________________________________________________________________________________ \\
// === PROCESS CONTACT FORM ================================================================== \\
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ \\

do {
    if (isset($_POST["ai4seo-contact-form-submit"])) {
        // check if the nonce is valid
        if (!isset($_POST['ai4seo-contact-form-nonce']) || !wp_verify_nonce($_POST['ai4seo-contact-form-nonce'], 'ai4seo-contact-form')) {
            // Invalid nonce, stop the script.
            echo "<div class='notice notice-error is-dismissible'>";
                echo "<p>" . esc_html__("Security check failed. Please try again.", "ai-for-seo") . "</p>";
            echo "</div>";
            break;
        }

        // Stop script if the user tries to submit the form within 60 seconds after the last submit
        $ai4seo_last_contact_form_submit_time = (int) get_transient('ai4seo_last_contact_form_submit_timestamp');
        
        if ($ai4seo_last_contact_form_submit_time && (time() - $ai4seo_last_contact_form_submit_time) < 60) {
            echo "<div class='notice notice-error is-dismissible'>";
                echo "<p>" . esc_html__("You can submit only one request every 60 seconds. Please wait a moment and try again.", "ai-for-seo") . "</p>";
            echo "</div>";
            break;
        }

        // Sanitize
        $ai4seo_contact_form_name = sanitize_text_field($_POST["ai4seo-contact-form-name"] ?? "");
        $ai4seo_contact_form_email = sanitize_email($_POST["ai4seo-contact-form-email"] ?? "");
        $ai4seo_contact_form_subject = sanitize_text_field($_POST["ai4seo-contact-form-subject"] ?? "");
        $ai4seo_contact_form_message = sanitize_textarea_field($_POST["ai4seo-contact-form-message"] ?? "");

        // shorten name and message
        $ai4seo_contact_form_name = substr($ai4seo_contact_form_name, 0, 64);
        $ai4seo_contact_form_message = substr($ai4seo_contact_form_message, 0, 5000);

        // Make sure that name exists
        if (!$ai4seo_contact_form_name || !preg_match("/^[\p{L} '-]+$/u", $ai4seo_contact_form_name)) {
            echo "<div class='notice notice-error is-dismissible'>";
                echo "<p>" . esc_html__("Please enter a valid name!", "ai-for-seo") . "</p>";
            echo "</div>";
            break;
        }

        // Make sure that email exists
        if (!$ai4seo_contact_form_email || !filter_var($ai4seo_contact_form_email, FILTER_VALIDATE_EMAIL)) {
            echo "<div class='notice notice-error is-dismissible'>";
                echo "<p>" . esc_html__("Please enter a valid email-address!", "ai-for-seo") . "</p>";
            echo "</div>";
            break;
        }

        // Make sure that subject exists
        if (!$ai4seo_contact_form_subject || $ai4seo_contact_form_subject == "0" || !isset($ai4seo_contact_subject_options[$ai4seo_contact_form_subject])) {
            echo "<div class='notice notice-error is-dismissible'>";
                echo "<p>" . esc_html__("Please enter a valid subject!", "ai-for-seo") . "</p>";
            echo "</div>";
            break;
        }

        // Make sure that message exists
        if (!$ai4seo_contact_form_message) {
            echo "<div class='notice notice-error is-dismissible'>";
                echo "<p>" . esc_html__("Please enter a message!", "ai-for-seo") . "</p>";
            echo "</div>";
            break;
        }

        // Prepare send email
        $ai4seo_email_recipient = esc_html(sanitize_email(AI4SEO_SUPPORT_EMAIL));
        $ai4seo_contact_form_subject = esc_html($ai4seo_contact_form_subject);
        $ai4seo_contact_form_message = nl2br(esc_textarea($ai4seo_contact_form_message));

        // Prepare headers
        $ai4seo_email_headers = array(
            "MIME-Version: 1.0",
            "Content-type: text/html; charset=utf-8",
            "From: " . esc_html($ai4seo_contact_form_name) . " <" . esc_html($ai4seo_contact_form_email) . ">",
        );

        // Send email
        $ai4seo_sent_email_successfully = wp_mail($ai4seo_email_recipient, $ai4seo_contact_form_subject, $ai4seo_contact_form_message, $ai4seo_email_headers);

        // Display success message
        if ($ai4seo_sent_email_successfully) {
            echo "<div class='notice notice-success is-dismissible'>";
                echo "<p>" . esc_html__("Thank you for your message. We have successfully received your email and will be in touch with you shortly.", "ai-for-seo") . "</p>";
            echo "</div>";

            set_transient('ai4seo_last_contact_form_submit_timestamp', time(), 60);
        }

        // Display error message
        else {
            echo "<div class='notice notice-error is-dismissible'>";
            echo "<p>" . sprintf(
                /* translators: %s: contact URL */
                esc_html__("Your system encountered an issue sending the email. Please try again later, or feel free to <a href='%s' target='_blank'>contact us</a> directly if the problem persists.", "ai-for-seo"),
                esc_html(AI4SEO_OFFICIAL_CONTACT_URL),
            ) . "</p>";
            echo "</div>";
        }
    }
} while (0);


// ___________________________________________________________________________________________ \\
// === OUTPUT ================================================================================ \\
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ \\

echo "<div class='ai4seo-help-selection-container'>";

    // === CONTAINERS FOR THE BUTTONS TO THE HELP-AREAS ========================================== \\

    // Getting started
    echo "<a href='#ai4seo-getting-started-section'><div class='ai4seo-help-preview-selection ai4seo-help-navigation-link' data-ai4seo-help-target='ai4seo-help-getting-started'>";
        ai4seo_echo_wp_kses(ai4seo_get_svg_tag("rocket"));
        echo "<span>" . esc_html__("Getting started", "ai-for-seo") . "</span>";
    echo "</div></a>";

    // FAQ
    echo "<a href='#ai4seo-faq-section'><div class='ai4seo-help-preview-selection ai4seo-help-navigation-link' data-ai4seo-help-target='ai4seo-help-faq'>";
        echo "<i class='dashicons dashicons-editor-help'></i>";
        echo "<span>" . esc_html__("F.A.Q.", "ai-for-seo") . "</span>";
    echo "</div></a>";

    // Contact
    #echo "<a href='#ai4seo-contact-section'><div class='ai4seo-help-preview-selection'  onclick='jQuery(\".ai4seo-help-content\").hide();jQuery(\"#ai4seo-help-contact\").show();'>";
    echo "<a href='" . esc_attr(AI4SEO_OFFICIAL_CONTACT_URL) . "' target='_blank'><div class='ai4seo-help-preview-selection'>";
        echo "<i class='dashicons dashicons-email'></i>";
        echo "<span>" . esc_html__("Contact", "ai-for-seo") . "</span><br>";
        echo "<span style='font-weight: normal; font-size: 12px; margin-top: -8px;'>" . esc_html__("(All Languages)", "ai-for-seo") . "</span><br>";
    echo "</div></a>";

    // Troubleshooting
    echo "<a href='#ai4seo-troubleshooting-section'><div class='ai4seo-help-preview-selection ai4seo-help-navigation-link' data-ai4seo-help-target='ai4seo-help-troubleshooting'>";
        echo "<i class='dashicons dashicons-hammer'></i>";
        echo "<span>" . esc_html__("Troubleshooting", "ai-for-seo") . "</span>";
    echo "</div></a>";

    // Useful links
    echo "<a href='#ai4seo-links-section'><div class='ai4seo-help-preview-selection ai4seo-help-navigation-link' data-ai4seo-help-target='ai4seo-help-links'>";
        echo "<i class='dashicons dashicons-admin-links'></i>";
        echo "<span>" . esc_html__("Useful links", "ai-for-seo") . "</span>";
    echo "</div></a>";

echo "</div>";

echo "<div class='ai4seo-clear'></div>";


// === GETTING STARTED ======================================================================= \\

echo "<div class='ai4seo-display-none ai4seo-help-content' id='ai4seo-help-getting-started'>";
    // Headline
    echo "<h1 id='ai4seo-getting-started-section'>";
        echo esc_html__("Getting started", "ai-for-seo");
    echo "</h1>";

    // === FIRST STEPS =========================================================================== \\

    // Dashboard
    $ai4seo_this_accordion_content = "<p><b>1.</b> " . __("<b>Dashboard</b>: Take a look at the statistics at the top of the page. These show which parts of your website have been optimized and which parts have not.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-1.jpg")) . "' style='width: 100%;' />";
    $ai4seo_this_accordion_content .= "<p><b>2.</b> " . __("<b>Dashboard -> Credits</b>: In this section you will see how many Credits are currently available to use. Underneath the total number of Credits you will see an exact cost breakdown followed by the button <b>Get more Credits</b>. If you click on this button, you will see a modal with different purchase options to obtain more Credits.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>2.1.</b> " . __("<b>Dashboard -> Credits -> Get more Credits</b>: After clicking on this button a modal with different purchase options will open. Here you can purchase Credits Packs, start or manage a monthly or yearly subscription and customize the Pay-As-You-Go feature to automatically refill your Credits balance with a pre-set amount. Additionally you will see information about the next free daily Credits you will receive.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>3.</b> " . __("<b>Dashboard → SEO Autopilot (Bulk Generation)</b>: In this section, you can view the current status of the SEO Autopilot. At the bottom of this section, you’ll find buttons to set up or stop the SEO Autopilot.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>3.1.</b> " . __("<b>Dashboard → SEO Autopilot (Bulk Generation) → Set up SEO Autopilot</b>: Clicking this button opens a modal with the settings for the SEO Autopilot. In this modal, you can choose the content types for which the SEO Autopilot should generate SEO data. You can also specify whether it should manage only new content entries, only existing ones, or both. Additionally, you can define the order in which the SEO Autopilot processes the content entries.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-2.jpg")) . "' style='width: 100%;' />";
    $ai4seo_this_accordion_content .= "<p><b>4.</b> " . __("<b>Dashboard -> Recent activity</b>: This section will display the recent plugin activity. Next to each item in this list you will see a button to display each content and a button to edit the SEO settings for the entry.", "ai-for-seo") . "</p>";

    // Account
    $ai4seo_this_accordion_content .= "<p><b>5.</b> ";
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= sprintf(esc_html__("<b>Account</b>: Check out the account settings of the *%s* plugin by clicking on the \"Account\" menu item in the plugin navigation. On this page you will find your license-details, the settings for SEO and Web Agencies, as well as a section for Privacy & Agreements.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-3.jpg")) . "' style='width: 100%;' />";
    $ai4seo_this_accordion_content .= "<p><b>5.1.</b> " . __("<b>Account -> License</b>: In this section you will find input fields for the license-owner and the license-key. Additionally you will have access to different buttons to manage and set up payment options.", "ai-for-seo") . "</p>";
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p><b>5.2.</b> " . sprintf(esc_html__("<b>Account -> For SEO and Web Agencies</b>: Here you can set up different plugin-features that are mainly designed for agencies. These settings allow you to enable the incognito mode to hide the plugin from other users. You will also find the white-label settings that you can use to put your own spin on the *%s* plugin to make it your own.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";

    // Settings
    $ai4seo_this_accordion_content .= "<p><b>6.</b> " . __("<b>Settings</b>: Checkout the plugins default-settings listed in the \"Settings\" menu item. Make sure that those settings meet your needs and adjust them accordingly if necessary.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-4.jpg")) . "' style='width: 100%;' />";
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p><b>6.1.</b> " . sprintf(esc_html__("<b>Settings -> Metadata</b>: In this section you can change the settings for the metadata generated by the *%s* plugin. This will affect content types such as pages, posts and products.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";

    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p><b>6.2.</b> " . sprintf(esc_html__("<b>Settings -> Media attributes</b>: In this section you can change the settings for the media attributes generated by the *%s* plugin. This will affect media files.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";

    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p><b>6.3.</b> " . sprintf(esc_html__("<b>Settings -> User Management</b>: Here you can select the user groups that should be able to manage the *%s* plugin.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>6.4.</b> " . __("<b>Settings -> Troubleshooting -> SEO Autopilot (Bulk Generation) Duration</b>: In this section, you can define the duration of a single SEO Autopilot run. Adjusting this setting may help you process your site's content more efficiently in certain cases.", "ai-for-seo") . "</p>";

    // Content tabes
    $ai4seo_this_accordion_content .= "<p><b>7.</b> " . __("<b>Content pages</b>: Inside the plugin you will find menu items for each supported content type (i.e. Page, Post, etc.). Click on any menu item and open the metadata editor by clicking on the button on the right-hand side of an entry.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>8.</b> " . __("<b>Metadata editor</b>: After clicking on the button to open the metadata editor you will find the \"Generate & Overwrite\" button at the top of the editor. Click this button to generate all metadata for the selected content-entry. Additionally you will find the \"Generate with SOOZ\"-button underneath every input field which allows you to generate the metadata for a single metadata input field. After the new data has been generated you can either save the changes as generated or you can edit them if you would like to apply any changes and save afterwards.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-5.jpg")) . "' style='width: 100%;' />";
    $ai4seo_this_accordion_content .= "<p><b>9.</b> " . __("<b>Media page</b>: After clicking on the media menu item you can open the media attribute editor by clicking on the button on the right-hand side of each media-entry.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>10.</b> " . __("<b>Media attribute editor</b>: After clicking on the button to open the media attribute editor you will find the \"Generate & Overwrite\" button at the top of the editor. Click this button to generate all media attributes for the selected media entry. Additionally you will find the \"Generate with SOOZ\"-button underneath every input field which allows you to generate the media attributes for a single attributes input field. After the new data has been generated you can either save the changes as generated or you can edit them if you would like to apply any changes and save afterwards.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-6.jpg")) . "' style='width: 100%;' />";

    // Help & contact
    $ai4seo_this_accordion_content .= "<p><b>11.</b> " . __("<b>Help</b>: You should also check out the \"Help\" page of the plugin. On this page we put together several helpful tips and tutorials for you. In addition you will find some troubleshooting functions as well as ways to get in touch with us.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<p><b>11.1.</b> " . __("<b>Help -> Troubleshooting</b>: In this section you have the option to reset some or all of the plugin date. Please make sure to use these functions with CAUTION. Feel free to reach prior to using these functions if you have any questions about them.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("help-screenshots/first-steps-7.jpg")) . "' style='width: 100%;' />";
    $ai4seo_this_accordion_content .= "<p><b>12.</b> " . __("<b>Contact us</b>: If you have questions, suggestions, need further support or require a specific amount of credits, please contact us via Help > Contact. We typically respond within 8 hours.", "ai-for-seo") . "</p>";

    ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("First steps", "ai-for-seo"), $ai4seo_this_accordion_content));

    // === How to edit specific page or post ===================================================== \\

    // First step: Navigate to the page you want to edit
    $ai4seo_this_accordion_content = "<p><b>1.</b> " . esc_html__("Navigate to the page or post you want to edit. You can do this through the normal editor, using a page builder like Elementor, or by opening the page directly in the frontend.", "ai-for-seo") . "</p>";

    // Second step: Open the "AI for SEO" tool
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p><b>2.</b> " . sprintf(esc_html__("Click on the *%s* button located in the top admin-bar. This will open up the Metadata Editor.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-page-post-1.jpg")) . "' style='width: 100%;' />";

    // Third step: Modify or generate SEO content
    $ai4seo_this_accordion_content .= "<p><b>3.</b> " . esc_html__("Edit existing SEO content or generate new content using our \"Generate with SOOZ\" buttons.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-page-post-2.jpg")) . "' style='width: 100%;' />";

    // Additional information: Alternate way to access the "SEO Metadata Editor"
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p>" . sprintf(esc_html__("<b>Alternatively,</b> you can go to the \"Pages\" or \"Posts\" page within the *%s* plugin. From there, you can browse through your pages and posts, and choose the ones you want to edit.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-page-post-3.jpg")) . "' style='width: 100%;' />";

    ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How to generate or edit SEO-relevant metadata for a specific page or post", "ai-for-seo"), $ai4seo_this_accordion_content));


    // === Hot to edit specific media-entry ====================================================== \\

    // First step: Select the Relevant Section
    $ai4seo_this_accordion_content = "<p><b>1.</b> " . esc_html__("Click on the \"Media\"-link in the main admin-menu of your WordPress-backend", "ai-for-seo") . "</p>";

    // Second step: Activate the Automation Feature
    $ai4seo_this_accordion_content .= "<p><b>2.1</b> " . esc_html__("If your media-page is using the grid view, click on the specific image file for which you would like to add/edit the attributes for.", "ai-for-seo") . "<br />";
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= sprintf(esc_html__("Once the media-modal is opened you will see the *%s*-generate-buttons on the right side above and within the form. Then click on the button to generate the content for each attribute.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";

    $ai4seo_this_accordion_content .= "<p><b>2.2</b> " . esc_html__("If your media-page is using the table view, click on the edit-button which will appear once you hover over the entry of the specific image file for which you would like to add/edit the attributes for.", "ai-for-seo") . "<br />";
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= sprintf(esc_html__("Once the edit-media-page is opened you will see the *%s*-generate-buttons within the form of the page. Then click on the button to generate the content for each attribute.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p>" . sprintf(esc_html__("<b>Alternatively,</b> you can go to the \"Media\" page within the *%s* plugin. From there, you can browse through your media-entries, and choose the ones you want to edit.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";

    ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How to add alt-text, captions, titles and descriptions for media files", "ai-for-seo"), $ai4seo_this_accordion_content));


    // === Bulk generate metadata ======================================================== \\

    // First step: Click the "Set up SEO Autopilot"-button on the plugin dashboard
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content = "<p><b>1.</b> " . sprintf(esc_html__("Click on the \"Set up SEO Autopilot\"-button at the bottom of the \"SEO Autopilot (Bulk Generation)\"-section on the dashboard of the *%s* plugin page. This will open the \"Set up SEO Autopilot\" modal.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-seo-autopilot-1.jpg")) . "' style='width: 100%;' />";

    // Second step: Settings of the SEO Autopilot
    $ai4seo_this_accordion_content .= "<p><b>2.</b> " . esc_html__("Within the \"Set up SEO Autopilot\" modal you can then change the settings of the \"SEO Autopilot (Bulk Generation)\" to fit your needs. When you set everything up to your liking you can simply save the settings by clicking on the \"Update SEO Autopilot\"-button at the bottom of the modal.", "ai-for-seo") . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-seo-autopilot-2.jpg")) . "' style='width: 100%;' />";

    // Third step: Settings of the SEO Autopilot
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content .= "<p><b>3.</b> " . sprintf(esc_html__("If you wish to disable the \"SEO Autopilot\", simply click on the \"Stop SEO Autopilot\"-button at the bottom of the \"SEO Autopilot (Bulk Generation)\"-section on the dashboard of the *%s* plugin page.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
    $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-seo-autopilot-3.jpg")) . "' style='width: 100%;' />";

    ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How to activate bulk generation", "ai-for-seo"), $ai4seo_this_accordion_content));


    // === Credits ======================================================================== \\

    // Prepare the details to the available credits-packs
    $ai4seo_available_credits_packs = array();
    foreach ($ai4seo_credits_packs AS $ai4seo_this_payg_stripe_price_id => $ai4seo_credits_pack_entry) {
        if (isset($ai4seo_credits_pack_entry["credits_amount"])) {
            $ai4seo_available_credits_packs[] = number_format($ai4seo_credits_pack_entry["credits_amount"]);
        }
    }
    $ai4seo_available_credits_packs_string = implode(", ", $ai4seo_available_credits_packs);

    // Explanation of how credits are consumed
    /* translators: %s: plugin name */
    $ai4seo_this_accordion_content = "<p>" . sprintf(esc_html__("Credits are used when *%s* generates metadata for your content (posts, pages, products, media files etc.). The amount of Credits required depends on the selected active meta tags and media attributes (see Settings).", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";

    // Details on credits available with different plans
    $ai4seo_this_accordion_content .= "<p>" . sprintf(
        /* translators: %1$u: number of credits, %2$u: number of daily free credits, %3$u: number of credits */
        __('The <b>free plan</b> provides you with %1$u Credits, allowing you to experiment with AI-generated SEO content without any cost. In addition, we provide you with %2$u free Credits every day if your balance falls below %3$u Credits.', "ai-for-seo"),
        esc_html($ai4seo_free_plan_credits),
        esc_html(AI4SEO_DAILY_FREE_CREDITS_AMOUNT),
        esc_html($ai4seo_free_plan_credits),
    ) . "</p>";
    $ai4seo_this_accordion_content .= "<p>" . sprintf(
        /* translators: %u: number of credits */
        __("With the <b>Basic subscription</b> you receive %u Credits per month: Ideal for smaller websites or blogs.", "ai-for-seo"),
        esc_html($ai4seo_s_plan_credits)
    ) . "</p>";
    $ai4seo_this_accordion_content .= "<p>" . sprintf(
        /* translators: %u: number of credits */
        __("With the <b>Pro subscription</b> you receive %u Credits per month: Ideal for professionals who need more extensive SEO support.", "ai-for-seo"),
        esc_html($ai4seo_m_plan_credits)
    ) . "</p>";
    $ai4seo_this_accordion_content .= "<p>" . sprintf(
        /* translators: %u: number of credits */
        __("With the <b>Premium subscription</b> you receive %u Credits per month: Ideal for businesses that require substantial SEO support and features.", "ai-for-seo"),
        esc_html($ai4seo_l_plan_credits)
    ) . "</p>";
    $ai4seo_this_accordion_content .= "<p>" . sprintf(
        /* translators: %s: available credits packs */
        __("In addition to the subscriptions you can purchase individual <b>Credits Packs</b> to fit your needs perfectly. Credits packs are available in the following sizes: <b>%s</b>", "ai-for-seo"),
        esc_html($ai4seo_available_credits_packs_string)
    ) . "</p>";
    $ai4seo_this_accordion_content .= "<p>" . __("We offer a <strong>Pay-As-You-Go (PAYG)</strong> option which enables you to automatically refill your Credits balance with a custom number of Credits. This way you don't have to worry about purchasing new Credits or ever running out of them. The plugin will automatically purchase Credits for you as soon as you're about to run out.", "ai-for-seo") . "</p>";

    ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How do Credits work?", "ai-for-seo"), $ai4seo_this_accordion_content));


    // === "Yoast SEO" elements ======================================================================== \\

    if (ai4seo_is_plugin_or_theme_active(AI4SEO_THIRD_PARTY_PLUGIN_YOAST_SEO)) {
        // First step: Open the Page or Post
        $ai4seo_this_accordion_content = "<p><b>1.</b> " . esc_html__("Begin by navigating to the page or blog post you want to edit.", "ai-for-seo") . "</p>";

        // Second step: Initiate AI Generation
        $ai4seo_this_accordion_content .= "<p><b>2.</b> " . esc_html__("Click on the \"Generate with SOOZ\" button, which you'll find within the SEO-form.", "ai-for-seo") . "</p>";
        $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-yoast-1.jpg")) . "' style='width: 100%;' />";

        // Third step: Review AI-Generated Description
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= "<p><b>3.</b> " . sprintf(esc_html__("*%s* will generate a SEO-relevant description based on the content of the selected page or blog post. Review this description to ensure it aligns with your content and objectives.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
        $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-yoast-2.jpg")) . "' style='width: 100%;' />";

        // Fourth step: Apply AI-Generated SEO to All Fields
        $ai4seo_this_accordion_content .= "<p><b>4.</b> " . esc_html__("To streamline the process, click the \"AI Generate all SEO\" button. This will apply the AI-generated descriptions to all corresponding input fields, enhancing the SEO across the entire page or post.", "ai-for-seo") . "</p>";
        $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-yoast-3.jpg")) . "' style='width: 100%;' />";

        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Yoast integration", "ai-for-seo"), $ai4seo_this_accordion_content));
    }

    // === Elementor-elements ==================================================================== \\

    if (ai4seo_is_plugin_or_theme_active(AI4SEO_THIRD_PARTY_PLUGIN_ELEMENTOR)) {
        // First step: Open the Elementor Editor
        $ai4seo_this_accordion_content = "<p><b>1.</b> " . esc_html__("Open the page or post you want to edit in Elementor.", "ai-for-seo") . "</p>";

        // Second step: Access the Elementor Sidebar
        $ai4seo_this_accordion_content .= "<p><b>2.</b> " . esc_html__("Click on the cog-icon located in the Elementor top-bar to open the settings of the page or post.", "ai-for-seo") . "</p>";
        $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-elementor-1.jpg")) . "' style='width: 100%;' />";

        // Third step: Open "AI for SEO" layer
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= "<p><b>3.</b> " . sprintf(esc_html__("In the settings section, click on the \"Show all SEO settings\" button to open the *%s* metadata editor. Here, you can adjust the metadata using our AI-driven algorithms.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
        $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-elementor-2.jpg")) . "' style='width: 100%;' />";

        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Elementor integration", "ai-for-seo"), $ai4seo_this_accordion_content));
    }

    // === Be-Builder-elements =================================================================== \\

    if (ai4seo_is_plugin_or_theme_active(AI4SEO_THIRD_PARTY_PLUGIN_BETHEME)) {
        // First step: Open the BeBuilder Editor
        $ai4seo_this_accordion_content = "<p><b>1.</b> " . esc_html__("Open the page or post you want to edit in BeBuilder, the page-building tool within the BeTheme framework.", "ai-for-seo") . "</p>";

        // Second step: Access SEO Section in BeBuilder
        $ai4seo_this_accordion_content .= "<p><b>2.</b> " . esc_html__("Click on the page-options-button on the left side of the BeBuilder navigation, then scroll down to the SEO section. This will display all SEO-related settings for the current page.", "ai-for-seo") . "</p>";

        // Third step: Open "AI for SEO" metadata editor
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= "<p><b>3.</b> " . sprintf(esc_html__("Click on the \"Show all SEO settings\" button within the SEO section to open the *%s* metadata editor. Here, you can access and manipulate metadata using our AI-driven algorithms.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</p>";
        $ai4seo_this_accordion_content .= "<img src='" . esc_url(ai4seo_get_assets_images_url("faq-screenshots/screenshot-be-builder-1.jpg")) . "' style='width: 100%;' />";

        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Be-Builder integration", "ai-for-seo"), $ai4seo_this_accordion_content));
    }
echo "</div>";


// === FAQ =================================================================================== \\

echo "<div class='ai4seo-display-none ai4seo-help-content' id='ai4seo-help-faq'>";
    // Headline
    echo "<h1 id='ai4seo-faq-section'>";
        echo esc_html__("F.A.Q.", "ai-for-seo");
    echo "</h1>";


    // === SEARCH ================================================================================ \\

    // Input for the search
    echo "<div class='ai4seo-help-search-wrapper'>";
        ai4seo_echo_wp_kses(ai4seo_get_svg_tag("magnifying-glass"));
        echo "<input type='text' class='ai4seo-help-search' id='ai4seo-help-search' placeholder='" . esc_attr__("Search F.A.Q. (enter min.3 characters)", "ai-for-seo") . "' />";
    echo "</div>";

    // Container with the message that no entries could be found based on the search-input
    echo "<div class='ai4seo-help-search-notice ai4seo-help-faq-search-notice ai4seo-display-none' id='ai4seo-help-faq-search-notice'>";
        echo "<p>" . esc_html__("No results could be found based on your search. Please try a different search term.", "ai-for-seo") . "</p>";
    echo "</div>";

    echo "<div class='ai4seo-gap'></div>";

    // === GENERAL =============================================================================== \\

    echo "<div class='ai4seo-faq-section-holder'>";
        // Headline
        echo "<h3>" . esc_html__("General", "ai-for-seo") . "</h3>";

        $ai4seo_this_accordion_content = sprintf(
        /* translators: %1$s plugin name, %2$s plugin name */
            esc_html__('*%1$s* is compatible with all major SEO plugins. The metadata generated by *%2$s* can be synchronized with popular plugins such as Yoast SEO, Rank Math, SEOPress, All in One SEO, Slim SEO, SEO Simple Pack, Squirrly SEO, The SEO Framework, and Blog2Social. This ensures your metadata remains up-to-date and seamlessly integrates with your preferred SEO tool.', 'ai-for-seo'),
            esc_html(AI4SEO_PLUGIN_NAME),
            esc_html(AI4SEO_PLUGIN_NAME)
        );
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("Can I use *%s* alongside another SEO plugin?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("To enable synchronization with another SEO plugin:<br><br>1. Navigate to the plugin settings and go to the 'Sync *%s* Changes': section.<br>2. Check the box next to your desired SEO plugin to activate syncing.<br><br>If you're using the SEO Autopilot (Bulk Generation) feature, make sure the relevant meta tags are enabled in the 'Overwrite Existing Metadata (SEO Autopilot Only)': section to replace outdated data within your existing SEO plugin.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));

        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How do I activate the synchronization with another SEO plugin?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s plugin name */
            __('Changes made later in a third-party SEO plugin are not visible because *%1$s* handles the frontend output of your meta tags.<br><br>You have two options:<br>1. Apply your updates in the *%2$s* metadata editor and let them sync to your third-party SEO plugin.<br>2. Go to Settings > Show Advanced Settings > Meta Tag Output Mode and set it to "Complementary".', "ai-for-seo"),
            esc_html(AI4SEO_PLUGIN_NAME),
            esc_html(AI4SEO_PLUGIN_NAME)
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Changes in third-party SEO plugins are not applied. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Providing SEO metadata helps search engines better understand your content, which can lead to higher rankings in search results. This improvement in visibility can drive more clicks, visitors, sales, and leads to your website.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What are the benefits of providing SEO metadata for my website?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Go to Settings > Metadata > Include product price in metadata (available when WooCommerce is active) and choose between 'Never', 'Fixed', or 'Dynamic'. 'Never' omits pricing, 'Fixed' stores the current amount directly in the generated copy, and 'Dynamic' inserts a placeholder that is replaced with the live price during rendering.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I include WooCommerce product prices in generated metadata?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Add placeholders directly to the prefix or suffix fields under Settings > Metadata or Settings > Media Attributes.<br><br>Supported placeholders (case-insensitive): {WEBSITE_URL}, {WEBSITE_NAME}, {POST_ID}, {PRODUCT_NAME}, {PRODUCT_PRICE}, {FILE_NAME}, {FILE_TYPE}, {FILE_SIZE}, {IMAGE_DIMENSIONS}.<br><br>The plugin replaces them automatically when meta tags are injected or when attachment attributes are saved.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I use placeholders in metadata or media prefixes and suffixes?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Open %s > Settings and locate the \"Active Post Types\" checkboxes in the Metadata section. Uncheck any post types you want to hide. The plugin keeps their existing metadata untouched but removes them from the dashboard, menu and SEO Autopilot queues until you re-enable them.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("How do I hide certain post types from the %s dashboard?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Yes. Open %s > Settings and use the checkboxes \"Active Authors\" in the Metadata section or \"Active Media Authors\" in the Media Attributes section. Uncheck any authors you want to exclude. Their existing metadata or media attributes stay untouched, but their posts or media files are removed from the dashboard and the SEO Autopilot until you enable them again.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can I filter pages, posts, products or media files by the author?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Yes. Open %s > Settings and use the \"Active Categories (taxonomy terms)\" checkboxes in the Metadata section. Uncheck any categories you want to exclude. Their existing metadata stays untouched. By default, entries remain included as long as they still have at least one active category assigned, and you can enable the stricter option (advanced setting) to exclude an entry as soon as one disabled category is assigned.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can I filter posts, products or other content by category (taxonomy term)?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Including image metadata helps search engines better interpret your images, potentially boosting your rankings in image search results and the overall quality of your website. In addition, it also shows your commitment to accessibility, catering to a wider audience and complying with accessibility standards.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What are the benefits of providing alt text, titles, captions, and descriptions for images on my website?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you notice that alt text is missing on images, it may be due to your theme or other plugins not properly outputting the alt text stored in the database. In such cases, you can enable the 'Alt Text Injection' setting in the plugin settings. This feature injects alt text directly at the render level, ensuring that images display the correct alt text and improving accessibility and SEO compliance.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What can I do if alt text is missing on images?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("The 'Alt Text Injection' setting ensures that images on your website always display the correct alt text, even when your theme or other plugins fail to properly output the alt text stored in the database. When enabled, *%s* will inject alt text directly at the render level, helping to improve accessibility and SEO compliance. This setting is particularly useful if you experience issues with missing alt text on images due to theme or plugin limitations. It is enabled by default and can be found in the plugin settings.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What is the 'Alt Text Injection' setting and why should I use it?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %s: link to Google Developers blog post */
            __("Currently, Google's stance on the use of AI or automation in content creation is generally permissive, as indicated in a Google Developers blog post from February 2023. They state that appropriate use of AI or automation is not against their guidelines. More information can be found at %s.", "ai-for-seo"),
            "<a target='_blank' href='https://developers.google.com/search/blog/2023/02/google-search-and-ai-content'>https://developers.google.com/search/blog/2023/02/google-search-and-ai-content</a>"
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Is AI-generated SEO-content harmful to my SEO-ranking?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Yes, you can use your existing subscription and Credits Packs on another website. Simply enter the same license holder and the license key on the new website under %s > Account. You can link any number of websites together. All linked websites share the same pool of Credits and various settings. You can even export and import settings between websites using the 'Export/Import Settings' button in the plugin settings.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can I use my already purchased subscription or Credits Packs on another website?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %s: link to contact page */
            __("We are always eager to hear your suggestions and feedback! Feel free to <a href='%s' target='_blank'>contact us</a> with your ideas. We welcome messages in any language.", "ai-for-seo"),
            esc_url(AI4SEO_OFFICIAL_CONTACT_URL)
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can you add feature x, y or z to the plugin?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Yes, the AI tool will generate SEO-relevant data based on the content of the selected page, blog post or media file.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Will the AI tool automatically analyze my content?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("We currently support Elementor, BeTheme (Muffin-Builder / Be-Builder) and the standard editor. We are working on supporting more editors.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What editors are supported?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("We are currently working on fixing this issue. As a workaround, we recommend saving the generated data and reloading the page before applying changes to the generated data.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I can't remove the AI-generated text within the Yoast SEO plugin", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Yes, the plugin does support multi-language websites. The plugin also supports the WPML-plugin through which you can generate metadata and media attributes for all available languages separately.", "ai-for-seo");
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("Does *%s* support multi-language websites?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("The best setup is to use a cronjob outside the WordPress cron system (external cron job, either on your own server or through a third-party service) that runs every minute. This ensures that the SEO Autopilot and scheduled tasks run smoothly without being dependent on WordPress's internal cron system, which may not execute reliably on low-traffic sites.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What is the recommended cron job setting for WordPress?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If possible, switch to a cron job system outside the WordPress cron system (external cron job, either on your own server or through a third-party service) that runs every minute. If this is not an option and you experience slow SEO Autopilot, consider increasing the SEO Autopilot Duration setting (Settings > Troubleshooting > SEO Autopilot Duration) to allow more processing time per batch.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I use WordPress’s internal cron system (WP-Cron). What should I consider?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If your external cron job runs less frequently than once per minute, we recommend increasing the <strong>SEO Autopilot Duration</strong> setting (Settings > Troubleshooting > SEO Autopilot Duration). This allows each cycle to handle more tasks at once, compensating for the lower execution frequency.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I use an external cron job system, but I can only run the cron job every 2+ minutes or less frequently. What should I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("By default, the SEO Autopilot skips entries with a complete set of metadata or media attributes, assuming they are optimized.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("If you want to regenerate metadata or media attributes even for entries that are marked as complete:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __('Enable "Include Complete Entries When Overwriting (SEO Autopilot Only)" in the Metadata section.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __('Enable "Include Complete Entries When Overwriting (SEO Autopilot Only)" in the Media Attributes section.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("You can find these options in the plugin settings. This will force the SEO Autopilot to overwrite all existing metadata and media attributes, even if they are already set.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("The SEO Autopilot ignored some entries or marked them as already completed. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you notice outdated data appearing while generating metadata or media attributes, try the following steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("1. Reset Cache – This will clear stored data and force the plugin to create new temporary data (cache)..", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. If the issue persists, Reset Environmental Variables – This can help resolve cases where incorrect internal values are affecting data processing.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("You can find both options under Help > Troubleshooting > Reset Plugin.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I see old data in the plugin while generating metadata or media attributes. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you want to revert the plugin settings to their default state: Use the Reset Settings option under Help > Troubleshooting > Reset Plugin. This will restore all settings to their original values but will not delete generated metadata or media attributes.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I reset the plugin settings to their default values?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you want to fully remove all generated metadata and plugin data before uninstalling:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("1. Go to Help > Troubleshooting > Reset Plugin and select every checkbox.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. Deactivate and uninstall the plugin.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("Note: Media Attributes and synced metadata (to third-party SEO plugins) cannot be removed or undone by the reset. You will need to manually update or remove them in their respective editors.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I want to uninstall the plugin and remove all generated data. How can I do this?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s plugin name, %3$s plugin name */
            esc_html__('It depends on how the metadata is stored and used. If *%1$s* has synchronized the generated metadata with a third-party SEO plugin like Yoast SEO, Rank Math, SEOPress, or similar, then the metadata will remain even after uninstalling *%2$s*. You can check and enable synchronization in your *%3$s* settings.', 'ai-for-seo'),
            esc_html(AI4SEO_PLUGIN_NAME),
            esc_html(AI4SEO_PLUGIN_NAME),
            esc_html(AI4SEO_PLUGIN_NAME)
        ) . "<br /><br />";

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= sprintf(esc_html__("However, if synchronization was not enabled, and *%s* was solely responsible for outputting meta tags on your site, then those tags will no longer be generated once the plugin is deactivated or uninstalled.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Will all the generated texts disappear if I uninstall the plugin?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you generated metadata or media attributes with incorrect settings, follow these steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __('1. Use "Reset Generated Data" under Help > Troubleshooting > Reset Plugin to remove all generated metadata. Media files are marked as "not generated" and can be reprocessed again.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __('2. If the generated metadata was already synced with a third-party SEO plugin, consider enabling: "Include Complete Entries When Overwriting (SEO Autopilot Only)" in the Metadata section.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __('3. If you generated media attributes, consider enabling: "Include Complete Entries When Overwriting (SEO Autopilot Only)" in the Media Attributes section.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("These settings will allow the plugin to regenerate and overwrite metadata and media attributes, even for entries that were previously marked as complete.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I used the wrong settings for manual or bulk generation (e.g., wrong language or missing sync with other SEO plugins). What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content  = __("Enable \"Pause pages and media files analysis\" under Help > Troubleshooting.", "ai-for-seo");
        $ai4seo_this_accordion_content .= "<br /><br />" . __("Switch the setting off after debugging to resume normal data analysis.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I run into performance while pages and media files are being analyzed. How can I pause the analysis?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("To import all images from the NextGen Gallery into *%s*, click the Import button in the Media section. Once imported, you can generate alt text, titles, captions, and descriptions for these images using the plugin. All changes will automatically sync with the NextGen Gallery plugin.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I use the NextGen Gallery plugin — how do I generate media attributes for my images?", "ai-for-seo"), $ai4seo_this_accordion_content));


        // === FAQ: Alt Text Injection not visible ================================== \\

        $ai4seo_this_accordion_content  = __( 'If you generated alt text but it does not appear on the front page, try:', 'ai-for-seo' ) . '<br /><br />';
        $ai4seo_this_accordion_content .= __( '1. Go to Settings > Show Advanced Settings > Troubleshooting. Enable "Alt Text Injection", save, then check again.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '2. Optionally enable "Image Title Injection" to add a tooltip on hover.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '3. Clear caches (plugin/theme cache, page cache, CDN) so updated attributes render on cached pages.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '4. Ensure images are real <img> tags. Background images set via CSS cannot have alt text.', 'ai-for-seo' );

        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                '> ' . esc_html__( 'I do not see generated alt text on the front page. What can I do?', 'ai-for-seo' ),
                $ai4seo_this_accordion_content
            )
        );


        // === FAQ: Image Upload Method = Data ====================================== \\

        $ai4seo_this_accordion_content  = __( 'If you see errors while generating alt text or other media attributes, switch the upload method:', 'ai-for-seo' ) . '<br /><br />';
        $ai4seo_this_accordion_content .= __( '1. Go to Settings > Show Advanced Settings > Troubleshooting. Set "Image Upload Method" to "Data".', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '2. Save settings and retry generation (Alt Text, Title, Caption).', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '3. Why this helps: Some CDNs, firewalls, or hosts (e.g., Cloudflare, signed URLs, private media paths) block direct URL fetching. "Data" sends the image bytes instead of a public URL and is often more reliable.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '4. If issues persist, clear all caches and confirm the image is a real <img> tag, not a CSS background.', 'ai-for-seo' );

        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                '> ' . esc_html__( 'Generating alt text fails. Should I switch "Image Upload Method" to "Data"?', 'ai-for-seo' ),
                $ai4seo_this_accordion_content
            )
        );

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content  = sprintf(esc_html__("Yes, you can use *%s* on staging or local development sites.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                /* translators: %s: plugin name */
                '> ' . sprintf(esc_html__("Can I use *%s* on a staging or local development site?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)),
                $ai4seo_this_accordion_content
            )
        );

        // === FAQ: Generated metadata is not visible on the frontend =============================================== \\

        $ai4seo_this_accordion_content = __("If generated metadata does not appear on the frontend, try the following steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("1. If you use a caching plugin (e.g., WP Rocket, W3 Total Cache, etc.), enable \"Purge caches after saving metadata\" under Settings > Show Advanced Settings > Frontend Cache Purge, then save settings and test again.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. If you do not use a caching plugin or the issue persists, please contact our support team for further assistance.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Generated metadata is not visible on the frontend. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

    echo "</div>";

    echo "<div class='ai4seo-gap'></div>";


    // === AUTOMATION ============================================================================ \\

    echo "<div class='ai4seo-faq-section-holder'>";
        // Headline
        echo "<h3>" . esc_html__("Automation", "ai-for-seo") . "</h3>";

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("You can automate the generation of metadata by selecting the desired content type within the 'Set up SEO Autopilot' modal. This modal can be accessed by clicking the 'Set up SEO Autopilot'-button within the 'SEO Autopilot (Bulk Generation)'-section on the *%s* dashboard of your WordPress website.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I automate the process of generating metadata for my website?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("You can automate the generation of alt text, titles, captions, and descriptions for images by selecting 'Media files' within the 'Set up SEO Autopilot' modal. This modal can be accessed by clicking the 'Set up SEO Autopilot'-button within the 'SEO Autopilot (Bulk Generation)'-section on the *%s* dashboard of your WordPress website.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I automate the process of generating alt text, titles, captions, and descriptions for images on my website?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s plugin name */
            esc_html__('Yes, simply deactivate the checkbox next to the desired content type within the "Set up SEO Autopilot" modal. This modal can be accessed by clicking the "Set up SEO Autopilot"-button within the "SEO Autopilot (Bulk Generation)"-section on the *%1$s* dashboard of your WordPress website. If you would like to disable the automation for every content type entirely you can click the "Stop SEO Autopilot" button within the "SEO Autopilot (Bulk Generation)"-section on the *%2$s* dashboard of your WordPress website.', 'ai-for-seo'),
            esc_html(AI4SEO_PLUGIN_NAME),
            esc_html(AI4SEO_PLUGIN_NAME)
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can I turn off the automation feature after I've activated it?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Yes! You can decide exactly how the SEO Autopilot behaves. By default, the plugin automatically generates metadata and media attributes for both new and existing content. However, you can customize this behavior using three options:<br>• New and existing entries<br>• New entries only<br>• Existing entries only<br><br>You can change these settings anytime in the <strong>Set up SEO Autopilot</strong> modal. Just click the <strong>Set up SEO Autopilot</strong> button in the <strong>SEO Autopilot (Bulk Generation)</strong> section of your *%s* dashboard.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Does the SEO Autopilot (bulk generation) feature work for new content?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Not by default. However, you can enable the 'Overwrite Existing Metadata (SEO Autopilot Only)'-option in the settings if needed.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Will the SEO Autopilot (bulk generation) feature affect existing data (meta-title, meta-description, etc.)?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Yes, in the 'Active Meta Tags'-section of the settings, you can choose to include or exclude specific meta tags from the header output generated by our plugin. This gives you full control to customize the meta tags based on your specific requirements.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Is there any way to control what meta tags are outputted?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Yes, *%s* lets you decide which media attributes (like 'alt text' or 'title') should be generated. You can configure this in the 'Active Media Attributes:' section of the settings to match your content needs. Simply select the desired attributes and the SEO Autopilot will generate the data accordingly.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can I choose which media attributes the plugin should generate?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("You can find the 'Retry all failed' button in any content pages (e.g. Pages, Posts or media) and on your %s dashboard. This allows you to retry all failed metadata generations with a single click, saving you time and effort. Please note that this button will only be displayed if at least one error has occurred.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I retry all failed metadata generations with just one click?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("We use WordPress's internal task scheduler to manage automatic generation efficiently. This helps prevent overloading your server with too many simultaneous tasks.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("If you see a 'Pending' status in the 'SEO coverage' column, it means one of two things:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("1. The plugin is waiting for the next scheduled task to run (typically within 1-5 minutes).", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. The plugin is currently generating data for other entries.", "ai-for-seo") . "<br /><br />";
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= sprintf(esc_html__("You can check the *%s* dashboard to see if any generation is in progress for other items. If many items are pending, it may take longer to process them all.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "<br /><br />";
        $ai4seo_this_accordion_content .= __("Rest assured, the plugin will automatically generate data for all pending items over time. If you need immediate results, you can use the manual generation option for specific items.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Why is the automatic metadata or media attributes generation pending?", "ai-for-seo"), $ai4seo_this_accordion_content));

    echo "</div>";

    echo "<div class='ai4seo-gap'></div>";


    // === NAVIGATION ============================================================================ \\

    echo "<div class='ai4seo-faq-section-holder'>";
        // Headline
        echo "<h3>" . esc_html__("Navigation", "ai-for-seo") . "</h3>";

        $ai4seo_this_accordion_content = __("You can navigate to the page or post you want to edit through the normal editor, using a page builder like Elementor, or by opening the page directly in the frontend.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How do I navigate to the page I want to edit for SEO?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("You can find the *%s* button in the top admin-bar. Clicking on this will open up the metadata editor where you can modify or generate metadata.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("Where is the *%s* metadata editor located?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("After opening the *%s* metadata editor, you can either edit the existing metadata manually or generate new metadata using the 'Generate with SOOZ' buttons.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I generate or edit metadata?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Yes, alternatively, you can go to the 'Pages' or 'Posts' page within the *%s* plugin. From there, you can browse through your pages and posts, and choose the ones you want to edit.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("Is there an alternate way to access *%s*'s Metadata Editor?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("1. Open the page or post you want to edit in Elementor.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. Click the settings button (cog icon) at the top of the Elementor header to reveal the page or post settings.", "ai-for-seo") . "<br />";
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= sprintf(esc_html__("3. In the settings section, click on the 'Show all SEO settings' button to open the *%s* metadata editor. Here, you can adjust the metadata manually or generate new metadata using AI-driven algorithms.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("How do I edit metadata in Elementor with *%s*?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("1. Open the page or post you want to edit in BeBuilder, the page-building tool within the BeTheme framework.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. Click on the page-options-button on the left side of the BeBuilder navigation, then scroll down to the SEO section.", "ai-for-seo") . "<br />";
        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content .= sprintf(esc_html__("3. Click on the 'Show all SEO settings' button within the SEO section to open the *%s* metadata editor. Here, you can access and manipulate the metadata using AI-driven algorithms.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("How do I edit SEO settings in BeBuilder with *%s*?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        // === FAQ: Cannot access plugin due to incognito mode restriction ================= \\

        $ai4seo_account_settings_url = ai4seo_get_subpage_url("account", array("ai4seo_debug_bypass_incognito_mode" => "true"));

        $ai4seo_this_accordion_content = __("If you cannot access the plugin due to incognito mode restriction, follow these steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %s: link to account settings */
            __("1. Click %s to temporarily bypass the incognito mode restriction.", "ai-for-seo") . "<br />",
            "<a href='" . esc_url($ai4seo_account_settings_url) . "'>" . esc_html__("here", "ai-for-seo") . "</a>"
        );
        $ai4seo_this_accordion_content .= __("2. Disable incognito mode and save your settings.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("3. If needed, you may enable incognito mode again after saving.", "ai-for-seo");

        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I cannot access the plugin due to incognito mode restriction. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));
    echo "</div>";

    echo "<div class='ai4seo-gap'></div>";


    // === PLANS / SUBSCRIPTIONS ================================================================= \\

    echo "<div class='ai4seo-faq-section-holder'>";
        // Headline
        echo "<h3>" . esc_html__("Plans / Subscriptions", "ai-for-seo") . "</h3>";

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$u: daily free credits, %2$u: free plan credits */
            __('The free plan renews on a daily basis. You will receive %1$u free Credits every day if your balance falls below %2$u Credits, allowing you to continue using the basic features of the plugin at no cost.', "ai-for-seo"),
            esc_html(AI4SEO_DAILY_FREE_CREDITS_AMOUNT),
            esc_html($ai4seo_free_plan_credits),
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Are Credits renewed in the Free plan?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("You don't need to do anything—they'll be automatically added to your account every day if your balance falls below 100 Credits. Just make sure the plugin remains active on your website.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("What do I need to do to receive the free daily Credits?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Yes, you'll continue to receive the free daily Credits even if you're on a paid subscription if your balance falls below 100 Credits. These Credits are in addition to those included in your subscription.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Will I still receive the free daily Credits if I'm on a paid subscription?", "ai-for-seo"), $ai4seo_this_accordion_content));

        /* translators: %s: plugin name */
        $ai4seo_this_accordion_content = sprintf(esc_html__("Credits are used when *%s* generates metadata for your content (posts, pages, products, media files etc.). The amount of Credits required depends on the selected active meta tags and media attributes (see Settings).", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "<br /><br />";
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("How are Credits consumed in the *%s* plugin?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$u: free plan credits, %2$u: daily free credits, %3$u: free plan credits */
            __('Yes, the free plan provides you with %1$u Credits, allowing you to experiment with AI-generated SEO content without any cost. In addition, we provide you with %2$u free Credits every day if your balance falls below %3$u Credits. However it does not include advanced features available in paid subscriptions.', "ai-for-seo"),
            esc_html($ai4seo_free_plan_credits),
            esc_html(AI4SEO_DAILY_FREE_CREDITS_AMOUNT),
            esc_html($ai4seo_free_plan_credits),
        );
        /* translators: %s: plugin name */
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . sprintf(esc_html__("Can I try the *%s* plugin without purchasing a subscription?", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$u: s plan credits, %2$u: s plan credits */
            "- " . __('The Basic subscription grants you %1$u Credits per month, suitable for smaller websites or blogs. It covers approximately %2$u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. Existing data can be used as reference for new data generations.', "ai-for-seo") . "<br />",
            esc_html($ai4seo_s_plan_credits),
            esc_html($ai4seo_s_plan_credits),
        );
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %1$u: m plan credits, %2$u: m plan credits */
            "- " . __('The Pro subscription grants you %1$u Credits per month, designed for professionals who need more extensive SEO capabilities. It covers approximately %2$u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. It also features improved entity recognition in images.', "ai-for-seo") . "<br />",
            esc_html($ai4seo_m_plan_credits),
            esc_html($ai4seo_m_plan_credits),
        );
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %1$u: l plan credits, %2$u: l plan credits */
            "- " . __('The Premium subscription grants you %1$u Credits per month, ideal for businesses that require substantial SEO support and features. It covers approximately %2$u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. It also features improved entity and celebrity face recognition in images.', "ai-for-seo"),
            esc_html($ai4seo_l_plan_credits),
            esc_html($ai4seo_l_plan_credits),
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How many Credits do I get with the Basic, Pro, and Premium subscriptions?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("You should choose a subscription based on the number of Credits and additional features you need for generating SEO content:", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %u: free plan credits */
            "- " . __("The free plan is great for experimentation. It covers approximately %u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. However it does not include advanced features available in paid subscriptions.", "ai-for-seo") . "<br />",
            esc_html($ai4seo_free_plan_credits),
        );
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %u: s plan credits */
            "- " . __("The Basic subscription is suitable for smaller websites or blogs. It covers approximately %u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. Existing data can be used as reference for new data generations.", "ai-for-seo") . "<br />",
            esc_html($ai4seo_s_plan_credits),
        );
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %u: m plan credits */
            "- " . __("The Pro subscription is designed for professionals who need more extensive SEO capabilities. It covers approximately %u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. It also features improved entity recognition in images.", "ai-for-seo") . "<br />",
            esc_html($ai4seo_m_plan_credits),
        );
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %u: l plan credits */
            "- " . __("The Premium subscription is ideal for businesses that require substantial SEO support and features. It covers approximately %u focus keyphrases, meta tags, or image attributes per month, depending on your selected settings. It also features improved entity and celebrity face recognition in images.", "ai-for-seo") . "<br />",
            esc_html($ai4seo_l_plan_credits),
        );
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %1$s: contact link, %2$s: discount percentage */
            "- " . __('If you have a shop with many products or a large blog, we’d love to help! <a href="%1$s" target="_blank">Contact us now</a> to discuss a custom plan tailored specifically to your needs. Messages in any language are welcome! We are currently offering a %2$s discount on all custom plans.', "ai-for-seo"),
            esc_html(AI4SEO_OFFICIAL_CONTACT_URL),
            esc_html(AI4SEO_CUSTOM_PLAN_DISCOUNT) . "%",
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How do I choose the right subscription for my needs?", "ai-for-seo"), $ai4seo_this_accordion_content));

        // lost key content
        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s lost license data text in bold */
            __('Go to %1$s > Account, click %2$s, then follow the on-screen steps.', "ai-for-seo"),
            esc_html(AI4SEO_PLUGIN_NAME),
            "<strong>" . esc_html__("Lost your license data?", "ai-for-seo") . "</strong>",
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element(
            "> " . esc_html__("What should I do if I lose my license key?", "ai-for-seo"),
            $ai4seo_this_accordion_content
        ));

        // login / customer portal
        $ai4seo_this_accordion_content = sprintf(
            /* translators: %s: plugin name */
            __('We currently do not offer a separate customer portal. All account-related actions, including subscription and payment management, can be accessed through the WordPress plugin. You can find the relevant links in your WordPress admin area under "$s" > "Account".', 'ai-for-seo'),
            esc_html(AI4SEO_PLUGIN_NAME),
        );

        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                sprintf(
                    /* translators: %s: plugin name */
                    '> ' . esc_html__( 'Where can I log in to my %s account / customer portal?', 'ai-for-seo' ),
                    esc_html(AI4SEO_PLUGIN_NAME),
                ),
                $ai4seo_this_accordion_content
            )
        );

        // invoices
        $ai4seo_this_accordion_content = sprintf(
            /* translators: %s: plugin name */
            __('A download link for your invoice is included in the confirmation email sent after each purchase. If you currently have an active subscription, you can also access and download your invoices through the WordPress plugin under "%s" > "Account" > "Manage Subscription / Invoices".', 'ai-for-seo'),
            esc_html(AI4SEO_PLUGIN_NAME),
        );

        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                '> ' . esc_html__( 'Where can I download my invoice?', 'ai-for-seo' ),
                $ai4seo_this_accordion_content
            )
        );


        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s cancel plan link */
            __('You can change or cancel your subscription at any time by going to the *%1$s* dashboard and clicking the <strong>Get more Credits</strong> button in the <strong>Credits</strong> section. In the <strong>How to get more Credits</strong> modal, click the <strong>Manage subscription</strong> button in the <strong>Subscription</strong> section. Alternatively, you can manage your subscription directly at this link: %2$s.', 'ai-for-seo') . "<br />",
            esc_html(AI4SEO_PLUGIN_NAME),
            "<a target='_blank' href='" . esc_html(AI4SEO_OFFICIAL_WEBSITE) . "/cancel-plan'>" . esc_html(AI4SEO_OFFICIAL_WEBSITE) . "/cancel-plan</a>",
        );
        $ai4seo_this_accordion_content .= __("You'll be redirected to Stripe, our invoice partner. Please follow the instructions on the Stripe website to change or cancel your subscription.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How do I change or cancel my subscription?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s stripe billing url */
            __('You can change or cancel your subscription at any time by going to the *%1$s* dashboard and clicking the <strong>Get more Credits</strong> button in the <strong>Credits</strong> section. In the <strong>How to get more Credits</strong> modal, click the <strong>Manage subscription</strong> button in the <strong>Subscription</strong> section. Alternatively, you can manage your subscription directly at this link: %2$s.', 'ai-for-seo') . "<br />",
            esc_html(AI4SEO_PLUGIN_NAME),
            "<a target='_blank' href='" . esc_html(AI4SEO_STRIPE_BILLING_URL) . "'>" . esc_html(AI4SEO_STRIPE_BILLING_URL) . "</a>",
        );
        $ai4seo_this_accordion_content .= __("You'll be redirected to Stripe, our invoice partner. Please follow the instructions on the Stripe website to change your subscription.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Can I upgrade or downgrade my subscription?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("No, any unused Credits will roll over to the next month, allowing you to fully utilize your Credits without losing them at the end of each billing cycle.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Do unused Credits expire at the end of the month?", "ai-for-seo"), $ai4seo_this_accordion_content));
    echo "</div>";
echo "</div>";


// === CONTACT FORM ========================================================================== \\

echo "<div class='ai4seo-display-none ai4seo-help-content' id='ai4seo-help-contact'>";
    // Headline
    echo "<h1 id='ai4seo-contact-section'>";
        echo esc_html__("Contact the makers of this plugin", "ai-for-seo");
    echo "</h1>";

    // Description
    echo "<p>";
        echo esc_html__("You can contact us (Space Codes) directly through this page, and we will respond to the email address you provide.", "ai-for-seo");
    echo "</p>";

    // Form
    echo "<form method='post' class='ai4seo-form ai4seo-contact-form' id='ai4seo-contact-form' name='ai4seo-contact-form'>";

        // Nonce
        wp_nonce_field('ai4seo-contact-form', 'ai4seo-contact-form-nonce');

        // Name
        echo "<div class='ai4seo-form-item'>";
            echo "<label for='ai4seo-contact-form-name'>" . esc_html__("Your name", "ai-for-seo") . ":</label>";
            echo "<div class='ai4seo-form-item-input-wrapper'>";
                echo "<input type='text' class='ai4seo-editor-textfield' id='ai4seo-contact-form-name' name='ai4seo-contact-form-name' placeholder='" . esc_attr__("Your name", "ai-for-seo") . "' value='' required />";
            echo "</div>";
        echo "</div>";

        // get default email address
        $ai4seo_default_email = sanitize_email(ai4seo_get_option('admin_email'));

        // Email
        echo "<div class='ai4seo-form-item'>";
            echo "<label for='ai4seo-contact-form-email'>" . esc_html__("Email", "ai-for-seo") . ":</label>";
            echo "<div class='ai4seo-form-item-input-wrapper'>";
                echo "<input type='email' class='ai4seo-editor-textfield' id='ai4seo-contact-form-email' name='ai4seo-contact-form-email' placeholder='" . esc_attr("example@page.com") . "' value='" . esc_attr($ai4seo_default_email) . "' required />";
            echo "</div>";
        echo "</div>";

        // Subject
        echo "<div class='ai4seo-form-item'>";
            echo "<label for='ai4seo-contact-form-subject'>" . esc_html__("Subject", "ai-for-seo") . ":</label>";
            echo "<div class='ai4seo-form-item-input-wrapper'>";
                echo "<select class='ai4seo-editor-select' name='ai4seo-contact-form-subject' id='ai4seo-contact-form-subject' required>";
                    foreach ($ai4seo_contact_subject_options as $ai4seo_this_option_key => $ai4seo_this_option_value) {
                        echo "<option value='" . esc_attr($ai4seo_this_option_key) . "'>" . esc_attr($ai4seo_this_option_value) . "</option>";
                    }
                echo "</select>";
            echo "</div>";
        echo "</div>";

        // Message
        echo "<div class='ai4seo-form-item'>";
            echo "<label for='ai4seo-contact-form-message'>" . esc_html__("Message", "ai-for-seo") . ":</label>";
            echo "<div class='ai4seo-form-item-input-wrapper'>";
                echo "<textarea class='ai4seo-editor-textarea' id='ai4seo-contact-form-message' name='ai4seo-contact-form-message' required></textarea>";
            echo "</div>";
        echo "</div>";

        // Submit button
        submit_button(esc_attr__("Send us an email", "ai-for-seo"), "primary", "ai4seo-contact-form-submit");
    echo "</form>";
echo "</div>";


// ___________________________________________________________________________________________ \\
// === TROUBLESHOOTING ====================================================================== \\
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ \\

$ai4seo_bulk_generation_duration = (int) ai4seo_get_setting(AI4SEO_SETTING_BULK_GENERATION_DURATION);
$ai4seo_disable_heavy_db_operations_input_name = ai4seo_get_prefixed_input_name(AI4SEO_SETTING_DISABLE_HEAVY_DB_OPERATIONS);
$ai4seo_disable_heavy_db_operations_value = (bool) ai4seo_get_setting(AI4SEO_SETTING_DISABLE_HEAVY_DB_OPERATIONS);
$ai4seo_debug_output_mode_input_name = ai4seo_get_prefixed_input_name(AI4SEO_SETTING_DEBUG_OUTPUT_MODE);
$ai4seo_debug_output_mode_value = ai4seo_get_setting(AI4SEO_SETTING_DEBUG_OUTPUT_MODE);
$ai4seo_debug_output_mode_options = ai4seo_get_debug_output_mode_options();
$ai4seo_debug_message_entries = get_option(AI4SEO_DEBUG_MESSAGES_OPTION_NAME, array());

if (!is_array($ai4seo_debug_message_entries)) {
    $ai4seo_debug_message_entries = array();
}

echo "<div class='ai4seo-display-none ai4seo-help-content' id='ai4seo-help-troubleshooting'>";
    // Headline
    echo "<h1 id='ai4seo-troubleshooting-section'>";
        echo esc_html__("Troubleshooting", "ai-for-seo");
    echo "</h1>";

    // WARNING
    echo esc_html__("ATTENTION: The following tools are for advanced users only or if you are advised to use them by our support team.", "ai-for-seo");
    echo "<div class='ai4seo-gap'></div>";


    // === DEBUGGING TOOLS ================================================================================= \\

    echo "<div class='ai4seo-form ai4seo-unsaved-changes-warnings'>";
        echo "<div class='card ai4seo-form-section ai4seo-troubleshooting-settings-card'>";
            // Headline
            echo "<h2>";
                echo '<i class="dashicons dashicons-sos"></i>';
                echo esc_html__("Debugging tools", "ai-for-seo");
            echo "</h2>";

            echo "<div class='ai4seo-form-item'>";
                echo "<label for='" . esc_attr($ai4seo_disable_heavy_db_operations_input_name) . "'>";
                    echo esc_html__("Deactivate heavy database operations:", "ai-for-seo");
                echo "</label>";

                echo "<div class='ai4seo-form-item-input-wrapper'>";
                    echo "<label for='" . esc_attr($ai4seo_disable_heavy_db_operations_input_name) . "'>";
                        echo "<input type='checkbox' id='" . esc_attr($ai4seo_disable_heavy_db_operations_input_name) . "' name='" . esc_attr($ai4seo_disable_heavy_db_operations_input_name) . "' value='1' class='ai4seo-single-checkbox ai4seo-lockable'" . ($ai4seo_disable_heavy_db_operations_value ? " checked='checked'" : "") . "/> ";
                        echo esc_html__("Pause pages and media files analysis", "ai-for-seo");
                    echo "</label>";

                    $ai4seo_disable_heavy_db_operations_description = __("Temporarily stop heavy database refresh operations to reduce load. Coverage statistics and summaries will stop updating, and the plugin shows a warning until you turn this off again.", "ai-for-seo");
                    $ai4seo_disable_heavy_db_operations_description .= "<br /><br />" . __("Only enable this when investigating issues and disable it afterwards so data stays up to date.", "ai-for-seo");

                    echo "<p class='ai4seo-form-item-description'>";
                        ai4seo_echo_wp_kses($ai4seo_disable_heavy_db_operations_description);
                    echo "</p>";
                echo "</div>";
            echo "</div>";

            // Divider
            echo "<hr class='ai4seo-form-item-divider'>";

            echo "<div class='ai4seo-form-item'>";
                echo "<label for='" . esc_attr($ai4seo_debug_output_mode_input_name) . "'>";
                    echo esc_html__("Preferred debug output:", "ai-for-seo");
                echo "</label>";

                echo "<div class='ai4seo-form-item-input-wrapper'>";
                    echo "<select class='ai4seo-editor-select ai4seo-lockable' id='" . esc_attr($ai4seo_debug_output_mode_input_name) . "' name='" . esc_attr($ai4seo_debug_output_mode_input_name) . "'>";
                        foreach ($ai4seo_debug_output_mode_options as $ai4seo_this_output_mode_value => $ai4seo_this_output_mode_label) {
                            echo "<option value='" . esc_attr($ai4seo_this_output_mode_value) . "'" . selected($ai4seo_debug_output_mode_value, $ai4seo_this_output_mode_value, false) . ">" . esc_html($ai4seo_this_output_mode_label) . "</option>";
                        }
                    echo "</select>";

                    /* translators: %s: plugin name */
                    $ai4seo_debug_output_mode_description = sprintf(__("Choose how %s delivers diagnostics: disable output, send to the PHP/WP debug log (PHP default error_log or wp-content/debug.log when WP_DEBUG_LOG is enabled), append to <code>wp-content/uploads/ai-for-seo-debug.log</code>, store up to 1000 entries in the database, display a admin notice, or print a formatted block on the page. Notice and print outputs only appear for users who can manage this plugin.", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME));

                    echo "<p class='ai4seo-form-item-description'>";
                        ai4seo_echo_wp_kses($ai4seo_debug_output_mode_description);
                    echo "</p>";
                echo "</div>";
            echo "</div>";
        echo "</div>";

        ai4seo_echo_wp_kses(ai4seo_get_submit_button_tag(esc_html__("Save troubleshooting settings", "ai-for-seo"), "ai4seo-start-inactive ai4seo-lockable", "ai4seo_save_anything(jQuery(this), ai4seo_validate_troubleshooting_settings);"));
    echo "</div>";


    // === DEBUG MESSAGE LOG ================================================================================= \\

    $ai4seo_debug_messages_container_for_clipboard = array();

    echo "<div class='card ai4seo-form-section ai4seo-troubleshooting-settings-card'>";
        echo "<h2>";
            echo '<i class="dashicons dashicons-media-text"></i>';
            echo esc_html__("Debug message log", "ai-for-seo");
        echo "</h2>";

        echo "<div id='ai4seo-debug-message-log-entries' style='max-height: 240px; overflow: auto; padding: 0 1.5rem 1rem 1.5rem; max-width: 100%; white-space: pre-wrap;'>";
            if (empty($ai4seo_debug_message_entries)) {
                    echo "<p style='margin: 0;'>" . esc_html__("No debug messages recorded yet. Entries stored with \"Store in the database\" will appear here.", "ai-for-seo") . "</p>";
            } else {
                foreach ($ai4seo_debug_message_entries as $ai4seo_this_debug_entry) {
                    $ai4seo_this_time = $ai4seo_this_debug_entry['time'] && is_int($ai4seo_this_debug_entry['time']) ? date_i18n('Y-m-d H:i:s', $ai4seo_this_debug_entry['time']) : '???';
                    $ai4seo_this_code = (int) ($ai4seo_this_debug_entry['code'] ?? 2123126);
                    $ai4seo_this_message = $ai4seo_this_debug_entry['message'] ?? esc_html__("No message", "ai-for-seo");
                    $ai4seo_this_backtrace = $ai4seo_this_debug_entry['backtrace'] ?? '';
                    $ai4seo_no_br_backtrace = '';

                    ai4seo_echo_wp_kses("> <strong>[" . $ai4seo_this_time . "]</strong> " . $ai4seo_this_message . " Code: #" . $ai4seo_this_code);

                    if ($ai4seo_this_backtrace) {
                        ai4seo_echo_wp_kses("<br />" . $ai4seo_this_backtrace);
                        $ai4seo_no_br_backtrace = str_replace(array("\n", "\r", "<br>", "<br />"), ' > ', $ai4seo_this_backtrace);
                    }

                    $ai4seo_debug_messages_container_for_clipboard[] = "[" . $ai4seo_this_time . "] " . $ai4seo_this_message . " Code: #" . $ai4seo_this_code . ($ai4seo_no_br_backtrace ? ". Backtrace: " . esc_html($ai4seo_no_br_backtrace) : "");

                    echo "<div class='ai4seo-medium-gap'></div>";
                }
            }
        echo "</div>";
    echo "</div>";

    echo "<div class='ai4seo-buttons-wrapper ai4seo-help-debug-log-buttons'>";
        if (!empty($ai4seo_debug_message_entries)) {

            // copy to clipboard button
            echo "<button type='button' class='ai4seo-button ai4seo-copy-to-clipboard ai4seo-debug-log-copy-button' data-clipboard-text='" . esc_attr(implode("\n", $ai4seo_debug_messages_container_for_clipboard)) . "' title='" . esc_attr__("Copy debug log to clipboard", "ai-for-seo") . "'>";
                ai4seo_echo_wp_kses(ai4seo_get_svg_tag("copy") . " " . esc_html__("Copy debug log to clipboard", "ai-for-seo"));
                echo " <span style='float: right' class='ai4seo-debug-log-copy-to-clipboard-tooltip ai4seo-copied-to-clipboard' style='display: none'>👍 " . esc_html__("Copied!", "ai-for-seo") . "</span>";
            echo "</button>";

            // clear log button
            echo "<button type='button' class='ai4seo-button ai4seo-abort-button ai4seo-clear-debug-log-button ai4seo-lockable' title='" . esc_attr__("Clear debug log", "ai-for-seo") . "'>";
                ai4seo_echo_wp_kses(ai4seo_get_svg_tag("circle-xmark") . " " . esc_html__("Clear log", "ai-for-seo"));
            echo "</button>";

        }
    echo "</div>";

    echo "<div class='ai4seo-large-gap'></div>";


    // === RESET PLUGIN ======================================================================== \\

    echo "<div class='ai4seo-form ai4seo-unsaved-changes-warnings'>";
        echo "<div class='card ai4seo-form-section ai4seo-troubleshooting-settings-card'>";

            // Headline
            echo "<h2>";
                echo '<i class="dashicons dashicons-image-rotate"></i>';
                echo esc_html__("Reset plugin data", "ai-for-seo");
            echo "</h2>";

            echo "<div class='ai4seo-form-item'>";
                echo "<label for='ai4seo-troubleshooting-reset-cache'>";
                    echo esc_html__("Choose the data you want to reset:", "ai-for-seo");
                echo "</label>";

                echo "<div class='ai4seo-form-item-input-wrapper'>";

                    // checkboxes for reset cache, resent environmental variables (you have to re-enter license data), reset plugin settings, reset generated metadata

                    // select all button
                    ai4seo_echo_wp_kses(ai4seo_get_select_all_checkbox("ai4seo-troubleshooting-reset-checkbox"));
                    echo "<div class='ai4seo-medium-gap'></div>";

                    // Reset cache
                    echo "<div class='ai4seo-form-multiple-inputs'>";
                        echo "<input type='checkbox' id='ai4seo-troubleshooting-reset-cache' name='ai4seo-troubleshooting-reset-checkbox[]' />";
                        echo "<label for='ai4seo-troubleshooting-reset-cache'>" . esc_html__("Reset cache", "ai-for-seo") . "</label>";
                    echo "</div>";

                    // Reset notifications
                    echo "<div class='ai4seo-form-multiple-inputs'>";
                        echo "<input type='checkbox' id='ai4seo-troubleshooting-reset-notifications' name='ai4seo-troubleshooting-reset-checkbox[]' />";
                        echo "<label for='ai4seo-troubleshooting-reset-notifications'>" . esc_html__("Reset notifications", "ai-for-seo") . "</label>";
                        $ai4seo_notifications_tooltip = __("Dismissed notifications will be reset and eventually reappear in the notifications section of the plugin.", "ai-for-seo");
                        ai4seo_echo_wp_kses(ai4seo_get_icon_with_tooltip_tag($ai4seo_notifications_tooltip));
                    echo "</div>";

                    // Reset environmental variables
                    echo "<div class='ai4seo-form-multiple-inputs'>";
                        echo "<input type='checkbox' id='ai4seo-troubleshooting-reset-env' name='ai4seo-troubleshooting-reset-checkbox[]' />";
                        echo "<label for='ai4seo-troubleshooting-reset-env'>" . esc_html__("Reset environmental variables", "ai-for-seo") . "</label>";
                        $ai4seo_environmental_variables_tooltip = __("<strong>This will reset all environmental variables.</strong><br>Use this option if you are advised to do so by our support team.<br><br><strong>Note:</strong> You will need to re-enter your license data after using this option.", "ai-for-seo");
                        ai4seo_echo_wp_kses(ai4seo_get_icon_with_tooltip_tag($ai4seo_environmental_variables_tooltip));
                    echo "</div>";

                    // Reset plugin settings
                    echo "<div class='ai4seo-form-multiple-inputs'>";
                        echo "<input type='checkbox' id='ai4seo-troubleshooting-reset-settings' name='ai4seo-troubleshooting-reset-checkbox[]' />";
                        echo "<label for='ai4seo-troubleshooting-reset-settings'>" . esc_html__("Reset plugin settings", "ai-for-seo") . "</label>";
                        $ai4seo_settings_tooltip = __("<strong>This will reset all settings across the following pages:</strong><br>Settings Page, Account Page (license data will be kept), Pay-As-You-Go Settings, and Autopilot Settings.<br><br>To reset only the Settings Page, please use the \"Restore Default\" button on that page.", "ai-for-seo");
                        ai4seo_echo_wp_kses(ai4seo_get_icon_with_tooltip_tag($ai4seo_settings_tooltip));
                    echo "</div>";

                    // Reset generated metadata
                    echo "<div class='ai4seo-form-multiple-inputs'>";
                        echo "<input type='checkbox' id='ai4seo-troubleshooting-reset-metadata' name='ai4seo-troubleshooting-reset-checkbox[]' />";
                        echo "<label for='ai4seo-troubleshooting-reset-metadata'>" . esc_html__("Remove AI-generated data", "ai-for-seo") . "</label>";
                        ai4seo_echo_wp_kses(ai4seo_get_icon_with_tooltip_tag($ai4seo_reset_generated_data_tooltip));
                    echo "</div>";

                    echo "<div class='ai4seo-medium-gap'></div>";

                    // needed for extra information in the upcoming notification modal
                    echo "<div id='ai4seo-reset-generated-data-tooltip-text' style='display: none'>";
                        ai4seo_echo_wp_kses($ai4seo_reset_generated_data_tooltip);
                    echo "</div>";
                echo "</div>";
            echo "</div>";
        echo "</div>";

        // Reset button
        ai4seo_echo_wp_kses(ai4seo_get_submit_button_tag(esc_html__("Reset selected data", "ai-for-seo"), "ai4seo-start-inactive ai4seo-lockable ai4seo-troubleshooting-reset-button", "ai4seo_confirm_reset_plugin_data();"));
    echo "</div>";


    // === TROUBLESHOOTING F.A.Q ================================================================================= \\

    echo "<h1>";
        echo esc_html__("Troubleshooting F.A.Q.", "ai-for-seo");
    echo "</h1>";

    // Input for the search
    echo "<div class='ai4seo-help-search-wrapper'>";
        ai4seo_echo_wp_kses(ai4seo_get_svg_tag("magnifying-glass"));
        echo "<input type='text' class='ai4seo-help-search' id='ai4seo-help-search-troubleshooting' placeholder='" . esc_attr__("Search F.A.Q. (enter min.3 characters)", "ai-for-seo") . "' />";
    echo "</div>";

    // Container with the message that no entries could be found based on the search-input
    echo "<div class='ai4seo-help-search-notice ai4seo-help-faq-search-notice ai4seo-display-none' id='ai4seo-help-troubleshooting-search-notice'>";
        echo "<p>" . esc_html__("No results could be found based on your search. Please try a different search term.", "ai-for-seo") . "</p>";
    echo "</div>";

    echo "<div class='ai4seo-gap'></div>";

    echo "<div class='ai4seo-faq-section-holder'>";
        $ai4seo_this_accordion_content = __("If you want to revert the plugin settings to their default state: Use the Reset Settings option under Help > Troubleshooting > Reset Plugin. This will restore all settings to their original values but will not delete generated metadata or media attributes.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("How can I reset the plugin settings to their default values?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you want to fully remove all generated metadata and plugin data before uninstalling:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("1. Go to Help > Troubleshooting > Reset Plugin and select every checkbox.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. Deactivate and uninstall the plugin.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("Note: Media Attributes and synced metadata (to third-party SEO plugins) cannot be removed or undone by the reset. You will need to manually update or remove them in their respective editors.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I want to uninstall the plugin and remove all generated data. How can I do this?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("If you generated metadata or media attributes with incorrect settings, follow these steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __('1. Use "Reset Generated Data" under Help > Troubleshooting > Reset Plugin to remove all generated metadata. Media files are marked as "not generated" and can be reprocessed again.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __('2. If the generated metadata was already synced with a third-party SEO plugin, consider enabling: "Include Complete Entries When Overwriting (SEO Autopilot Only)" in the Metadata section.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __('3. If you generated media attributes, consider enabling: "Include Complete Entries When Overwriting (SEO Autopilot Only)" in the Media Attributes section.', "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("These settings will allow the plugin to regenerate and overwrite metadata and media attributes, even for entries that were previously marked as complete.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I used the wrong settings for manual or bulk generation (e.g., wrong language or missing sync with other SEO plugins). What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content  = __("Enable \"Pause pages and media files analysis\" under Help > Troubleshooting.", "ai-for-seo");
        $ai4seo_this_accordion_content .= "<br /><br />" . __("Switch the setting off after debugging to resume normal data analysis.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I run into performance while pages and media files are being analyzed. How can I pause the analysis?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = __("Use Help > Troubleshooting > Preferred Debug Output to direct ai4seo_debug_message() diagnostics to the PHP/WP debug log, an uploads log file, the Debug message log below, an admin notice, or inline printouts. Turn output back to None when finished. You can also open the Debug Message Log at the bottom of this section to review stored entries (max. 1000), and enable WP_DEBUG_LOG if you prefer writing to wp-content/debug.log.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I want to debug an unexpected plugin behaviour. What tools can I use to debug?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content  = __("WordPress's internal cron system (WP-Cron) may not run reliably in every hosting setup, which can delay tasks such as SEO Autopilot jobs.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("Recommended setup:", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("1. Disable WP-Cron in your wp-config.php file (set DISABLE_WP_CRON to true).", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. Create an external cron job on your server or hosting panel that calls wp-cron.php every minute.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("3. Save and test the cron job to confirm it runs regularly.", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %s: YouTube tutorial link for setting up an external cron job */
            __("For a detailed step-by-step walkthrough, watch this tutorial: <a href='%s' target='_blank' rel='noopener noreferrer'>How to set up an external WordPress cron job (YouTube)</a>.", "ai-for-seo"),
            esc_url("https://youtu.be/YzPup-6NgQQ?si=yzcAve9lpA3Aepap")
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("WP-Cron is not running reliably on my website. How do I switch to an external cron job?", "ai-for-seo"), $ai4seo_this_accordion_content));

        // === FAQ: Alt Text Injection not visible ================================== \\

        $ai4seo_this_accordion_content  = __( 'If you generated alt text but it does not appear on the front page, try:', 'ai-for-seo' ) . '<br /><br />';
        $ai4seo_this_accordion_content .= __( '1. Go to Settings > Show Advanced Settings > Troubleshooting. Enable "Alt Text Injection", save, then check again.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '2. Optionally enable "Image Title Injection" to add a tooltip on hover.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '3. Clear caches (plugin/theme cache, page cache, CDN) so updated attributes render on cached pages.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '4. Ensure images are real <img> tags. Background images set via CSS cannot have alt text.', 'ai-for-seo' );

        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                '> ' . esc_html__( 'I do not see generated alt text on the front page. What can I do?', 'ai-for-seo' ),
                $ai4seo_this_accordion_content
            )
        );

        // === FAQ: Image Upload Method = Data ====================================== \\

        $ai4seo_this_accordion_content  = __( 'If you see errors while generating alt text or other media attributes, switch the upload method:', 'ai-for-seo' ) . '<br /><br />';
        $ai4seo_this_accordion_content .= __( '1. Go to Settings > Show Advanced Settings > Troubleshooting. Set "Image Upload Method" to "Data".', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '2. Save settings and retry generation (Alt Text, Title, Caption).', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '3. Why this helps: Some CDNs, firewalls, or hosts (e.g., Cloudflare, signed URLs, private media paths) block direct URL fetching. "Data" sends the image bytes instead of a public URL and is often more reliable.', 'ai-for-seo' ) . '<br />';
        $ai4seo_this_accordion_content .= __( '4. If issues persist, clear all caches and confirm the image is a real <img> tag, not a CSS background.', 'ai-for-seo' );

        ai4seo_echo_wp_kses(
            ai4seo_get_accordion_element(
                '> ' . esc_html__( 'Generating alt text fails. Should I switch "Image Upload Method" to "Data"?', 'ai-for-seo' ),
                $ai4seo_this_accordion_content
            )
        );

        // === FAQ: Cannot access plugin due to incognito mode restriction ================= \\

        $ai4seo_account_settings_url = ai4seo_get_subpage_url("account", array("ai4seo_debug_bypass_incognito_mode" => "true"));

        $ai4seo_this_accordion_content = __("If you cannot access the plugin due to incognito mode restriction, follow these steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= sprintf(
            /* translators: %s: here link */
            __("1. Click %s to temporarily bypass the incognito mode restriction.", "ai-for-seo") . "<br />",
            "<a href='" . esc_url($ai4seo_account_settings_url) . "'>" . esc_html__("here", "ai-for-seo") . "</a>"
        );
        $ai4seo_this_accordion_content .= __("2. Disable incognito mode and save your settings.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("3. If needed, you may enable incognito mode again after saving.", "ai-for-seo");

        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("I cannot access the plugin due to incognito mode restriction. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        // === FAQ: Generated metadata is not visible on the frontend =============================================== \\

        $ai4seo_this_accordion_content = __("If generated metadata does not appear on the frontend, try the following steps:", "ai-for-seo") . "<br /><br />";
        $ai4seo_this_accordion_content .= __("1. If you use a caching plugin (e.g., WP Rocket, W3 Total Cache, etc.), enable \"Purge caches after saving metadata\" under Settings > Show Advanced Settings > Frontend Cache Purge, then save settings and test again.", "ai-for-seo") . "<br />";
        $ai4seo_this_accordion_content .= __("2. If you do not use a caching plugin or the issue persists, please contact our support team for further assistance.", "ai-for-seo");
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Generated metadata is not visible on the frontend. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

        $ai4seo_this_accordion_content = sprintf(
            /* translators: %1$s plugin name, %2$s plugin name */
            __('Changes made later in a third-party SEO plugin are not visible because *%1$s* handles the frontend output of your meta tags.<br><br>You have two options:<br>1. Apply your updates in the *%2$s* metadata editor and let them sync to your third-party SEO plugin.<br>2. Go to Settings > Show Advanced Settings > Meta Tag Output Mode and set it to "Complementary".', "ai-for-seo"),
            esc_html(AI4SEO_PLUGIN_NAME),
            esc_html(AI4SEO_PLUGIN_NAME)
        );
        ai4seo_echo_wp_kses(ai4seo_get_accordion_element("> " . esc_html__("Changes in third-party SEO plugins are not applied. What can I do?", "ai-for-seo"), $ai4seo_this_accordion_content));

    echo "</div>";
echo "</div>";


// === USEFUL LINKS ========================================================================== \\

echo "<div class='ai4seo-display-none ai4seo-help-content' id='ai4seo-help-links'>";
    // Headline
    echo "<h1 id='ai4seo-links-section'>";
        echo esc_html__("Useful links", "ai-for-seo");
    echo "</h1>";

    // Plugin website
    echo "<p>";
        echo "<i class='dashicons dashicons-admin-links'></i> ";
        echo "<b>" . esc_html__("Official plugin website", "ai-for-seo") . "</b><br />";
        echo "<a href='" . esc_attr(AI4SEO_OFFICIAL_WEBSITE) . "' target='_blank'>" . esc_html__("Check out the official plugin website to learn more about this plugin.", "ai-for-seo") . "</a>";
    echo "</p>";

    // WordPress plugin-page
    echo "<p>";
        echo "<i class='dashicons dashicons-admin-links'></i> ";
        echo "<b>" . esc_html__("WordPress plugin-page", "ai-for-seo") . "</b><br />";
        echo "<a href='" . esc_attr(AI4SEO_PLUGINS_OFFICIAL_WORDPRESS_ORG_PAGE) . "' target='_blank'>" . esc_html__("Check out this plugin directly on WordPress.org!", "ai-for-seo") . "</a>";
    echo "</p>";

    // WordPress.org Support forum
    echo "<p>";
        echo "<i class='dashicons dashicons-admin-links'></i> ";
        echo "<b>" . esc_html__("Support-Forum", "ai-for-seo") . "</b><br />";
        echo "<a href='https://wordpress.org/support/plugin/ai-for-seo/' target='_blank'>" . esc_html__("Do you need assistance? Check out the official support-forum on WordPress.org!", "ai-for-seo") . "</a>";
    echo "</p>";

    // Space Codes website
    echo "<p>";
        echo "<i class='dashicons dashicons-admin-links'></i> ";
        /* translators: %s: plugin name */
        echo "<b>" . sprintf(esc_html__("The makers of *%s*", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</b><br />";
        /* translators: %s: plugin name */
        echo "<a href='https://spa.ce.codes' target='_blank'>" . sprintf(esc_html__("Do you want to learn more about the makers of *%s*? Then this is the right place for you!", "ai-for-seo"), esc_html(AI4SEO_PLUGIN_NAME)) . "</a>";
    echo "</p>";
echo "</div>";
