<?php

class Whizzie {

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

	public function init()
	{
	
	}

	public static function production_industry_setup_widgets(){

	set_theme_mod( 'production_industry_header_advertisement_text', 'Our Experienced Skilled Team Is Available Around The Clock' );
	set_theme_mod( 'production_industry_header_faq_text', 'FAQs' );
	set_theme_mod( 'production_industry_header_faq_url', '#' );
	set_theme_mod( 'production_industry_header_terms_text', 'Terms' );
	set_theme_mod( 'production_industry_header_terms_url', '#' );
	set_theme_mod( 'production_industry_header_phone_number_text', 'CUSTOMER SUPPORT' );
	set_theme_mod( 'production_industry_header_phone_number', '+1 123 456 789' );
	set_theme_mod( 'production_industry_header_time_text', 'WORKING TIME' );
	set_theme_mod( 'production_industry_header_time', 'Mon-Sat: 08:00 - 18:00' );
	set_theme_mod( 'production_industry_header_button_text', 'Buy Now' );
	set_theme_mod( 'production_industry_header_button_url', '#' );

	set_theme_mod('production_industry_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"
		)
	));
	set_theme_mod('production_industry_sidebar_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"
		)
	));

	set_theme_mod( 'production_industry_sidebar_header_text', 'Our Experienced Skilled Team Is Available Around The Clock' );
	set_theme_mod( 'production_industry_sidebar_header_location_text', '123 New York' );
	set_theme_mod( 'production_industry_sidebar_header_email_address', 'production@example.com' );
	set_theme_mod( 'production_industry_sidebar_header_phone_number', '1234567890' );

	/* Create Menu */
            $production_industry_menuname  = 'Main Menus';
            $production_industry_location  = 'primary';

            $production_industry_menu = wp_get_nav_menu_object( $production_industry_menuname );

            if ( ! $production_industry_menu ) {
            $production_industry_menu_id = wp_create_nav_menu( $production_industry_menuname );

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

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

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

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

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

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

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

                $production_industry_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($production_industry_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$production_industry_blog_page_query->have_posts()) {
                    $production_industry_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $production_industry_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $production_industry_blog_page_id = wp_insert_post($production_industry_blog_page);
                    update_option('page_for_posts', $production_industry_blog_page_id);

                    wp_update_nav_menu_item($production_industry_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'production-industry'),
                        'menu-item-url'        => get_permalink($production_industry_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $production_industry_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }
            
			/* Assign Menu Location */
			$production_industry_locations = get_theme_mod( 'nav_menu_locations', array() );
			$production_industry_locations[ $production_industry_location ] = $production_industry_menu_id;
			set_theme_mod( 'nav_menu_locations', $production_industry_locations );
		}

	/* Create Menu */

	// select Post Box
	$production_industry_title_array = array("Manufacturing Services", "Industrial Services", "Custom Solutions", "Equipment Installation");

	// Ensure the category exists
	$production_industry_category_name = 'Services';
	$production_industry_category_id = get_cat_ID($production_industry_category_name);

	if ($production_industry_category_id == 0) {
		$production_industry_category_id = wp_create_category($production_industry_category_name);
	}

	for ($production_industry_i = 1; $production_industry_i <= 4; $production_industry_i++) {
		// Create post
		$production_industry_title = $production_industry_title_array[$production_industry_i - 1];
		$production_industry_content = 'Lorem Ipsum has been the industry standard dummy text';

		$production_industry_my_post = array(
			'post_title'    => wp_strip_all_tags($production_industry_title),
			'post_content'  => $production_industry_content,
			'post_status'   => 'publish',
			'post_type'     => 'post',
			'post_category' => array($production_industry_category_id),
		);

		$production_industry_post_id = wp_insert_post($production_industry_my_post);

		// Get image URL
		$production_industry_image_url = get_template_directory_uri() . '/assets/images/image' . $production_industry_i . '.png';
		$production_industry_image_data = wp_remote_get($production_industry_image_url);

		if (!is_wp_error($production_industry_image_data)) {
			$production_industry_image_body = wp_remote_retrieve_body($production_industry_image_data);
			$production_industry_upload_dir = wp_upload_dir();
			$production_industry_image_name = 'image' . $production_industry_i . '.png';
			$uploaded_file = wp_upload_bits($production_industry_image_name, null, $production_industry_image_body);

			if (!$uploaded_file['error']) {
				$attachment = array(
					'post_mime_type' => $uploaded_file['type'],
					'post_title'     => sanitize_file_name($production_industry_image_name),
					'post_content'   => '',
					'post_status'    => 'inherit',
				);
				$production_industry_attach_id = wp_insert_attachment($attachment, $uploaded_file['file'], $production_industry_post_id);
				require_once(ABSPATH . 'wp-admin/includes/image.php');
				$production_industry_attach_data = wp_generate_attachment_metadata($production_industry_attach_id, $uploaded_file['file']);
				wp_update_attachment_metadata($production_industry_attach_id, $production_industry_attach_data);
				set_post_thumbnail($production_industry_post_id, $production_industry_attach_id);
			}
		}
	}
	
	}

}
 