<?php

class Whizzie {

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

	public function init()
	{
	
	}

	public static function magazine_news_agency_setup_widgets(){


	/* Create Menu */
            $magazine_news_agency_menuname  = 'Main Menus';
            $magazine_news_agency_location  = 'main-menu';

            $magazine_news_agency_menu = wp_get_nav_menu_object( $magazine_news_agency_menuname );

            if ( ! $magazine_news_agency_menu ) {
            $magazine_news_agency_menu_id = wp_create_nav_menu( $magazine_news_agency_menuname );

           // Home Page 
			wp_update_nav_menu_item( $magazine_news_agency_menu_id, 0, array(
				'menu-item-title'     => __( 'Home', 'magazine-news-agency' ),
				'menu-item-url'       => home_url( '/' ),
				'menu-item-type'      => 'custom',
				'menu-item-status'    => 'publish',
				'menu-item-position'  => 1,
			) );

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

			if ( $magazine_news_agency_about_id ) {
			wp_update_nav_menu_item( $magazine_news_agency_menu_id, 0, array(
			'menu-item-title'     => 'Trending',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $magazine_news_agency_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
            'menu-item-position'  => 2,
			) );
			}

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

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

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

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

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

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

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

                $magazine_news_agency_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($magazine_news_agency_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$magazine_news_agency_blog_page_query->hae_posts()) {
                    $magazine_news_agency_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $magazine_news_agency_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $magazine_news_agency_blog_page_id = wp_insert_post($magazine_news_agency_blog_page);
                    update_option('page_for_posts', $magazine_news_agency_blog_page_id);

                    wp_update_na_menu_item($magazine_news_agency_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'magazine-news-agency'),
                        'menu-item-url'        => get_permalink($magazine_news_agency_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $magazine_news_agency_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }

			/* ---------- Assign Menu Location ---------- */
			$magazine_news_agency_locations = get_theme_mod( 'nav_menu_locations', array() );
			$magazine_news_agency_locations[ $magazine_news_agency_location ] = $magazine_news_agency_menu_id;
			set_theme_mod( 'nav_menu_locations', $magazine_news_agency_locations );
		}
	
	}
}
 