<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>

<div class="overlay" id="overlay"></div>

<?php

$stored_response = get_option( 'unleash_ai_registration_response' );
if ( $stored_response ) {
    $stored_response = json_decode( $stored_response, true ); // Decode if needed
    $username =  $stored_response['username'];
}
 //print_r($response_data);
        if($stored_response){
   
 // Display secret key and regeneration form
 echo '<div class="flexWrap47New">';
    echo '<div class="wrap secretKetM loginButtonsKey">';
echo '<p class="h2ClsCG">Secret Key Management</p>';
	echo '<h5 style="margin-bottom: 30px;     font-weight: normal;    font-size: 15px;   margin-top: 20px;">You are currently logged in as: <b>' . esc_html($username) . '</b></h5>';
    echo '<h5>Your current secret key is</h5>';
    echo '<pre id="text-to-copy">' . esc_html($secret_key) . '</pre>';
	echo '<div class="centerButtonsKey centerButtonsKeyM20">';
    echo '<button class="normalBtnCg copy-btn copy-btnKey" id="copy-btn">Copy to Clipboard</button>';
    echo '<p id="copy-status" style="color: green; margin-top: 10px; display: none;">Copied!</p>';

    echo '<form method="POST">';
    wp_nonce_field('unleash_ai_regenerate_secret_key_action', 'regenerate_nonce');
    echo '<button type="submit" name="regenerate_key" class="normalBtnCg button button-primary">Regenerate Secret Key</button>';
    echo '</form>';
	echo '</div>';
   // echo '<div class="unmesg"><b>Great!</b> You can now generate meta tags and alt tags directly using the plugin. If you prefer to generate them through the Unleash Portal, please follow the instructions provided on the right.</div>';
    echo '<div class="centerButtonsKey centerButtonsKeyUnlink">';
    echo '<button class="normalBtnCg unlinkK" id="switch-unleashai-account">Switch UnleashAI account</button>';
	echo '</div>';   
	
	echo '</div>';
	echo '<div class="secretKetM">';
	echo '<h2>How to Connect  Multiple  Websites with Unleash AI’s  Web Dashboard</h2>';
    echo '<ol>';
    echo '<li>Complete the plugin activation process on each site you want to manage.</li>';
    echo '<li><a href="https://unleashai.co/auth/login">Log in</a> to the web dashboard at and navigate to the Manage Site section.</li>';
    echo '<li>Enter your website address and secret key (you can find the secret key under the Account Settings page in the Unleash AI plugin on your site).</li>';
    echo '<liClick the Connect Site button.</li>';
    echo '<li>Your site is now connected to Unleash AI and ready to generate metadata and alt text.</li>';
    echo '<li><b>You can now use the web dashboard to:</b>: <ul><li>Generate titles, descriptions, and alt text.</li><li>Switch between connected sites seamlessly.</li></ul></li>';
   echo '</ol>';	
	echo '</div></div>';

  } else { ?>
    <div>You are not logged in. Please log in <a href="?page=cg_meta_al">here</a> to continue.</div>
<?php  exit; }?>
  </div> </div></div>