<?php

class Whizzie {

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

	public function init()
	{
		
	}

	public static function yoga_center_setup_widgets(){

		set_theme_mod( 'yoga_center_header_advertisement_text', 'Lorem Ipsum is simply dummy text of the printing.' );
		set_theme_mod( 'yoga_center_header_phone_number', '+12 123456789' );
		set_theme_mod( 'yoga_center_header_email', 'yoga@example.com' );
		set_theme_mod( 'yoga_center_header_location_text', '12 York Street USA' );

		/* Create Menu */
            $yoga_center_menuname  = 'Main Menus';
            $yoga_center_location  = 'main-menu';

            $yoga_center_menu = wp_get_nav_menu_object( $yoga_center_menuname );

            if ( ! $yoga_center_menu ) {
            $yoga_center_menu_id = wp_create_nav_menu( $yoga_center_menuname );

           // Home Page 
			wp_update_nav_menu_item( $yoga_center_menu_id, 0, array(
				'menu-item-title'     => __( 'Home', 'yoga-center' ),
				'menu-item-url'       => home_url( '/' ),
				'menu-item-type'      => 'custom',
				'menu-item-status'    => 'publish',
			) );

			// About Us Page 
			$yoga_center_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 ( $yoga_center_about_id ) {
			wp_update_nav_menu_item( $yoga_center_menu_id, 0, array(
			'menu-item-title'     => 'About Us',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $yoga_center_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
			) );
			}

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

                $yoga_center_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($yoga_center_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$yoga_center_blog_page_query->hae_posts()) {
                    $yoga_center_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $yoga_center_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $yoga_center_blog_page_id = wp_insert_post($yoga_center_blog_page);
                    update_option('page_for_posts', $yoga_center_blog_page_id);

                    wp_update_na_menu_item($yoga_center_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'yoga-center'),
                        'menu-item-url'        => get_permalink($yoga_center_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $yoga_center_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }

			/* Assign Menu Location */
			$yoga_center_locations = get_theme_mod( 'nav_menu_locations', array() );
			$yoga_center_locations[ $yoga_center_location ] = $yoga_center_menu_id;
			set_theme_mod( 'nav_menu_locations', $yoga_center_locations );
		}

	}

}
 