<?php

/* ------------------------------------------------------------------------------
* Author: web-zone.org
* @package Airin Blog
* Description: Theme settings
* ------------------------------------------------------------------------------ */
if ( !function_exists( 'airinblog_fun_general_settings' ) ) {
    function airinblog_fun_general_settings() {
        // Add item menu
        function airinblog_fun_add_theme_settings() {
            add_theme_page(
                // 'main_theme_settings', // Mother page address
                'Pro ' . AIRINBLOG_NAME,
                // Page Title
                'Page ' . AIRINBLOG_NAME,
                // Menu item name
                'manage_options',
                // Access rights
                'dmcwzmulti_page_settings',
                // Page address
                'airinblog_fun_settings_function',
                // Function name
                20
            );
        }

        add_action( 'admin_menu', 'airinblog_fun_add_theme_settings' );
        // Message about save
        function airinblog_fun_options_notice() {
            if ( isset( $_GET['page'] ) && 'dmcwzmulti_page_settings' == $_GET['page'] && isset( $_GET['settings-updated'] ) && true == $_GET['settings-updated'] ) {
                echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'All settings saved!', 'airin-blog' ) . '</p></div>';
            }
        }

        add_action( 'admin_notices', 'airinblog_fun_options_notice' );
        // Display the options page
        function airinblog_fun_settings_function() {
            ?>
            <div class="wrap">
                <?php 
            // Start page
            $tab = 'support-tab';
            // Which tab is active
            if ( isset( $_GET['tab'] ) ) {
                $tab = $_GET['tab'];
            }
            ?>
                <h1><?php 
            echo esc_html__( 'Pro page', 'airin-blog' ) . ' ' . AIRINBLOG_NAME;
            ?></h1>
                
                <!-- Output the tabs -->
                <h2 class="nav-tab-wrapper">
                    <a href="<?php 
            echo esc_url( admin_url( 'themes.php?page=dmcwzmulti_page_settings&tab=general-tab' ) );
            ?>" 
                        class="nav-tab <?php 
            echo esc_attr( ( $tab == 'general-tab' ? 'nav-tab-active' : '' ) );
            ?> "><?php 
            esc_html_e( 'General', 'airin-blog' );
            ?>
                    </a>
                    <a href="<?php 
            echo esc_url( admin_url( 'themes.php?page=dmcwzmulti_page_settings&tab=hook-tab' ) );
            ?>" 
                        class="nav-tab <?php 
            echo esc_attr( ( $tab == 'hook-tab' ? 'nav-tab-active' : '' ) );
            ?> "><?php 
            esc_html_e( 'Codes (Hooks theme)', 'airin-blog' );
            ?>
                    </a>
                    <?php 
            // Hook for adding new tabs via plugin
            do_action( 'dmcwzmulti_hook_tab_settings' );
            ?>
                    <a href="<?php 
            echo esc_url( admin_url( 'themes.php?page=dmcwzmulti_page_settings&tab=support-tab' ) );
            ?>" 
                        class="nav-tab <?php 
            echo esc_attr( ( $tab == 'support-tab' ? 'nav-tab-active' : '' ) );
            ?> "><?php 
            esc_html_e( 'Information', 'airin-blog' );
            ?>
                    </a>
                    <?php 
            // Hook for adding new tabs after all tabs
            do_action( 'airinblog_hook_tab_settings_after' );
            ?>
                </h2>

                <!-- Output functions -->

                <?php 
            do_action( 'dmcwzmulti_hook_liberty_functions' );
            ?>

                <form action="options.php" method="post">
                    <?php 
            if ( $tab == 'support-tab' ) {
                airinblog_fun_support_tab();
            } else {
                if ( $tab == 'general-tab' ) {
                    airinblog_fun_general_tab();
                } else {
                    settings_fields( $tab );
                    do_settings_sections( $tab );
                    submit_button();
                }
            }
            ?>
                </form>
            </div>
            <?php 
        }

        // function Useful links
        function airinblog_fun_admin_useful_links() {
            echo '
            <div class="airinblog-css-set-admin-info">
                <h2>' . esc_html__( 'Useful links', 'airin-blog' ) . '</h2>
                <p><a href="' . esc_url( '//web-zone.org/documentation/instruction-airin-blog' ) . '" target="_blank">' . sprintf( esc_html__( 'Management and configuration instructions for the %s', 'airin-blog' ), AIRINBLOG_NAME ) . '</a></p>
                <p><a href="' . esc_url( '//web-zone.org/category/themes/airin-blog' ) . '" target="_blank">' . sprintf( esc_html__( 'Information materials for the %s', 'airin-blog' ), AIRINBLOG_NAME ) . '</a></p>
                <p><a href="' . esc_url( '//airinblog.web-zone.org/demo-0' ) . '" target="_blank">' . esc_html__( 'Watch live sites demos', 'airin-blog' ) . '</a></p>
                <p><a href="' . esc_url( '//web-zone.org/updates/airin-blog-theme-updates' ) . '" target="_blank">' . sprintf( esc_html__( 'List of updates for the %s', 'airin-blog' ), AIRINBLOG_NAME ) . '</a></p>
                <p><a href="' . esc_url( '//wordpress.org/support/theme/airin-blog/reviews/' ) . '" target="_blank">' . esc_html__( 'Rate this theme', 'airin-blog' ) . '</a></p>
            </div>
            ';
        }

        // function Soc support links
        function airinblog_fun_admin_soc_sup_links() {
            $gtduri = get_template_directory_uri();
            echo '
            <div class="airinblog-css-set-admin-info">

                <h2>' . esc_html__( 'Social Media Links', 'airin-blog' ) . '</h2>
            
                <p>' . esc_html__( 'Follow theme updates, suggest new features, participate in polls, discuss, and ask questions', 'airin-blog' ) . '</p>

                <div class="airinblog-css-set-admin-info-soc-links">
                    <a href="' . esc_url( '//facebook.com/DMCWebZone' ) . '" target="_blank">
                        <img src="' . $gtduri . '/img/soc/square/flat/facebook.png' . '" alt="Facebook">
                    </a>
                    <a href="' . esc_url( 'x.com/DMCWebZone' ) . '" target="_blank">
                        <img src="' . $gtduri . '/img/soc/square/flat/twitterx.png' . '" alt="X">
                    </a>
                </div>

            </div>
            ';
        }

        // support-tab content
        function airinblog_fun_support_tab() {
            echo '<div class="airinblog-css-set-admin-content-box">';
            echo '<div class="airinblog-css-set-admin-primary">';
            // Comparison of Versions
            echo '
                        <div class="airinblog-css-set-admin-versions">
            
                            <h2>' . AIRINBLOG_NAME . ' Theme ' . esc_html__( '(Comparison of Versions)', 'airin-blog' ) . '</h2>
            
                            <div class="airinblog-css-set-admin-table-box">
                                <table>
                                    <thead>
                                        <tr>
                                            <th>' . esc_html__( 'Available features', 'airin-blog' ) . '</th>
                                            <th class="airinblog-css-set-admin-table-title">' . esc_html__( 'Free', 'airin-blog' ) . '</th>
                                            <th class="airinblog-css-set-admin-table-title">Premium</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>' . esc_html__( 'Powerful typography', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Modularity and flexibility', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . sprintf( esc_html__( 'Visual customizer support (%s)', 'airin-blog' ), 'WordPress' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Flexible heading customization with logo', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Flexible sidebar orientation', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Ability to choose your own sidebar orientation for posts and pages', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Selecting the width of the site', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Three pagination options', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Four menu locations', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Mega menu (mega lists, dropdown, single) in the main menu', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Social link customizer in the site header', 'airin-blog' ) . '</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Plugins adapting', 'airin-blog' ) . ' (WooCommerce, bbPress, The Events Calendar, Elementor, WPML, Jetpack, Yoast SEO, Newsletter, Contact Form 7)</td>
                                            <td><span class="icon-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Home page customizer (choice of 8 blocks)', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Megamenu (graphic) with customizer in the main menu', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Wide slider (below the main menu)', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'More fonts to choose from', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Powerful color settings', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Ready-made color schemes', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Reset theme settings and activate presets', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Full demo versions of sites (Import thematic demo versions in one click)', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Lots of hooks (windows for codes)', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Additional widgets', 'airin-blog' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . sprintf( esc_html__( 'Separate sidebars for %1$s and %2$s', 'airin-blog' ), 'WooCommerce', 'bbPress' ) . '</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                        <tr>
                                            <td>' . esc_html__( 'Expanded plugins adapting', 'airin-blog' ) . ' (WooCommerce, bbPress, The Events Calendar)</td>
                                            <td><span class="icon-no-check-mark"></span></td>
                                            <td><span class="icon-check-mark"></span></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>

                            <a href="' . admin_url( 'themes.php?page=dmcwzmulti_page_settings-pricing' ) . '">' . esc_html__( 'Buy', 'airin-blog' ) . ' Premium</a>

                        </div>
                        ';
            echo '</div>';
            echo '<div class="airinblog-css-set-admin-sidebar">';
            // Support
            echo '<div class="airinblog-css-set-admin-info">';
            settings_fields( 'support-tab' );
            do_settings_sections( 'support-tab' );
            echo '</div>';
            // Soc support
            airinblog_fun_admin_soc_sup_links();
            // Info
            airinblog_fun_admin_useful_links();
            echo '</div>';
            echo '</div>';
        }

        // general-tab content
        function airinblog_fun_general_tab() {
            $customize_url = admin_url( 'customize.php?return=%2Fwp-admin%2Fthemes.php%3Fpage%3Ddmcwzmulti_page_settings' );
            echo '<div class="airinblog-css-set-admin-content-box">';
            echo '<div class="airinblog-css-set-admin-primary">';
            // Quick links to settings
            echo '<div class="airinblog-css-set-admin-customize">';
            echo '<div class="airinblog-css-set-admin-customize-mes">';
            echo esc_html__( 'All settings of the front part of the theme are located in the visual editor', 'airin-blog' );
            echo ' &raquo; <a href="' . esc_url( $customize_url ) . '">' . esc_html__( 'Open', 'airin-blog' ) . '</a>';
            echo '</div>';
            echo '<h2>' . esc_html__( 'Visual Customizer Quick Links', 'airin-blog' ) . '</h2>';
            echo '<div class="airinblog-css-set-admin-customize-grid">';
            $url_lay = admin_url( 'customize.php?autofocus[control]=airinblog_cus_lay_all' );
            echo '<a href="' . esc_url( $url_lay ) . '">' . esc_html__( 'Template orientation', 'airin-blog' ) . '</a>';
            $url_color = admin_url( 'customize.php?autofocus[control]=airinblog_cus_colors_primary' );
            echo '<a href="' . esc_url( $url_color ) . '">' . esc_html__( 'Common colors', 'airin-blog' ) . '</a>';
            $url_font = admin_url( 'customize.php?autofocus[control]=airinblog_cus_typography_font' );
            echo '<a href="' . esc_url( $url_font ) . '">' . esc_html__( 'General typography', 'airin-blog' ) . '</a>';
            $url_logo = admin_url( 'customize.php?autofocus[control]=display_header_text' );
            echo '<a href="' . esc_url( $url_logo ) . '">' . esc_html__( 'Title and logo', 'airin-blog' ) . '</a>';
            $url_top_menu = admin_url( 'customize.php?autofocus[control]=airinblog_cus_top_menu_size' );
            echo '<a href="' . esc_url( $url_top_menu ) . '">' . esc_html__( 'Top menu', 'airin-blog' ) . '</a>';
            $url_main_menu = admin_url( 'customize.php?autofocus[control]=airinblog_cus_main_menu_full_width' );
            echo '<a href="' . esc_url( $url_main_menu ) . '">' . esc_html__( 'Main menu', 'airin-blog' ) . '</a>';
            $url_soc = admin_url( 'customize.php?autofocus[control]=airinblog_cus_soc' );
            echo '<a href="' . esc_url( $url_soc ) . '">' . esc_html__( 'Social links', 'airin-blog' ) . '</a>';
            $url_widget = admin_url( 'customize.php?autofocus[control]=airinblog_cus_widget_sidebar_design' );
            echo '<a href="' . esc_url( $url_widget ) . '">' . esc_html__( 'Widget settings', 'airin-blog' ) . '</a>';
            $url_cat = admin_url( 'customize.php?autofocus[panel]=airinblog_cus_panel_cat' );
            echo '<a href="' . esc_url( $url_cat ) . '">' . esc_html__( 'Categories', 'airin-blog' ) . '</a>';
            $url_post = admin_url( 'customize.php?autofocus[panel]=airinblog_cus_panel_post' );
            echo '<a href="' . esc_url( $url_post ) . '">' . esc_html__( 'Posts and pages', 'airin-blog' ) . '</a>';
            $url_main = admin_url( 'customize.php?autofocus[panel]=airinblog_cus_panel_top' );
            echo '<a href="' . esc_url( $url_main ) . '">' . esc_html__( 'Top part', 'airin-blog' ) . '</a>';
            $url_footer = admin_url( 'customize.php?autofocus[control]=airinblog_cus_footer_full' );
            echo '<a href="' . esc_url( $url_footer ) . '">' . esc_html__( 'Bottom part', 'airin-blog' ) . '</a>';
            echo '</div>';
            echo '</div>';
            // Expert settings
            echo '<div class="airinblog-css-set-admin-expert">';
            echo '<h2>' . esc_html__( 'Expert settings of the administrative part of the theme', 'airin-blog' ) . '</h2>';
            settings_fields( 'general-tab' );
            do_settings_sections( 'general-tab' );
            submit_button();
            echo '</div>';
            echo '</div>';
            echo '<div class="airinblog-css-set-admin-sidebar">';
            // Free
            echo '
                        <div class="airinblog-css-set-admin-premium">
                            <h2>' . AIRINBLOG_NAME . ' Premium</h2>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Home page customizer (choice of 8 blocks)', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Megamenu (graphic) with customizer in the main menu', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Wide slider (below the main menu)', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'More fonts to choose from', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Powerful color settings', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Ready-made color schemes', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Reset theme settings and activate presets', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Full demo versions of sites (Import thematic demo versions in one click)', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Lots of hooks (windows for codes)', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Additional widgets', 'airin-blog' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . sprintf( esc_html__( 'Separate sidebars for %1$s and %2$s', 'airin-blog' ), 'WooCommerce', 'bbPress' ) . '</p>
                            <p><span class="icon-check-mark"></span>' . esc_html__( 'Expanded plugins adapting', 'airin-blog' ) . ' (WooCommerce, bbPress, Events Calendar)</p>
                            <a href="' . admin_url( 'themes.php?page=dmcwzmulti_page_settings-pricing' ) . '">' . esc_html__( 'Buy', 'airin-blog' ) . ' Premium</a>
                        </div>
                        ';
            // Info
            airinblog_fun_admin_useful_links();
            echo '</div>';
            echo '</div>';
        }

        // Display scripts only on page (and tabs) dmcwzmulti_page_settings
        // Per WordPress rules - use $hook_suffix
        // info - developer.wordpress.org/reference/hooks/admin_footer-hook_suffix/
        // The page is defined as - appearance_page_dmcwzmulti_page_settings
        function airinblog_fun_admin_set_page_scripts(  $hook_suffix  ) {
            $tab_page = array(
                'appearance_page_dmcwzmulti_page_settings',
                'appearance_page_dmcwzmulti_page_settings-affiliation',
                'appearance_page_dmcwzmulti_page_settings-account',
                'appearance_page_dmcwzmulti_page_settings-contact',
                'appearance_page_dmcwzmulti_page_settings-addons',
                'appearance_page_dmcwzmulti_page_settings-pricing'
            );
            if ( !in_array( $hook_suffix, $tab_page ) ) {
                return;
            }
            // Style file for admin set page
            wp_enqueue_style(
                'airinblog-style-admin-set',
                get_template_directory_uri() . '/css/admin/admin-set-style.css',
                array(),
                AIRINBLOG_VERSION
            );
        }

        add_action( 'admin_enqueue_scripts', 'airinblog_fun_admin_set_page_scripts' );
    }

    airinblog_fun_general_settings();
}
// Registration, adding settings and sections
function airinblog_fun_theme_settings() {
    // Section - Support
    if ( !defined( 'DMCWZAF_VERSION' ) ) {
        add_settings_section(
            'airinblog_set_section_support_contact',
            esc_html__( 'Technical support', 'airin-blog' ),
            'airinblog_fun_callback_support_contact',
            'support-tab'
        );
    }
    // ------------------------------------------------------------
    // Images format
    // ------------------------------------------------------------
    // Section
    add_settings_section(
        'airinblog_set_section_img_all',
        '<hr><h3>' . esc_html__( 'Images format', 'airin-blog' ) . '</h3>',
        '',
        'general-tab'
    );
    // Setting the size of the main image of posts and pages (width)
    add_settings_field(
        'airinblog_set_size_imgs_all',
        esc_html__( 'Choose which images to use for the entire site', 'airin-blog' ),
        'airinblog_fun_callback_size_img_all',
        'general-tab',
        'airinblog_set_section_img_all'
    );
    register_setting( 'general-tab', 'airinblog_set_size_imgs_all' );
    // ------------------------------------------------------------
    // Main post image
    // ------------------------------------------------------------
    // Section
    add_settings_section(
        'airinblog_set_section_thumb_post',
        '<hr><h3>' . esc_html__( 'Main post image', 'airin-blog' ) . '</h3>',
        '',
        'general-tab'
    );
    // Setting the size of the main image of posts and pages (width)
    add_settings_field(
        'airinblog_set_size_img_post_w',
        esc_html__( 'Add a new image size and apply the default for the main image of posts and pages', 'airin-blog' ),
        'airinblog_fun_callback_size_img_post_w_front',
        'general-tab',
        'airinblog_set_section_thumb_post',
        array(
            'label_for' => 'airinblog_set_size_img_post_w',
            'class'     => 'airinblog-class',
            'name'      => 'airinblog_set_size_img_post_w',
        )
    );
    register_setting( 'general-tab', 'airinblog_set_size_img_post_w', 'absint' );
    // Setting the size of the main image of posts and pages (height)
    add_settings_field(
        'airinblog_set_size_img_post_h',
        esc_html__( 'To restore the default settings, clear the field data and save', 'airin-blog' ),
        'airinblog_fun_callback_size_img_post_h_front',
        'general-tab',
        'airinblog_set_section_thumb_post',
        array(
            'label_for' => 'airinblog_set_size_img_post_h',
            'class'     => 'airinblog-class',
            'name'      => 'airinblog_set_size_img_post_h',
        )
    );
    register_setting( 'general-tab', 'airinblog_set_size_img_post_h', 'absint' );
}

