<?php

class Whizzie {

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

	public function init()
	{
	
	}

	public static function charitable_non_profit_setup_widgets(){

		set_theme_mod( 'charitable_non_profit_elementor_header_adv_tittle', 'Welcome to charity' );
		set_theme_mod( 'charitable_non_profit_elementor_header_adv_text', 'Be the reason someone smiles today' );
		set_theme_mod( 'charitable_non_profit_header_location_text', 'Location' );
		set_theme_mod( 'charitable_non_profit_header_location', '25 Andy Sy 8820' );

		set_theme_mod( 'charitable_non_profit_header_phone_number_text', 'Call Us' );
		set_theme_mod( 'charitable_non_profit_header_phone_number', '+123456789' );
		set_theme_mod( 'charitable_non_profit_header_email_text', 'E-mail' );
		set_theme_mod( 'charitable_non_profit_header_email', 'ypurcharity@example.com' );
		set_theme_mod( 'charitable_non_profit_header_button_text', 'Donate Now' );
		set_theme_mod( 'charitable_non_profit_header_button_url', '#' );

		set_theme_mod('charitable_non_profit_social_links_settings', array(
            array(
                "link_text" => "fab fa-instagram",
                "link_url" => "www.instagram.com"
            ),
            array(
                "link_text" => "fab fa-twitter",
                "link_url" => "www.twitter.com"
            ),
            array(
                "link_text" => "fab fa-youtube",
                "link_url" => "www.youtube.com"
            ),
            array(
                "link_text" => "fab fa-linkedin-in",
                "link_url" => "www.linkedin.com"
            )
        ));

		/* Create Menu */
            $charitable_non_profit_menuname  = 'Main Menus';
            $charitable_non_profit_location  = 'main-menu';

            $charitable_non_profit_menu = wp_get_nav_menu_object( $charitable_non_profit_menuname );

            if ( ! $charitable_non_profit_menu ) {
            $charitable_non_profit_menu_id = wp_create_nav_menu( $charitable_non_profit_menuname );

           // Home Page 
			wp_update_nav_menu_item( $charitable_non_profit_menu_id, 0, array(
				'menu-item-title'     => __( 'Home', 'charitable-non-profit' ),
				'menu-item-url'       => home_url( '/' ),
				'menu-item-type'      => 'custom',
				'menu-item-status'    => 'publish',
				'menu-item-position'  => 1,
			) );

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

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

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

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

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

			// Contact Us Page 
			$charitable_non_profit_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 ( $charitable_non_profit_about_id ) {
			wp_update_nav_menu_item( $charitable_non_profit_menu_id, 0, array(
			'menu-item-title'     => 'Contact Us',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $charitable_non_profit_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
            'menu-item-position'  => 3,
			) );
			}

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

                $charitable_non_profit_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($charitable_non_profit_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$charitable_non_profit_blog_page_query->hae_posts()) {
                    $charitable_non_profit_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $charitable_non_profit_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $charitable_non_profit_blog_page_id = wp_insert_post($charitable_non_profit_blog_page);
                    update_option('page_for_posts', $charitable_non_profit_blog_page_id);

                    wp_update_na_menu_item($charitable_non_profit_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'charitable-non-profit'),
                        'menu-item-url'        => get_permalink($charitable_non_profit_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $charitable_non_profit_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }
            
			/* ---------- Assign Menu Location ---------- */
			$charitable_non_profit_locations = get_theme_mod( 'nav_menu_locations', array() );
			$charitable_non_profit_locations[ $charitable_non_profit_location ] = $charitable_non_profit_menu_id;
			set_theme_mod( 'nav_menu_locations', $charitable_non_profit_locations );
		}

	}
}
 