<?php

class Whizzie {

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

	public function init()
	{
	
	}

	public static function event_band_services_setup_widgets(){

            set_theme_mod( 'event_band_services_header_phone_number', '+1234567890' );
            set_theme_mod( 'event_band_services_header_email', 'echogroove@example.com' );
            set_theme_mod( 'event_band_services_header_adver_text', 'New Tour Dates Just Announced – Catch EchoGroove Live in Berlin soon.' );
            set_theme_mod( 'event_band_services_header_button_text', 'Contact Us' );
            set_theme_mod( 'event_band_services_header_button_url', '#' );

            set_theme_mod('event_band_services_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 */
            $event_band_services_menuname  = 'Main Menus';
            $event_band_services_location  = 'primary';

            $event_band_services_menu = wp_get_nav_menu_object( $event_band_services_menuname );

            if ( ! $event_band_services_menu ) {
            $event_band_services_menu_id = wp_create_nav_menu( $event_band_services_menuname );

           // Home Page 
			wp_update_nav_menu_item( $event_band_services_menu_id, 0, array(
				'menu-item-title'     => __( 'Home', 'event-band-services' ),
				'menu-item-url'       => home_url( '/' ),
				'menu-item-type'      => 'custom',
				'menu-item-status'    => 'publish',
			) );

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

			// Services Page 
			$event_band_services_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 ( $event_band_services_about_id ) {
			wp_update_nav_menu_item( $event_band_services_menu_id, 0, array(
			'menu-item-title'     => 'Services',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $event_band_services_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
			) );
			}

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

			if ( $event_band_services_about_id ) {
			wp_update_nav_menu_item( $event_band_services_menu_id, 0, array(
			'menu-item-title'     => 'Gallery',
			'menu-item-object'    => 'page',
			'menu-item-object-id' => $event_band_services_about_id,
			'menu-item-type'      => 'post_type',
			'menu-item-status'    => 'publish',
			) );
			}

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

             $event_band_services_blog_page_query = new WP_Query(array(
            'post_type'      => 'page',
            'name'           => sanitize_title($event_band_services_blog_page_title),
            'post_status'    => 'publish',
            'posts_per_page' => 1
            ));
            if (!$event_band_services_blog_page_query->have_posts()) {
            $event_band_services_blog_page = array(
            'post_type'   => 'page',
            'post_title'  => $event_band_services_blog_page_title,
            'post_status' => 'publish',
            'post_author' => 1,
            );
            $event_band_services_blog_page_id = wp_insert_post($event_band_services_blog_page);
            update_option('page_for_posts', $event_band_services_blog_page_id);

            wp_update_nav_menu_item($event_band_services_menu_id, 0, array(
            'menu-item-title'      => __('Blog', 'event-band-services'),
            'menu-item-url'        => get_permalink($event_band_services_blog_page_id),
            'menu-item-status'     => 'publish',
            'menu-item-object-id'  => $event_band_services_blog_page_id,
            'menu-item-object'     => 'page',
            'menu-item-type'       => 'post_type',
            ));
            }
            
			/* Assign Menu Location */
			$event_band_services_locations = get_theme_mod( 'nav_menu_locations', array() );
			$event_band_services_locations[ $event_band_services_location ] = $event_band_services_menu_id;
			set_theme_mod( 'nav_menu_locations', $event_band_services_locations );
		}

         /* Create Post */
        $event_band_services_title_array = array("Nightclubs", "Destination Weddings", "Festivals & Tours");

        $event_band_services_category_name = 'Events';
        $event_band_services_category_id = get_cat_ID($event_band_services_category_name);

        if ($event_band_services_category_id == 0) {
            $event_band_services_category_id = wp_create_category($event_band_services_category_name);
        }

        for ($event_band_services_i = 1; $event_band_services_i <= 3; $event_band_services_i++) {

            $event_band_services_title = $event_band_services_title_array[$event_band_services_i - 1];
            $event_band_services_content = 'High energy beats to keep the dance floor alive all night long';

            $event_band_services_my_post = array(
                'post_title'    => wp_strip_all_tags($event_band_services_title),
                'post_content'  => $event_band_services_content,
                'post_status'   => 'publish',
                'post_type'     => 'post',
                'post_category' => array($event_band_services_category_id),
            );

            $event_band_services_post_id = wp_insert_post($event_band_services_my_post);

            $event_band_services_image_url = get_template_directory_uri() . '/assets/images/event-post-' . $event_band_services_i . '.png';

            $event_band_services_image_data = wp_remote_get($event_band_services_image_url);

            if (!is_wp_error($event_band_services_image_data)) {

                $event_band_services_image_body = wp_remote_retrieve_body($event_band_services_image_data);
                $event_band_services_upload_dir = wp_upload_dir();
                $event_band_services_image_name = 'event-post-' . $event_band_services_i . '.png';

                $uploaded_file = wp_upload_bits($event_band_services_image_name, null, $event_band_services_image_body);

                if (!$uploaded_file['error']) {

                    $attachment = array(
                        'post_mime_type' => $uploaded_file['type'],
                        'post_title'     => sanitize_file_name($event_band_services_image_name),
                        'post_content'   => '',
                        'post_status'    => 'inherit',
                    );

                    $event_band_services_attach_id = wp_insert_attachment($attachment, $uploaded_file['file'], $event_band_services_post_id);
                    require_once(ABSPATH . 'wp-admin/includes/image.php');

                    $event_band_services_attach_data = wp_generate_attachment_metadata($event_band_services_attach_id, $uploaded_file['file']);
                    wp_update_attachment_metadata($event_band_services_attach_id, $event_band_services_attach_data);

                    set_post_thumbnail($event_band_services_post_id, $event_band_services_attach_id);
                }
            }
        }
    }
}
 