<?php

class Whizzie {

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

	public function init()
	{
	
	}

	public static function property_listing_elementor_setup_widgets(){

		set_theme_mod( 'property_listing_elementor_header_button_text', 'Sell Property' );
		set_theme_mod( 'property_listing_elementor_header_button_url', '#' );

		/* Create Menu */
            $property_listing_elementor_menuname  = 'Main Menus';
            $property_listing_elementor_location  = 'main-menu';

            $property_listing_elementor_menu = wp_get_nav_menu_object( $property_listing_elementor_menuname );

            if ( ! $property_listing_elementor_menu ) {
            $property_listing_elementor_menu_id = wp_create_nav_menu( $property_listing_elementor_menuname );

           // Home Page 
			wp_update_nav_menu_item( $property_listing_elementor_menu_id, 0, array(
				'menu-item-title'     => __( 'Home', 'property-listing-elementor' ),
				'menu-item-url'       => home_url( '/' ),
				'menu-item-type'      => 'custom',
				'menu-item-status'    => 'publish',
				'menu-item-position'  => 1,
			) );

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

			// Property Page 
			$property_listing_elementor_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'  => 'Property',
			'post_status' => 'publish',
			) );

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

			// Pages Page 
			$property_listing_elementor_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'  => 'Pages',
			'post_status' => 'publish',
			) );

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

			// Contact Us Page 
			$property_listing_elementor_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'  => 'Contact Us',
			'post_status' => 'publish',
			) );

			if ( $property_listing_elementor_about_id ) {
			wp_update_nav_menu_item( $property_listing_elementor_menu_id, 0, array(
			'menu-item-title'     => 'Contact Us',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $property_listing_elementor_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
            'menu-item-position'  => 3,
			) );
			}

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

                $property_listing_elementor_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($property_listing_elementor_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$property_listing_elementor_blog_page_query->hae_posts()) {
                    $property_listing_elementor_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $property_listing_elementor_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $property_listing_elementor_blog_page_id = wp_insert_post($property_listing_elementor_blog_page);
                    update_option('page_for_posts', $property_listing_elementor_blog_page_id);

                    wp_update_na_menu_item($property_listing_elementor_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'property-listing-elementor'),
                        'menu-item-url'        => get_permalink($property_listing_elementor_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $property_listing_elementor_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }
            
			/* ---------- Assign Menu Location ---------- */
			$property_listing_elementor_locations = get_theme_mod( 'nav_menu_locations', array() );
			$property_listing_elementor_locations[ $property_listing_elementor_location ] = $property_listing_elementor_menu_id;
			set_theme_mod( 'nav_menu_locations', $property_listing_elementor_locations );
		}

	}
}
 