__('home','animal-caretaker'), 'menu-item-classes' => 'home', 'menu-item-url' =>home_url( '/' ), 'menu-item-status' => 'publish') ); wp_update_nav_menu_item($animal_caretaker_menu_id, 0, array( 'menu-item-title' => __('About Us','animal-caretaker'), 'menu-item-classes' => 'about-us', 'menu-item-url' => home_url( '//about-us/' ), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($animal_caretaker_menu_id, 0, array( 'menu-item-title' => __('Features','animal-caretaker'), 'menu-item-classes' => 'features', 'menu-item-url' => home_url( '//features/' ), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($animal_caretaker_menu_id, 0, array( 'menu-item-title' => __('Gallery','animal-caretaker'), 'menu-item-classes' => 'gallery', 'menu-item-url' => home_url( '//gallery/' ), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($animal_caretaker_menu_id, 0, array( 'menu-item-title' => __('SHOP','animal-caretaker'), 'menu-item-classes' => 'shop', 'menu-item-url' => home_url( '//shop/' ), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($animal_caretaker_menu_id, 0, array( 'menu-item-title' => __('Blog','animal-caretaker'), 'menu-item-classes' => 'blog', 'menu-item-url' => home_url( '//blog/' ), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($animal_caretaker_menu_id, 0, array( 'menu-item-title' => __('Contact','animal-caretaker'), 'menu-item-classes' => 'contact', 'menu-item-url' => home_url( '//contact/' ), 'menu-item-status' => 'publish')); if( !has_nav_menu( $animal_caretaker_bpmenulocation ) ){ $locations = get_theme_mod('nav_menu_locations'); $locations[$animal_caretaker_bpmenulocation] = $animal_caretaker_menu_id; set_theme_mod( 'nav_menu_locations', $locations ); } } $animal_caretaker_home_id=''; $animal_caretaker_home_content = ''; $animal_caretaker_home_title = 'Home'; $animal_caretaker_home = array( 'post_type' => 'page', 'post_title' => $animal_caretaker_home_title, 'post_content' => $animal_caretaker_home_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'home' ); $animal_caretaker_home_id = wp_insert_post($animal_caretaker_home); add_post_meta( $animal_caretaker_home_id, '_wp_page_template', 'templates/template-homepage.php' ); update_option( 'page_on_front', $animal_caretaker_home_id ); update_option( 'show_on_front', 'page' ); //---Header--// set_theme_mod('animal_caretaker_header_button_link', '#'); set_theme_mod('animal_caretaker_header_button_text', 'Get in Touch'); //-----Slider-----// set_theme_mod( 'animal_caretaker_slide_on_off', 'on' ); set_theme_mod('animal_caretaker_slide_count','2'); $animal_caretaker_slider_title=array('Get Your Favourite Pet', 'Acquire Your Favorite Pet'); for ($i=1; $i <= 2; $i++) { set_theme_mod( 'animal_caretaker_slider_image'.$i, get_template_directory_uri().'/images/demo-import-images/slides/slide_'.$i.'.png' ); set_theme_mod('animal_caretaker_slider_heading'.$i, $animal_caretaker_slider_title[$i - 1]); set_theme_mod('animal_caretaker_slider_button_link'.$i, '#'); set_theme_mod('animal_caretaker_slider_button_text'.$i, 'Watch Video'); } //-----Products-----// set_theme_mod( 'animal_caretaker_product_on_off', 'on' ); set_theme_mod('animal_caretaker_featured_product_heading', 'Featured Products'); wp_insert_term( 'awesome-product', // the term 'product_cat', // the taxonomy array( 'description'=> '', 'slug' => 'awesome-product', 'term_id'=>12, 'term_taxonomy_id'=>34, ) ); set_theme_mod( 'animal_caretaker_featured_product_category', 'Awesome Product' ); if ( class_exists( 'WooCommerce' ) ) { $featured_product=array('Fishing Net', 'Flower Vaas', 'Tank Cleaner Pump', 'Rotating Sweeper'); for($i=1;$i<=4;$i++) { $title =$featured_product[$i-1]; $content = 'Lorem Ipsum simply Te obtinuit ut adepto satis somno. Aliisque institoribus iter deliciae vivet vita. Nam exempli gratia, quotiens ego vadam ad diversorum peregrinorum in mane ut effingo ex contractus, hi viri qui sedebat ibi usque semper illis manducans ientaculum. Solum cum bulla ut debui; EGO youd adepto a macula proiciendi.'; // Create post object $my_post = array( 'post_title' => wp_strip_all_tags( $title ), 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'product', ); // Insert the post into the database $post_id = wp_insert_post( $my_post ); // Gets term object from Tree in the database. $term = get_term_by('name', 'awesome-product', 'product_cat'); wp_set_object_terms($post_id, $term->term_id, 'product_cat'); update_post_meta( $post_id, '_price', '$50' ); update_post_meta( $post_id, '_sale_price', "$50" ); update_post_meta( $post_id, '_regular_price', "$100" ); $image_url = get_template_directory_uri().'/images/demo-import-images/products/featured-product_'.$i.'.png'; $image_name= 'image'.$i.'.png'; $upload_dir = wp_upload_dir(); // Set upload folder $image_data= file_get_contents($image_url); // Get image data $unique_file_name = wp_unique_filename( $upload_dir['path'], $image_name ); // Generate unique name $filename= basename( $unique_file_name ); // Create image file name // Check folder permission and define file location if( wp_mkdir_p( $upload_dir['path'] ) ) { $file = $upload_dir['path'] . '/' . $filename; } else { $file = $upload_dir['basedir'] . '/' . $filename; } // Create the image file on the server file_put_contents( $file, $image_data ); // Check image file type $wp_filetype = wp_check_filetype( $filename, null ); // Set attachment data $attachment = array( 'post_mime_type' => $wp_filetype['type'], 'post_title' => sanitize_file_name( $filename ), 'post_content' => '', 'post_type' => 'product', 'post_status' => 'inherit' ); // Create the attachment $attach_id = wp_insert_attachment( $attachment, $file, $post_id ); // Include image.php require_once(ABSPATH . 'wp-admin/includes/image.php'); // Define attachment metadata $attach_data = wp_generate_attachment_metadata( $attach_id, $file ); // Assign metadata to attachment wp_update_attachment_metadata( $attach_id, $attach_data ); // And finally assign featured image to post set_post_thumbnail( $post_id, $attach_id ); } } } ?>