add_action( 'admin_init', 'airinblog_fun_theme_settings' );
// ------------------------------------------------------------
// CALLBACK - Support links
// ------------------------------------------------------------
// Support
if ( !defined( 'DMCWZAF_VERSION' ) ) {
    function airinblog_fun_callback_support_contact() {
        echo '<p>Site: <a target="_blank" href="' . esc_url( 'https://support.web-zone.org' ) . '" >support.web-zone.org</a></p>';
        echo '<p>Email: support@web-zone.org</p>';
    }

}
// ------------------------------------------------------------
// CALLBACK - Images format
// ------------------------------------------------------------
function airinblog_fun_callback_size_img_all() {
    $opt = get_option( 'airinblog_set_size_imgs_all' );
    echo '<p>' . esc_html__( 'The theme creates multiple thumbnail sizes in a single 16x9 format and uses optimal sizes in the right places. This has a good effect on loading speed and proper display in a unified style.', 'airin-blog' ) . '</p><p>' . esc_html__( 'You can change this setting to control the size of the images yourself.', 'airin-blog' ) . '</p><br><input type="radio" id="airinblog_set_size_imgs_all_1" name="airinblog_set_size_imgs_all" value="1"' . checked( 1, $opt, false ) . ' checked/>
        <label for="airinblog_set_size_imgs_all_1">' . sprintf( esc_html__( '%s sizes', 'airin-blog' ), AIRINBLOG_NAME ) . '</label><br><br>
        <input type="radio" id="airinblog_set_size_imgs_all_2" name="airinblog_set_size_imgs_all" value="2"' . checked( 2, $opt, false ) . '/>
        <label for="airinblog_set_size_imgs_all_2">' . sprintf( esc_html__( '%s sizes', 'airin-blog' ), 'WordPress' ) . '</label><br><br><p>' . sprintf( esc_html__( 'It is important to know! These settings cannot delete or modify existing image files. Slicing of images occurs at the time of uploading a new image to the %s media library.', 'airin-blog' ), 'WordPress' ) . '</p><p>' . esc_html__( 'To change old pictures, use the thumbnail regeneration plugin.', 'airin-blog' ) . '</p>
    ';
}

