<?php

class Whizzie {

	public function __construct() {
		$this->init();
	}

	public function init()
	{
	
	}

	public static function ev_bike_shop_setup_widgets(){

		set_theme_mod( 'ev_bike_shop_header_advertisement_text', 'Stay Updated With Our Latest News' );
		set_theme_mod( 'ev_bike_shop_header_email', 'info@example.com' );
		set_theme_mod( 'ev_bike_shop_header_phone_number', '+123456789' );
		set_theme_mod( 'ev_bike_shop_details_button_text', 'More Details' );
		set_theme_mod( 'ev_bike_shop_details_button_url', '#' );
		set_theme_mod( 'ev_bike_shop_header_button_text', 'BOOK NOW' );
		set_theme_mod( 'ev_bike_shop_header_button_url', '#' );

		/* Create Menu */
            $ev_bike_shop_menuname  = 'Main Menus';
            $ev_bike_shop_location  = 'main-menu';

            $ev_bike_shop_menu = wp_get_nav_menu_object( $ev_bike_shop_menuname );

            if ( ! $ev_bike_shop_menu ) {
            $ev_bike_shop_menu_id = wp_create_nav_menu( $ev_bike_shop_menuname );

           // Home Page 
			wp_update_nav_menu_item( $ev_bike_shop_menu_id, 0, array(
				'menu-item-title'     => __( 'Home', 'ev-bike-shop' ),
				'menu-item-url'       => home_url( '/' ),
				'menu-item-type'      => 'custom',
				'menu-item-status'    => 'publish',
				'menu-item-position'  => 1,
			) );

			// About Page 
			$ev_bike_shop_about_id = wp_insert_post( array(
			'post_type'   => 'page',
			'post_content' => 'We are committed to providing reliable, professional, and result-oriented solutions tailored to meet individual needs. Our goal is to empower people with the right guidance, knowledge, and support to help them make informed decisions for a better future. <br><br> Our mission is to deliver high-quality services with honesty, transparency, and dedication. We focus on understanding client requirements and offering practical solutions that create long-term value. <br><br> With a client-centric approach, experienced professionals, and a commitment to excellence, we ensure every individual receives the attention and guidance they deserve. We believe in building trust through quality service and consistent results.',
			'post_title'  => 'About Us',
			'post_status' => 'publish',
			) );

			if ( $ev_bike_shop_about_id ) {
			wp_update_nav_menu_item( $ev_bike_shop_menu_id, 0, array(
			'menu-item-title'     => 'About Us',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $ev_bike_shop_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
            'menu-item-position'  => 2,
			) );
			}

			// Services Page 
			$ev_bike_shop_about_id = wp_insert_post( array(
			'post_type'   => 'page',
			'post_content' => 'We are committed to providing reliable, professional, and result-oriented solutions tailored to meet individual needs. Our goal is to empower people with the right guidance, knowledge, and support to help them make informed decisions for a better future. <br><br> Our mission is to deliver high-quality services with honesty, transparency, and dedication. We focus on understanding client requirements and offering practical solutions that create long-term value. <br><br> With a client-centric approach, experienced professionals, and a commitment to excellence, we ensure every individual receives the attention and guidance they deserve. We believe in building trust through quality service and consistent results.',
			'post_title'  => 'Services',
			'post_status' => 'publish',
			) );

			if ( $ev_bike_shop_about_id ) {
			wp_update_nav_menu_item( $ev_bike_shop_menu_id, 0, array(
			'menu-item-title'     => 'Services',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $ev_bike_shop_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
            'menu-item-position'  => 3,
			) );
			}

			// Materials Page 
			$ev_bike_shop_about_id = wp_insert_post( array(
			'post_type'   => 'page',
			'post_content' => 'We are committed to providing reliable, professional, and result-oriented solutions tailored to meet individual needs. Our goal is to empower people with the right guidance, knowledge, and support to help them make informed decisions for a better future. <br><br> Our mission is to deliver high-quality services with honesty, transparency, and dedication. We focus on understanding client requirements and offering practical solutions that create long-term value. <br><br> With a client-centric approach, experienced professionals, and a commitment to excellence, we ensure every individual receives the attention and guidance they deserve. We believe in building trust through quality service and consistent results.',
			'post_title'  => 'Materials',
			'post_status' => 'publish',
			) );

			if ( $ev_bike_shop_about_id ) {
			wp_update_nav_menu_item( $ev_bike_shop_menu_id, 0, array(
			'menu-item-title'     => 'Materials',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $ev_bike_shop_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
            'menu-item-position'  => 4,
			) );
			}

            // Create Blog Page
                $ev_bike_shop_blog_page_title = 'Blog';

                $ev_bike_shop_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($ev_bike_shop_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$ev_bike_shop_blog_page_query->hae_posts()) {
                    $ev_bike_shop_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $ev_bike_shop_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $ev_bike_shop_blog_page_id = wp_insert_post($ev_bike_shop_blog_page);
                    update_option('page_for_posts', $ev_bike_shop_blog_page_id);

                    wp_update_na_menu_item($ev_bike_shop_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'ev-bike-shop'),
                        'menu-item-url'        => get_permalink($ev_bike_shop_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $ev_bike_shop_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }
            
			/* ---------- Assign Menu Location ---------- */
			$ev_bike_shop_locations = get_theme_mod( 'nav_menu_locations', array() );
			$ev_bike_shop_locations[ $ev_bike_shop_location ] = $ev_bike_shop_menu_id;
			set_theme_mod( 'nav_menu_locations', $ev_bike_shop_locations );
		}

	}
}
 