<?php
/**
 * @package Demo Import
 * @since 1.0.0
 */

class ThemeWhizzie {

	protected $version = '1.1.0';

	/** @var string Current theme name, used as namespace in actions. */
	protected $theme_name = '';
	protected $theme_title = '';

	/** @var string Demo Import page slug and title. */
	protected $page_slug = '';
	protected $page_title = '';

	/** @var array Demo Import steps set by user. */
	protected $config_steps = array();
	public $parent_slug;
	/**
	 * Constructor
	 *
	 * @param $seo_specialist_config	Our config parameters
	*/
	public function __construct( $seo_specialist_config ) {
		$this->set_vars( $seo_specialist_config );
		$this->init();
	}

	/**
	 * Set some settings
	 * @since 1.0.0
	 * @param $seo_specialist_config	Our config parameters
	*/
	public function set_vars( $seo_specialist_config ) {
		if( isset( $seo_specialist_config['page_slug'] ) ) {
			$this->page_slug = esc_attr( $seo_specialist_config['page_slug'] );
		}
		if( isset( $seo_specialist_config['page_title'] ) ) {
			$this->page_title = esc_attr( $seo_specialist_config['page_title'] );
		}
		if( isset( $seo_specialist_config['steps'] ) ) {
			$this->config_steps = $seo_specialist_config['steps'];
		}

		$current_theme = wp_get_theme();
		$this->theme_title = $current_theme->get( 'Name' );
		$this->theme_name = strtolower( preg_replace( '#[^a-zA-Z]#', '', $current_theme->get( 'Name' ) ) );
		$this->page_slug = apply_filters( $this->theme_name . '_theme_setup_wizard_page_slug', $this->theme_name . '-demoimport' );
		$this->parent_slug = apply_filters( $this->theme_name . '_theme_setup_wizard_parent_slug', '' );
	}

	/**
	 * Hooks and filters
	 * @since 1.0.0
	*/
	public function init() {
		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
		add_action( 'admin_menu', array( $this, 'menu_page' ) );
		add_action( 'wp_ajax_setup_widgets', array( $this, 'setup_widgets' ) );
	}

	public function enqueue_scripts() {
		wp_enqueue_style( 'demo-import-style', get_template_directory_uri() . '/demo-import/assets/css/demo-import-style.css');
		wp_register_script( 'demo-import-script', get_template_directory_uri() . '/demo-import/assets/js/demo-import-script.js', array( 'jquery' ), time() );
		wp_localize_script(
			'demo-import-script',
			'seo_specialist_whizzie_params',
			array(
				'ajaxurl' 		=> admin_url( 'admin-ajax.php' ),
				'wpnonce' 		=> wp_create_nonce( 'whizzie_nonce' ),
				'verify_text'	=> esc_html( 'verifying', 'seo-specialist' )
			)
		);
		wp_enqueue_script( 'demo-import-script' );
	}

	/**  Make a modal screen for the wizard **/
	public function menu_page() {
		add_menu_page( esc_html( $this->page_title ), esc_html( $this->page_title ), 'manage_options', $this->page_slug, array( $this, 'seo_specialist_guide' ) ,'',40);
	}

	/** Make an interface for the wizard **/
	public function wizard_page() {
		/* If we arrive here, we have the filesystem */ ?>
		<div class="wrap">
			<?php echo '<div class="whizzie-wrap">';
				// The wizard is a list with only one item visible at a time
				$steps = $this->get_steps();
				echo '<ul class="whizzie-nav wizard-icon-nav">';?>
				<?php
					$stepI=1;
					foreach( $steps as $step ) {
						$stepAct=($stepI ==1)? 1 : 0;
						if( isset( $step['icon_text'] ) && $step['icon_text'] ) {
							echo '<li class="commom-cls nav-step-' . esc_attr( $step['id'] ) . '" wizard-steps="step-'.esc_attr( $step['id'] ).'" data-enable="'.$stepAct.'">
							<p>'.esc_attr( $step['icon_text'] ).'</p>
							</li>';
						}
					$stepI++;}
			 	echo '</ul>';
				echo '<ul class="whizzie-menu wizard-menu-page">';
				foreach( $steps as $step ) {
					$class = 'step step-' . esc_attr( $step['id'] );
					echo '<li data-step="' . esc_attr( $step['id'] ) . '" class="' . esc_attr( $class ) . '" >';
						$content = call_user_func( array( $this, $step['view'] ) );
						printf('<div class="wizard-button-wrapper">');
							if( isset( $step['button_text_one'] )) {
								printf(
									'<div class="button-wrap button-wrap-one">
										<a href="#" class="button button-primary do-it" data-callback="install_widgets" data-step="widgets"><p class="demo-type-text">%s</p></a>
									</div>',
									esc_html( $step['button_text_one'] )
								);
							}
						printf('</div>');
					echo '</li>';
				}
				echo '</ul>';
				?>
				<div class="step-loading"><span class="spinner">
					<img src="<?php echo esc_url(get_template_directory_uri().'/demo-import/assets/images/Spinner-Animaion.gif'); ?>">
				</span></div>
			<?php echo '</div>';?>
		</div>
	<?php }