// ------------------------------------------------------------
// CALLBACK - Main image for post
// ------------------------------------------------------------
// Adjusting the size of the main post image
function airinblog_fun_callback_size_img_post_w_front(  $args  ) {
    $value = get_option( $args['name'] );
    printf(
        '<p>' . esc_html__( 'These settings register a new size for the main (top) image of posts and pages.', 'airin-blog' ) . '</p>
        <p>' . esc_html__( 'After applying, all new uploaded images will be supplemented with the new size, which is apply by default for the main image of posts and pages.', 'airin-blog' ) . '</p>
        <br>' . esc_html__( 'Width', 'airin-blog' ) . ' <input type="number" min="0" id="%s" name="%s" value="%s"> px. (' . esc_html__( 'default', 'airin-blog' ) . ' - 0)
        ',
        esc_attr( $args['name'] ),
        esc_attr( $args['name'] ),
        absint( $value )
    );
}

// Adjusting the size of the main post image
function airinblog_fun_callback_size_img_post_h_front(  $args  ) {
    $value = get_option( $args['name'] );
    printf(
        esc_html__( 'Height', 'airin-blog' ) . ' <input type="number" min="0" id="%s" name="%s" value="%s"> px. (' . esc_html__( 'default', 'airin-blog' ) . ' - 0)<br><br><p>' . sprintf( esc_html__( 'It is important to know! These settings cannot delete or modify existing image files. Slicing of images occurs at the time of uploading a new image to the %s media library.', 'airin-blog' ), 'WordPress' ) . '</p><p>' . esc_html__( 'To change old pictures, use the thumbnail regeneration plugin.', 'airin-blog' ) . '</p>',
        esc_attr( $args['name'] ),
        esc_attr( $args['name'] ),
        absint( $value )
    );
}

