/* ------------------------------------------------------------------------------
* Author: DMCWebZone
* Author URL: https://web-zone.org
* Copyright © Airin Blog by DMCWebZone. All Rights Reserved.
* @package Airin Blog
* Description: Settings plans
* ------------------------------------------------------------------------------ */


jQuery(document).ready(function($) {

    'use strict';

        if ($('.airinblog-css-set-admin-sidebar').length) {

            var token = btoa(AIRINBLOG_PUB_KEY_SET.pluginKey + '|' + AIRINBLOG_PUB_KEY_SET.oneKey);

			// Content
            function airinBlogRenderWarning(data) {

                if (!data.show_info) return;

                var infoBlock = `
                    <div class="airinblog-css-set-admin-warning">
                        <h2>
                            ${data.h2}
                        </h2>
                        <div class="airinblog-css-set-admin-warning-info">
                            ${data.text}
                        </div>
                    </div>
                `;
                $('.airinblog-css-set-admin-sidebar').prepend(infoBlock);
                
            }

            // JSON
            $.ajax({
                url: 'https://data.web-zone.org/info/warning.json.php',
                headers: {'X-DMCWZMULTI-Token': token},
                dataType: 'json'
            })
            .done(airinBlogRenderWarning)
            .fail(function() {
                $.ajax({
                    url: 'https://data.web-zone.org/info/warning-airin-blog.json.php',
                    headers: {'X-AIRINBLOG-Token': token},
                    dataType: 'json',
                    success: airinBlogRenderWarning
                });
            });
            
        }
    
});