	/**
	 * Set options for the steps
	 * @return Array
	*/
	public function get_steps() {
		$dev_steps = $this->config_steps;
		$steps = array(
			'widgets' => array(
				'id'			=> 'widgets',
				'title'			=> __( 'Customizer', 'seo-specialist' ),
				'icon'			=> 'welcome-widgets-menus',
				'view'			=> 'get_step_widgets',
				'callback'		=> 'install_widgets',
				'button_text_one'	=> __( 'Import Demo', 'seo-specialist' ),
				'can_skip'		=> true,
				'icon_text'      => 'Import Demo'
			),
			'done' => array(
				'id'			=> 'done',
				'title'			=> __( 'All Done', 'seo-specialist' ),
				'icon'			=> 'yes',
				'view'			=> 'get_step_done',
				'callback'		=> '',
				'icon_text'      => 'Done'
			)
		);
		// Iterate through each step and replace with dev config values
		if( $dev_steps ) {
			// Configurable elements - these are the only ones the dev can update from config.php
			$can_config = array( 'title', 'icon', 'button_text', 'can_skip' );
			foreach( $dev_steps as $dev_step ) {
				// We can only proceed if an ID exists and matches one of our IDs
				if( isset( $dev_step['id'] ) ) {
					$id = $dev_step['id'];
					if( isset( $steps[$id] ) ) {
						foreach( $can_config as $element ) {
							if( isset( $dev_step[$element] ) ) {
								$steps[$id][$element] = $dev_step[$element];
							}
						}
					}
				}
			}
		}
		return $steps;
	}

	/**    Print the content for the intro step     **/
		public function get_step_importer() { ?>
		<div class="summary">
			<p>
				<?php esc_html_e('Thank you for choosing this SEO Specialist Theme. Using this quick setup wizard, you will be able to configure your new website and get it running in just a few minutes. Just follow these simple steps mentioned in the wizard and get started with your website.','seo-specialist'); ?>
			</p>
		</div>
	<?php }

	/**   Print the content for the widgets step   **/
	public function get_step_widgets() { ?>
		<div class="summary">
			<p>
				<?php esc_html_e('This theme allows you to import demo content and add widgets. Install them using the button below. You can also update or deactivate them using the Customizer.','seo-specialist'); ?>
			</p>
		</div>
	<?php }

	/** Print the content for the final step **/
	public function get_step_done() { ?>

		<div class="setup-finish">
			<p>
				<?php echo esc_html('Your demo content has been imported successfully. Click the finish button for more information.'); ?>
			</p>
			<div class="finish-buttons">
				<a href="<?php echo esc_url( admin_url( 'themes.php?page=seo-specialist-getstart-page' ) ); ?>" class="wz-btn-customizer" target="_blank"><?php esc_html_e('About SEO Specialist','seo-specialist') ?></a>
				<a href="<?php echo esc_url(admin_url('/customize.php')); ?>" class="wz-btn-customizer" target="_blank"><?php esc_html_e('Customize Your Demo','seo-specialist') ?></a>
				<a href="" class="wz-btn-builder" target="_blank"><?php esc_html_e('Customize Your Demo','seo-specialist'); ?></a>
				<a href="<?php echo esc_url(home_url()); ?>" class="wz-btn-visit-site" target="_blank"><?php esc_html_e('Visit Your Site','seo-specialist'); ?></a>
			</div>
			<div class="finish-buttons">
				<a href="<?php echo esc_url(admin_url()); ?>" class="button button-primary"><?php esc_html_e('Finish','seo-specialist'); ?></a>
			</div>
		</div>

	<?php }