//----------------------------------------------------------------------------------
//region Important notices
//----------------------------------------------------------------------------------
// Create nonce
function airinblog_fun_generate_one_key() {
    $nonce = get_option( 'airinblog_set_generate_nonce' );
    if ( !$nonce ) {
        $nonce = bin2hex( random_bytes( 8 ) );
        update_option( 'airinblog_set_generate_nonce', $nonce );
    }
    return $nonce;
}

// Display scripts only on page (and tabs) dmcwzmulti_page_settings
// Per WordPress rules - use $hook_suffix
// info - developer.wordpress.org/reference/hooks/admin_footer-hook_suffix/
// The page is defined as - appearance_page_dmcwzmulti_page_settings
function airinblog_fun_admin_set_page_script_plans(  $hook_suffix  ) {
    $tab_page = array('appearance_page_dmcwzmulti_page_settings', 'appearance_page_dmcwzmulti_page_settings-pricing');
    if ( !in_array( $hook_suffix, $tab_page ) ) {
        return;
    }
    if ( $hook_suffix === 'appearance_page_dmcwzmulti_page_settings-pricing' ) {
        // Scripts for plans (Important notices)
        wp_enqueue_script(
            'airinblog-script-admin-set-plans',
            get_template_directory_uri() . '/js/admin/usability.js',
            array('jquery'),
            AIRINBLOG_VERSION,
            true
        );
        wp_localize_script( 'airinblog-script-admin-set-plans', 'AIRINBLOG_PUB_KEY_PLAN', array(
            'pluginKey' => 'airinblog-public-key',
            'oneKey'    => airinblog_fun_generate_one_key(),
        ) );
    } else {
        // Scripts for settings (Important notices)
        wp_enqueue_script(
            'airinblog-script-admin-set-settings',
            get_template_directory_uri() . '/js/admin/usability-settings.js',
            array('jquery'),
            AIRINBLOG_VERSION,
            true
        );
        wp_localize_script( 'airinblog-script-admin-set-settings', 'AIRINBLOG_PUB_KEY_SET', array(
            'pluginKey' => 'airinblog-public-key',
            'oneKey'    => airinblog_fun_generate_one_key(),
        ) );
    }
}

add_action( 'admin_enqueue_scripts', 'airinblog_fun_admin_set_page_script_plans' );