<?php

class Whizzie {

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

	public function init()
	{
	
	}

	public static function ethical_hacking_setup_widgets(){

	set_theme_mod( 'ethical_hacking_header_button_text', 'Get A Quote' );
	set_theme_mod( 'ethical_hacking_header_button_url', '#' );

	// select Post Box
	$ethical_hacking_title_array = array("Penetration Testing", "Vulnerability Assessement" , "Ethical haking" );
	for ($ethical_hacking_i = 1; $ethical_hacking_i <= 3; $ethical_hacking_i++) {
		// Create post
		$ethical_hacking_title = $ethical_hacking_title_array[$ethical_hacking_i - 1];
		$ethical_hacking_content = 'Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book.';            
		$ethical_hacking_my_post = array(
				'post_title'   => wp_strip_all_tags($ethical_hacking_title),
				'post_content' => $ethical_hacking_content,
				'post_status'  => 'publish',
				'post_type'    => 'post',
		);
		$ethical_hacking_post_id = wp_insert_post($ethical_hacking_my_post);
		// Get image URL
		$ethical_hacking_image_url = get_template_directory_uri() . '/assets/images/image' . $ethical_hacking_i . '.png';
		$ethical_hacking_image_data = wp_remote_get($ethical_hacking_image_url);
		if (!is_wp_error($ethical_hacking_image_data)) {
				$ethical_hacking_image_body = wp_remote_retrieve_body($ethical_hacking_image_data);
				$ethical_hacking_upload_dir = wp_upload_dir();
				$ethical_hacking_image_name = 'image' . $ethical_hacking_i . '.png';
				$uploaded_file = wp_upload_bits($ethical_hacking_image_name, null, $ethical_hacking_image_body);
				if (!$uploaded_file['error']) {
					// Set attachment data
					$attachment = array(
						'post_mime_type' => $uploaded_file['type'],
						'post_title'     => sanitize_file_name($ethical_hacking_image_name),
						'post_content'   => '',
						'post_status'    => 'inherit',
					);
					$ethical_hacking_attach_id = wp_insert_attachment($attachment, $uploaded_file['file'], $ethical_hacking_post_id);
					require_once(ABSPATH . 'wp-admin/includes/image.php');
					$ethical_hacking_attach_data = wp_generate_attachment_metadata($ethical_hacking_attach_id, $uploaded_file['file']);
					wp_update_attachment_metadata($ethical_hacking_attach_id, $ethical_hacking_attach_data);
					set_post_thumbnail($ethical_hacking_post_id, $ethical_hacking_attach_id);
				}
		    }
	    }

		/* Create Menu */
            $ethical_hacking_menuname  = 'Main Menus';
            $ethical_hacking_location  = 'main-menu';

            $ethical_hacking_menu = wp_get_nav_menu_object( $ethical_hacking_menuname );

            if ( ! $ethical_hacking_menu ) {
            $ethical_hacking_menu_id = wp_create_nav_menu( $ethical_hacking_menuname );

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

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

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

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

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

                $ethical_hacking_blog_page_query = new WP_Query(array(
                    'post_type'      => 'page',
                    'name'           => sanitize_title($ethical_hacking_blog_page_title),
                    'post_status'    => 'publish',
                    'posts_per_page' => 1
                ));
                if (!$ethical_hacking_blog_page_query->hae_posts()) {
                    $ethical_hacking_blog_page = array(
                        'post_type'   => 'page',
                        'post_title'  => $ethical_hacking_blog_page_title,
                        'post_status' => 'publish',
                        'post_author' => 1,
                    );
                    $ethical_hacking_blog_page_id = wp_insert_post($ethical_hacking_blog_page);
                    update_option('page_for_posts', $ethical_hacking_blog_page_id);

                    wp_update_na_menu_item($ethical_hacking_menu_id, 0, array(
                        'menu-item-title'      => __('Blog', 'ethical-hacking'),
                        'menu-item-url'        => get_permalink($ethical_hacking_blog_page_id),
                        'menu-item-status'     => 'publish',
                        'menu-item-object-id'  => $ethical_hacking_blog_page_id,
                        'menu-item-object'     => 'page',
                        'menu-item-type'       => 'post_type',
                    ));
                }

			/* Assign Menu Location */
			$ethical_hacking_locations = get_theme_mod( 'nav_menu_locations', array() );
			$ethical_hacking_locations[ $ethical_hacking_location ] = $ethical_hacking_menu_id;
			set_theme_mod( 'nav_menu_locations', $ethical_hacking_locations );
		}
    }
}
 