	public function seo_specialist_customizer_nav_menu() {
		// ------- Create Primary Menu --------
		$seo_specialist_themename = 'SEO Specialist'; // Ensure the theme name is set
		$seo_specialist_menuname = $seo_specialist_themename . ' Responsive Menu';
		$seo_specialist_menulocation = 'responsive-menu';
		$seo_specialist_menu_exists = wp_get_nav_menu_object($seo_specialist_menuname);

		if (!$seo_specialist_menu_exists) {
			$seo_specialist_menu_id = wp_create_nav_menu($seo_specialist_menuname);

			// Home
			wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
				'menu-item-title' => __('Home', 'seo-specialist'),
				'menu-item-classes' => 'home',
				'menu-item-url' => home_url('/'),
				'menu-item-status' => 'publish'
			));

			// About
			$seo_specialist_page_about = get_page_by_path('about');
			if($seo_specialist_page_about){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('About', 'seo-specialist'),
					'menu-item-classes' => 'about',
					'menu-item-url' => get_permalink($seo_specialist_page_about),
					'menu-item-status' => 'publish'
				));
			}

			// Services
			$seo_specialist_page_services = get_page_by_path('services');
			if($seo_specialist_page_services){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Services', 'seo-specialist'),
					'menu-item-classes' => 'services',
					'menu-item-url' => get_permalink($seo_specialist_page_services),
					'menu-item-status' => 'publish'
				));
			}

			// Blog
			$seo_specialist_page_blog = get_page_by_path('blog');
			if($seo_specialist_page_blog){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Blog', 'seo-specialist'),
					'menu-item-classes' => 'blog',
					'menu-item-url' => get_permalink($seo_specialist_page_blog),
					'menu-item-status' => 'publish'
				));
			}

			// Project
			$seo_specialist_page_project = get_page_by_path('project');
			if($seo_specialist_page_project){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Project', 'seo-specialist'),
					'menu-item-classes' => 'project',
					'menu-item-url' => get_permalink($seo_specialist_page_project),
					'menu-item-status' => 'publish'
				));
			}

			// Contact Us
			$seo_specialist_page_contact = get_page_by_path('contact');
			if($seo_specialist_page_contact){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Contact Us', 'seo-specialist'),
					'menu-item-classes' => 'contact',
					'menu-item-url' => get_permalink($seo_specialist_page_contact),
					'menu-item-status' => 'publish'
				));
			}

			// Assign menu to location if not set
			if (!has_nav_menu($seo_specialist_menulocation)) {
				$seo_specialist_locations = get_theme_mod('nav_menu_locations');
				$seo_specialist_locations[$seo_specialist_menulocation] = $seo_specialist_menu_id; // Use $seo_specialist_menu_id here
				set_theme_mod('nav_menu_locations', $seo_specialist_locations);
			}
		}
	}
	
	public function seo_specialist_social_menu() {

		// ------- Create Social Menu --------
		$seo_specialist_themename = 'SEO Specialist'; // Ensure the theme name is set
		$seo_specialist_menuname = $seo_specialist_themename . ' Social Menu';
		$seo_specialist_menulocation = 'social-menu';
		$seo_specialist_menu_exists = wp_get_nav_menu_object( $seo_specialist_menuname );

		if( !$seo_specialist_menu_exists){
			$seo_specialist_menu_id = wp_create_nav_menu($seo_specialist_menuname);

			wp_update_nav_menu_item( $seo_specialist_menu_id, 0, array(
				'menu-item-title'  => __( 'Facebook', 'seo-specialist' ),
				'menu-item-url'    => 'https://www.facebook.com',
				'menu-item-status' => 'publish',
			) );

			wp_update_nav_menu_item( $seo_specialist_menu_id, 0, array(
				'menu-item-title'  => __( 'Pinterest', 'seo-specialist' ),
				'menu-item-url'    => 'https://www.pinterest.com',
				'menu-item-status' => 'publish',
			) );
	
			wp_update_nav_menu_item( $seo_specialist_menu_id, 0, array(
				'menu-item-title'  => __( 'Twitter', 'seo-specialist' ),
				'menu-item-url'    => 'https://www.twitter.com',
				'menu-item-status' => 'publish',
			) );
	
			wp_update_nav_menu_item( $seo_specialist_menu_id, 0, array(
				'menu-item-title'  => __( 'Youtube', 'seo-specialist' ),
				'menu-item-url'    => 'https://www.youtube.com',
				'menu-item-status' => 'publish',
			) );

			wp_update_nav_menu_item( $seo_specialist_menu_id, 0, array(
				'menu-item-title'  => __( 'Instagram', 'seo-specialist' ),
				'menu-item-url'    => 'https://www.instagram.com',
				'menu-item-status' => 'publish',
			) );

			if( !has_nav_menu( $seo_specialist_menulocation ) ){
					$locations = get_theme_mod('nav_menu_locations');
					$locations[$seo_specialist_menulocation] = $seo_specialist_menu_id;
					set_theme_mod( 'nav_menu_locations', $locations );
			}
		}
	}

	public function seo_specialist_customizer_left_menu() {
		// ------- Create Primary Menu --------
		$seo_specialist_themename = 'SEO Specialist'; // Ensure the theme name is set
		$seo_specialist_menuname = $seo_specialist_themename . ' Left Menu';
		$seo_specialist_menulocation = 'left-menu';
		$seo_specialist_menu_exists = wp_get_nav_menu_object($seo_specialist_menuname);

		if (!$seo_specialist_menu_exists) {
			$seo_specialist_menu_id = wp_create_nav_menu($seo_specialist_menuname);

			// Home
			wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
				'menu-item-title' => __('Home', 'seo-specialist'),
				'menu-item-classes' => 'home',
				'menu-item-url' => home_url('/'),
				'menu-item-status' => 'publish'
			));

			// About
			$seo_specialist_page_about = get_page_by_path('about');
			if($seo_specialist_page_about){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('About', 'seo-specialist'),
					'menu-item-classes' => 'about',
					'menu-item-url' => get_permalink($seo_specialist_page_about),
					'menu-item-status' => 'publish'
				));
			}

			// Services
			$seo_specialist_page_services = get_page_by_path('services');
			if($seo_specialist_page_services){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Services', 'seo-specialist'),
					'menu-item-classes' => 'services',
					'menu-item-url' => get_permalink($seo_specialist_page_services),
					'menu-item-status' => 'publish'
				));
			}

			// Assign menu to location if not set
			if (!has_nav_menu($seo_specialist_menulocation)) {
				$seo_specialist_locations = get_theme_mod('nav_menu_locations');
				$seo_specialist_locations[$seo_specialist_menulocation] = $seo_specialist_menu_id; // Use $seo_specialist_menu_id here
				set_theme_mod('nav_menu_locations', $seo_specialist_locations);
			}
		}
	}

	public function seo_specialist_customizer_right_menu() {
		// ------- Create Primary Menu --------
		$seo_specialist_themename = 'SEO Specialist'; // Ensure the theme name is set
		$seo_specialist_menuname = $seo_specialist_themename . ' Right Menu';
		$seo_specialist_menulocation = 'right-menu';
		$seo_specialist_menu_exists = wp_get_nav_menu_object($seo_specialist_menuname);

		if (!$seo_specialist_menu_exists) {
			$seo_specialist_menu_id = wp_create_nav_menu($seo_specialist_menuname);

			// Blog
			$seo_specialist_page_blog = get_page_by_path('blog');
			if($seo_specialist_page_blog){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Blog', 'seo-specialist'),
					'menu-item-classes' => 'blog',
					'menu-item-url' => get_permalink($seo_specialist_page_blog),
					'menu-item-status' => 'publish'
				));
			}

			// Project
			$seo_specialist_page_project = get_page_by_path('project');
			if($seo_specialist_page_project){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Project', 'seo-specialist'),
					'menu-item-classes' => 'project',
					'menu-item-url' => get_permalink($seo_specialist_page_project),
					'menu-item-status' => 'publish'
				));
			}

			// Contact Us
			$seo_specialist_page_contact = get_page_by_path('contact');
			if($seo_specialist_page_contact){
				wp_update_nav_menu_item($seo_specialist_menu_id, 0, array(
					'menu-item-title' => __('Contact Us', 'seo-specialist'),
					'menu-item-classes' => 'contact',
					'menu-item-url' => get_permalink($seo_specialist_page_contact),
					'menu-item-status' => 'publish'
				));
			}

			// Assign menu to location if not set
			if (!has_nav_menu($seo_specialist_menulocation)) {
				$seo_specialist_locations = get_theme_mod('nav_menu_locations');
				$seo_specialist_locations[$seo_specialist_menulocation] = $seo_specialist_menu_id; // Use $seo_specialist_menu_id here
				set_theme_mod('nav_menu_locations', $seo_specialist_locations);
			}
		}
	}

	/**
	* Imports the Demo Content
	* @since 1.1.0
	*/
	public function setup_widgets() {

		//................................................. MENU PAGES .................................................//
		
		$seo_specialist_home_id='';
		$seo_specialist_home_content = '';

		$seo_specialist_home_title = 'Home';
		$seo_specialist_home = array(
				'post_type' => 'page',
				'post_title' => $seo_specialist_home_title,
				'post_content'  => $seo_specialist_home_content,
				'post_status' => 'publish',
				'post_author' => 1,
				'post_slug' => 'home'
		);
		$seo_specialist_home_id = wp_insert_post($seo_specialist_home);

		//Set the home page template
		add_post_meta( $seo_specialist_home_id, '_wp_page_template', 'revolution-home.php' );

		//Set the static front page
		$seo_specialist_home = get_page_by_title( 'Home' );
		update_option( 'page_on_front', $seo_specialist_home->ID );
		update_option( 'show_on_front', 'page' );


		// Create a posts page and assign the template
		$seo_specialist_project_title = 'Project';
		$seo_specialist_project_check = get_page_by_path('project');
		if (!$seo_specialist_project_check) {
			$seo_specialist_project = array(
				'post_type'    => 'page',
				'post_title'   => $seo_specialist_project_title,
				'post_content'   => '"More About The Free SEO WordPress Theme"
									The Free SEO WordPress Theme is built with search engine optimization in mind and comes with clean, optimised code that improves page load speed and helps your website rank better in search results. The theme’s responsive and retina-ready design ensures that your website looks stunning on any device, whether a user is browsing on a desktop, tablet, or smartphone. The retina-ready design also ensures that visuals, including photography and graphics, appear in high definition, offering a professional and clean look across all screen sizes. Another standout feature is its customization options. Despite being a free theme, it offers extensive flexibility, allowing businesses to tailor the website to their specific needs. Customizable banners and sections like team bios and client testimonials help enhance credibility while adding a personal touch to your website.

									The Free SEO WordPress Theme allows you to publish blog posts, case studies, or guides, which can significantly boost your site’s SEO rankings. The blog feature also helps position your agency as an expert in digital marketing, SEO, or PPC services, further increasing your credibility in the industry. The theme comes with built-in call-to-action buttons and forms that are crucial for converting visitors into leads. Well-placed CTA buttons can significantly enhance the user journey, improving conversion rates and customer engagement. Social media integration is another key aspect of this theme. It allows you to seamlessly link your website to your social media platforms, such as Facebook, Twitter, LinkedIn, or Instagram. By connecting your social profiles to your website, you can grow your audience and engage with potential clients more effectively.

									The WooCommerce integration adds eCommerce functionality to your website, making it easy for digital marketing agencies to offer products or services directly from their site. Whether you’re selling SEO packages, digital marketing courses, or even branded merchandise, WooCommerce allows for a seamless shopping experience. For those who want to set up their website quickly, the theme includes demo content import. With a single click, you can load demo content to see how the theme looks in action, making it easier to customise and set up. This feature is particularly useful for digital marketing firms or SEM companies that need to establish an online presence quickly without extensive design work. Finally, the theme is optimised for speed and security. Additionally, the theme is compatible with security plugins, offering peace of mind to agencies that handle sensitive client information.',
				'post_status'  => 'publish',
				'post_author'  => 1,
				'post_name'    => 'project' // Unique slug for the project page
			);
			$seo_specialist_project_id = wp_insert_post($seo_specialist_project);

			// Set the posts page
			if (!is_wp_error($seo_specialist_project_id)) {
				update_option('page_for_posts', $seo_specialist_project_id);
			}
		}


		// Create a posts page and assign the template
		$seo_specialist_blog_title = 'Blog';
		$seo_specialist_blog_check = get_page_by_path('blog');
		if (!$seo_specialist_blog_check) {
			$seo_specialist_blog = array(
				'post_type'    => 'page',
				'post_title'   => $seo_specialist_blog_title,
				'post_status'  => 'publish',
				'post_author'  => 1,
				'post_name'    => 'blog' // Unique slug for the blog page
			);
			$seo_specialist_blog_id = wp_insert_post($seo_specialist_blog);

			// Set the posts page
			if (!is_wp_error($seo_specialist_blog_id)) {
				update_option('page_for_posts', $seo_specialist_blog_id);
			}
		}

		// Create a Contact Us page and assign the template
		$seo_specialist_contact_title = 'Contact Us';
		$seo_specialist_contact_check = get_page_by_path('contact');
		if (!$seo_specialist_contact_check) {
			$seo_specialist_contact = array(
				'post_type'    => 'page',
				'post_title'   => $seo_specialist_contact_title,
				'post_content'   => '"More About The Free SEO WordPress Theme"
									The Free SEO WordPress Theme is built with search engine optimization in mind and comes with clean, optimised code that improves page load speed and helps your website rank better in search results. The theme’s responsive and retina-ready design ensures that your website looks stunning on any device, whether a user is browsing on a desktop, tablet, or smartphone. The retina-ready design also ensures that visuals, including photography and graphics, appear in high definition, offering a professional and clean look across all screen sizes. Another standout feature is its customization options. Despite being a free theme, it offers extensive flexibility, allowing businesses to tailor the website to their specific needs. Customizable banners and sections like team bios and client testimonials help enhance credibility while adding a personal touch to your website.

									The Free SEO WordPress Theme allows you to publish blog posts, case studies, or guides, which can significantly boost your site’s SEO rankings. The blog feature also helps position your agency as an expert in digital marketing, SEO, or PPC services, further increasing your credibility in the industry. The theme comes with built-in call-to-action buttons and forms that are crucial for converting visitors into leads. Well-placed CTA buttons can significantly enhance the user journey, improving conversion rates and customer engagement. Social media integration is another key aspect of this theme. It allows you to seamlessly link your website to your social media platforms, such as Facebook, Twitter, LinkedIn, or Instagram. By connecting your social profiles to your website, you can grow your audience and engage with potential clients more effectively.

									The WooCommerce integration adds eCommerce functionality to your website, making it easy for digital marketing agencies to offer products or services directly from their site. Whether you’re selling SEO packages, digital marketing courses, or even branded merchandise, WooCommerce allows for a seamless shopping experience. For those who want to set up their website quickly, the theme includes demo content import. With a single click, you can load demo content to see how the theme looks in action, making it easier to customise and set up. This feature is particularly useful for digital marketing firms or SEM companies that need to establish an online presence quickly without extensive design work. Finally, the theme is optimised for speed and security. Additionally, the theme is compatible with security plugins, offering peace of mind to agencies that handle sensitive client information.',
				'post_status'  => 'publish',
				'post_author'  => 1,
				'post_name'    => 'contact' // Unique slug for the Contact Us page
			);
			wp_insert_post($seo_specialist_contact);
		}

		// Create a About page and assign the template
		$seo_specialist_about_title = 'About';
		$seo_specialist_about_check = get_page_by_path('about');
		if (!$seo_specialist_about_check) {
			$seo_specialist_about = array(
				'post_type'    => 'page',
				'post_title'   => $seo_specialist_about_title,
				'post_content'   => '"More About The Free SEO WordPress Theme"
									The Free SEO WordPress Theme is built with search engine optimization in mind and comes with clean, optimised code that improves page load speed and helps your website rank better in search results. The theme’s responsive and retina-ready design ensures that your website looks stunning on any device, whether a user is browsing on a desktop, tablet, or smartphone. The retina-ready design also ensures that visuals, including photography and graphics, appear in high definition, offering a professional and clean look across all screen sizes. Another standout feature is its customization options. Despite being a free theme, it offers extensive flexibility, allowing businesses to tailor the website to their specific needs. Customizable banners and sections like team bios and client testimonials help enhance credibility while adding a personal touch to your website.

									The Free SEO WordPress Theme allows you to publish blog posts, case studies, or guides, which can significantly boost your site’s SEO rankings. The blog feature also helps position your agency as an expert in digital marketing, SEO, or PPC services, further increasing your credibility in the industry. The theme comes with built-in call-to-action buttons and forms that are crucial for converting visitors into leads. Well-placed CTA buttons can significantly enhance the user journey, improving conversion rates and customer engagement. Social media integration is another key aspect of this theme. It allows you to seamlessly link your website to your social media platforms, such as Facebook, Twitter, LinkedIn, or Instagram. By connecting your social profiles to your website, you can grow your audience and engage with potential clients more effectively.

									The WooCommerce integration adds eCommerce functionality to your website, making it easy for digital marketing agencies to offer products or services directly from their site. Whether you’re selling SEO packages, digital marketing courses, or even branded merchandise, WooCommerce allows for a seamless shopping experience. For those who want to set up their website quickly, the theme includes demo content import. With a single click, you can load demo content to see how the theme looks in action, making it easier to customise and set up. This feature is particularly useful for digital marketing firms or SEM companies that need to establish an online presence quickly without extensive design work. Finally, the theme is optimised for speed and security. Additionally, the theme is compatible with security plugins, offering peace of mind to agencies that handle sensitive client information.',
				'post_status'  => 'publish',
				'post_author'  => 1,
				'post_name'    => 'about' // Unique slug for the About page
			);
			wp_insert_post($seo_specialist_about);
		}

		// Create a Services page and assign the template
		$seo_specialist_services_title = 'Services';
		$seo_specialist_services_check = get_page_by_path('services');
		if (!$seo_specialist_services_check) {
			$seo_specialist_services = array(
				'post_type'    => 'page',
				'post_title'   => $seo_specialist_services_title,
				'post_content'   => '"More About The Free SEO WordPress Theme"
									The Free SEO WordPress Theme is built with search engine optimization in mind and comes with clean, optimised code that improves page load speed and helps your website rank better in search results. The theme’s responsive and retina-ready design ensures that your website looks stunning on any device, whether a user is browsing on a desktop, tablet, or smartphone. The retina-ready design also ensures that visuals, including photography and graphics, appear in high definition, offering a professional and clean look across all screen sizes. Another standout feature is its customization options. Despite being a free theme, it offers extensive flexibility, allowing businesses to tailor the website to their specific needs. Customizable banners and sections like team bios and client testimonials help enhance credibility while adding a personal touch to your website.

									The Free SEO WordPress Theme allows you to publish blog posts, case studies, or guides, which can significantly boost your site’s SEO rankings. The blog feature also helps position your agency as an expert in digital marketing, SEO, or PPC services, further increasing your credibility in the industry. The theme comes with built-in call-to-action buttons and forms that are crucial for converting visitors into leads. Well-placed CTA buttons can significantly enhance the user journey, improving conversion rates and customer engagement. Social media integration is another key aspect of this theme. It allows you to seamlessly link your website to your social media platforms, such as Facebook, Twitter, LinkedIn, or Instagram. By connecting your social profiles to your website, you can grow your audience and engage with potential clients more effectively.

									The WooCommerce integration adds eCommerce functionality to your website, making it easy for digital marketing agencies to offer products or services directly from their site. Whether you’re selling SEO packages, digital marketing courses, or even branded merchandise, WooCommerce allows for a seamless shopping experience. For those who want to set up their website quickly, the theme includes demo content import. With a single click, you can load demo content to see how the theme looks in action, making it easier to customise and set up. This feature is particularly useful for digital marketing firms or SEM companies that need to establish an online presence quickly without extensive design work. Finally, the theme is optimised for speed and security. Additionally, the theme is compatible with security plugins, offering peace of mind to agencies that handle sensitive client information.',
				'post_status'  => 'publish',
				'post_author'  => 1,
				'post_name'    => 'services' // Unique slug for the Services page
			);
			wp_insert_post($seo_specialist_services);
		}


		//................................................. HEADER .................................................//

			set_theme_mod('seo_specialist_header_info_address','Lorem ipsum dolor sit amet consectetur.');

			set_theme_mod('seo_specialist_facebook_link_option','#');
			set_theme_mod('seo_specialist_twitter_link_option','#');
			set_theme_mod('seo_specialist_linkedin_link_option','#');
			set_theme_mod('seo_specialist_instagram_link_option','#');
			set_theme_mod('seo_specialist_youtube_link_option','#');

			set_theme_mod('seo_specialist_enable_slider',1);
			set_theme_mod('seo_specialist_enable_event',1);

		//................................................. SLIDER SECTION .................................................//

			for($seo_specialist_i=1;$seo_specialist_i<=3;$seo_specialist_i++){
				set_theme_mod( 'seo_specialist_slider_image'.$seo_specialist_i,get_template_directory_uri().'/revolution/assets/images/slider'.$seo_specialist_i.'.png' );
				set_theme_mod( 'seo_specialist_slider_heading'.$seo_specialist_i, 'Welcome To Digital Marketing' );
				set_theme_mod( 'seo_specialist_slider_text'.$seo_specialist_i, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do elusmod tempor incididunt ut labore et dolore' );
			}


		// ------------------------------------------ Gallery Section -------------------------------------- //

		set_theme_mod('seo_specialist_event_text','Our Best Gallery');

		wp_delete_post(1);
		$blog_title=array('Gallery Image Title 1','Gallery Image Title 2','Gallery Image Title 3','Gallery Image Title 4');
		for($i=1;$i<=4;$i++){
			$title =$blog_title[$i-1];
			$content = 'Lorem Ipsum is simply dummy text';

			// Create post object
			$my_post = array(
				'post_title'    => wp_strip_all_tags( $title ),
				'post_content'  => $content,
				'post_status'   => 'publish',
				'post_type'     => 'post',
			);

			// Insert the post into the database
			$post_id = wp_insert_post( $my_post );

			$image_url = get_template_directory_uri().'/revolution/assets/images/gallery'.$i.'.png';

			$image_name= 'gallery'.$i.'.png';
			$upload_dir       = wp_upload_dir();
			// Set upload folder
			$image_data       = file_get_contents($image_url);
			// Get image data
			$unique_file_name = wp_unique_filename( $upload_dir['path'], $image_name );
			// Generate unique name
			$filename= basename( $unique_file_name );
			// Create image file name
			// Check folder permission and define file location
			if( wp_mkdir_p( $upload_dir['path'] ) ) {
				 $file = $upload_dir['path'] . '/' . $filename;
			} else {
				 $file = $upload_dir['basedir'] . '/' . $filename;
			}
			// Create the image  file on the server
			if ( ! function_exists( 'WP_Filesystem' ) ) {
				require_once( ABSPATH . 'wp-admin/includes/file.php' );
			}

			WP_Filesystem();
			global $wp_filesystem;

			if ( ! $wp_filesystem->put_contents( $file, $image_data, FS_CHMOD_FILE ) ) {
				wp_die( 'Error saving file!' );
			}
			// Check image file type
			$wp_filetype = wp_check_filetype( $filename, null );
			// Set attachment data
			$attachment = array(
			 'post_mime_type' => $wp_filetype['type'],
			 'post_title'     => sanitize_file_name( $filename ),
			 'post_content'   => '',
			 'post_type'     => 'post',
			 'post_status'    => 'inherit'
			);
			// Create the attachment
			$attach_id = wp_insert_attachment( $attachment, $file, $post_id );
			// Include image.php
			require_once(ABSPATH . 'wp-admin/includes/image.php');
			// Define attachment metadata
			$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
			// Assign metadata to attachment
			 wp_update_attachment_metadata( $attach_id, $attach_data );
			// And finally assign featured image to post
			set_post_thumbnail( $post_id, $attach_id );
		}

	
		$this->seo_specialist_customizer_nav_menu();
		$this->seo_specialist_social_menu();
		$this->seo_specialist_customizer_left_menu();
		$this->seo_specialist_customizer_right_menu();
	}

	public function seo_specialist_guide() {
		$display_string = '';
		$return = add_query_arg( array()) ;
		$theme = wp_get_theme( 'seo-specialist' );
		?>
		<div class="wrapper-info get-stared-page-wrap">
			<div class="wrapper-info-content">
				<div class="buynow__">
					<h2><?php esc_html_e( 'Welcome to SEO Specialist', 'seo-specialist' ); ?> <span class="version">Version: <?php echo esc_html($theme['Version']);?></span></h2>
					<p><?php esc_html_e('The quick setup wizard will assist you in configuring your new website. This wizard will import the demo content.', 'seo-specialist'); ?></p>
				</div>
				<div class="buynow_">
					<a target="_blank" class="buynow_themepage" href="<?php echo esc_url('https://www.revolutionwp.com/products/seo-agency-wordpress-theme'); ?>"><?php echo esc_html__('Go Premium Now', 'seo-specialist'); ?></a>
				</div>
			</div>
			<div class="tab-sec theme-option-tab">
				<div id="demo_offer" class="tabcontent open">
					<?php $this->wizard_page(); ?>
				</div>
			</div>
		</div>
	<?php }
}