<?php if (!defined('ABSPATH')) exit; ?>
<?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] === 'true'): ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
    if (typeof mementorTTSShowNotification === 'function') {
        mementorTTSShowNotification('<?php echo esc_js(__('Settings saved.', 'text-to-speech-tts')); ?>', 'success');
    }
});
</script>
<?php endif; ?>
    <div class="tts-footer-text">
        <?php if (get_option('mementor_tts_has_reviewed', false)) : ?>
            <?php echo wp_kses_post(sprintf(
                /* translators: %s: TTSWP.com link */
                __('Built with <span class="tts-footer-heart">&#9829;</span> by <a href="%1$s" target="_blank">TTSWP.com</a><br><span class="tts-footer-sub">A division of <a href="%2$s" target="_blank">Mementor Web Design &amp; Digital Marketing Agency AS</a></span>', 'text-to-speech-tts'),
                'https://ttswp.com',
                'https://mementor.no/en/'
            )); ?>
        <?php else : ?>
            <?php echo wp_kses_post(sprintf(
                /* translators: %1$s: review link, %2$s: TTSWP.com link */
                __('If you like Text to Speech (TTS) please <a href="%1$s" target="_blank" id="tts-leave-review" class="tts-review-link">leave us a &#9733;&#9733;&#9733;&#9733;&#9733; rating</a>. A huge thanks in advance from all @ <a href="%2$s" target="_blank">TTSWP.com</a>', 'text-to-speech-tts'),
                'https://wordpress.org/support/plugin/text-to-speech-tts/reviews/?rate=5#new-post',
                'https://ttswp.com'
            )); ?>
        <?php endif; ?>
    </div>
    <script>
    (function() {
        var reviewLink = document.getElementById('tts-leave-review');
        if (reviewLink) {
            reviewLink.addEventListener('click', function() {
                fetch(ajaxurl, {
                    method: 'POST',
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    body: new URLSearchParams({
                        action: 'mementor_tts_mark_reviewed',
                        nonce: '<?php echo esc_js(wp_create_nonce('mementor_tts_nonce')); ?>'
                    })
                });
            });
        }
    })();
    </script>
    </div><!-- .tts-main-content -->
  </div><!-- .tts-main -->
</div><!-- .tts-admin-wrap -->
