<?php

/**
 * About setup
 *
 * @package Ai Blog
 */

require_once trailingslashit(get_template_directory()) . 'inc/about/class.about.php';

if (!function_exists('ai_blog_about_setup')) :

	/**
	 * About setup.
	 *
	 * @since 1.0.0
	 */
	function ai_blog_about_setup()
	{
		$theme = wp_get_theme();
		$xtheme_name = $theme->get('Name');
		$xtheme_domain = $theme->get('TextDomain');




		$config = array(
			// Menu name under Appearance.
			'menu_name'               => sprintf(esc_html__('%s Info', 'ai-blog'), $xtheme_name),
			// Page title.
			'page_name'               => sprintf(esc_html__('%s Info', 'ai-blog'), $xtheme_name),
			/* translators: Main welcome title */
			'welcome_title'         => sprintf(esc_html__('Welcome to %s! - Version ', 'ai-blog'), $theme['Name']),
			// Main welcome content
			// Welcome content.
			'welcome_content' => sprintf(esc_html__('%1$s is now installed and ready to use. We want to make sure you have the best experience using the theme and that is why we gathered here all the necessary information for you. Thanks for using our theme!', 'ai-blog'), $theme['Name']),

			// Tabs.
			'tabs' => array(
				'getting_started' => esc_html__('Getting Started', 'ai-blog'),
				'recommended_actions' => esc_html__('Recommended Actions', 'ai-blog'),
				'useful_plugins'  => esc_html__('Useful Plugins', 'ai-blog'),
				'free_pro'  => esc_html__('Free Vs Pro', 'ai-blog'),
			),

			// Quick links.
			'quick_links' => array(
				'xmagazine_url' => array(
					'text'   => esc_html__('UPGRADE Ai Blog PRO', 'ai-blog'),
					'url'    => 'https://wpthemespace.com/product/ai-blog-pro/?add-to-cart=8864',
					'button' => 'danger',
				),

				'update_url' => array(
					'text'   => esc_html__('Ai Blog PRO Video', 'ai-blog'),
					'url'    => 'https://www.youtube.com/watch?v=Bcf5Ve1eObE',
					'button' => 'danger',
				),

			),

			// Getting started.
			'getting_started' => array(
				'one' => array(
					'title'       => esc_html__('Demo Content', 'ai-blog'),
					'icon'        => 'dashicons dashicons-layout',
					'description' => sprintf(esc_html__('Demo content is pro feature. To import sample demo content, %1$s plugin should be installed and activated. After plugin is activated, visit Import Demo Data menu under Appearance.', 'ai-blog'), esc_html__('One Click Demo Import', 'ai-blog')),
					'button_text' => esc_html__('UPGRADE For  Demo Content', 'ai-blog'),
					'button_url'  => 'https://wpthemespace.com/product/ai-blog-pro/?add-to-cart=8864',
					'button_type' => 'primary',
					'is_new_tab'  => true,
				),

				'two' => array(
					'title'       => esc_html__('Theme Options', 'ai-blog'),
					'icon'        => 'dashicons dashicons-admin-customizer',
					'description' => esc_html__('Theme uses Customizer API for theme options. Using the Customizer you can easily customize different aspects of the theme.', 'ai-blog'),
					'button_text' => esc_html__('Customize', 'ai-blog'),
					'button_url'  => wp_customize_url(),
					'button_type' => 'primary',
				),
				'three' => array(
					'title'       => esc_html__('Show Video', 'ai-blog'),
					'icon'        => 'dashicons dashicons-layout',
					'description' => sprintf(esc_html__('You may show Ai Blog short video for better understanding', 'ai-blog'), esc_html__('One Click Demo Import', 'ai-blog')),
					'button_text' => esc_html__('Show video', 'ai-blog'),
					'button_url'  => 'https://www.youtube.com/watch?v=Bcf5Ve1eObE',
					'button_type' => 'primary',
					'is_new_tab'  => true,
				),
				'five' => array(
					'title'       => esc_html__('Set Widgets', 'ai-blog'),
					'icon'        => 'dashicons dashicons-tagcloud',
					'description' => esc_html__('Set widgets in your sidebar, Offcanvas as well as footer.', 'ai-blog'),
					'button_text' => esc_html__('Add Widgets', 'ai-blog'),
					'button_url'  => admin_url() . '/widgets.php',
					'button_type' => 'link',
					'is_new_tab'  => true,
				),
				'six' => array(
					'title'       => esc_html__('Theme Preview', 'ai-blog'),
					'icon'        => 'dashicons dashicons-welcome-view-site',
					'description' => esc_html__('You can check out the theme demos for reference to find out what you can achieve using the theme and how it can be customized. Theme demo only work in pro theme', 'ai-blog'),
					'button_text' => esc_html__('View Demo', 'ai-blog'),
					'button_url'  => 'https://blog.wpteamx.com/ai/ai-demos/',
					'button_type' => 'link',
					'is_new_tab'  => true,
				),
				'seven' => array(
					'title'       => esc_html__('Contact Support', 'ai-blog'),
					'icon'        => 'dashicons dashicons-sos',
					'description' => esc_html__('Got theme support question or found bug or got some feedbacks? Best place to ask your query is the dedicated Support forum for the theme.', 'ai-blog'),
					'button_text' => esc_html__('Contact Support', 'ai-blog'),
					'button_url'  => 'https://wpthemespace.com/support/',
					'button_type' => 'link',
					'is_new_tab'  => true,
				),
			),

			'useful_plugins'        => array(
				'description' => esc_html__('Theme supports some helpful WordPress plugins to enhance your site. But, please enable only those plugins which you need in your site. For example, enable WooCommerce only if you are using e-commerce.', 'ai-blog'),
				'already_activated_message' => esc_html__('Already activated', 'ai-blog'),
				'version_label' => esc_html__('Version: ', 'ai-blog'),
				'install_label' => esc_html__('Install and Activate', 'ai-blog'),
				'activate_label' => esc_html__('Activate', 'ai-blog'),
				'deactivate_label' => esc_html__('Deactivate', 'ai-blog'),
				'content'                   => array(
					array(
						'slug' => 'magical-addons-for-elementor',
						'icon' => 'svg',
					),
					array(
						'slug' => 'magical-products-display'
					),
					array(
						'slug' => 'magical-posts-display'
					),
					array(
						'slug' => 'click-to-top'
					),
					array(
						'slug' => 'gallery-box',
						'icon' => 'svg',
					),
					array(
						'slug' => 'magical-blocks'
					),
					array(
						'slug' => 'easy-share-solution',
						'icon' => 'svg',
					),
					array(
						'slug' => 'wp-edit-password-protected',
						'icon' => 'svg',
					),
				),
			),
			// Required actions array.
			'recommended_actions'        => array(
				'install_label' => esc_html__('Install and Activate', 'ai-blog'),
				'activate_label' => esc_html__('Activate', 'ai-blog'),
				'deactivate_label' => esc_html__('Deactivate', 'ai-blog'),
				'content'            => array(
					'magical-blocks' => array(
						'title'       => __('Magical Posts Display', 'ai-blog'),
						'description' => __('Now you can add or update your site elements very easily by Magical Products Display. Supercharge your Elementor block with highly customizable Magical Blocks For WooCommerce.', 'ai-blog'),
						'plugin_slug' => 'magical-products-display',
						'id' => 'magical-posts-display'
					),
					'go-pro' => array(
						'title'       => '<a target="_blank" class="activate-now button button-danger" href="https://wpthemespace.com/product/ai-blog-pro/?add-to-cart=8864">' . __('UPGRADE Ai Blog PRO', 'ai-blog') . '</a>',
						'description' => __('You will get more frequent updates and quicker support with the Pro version.', 'ai-blog'),
						//'plugin_slug' => 'x-instafeed',
						'id' => 'go-pro'
					),

				),
			),
			// Free vs pro array.
			'free_pro'                => array(
				'free_theme_name'     => $xtheme_name,
				'pro_theme_name'      => $xtheme_name . __(' Pro', 'ai-blog'),
				'pro_theme_link'      => 'https://wpthemespace.com/product/ai-blog-pro/',
				/* translators: View link */
				'get_pro_theme_label' => sprintf(__('Get %s', 'ai-blog'), 'Ai Blog Pro'),
				'features'            => array(
					array(
						'title'       => esc_html__('Daring Design for Devoted Readers', 'ai-blog'),
						'description' => esc_html__('Ai Blog\'s design helps you stand out from the crowd and create an experience that your readers will love and talk about. With a flexible home page you have the chance to easily showcase appealing content with ease.', 'ai-blog'),
						'is_in_lite'  => 'true',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Mobile-Ready For All Devices', 'ai-blog'),
						'description' => esc_html__('Ai Blog makes room for your readers to enjoy your articles on the go, no matter the device their using. We shaped everything to look amazing to your audience.', 'ai-blog'),
						'is_in_lite'  => 'true',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Home slider', 'ai-blog'),
						'description' => esc_html__('Ai Blog gives you extra slider feature. You can create awesome home slider in this theme.', 'ai-blog'),
						'is_in_lite'  => 'true',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Widgetized Sidebars To Keep Attention', 'ai-blog'),
						'description' => esc_html__('Ai Blog comes with a widget-based flexible system which allows you to add your favorite widgets over the Sidebar as well as on offcanvas too.', 'ai-blog'),
						'is_in_lite'  => 'true',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Auto Set-up Feature', 'ai-blog'),
						'description' => esc_html__('You can import demo site only one click so you can setup your site like demo very easily.', 'ai-blog'),
						'is_in_lite'  => 'ture',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Multiple Header Layout', 'ai-blog'),
						'description' => esc_html__('Ai Blog gives you extra ways to showcase your header with miltiple layout option you can change it on the basis of your requirement', 'ai-blog'),
						'is_in_lite'  => 'true',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('One Click Demo install', 'ai-blog'),
						'description' => esc_html__('You can import demo site only one click so you can setup your site like demo very easily.', 'ai-blog'),
						'is_in_lite'  => 'ture',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Extra Drag and drop support', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Advanced News Filter', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('News/posts Carousel', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Diffrent Style Blog', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Flexible Home Page Design', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Pro Service Section', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Animation Home Text', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Advance Customizer Options', 'ai-blog'),
						'description' => esc_html__('Advance control for each element gives you different way of customization and maintained you site as you like and makes you feel different.', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('Advance Pagination', 'ai-blog'),
						'description' => esc_html__('Multiple Option of pagination via customizer can be obtained on your site like Infinite scroll, Ajax Button On Click, Number as well as classical option are available.', 'ai-blog'),
						'is_in_lite'  => 'ture',
						'is_in_pro'   => 'true',
					),

					array(
						'title'       => esc_html__('Premium Support and Assistance', 'ai-blog'),
						'description' => esc_html__('We offer ongoing customer support to help you get things done in due time. This way, you save energy and time, and focus on what brings you happiness. We know our products inside-out and we can lend a hand to help you save resources of all kinds.', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
					array(
						'title'       => esc_html__('No Credit Footer Link', 'ai-blog'),
						'description' => esc_html__('You can easily remove the Theme: Ai Blog by Ai Blog copyright from the footer area and make the theme yours from start to finish.', 'ai-blog'),
						'is_in_lite'  => 'false',
						'is_in_pro'   => 'true',
					),
				),
			),

		);

		ai_blog_About::init($config);
	}

endif;

add_action('after_setup_theme', 'ai_blog_about_setup');



function ai_blog_pnotice_output()
{

?>
	<div class="ai-blog-pro-notice" id="ai-blog-pro-notice">
		<div class="ai-blog-pro-notice-inner">
			<div class="ai-blog-pro-notice-content">
				<?php
				$current_theme = wp_get_theme();
				$current_theme_name = $current_theme->get('Name');
				$current_user = wp_get_current_user();
				$pro_link = esc_url('https://wpthemespace.com/product/ai-blog-pro/?add-to-cart=8864');
				$demo_link = esc_url('https://wpthemespace.com/product/ai-blog-pro/');
				?>
				<div class="ai-blog-pro-notice-header">
					<span class="ai-blog-pro-greeting">Hello, <?php echo esc_html($current_user->display_name); ?> 👋</span>
					<span class="ai-blog-pro-badge">PRO</span>
				</div>
				<h3 class="ai-blog-pro-notice-title">🚀 Upgrade to <?php echo esc_html($current_theme_name); ?> Pro</h3>
				<p class="ai-blog-pro-notice-desc">Get advanced customization, premium templates, priority support & lifetime updates. <strong>Special offer: $21 + FREE setup!</strong></p>
				<div class="ai-blog-pro-changelog">
					<span class="ai-blog-pro-changelog-badge">v1.1.1</span>
					<span class="ai-blog-pro-changelog-text">New: AI Marketing Expert integration, improved caching, mobile menu fixes</span>
				</div>
			</div>
			<div class="ai-blog-pro-notice-actions">
				<a href="<?php echo esc_url($pro_link); ?>" target="_blank" class="ai-blog-pro-btn ai-blog-pro-btn-primary">🔥 Upgrade Now</a>
				<a href="<?php echo esc_url($demo_link); ?>" target="_blank" class="ai-blog-pro-btn ai-blog-pro-btn-secondary">👀 View Pro</a>
				<button class="ai-blog-pro-btn ai-blog-pro-btn-dismiss" id="ai-blog-pro-dismiss">Maybe Later</button>
			</div>
			<button class="ai-blog-pro-notice-close" id="ai-blog-pro-close" aria-label="Dismiss">
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
			</button>
		</div>
	</div>
<?php
}


//Admin notice 
function ai_blog_new_optins_texts()
{
	$hide_date = get_option('ai_blog_info_text_notice');
	if (!empty($hide_date)) {
		$clickhide = round((time() - strtotime($hide_date)) / 24 / 60 / 60);
		if ($clickhide < 25) {
			return;
		}
	}


?>
	<div class="mgadin-notice notice notice-success mgadin-theme-dashboard mgadin-theme-dashboard-notice mge is-dismissible meis-dismissible">
		<?php ai_blog_pnotice_output(); ?>
	</div>
<?php

}
add_action('admin_notices', 'ai_blog_new_optins_texts');



function ai_blog_new_optins_texts_init()
{
	if (isset($_GET['xbnotice']) && $_GET['xbnotice'] == 1) {
		update_option('ai_blog_info_text_notice', current_time('mysql'));
	}
}
add_action('init', 'ai_blog_new_optins_texts_init');

/**
 * Enqueue admin notice assets
 */
function ai_blog_enqueue_admin_notice_assets($hook) {
    // Only load on admin pages where the notice appears
    if (is_admin()) {
        wp_enqueue_script(
            'ai-blog-admin-notice',
            get_template_directory_uri() . '/assets/js/admin-notice.js',
            array('jquery'),
            '1.0.1',
            true
        );
        
        // Enqueue admin bar styles
        wp_enqueue_style(
            'ai-blog-admin-bar',
            get_template_directory_uri() . '/assets/css/admin-bar.css',
            array(),
            '1.0.0'
        );
    }
}
add_action('admin_enqueue_scripts', 'ai_blog_enqueue_admin_notice_assets');

/**
 * Enqueue admin bar styles for frontend
 */
function ai_blog_enqueue_admin_bar_styles() {
    // Only load when admin bar is showing
    if (is_admin_bar_showing()) {
        wp_enqueue_style(
            'ai-blog-admin-bar',
            get_template_directory_uri() . '/assets/css/admin-bar.css',
            array(),
            '1.0.0'
        );
    }
}
add_action('wp_enqueue_scripts', 'ai_blog_enqueue_admin_bar_styles');
