<?php

/**
 * file for holding dashboard welcome page for theme
 */
if (!function_exists('newsetmag_is_plugin_installed')) {
    function newsetmag_is_plugin_installed($plugin_slug)
    {
        $plugin_path = WP_PLUGIN_DIR . '/' . $plugin_slug;
        return file_exists($plugin_path);
    }
}
if (!function_exists('newsetmag_is_plugin_activated')) {
    function newsetmag_is_plugin_activated($plugin_slug)
    {
        return is_plugin_active($plugin_slug);
    }
}
if (!function_exists('newsetmag_welcome_notice')) :
    function newsetmag_welcome_notice()
    {
        global $pagenow;
        $meta            = get_option('newsetmag-welcome-notice');
        $current_screen  = get_current_screen();

        if (is_admin() && !$meta) {
            if ($current_screen->id !== 'dashboard' && $current_screen->id !== 'themes') {
                return;
            }
            if (is_network_admin()) {
                return;
            }
            if (!current_user_can('manage_options')) {
                return;
            }
            $theme = wp_get_theme();

            if (is_child_theme()) {
                $theme = wp_get_theme()->parent();
            }
            $newsetmag_version = $theme->get('Version');
            $newsetmag_admin_url = get_template_directory_uri();
            $newsetmag_admin_img = array(
                $newsetmag_admin_url . '/assets/images/admin-image.png'
            );
?>
            <div class="newsetmag-admin-notice notice notice-info is-dismissible content-install-plugin theme-info-notice">
                <div class="info-container">
                    <div class="info-content">
                        <h1><?php echo __('Welcome to Newsverse! Please Install and activate all recommended plugins to import the demo with a single click.', 'newsetmag'); ?></h1>
                        <ul class="required-plugin-list">
                            <li>
                                <?php echo __('Walker Core', 'newsetmag'); ?>
                                    <?php
                                    if (newsetmag_is_plugin_activated('walker-core/walker-core.php')) {
                                        echo __(': Plugin has been already activated!', 'newsetmag');
                                    } elseif (newsetmag_is_plugin_installed('walker-core/walker-core.php')) {
                                        echo __(': Plugin is not activated, Activate the plugin to use one click demo import and unlock premium features.', 'newsetmag');
                                    } else {
                                        echo ': <a href="' . get_admin_url() . 'plugin-install.php?tab=plugin-information&plugin=walker-core&TB_iframe=true&width=600&height=550">' . esc_html__('Install and Activate', 'newsetmag') . '</a>';
                                    }
                                    ?>
                                
                            </li>
                            <li>
                                <?php echo __('Advanced Import - Need only to use "one click demo import" features', 'newsetmag'); ?>
                                    <?php
                                    if (newsetmag_is_plugin_activated('advanced-import/advanced-import.php')) {
                                        echo __(': Plugin has been already activated!', 'newsetmag');
                                    } elseif (newsetmag_is_plugin_installed('advanced-import/advanced-import.php')) {
                                        echo __(': Plugin does not activated, Activate the plugin to use one click demo import feature.', 'newsetmag');
                                    } else {
                                        echo ': <a href="' . get_admin_url() . 'plugin-install.php?tab=plugin-information&plugin=advanced-import&TB_iframe=true&width=600&height=550">' . esc_html__('Install and Activate', 'newsetmag') . '</a>';
                                    }
                                    ?>
                            </li>
                        </ul>
                        <div class='admin-btn'>
                            <a href="<?php echo admin_url(); ?>themes.php?page=about-newsetmag" class="button admin-button info-button"><?php echo __('Explore Newsetmag', 'newsetmag'); ?></a>
                        </div>
                    </div>
                    <div class="theme-display-image">
                        <img src="<?php echo esc_url($newsetmag_admin_img[0]) ?>" />
                    </div>
                </div>
            </div>
    <?php
        }
    }
endif;
add_action('admin_notices', 'newsetmag_welcome_notice');

if (!function_exists('newsetmag_ignore_admin_notice')) :
    function newsetmag_ignore_admin_notice()
    {
        if (isset($_GET['newsetmag']) && $_GET['newsetmag-welcome-notice'] = 'true') {
            update_option('newsetmag-welcome-notice', true);
        }
    }
endif;
add_action('admin_init', 'newsetmag_ignore_admin_notice');
function newsetmag_dashboard_menu()
{
    add_theme_page(esc_html__('Newsetmag', 'newsetmag'), esc_html__('Newsetmag', 'newsetmag'), 'edit_theme_options', 'about-newsetmag', 'newsetmag_theme_info_display');
}
add_action('admin_menu', 'newsetmag_dashboard_menu');
function newsetmag_theme_info_display()
{ ?>
    <div class="dashboard-about-newsetmag">
        <h1> <?php echo __('Welcome to the Newsetmag - FSE WordPress Theme', 'newsetmag') ?></h1>
        <p><?php echo __("Newsetmag, the all-in-one WordPress theme designed for captivating news and stories, empowers you to create a unique and professional website effortlessly. With full site editing and a drag-and-drop builder, customization is a breeze. Focus on crafting compelling content with the one-click demo importer and responsive design, while SEO optimization ensures your voice is heard. Unleash the power of your narrative and take your website to the next level with Newsetmag!", 'newsetmag') ?></p>

        <h3 class="newsetmag-baisc-guideline-header"><?php echo __('Basic Theme Setup', 'newsetmag') ?></h3>
        <div class="newsetmag-baisc-guideline">
            <div class="featured-box">
                <ul>
                    <li><strong><?php echo __('Setup Header Layout:', 'newsetmag') ?></strong>
                        <ul>
                            <li> - <?php echo __('Go to Appearance -> Editor -> Template Parts -> Header:', 'newsetmag') ?></li>
                            <li> - <?php echo __('Click on Header -> Click on Edit (Icon) > Add or Remove Requirend block/content as your requirement.:', 'newsetmag') ?></li>
                            <li> - <?php echo __('Click on save to update your layout', 'newsetmag') ?></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="featured-box">
                <ul>
                    <li><strong><?php echo __('Setup Footer Layout:', 'newsetmag') ?></strong>
                        <ul>
                            <li> - <?php echo __('Go to Appearance -> Editor -> Template Parts -> Footer:', 'newsetmag') ?></li>
                            <li> - <?php echo __('click on Footer > Click on Edit (Icon) > Add or Remove Requirend block/content as your requirement.:', 'newsetmag') ?></li>
                            <li> - <?php echo __('Click on save to update your layout', 'newsetmag') ?></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="featured-box">
                <ul>
                    <li><strong><?php echo __('Setup Templates like Homepage/404/Search/Page/Single and more templates Layout:', 'newsetmag') ?></strong>
                        <ul>
                            <li> - <?php echo __('Go to Appearance -> Editor -> Templates:', 'newsetmag') ?></li>
                            <li> - <?php echo __('click on Template(You need to edit/update) > Click on Edit (Icon) > Add or Remove Requirend block/content as your requirement.:', 'newsetmag') ?></li>
                            <li> - <?php echo __('Click on save to update your layout', 'newsetmag') ?></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <h3><?php echo __('Required Plugins', 'newsetmag'); ?></h3>
        <p class="notice-text"><?php echo __('Please install and activate all recommended pluign to import the demo with "one click demo import" feature and unlock premium features!(For Pro version)', 'newsetmag') ?></p>
        <ul class="newsetmag-required-plugin">
            <li>
                <h4><?php echo __('1.  Walker Core', 'newsetmag'); ?>
                    <?php
                    if (newsetmag_is_plugin_activated('walker-core/walker-core.php')) {
                        echo __(': Plugin has been already activated!', 'newsetmag');
                    } elseif (newsetmag_is_plugin_installed('walker-core/walker-core.php')) {
                        echo __(': Plugin does not activated, Activate the plugin to use one click demo import and unlock premium features.', 'newsetmag');
                    } else {
                        echo ': <a href="' . get_admin_url() . 'plugin-install.php?tab=plugin-information&plugin=walker-core&TB_iframe=true&width=600&height=550">' . esc_html__('Install and Activate', 'newsetmag') . '</a>';
                    }
                    ?>
                </h4>
            </li>
            <li>
                <h4><?php echo __('2. Advanced Import - Need only to use "one click demo import" features', 'newsetmag'); ?>
                    <?php
                    if (newsetmag_is_plugin_activated('advanced-import/advanced-import.php')) {
                        echo __(': Plugin has been already activated!', 'newsetmag');
                    } elseif (newsetmag_is_plugin_installed('advanced-import/advanced-import.php')) {
                        echo __(': Plugin does not activated, Activate the plugin to use one click demo import feature.', 'newsetmag');
                    } else {
                        echo ': <a href="' . get_admin_url() . 'plugin-install.php?tab=plugin-information&plugin=advanced-import&TB_iframe=true&width=600&height=550">' . esc_html__('Install and Activate', 'newsetmag') . '</a>';
                    }
                    ?>
                </h4>
            </li>
        </ul>
        <div class="featured-list">
            <div class="half-col free-features">
                <h3><?php echo __('Newsetmag Features (Free)', 'newsetmag') ?></h3>
                <ul>
                    <li><strong> - <?php echo __('Home Sections and Patterns', 'newsetmag') ?></strong>
                        <ul>
                            <li> <?php echo __('404 - Page Not Found pattern', 'newsetmag') ?></li>
                            <li> <?php echo __('Blog section pattern - 9', 'newsetmag') ?></li>
                            <li> <?php echo __('Sidebar pattern', 'newsetmag') ?></li>
                        </ul>
                    </li>
                    <li> <strong>- <?php echo __('Our FSE Templates Ready', 'newsetmag') ?></strong>
                        <ul>
                            <li> <?php echo __('404 Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Archive Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Blank Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Front Page Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Left Sidebar Page Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Page Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Right Sidebar Page Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Search Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Left Sidebar Single Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Single Full Width Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Single Right Sidebar Template', 'newsetmag') ?></li>
                            <li> <?php echo __('Sitemap Template', 'newsetmag') ?></li>
                        </ul>
                    <li>
                    <li><strong> - <?php echo __('Header Layouts', 'newsetmag') ?></strong></li>
                    <li> <strong>- <?php echo __('Footer Layouts', 'newsetmag') ?></strong></li>
                    <li> <strong>- <?php echo __('Sidebar Layouts', 'newsetmag') ?></strong></li>
                    <li><strong> - <?php echo __('Multiple Beautiful Fonts Option', 'newsetmag') ?></strong></li>
                </ul>
            </div>
            <div class="half-col pro-features">
                <h3><?php echo __('Premium Features', 'newsetmag') ?></h3>
                <ul>
                    <li><?php echo __('Including all free features and more Premium patterns (20+ Patterns and 10+ Templates)', 'newsetmag') ?></strong></li>
                    <li><?php echo __('13 Blog Parts Layout', 'newsetmag') ?></li>
                    <li><?php echo __('6 Slider Patterns', 'newsetmag') ?></li>
                    <li><?php echo __('2 Card Carousel Patterns', 'newsetmag') ?></li>
                    <li><?php echo __('Trending Blods Slider Patterns', 'newsetmag') ?></li>
                    <li><?php echo __('Pro Sidebar Patterns', 'newsetmag') ?></li>
                    <li><?php echo __('Multiple Blog Layout Variations', 'newsetmag') ?></li>
                </ul>
            </div>
        </div>
    </div>
<?php
}
