__('HOME', 'bakery-cafe'), 'menu-item-classes' => 'home', 'menu-item-url' => home_url('/'), 'menu-item-status' => 'publish', )); wp_update_nav_menu_item($bakery_cafe_menu_id, 0, array( 'menu-item-title' => __('PAGES', 'bakery-cafe'), 'menu-item-classes' => 'pages', 'menu-item-url' => get_permalink(get_page_id_by_title('pages')), 'menu-item-status' => 'publish', )); wp_update_nav_menu_item($bakery_cafe_menu_id, 0, array( 'menu-item-title' => __('SPECIAL MENU', 'bakery-cafe'), 'menu-item-classes' => 'special-menu', 'menu-item-url' => get_permalink(get_page_id_by_title('special-menu')), 'menu-item-status' => 'publish', )); wp_update_nav_menu_item($bakery_cafe_menu_id, 0, array( 'menu-item-title' => __('BLOG', 'bakery-cafe'), 'menu-item-classes' => 'blog', 'menu-item-url' => get_permalink(get_page_id_by_title('blog')), 'menu-item-status' => 'publish', )); wp_update_nav_menu_item($bakery_cafe_menu_id, 0, array( 'menu-item-title' => __('SHOP', 'bakery-cafe'), 'menu-item-classes' => 'shop', 'menu-item-url' => get_permalink(get_page_id_by_title('shop')), 'menu-item-status' => 'publish', )); wp_update_nav_menu_item($bakery_cafe_menu_id, 0, array( 'menu-item-title' => __('ELEMENTS', 'bakery-cafe'), 'menu-item-classes' => 'elements', 'menu-item-url' => get_permalink(get_page_id_by_title('elements')), 'menu-item-status' => 'publish', )); if (!has_nav_menu($bakery_cafe_bpmenulocation)) { $locations = get_theme_mod('nav_menu_locations'); $locations[$bakery_cafe_bpmenulocation] = $bakery_cafe_menu_id; set_theme_mod('nav_menu_locations', $locations); } } } public function setup_widgets() { $bakery_cafe_home_id=''; $bakery_cafe_home_content = ''; $bakery_cafe_home_title = 'HOME'; $bakery_cafe_home = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_home_title, 'post_content' => $bakery_cafe_home_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'home' ); $bakery_cafe_home_id = wp_insert_post($bakery_cafe_home); add_post_meta( $bakery_cafe_home_id, '_wp_page_template', 'frontpage.php' ); update_option( 'page_on_front', $bakery_cafe_home_id ); update_option( 'show_on_front', 'page' ); // Create a Posts Page $bakery_cafe_blog_title = 'PAGES'; $bakery_cafe_blog_check = get_page_id_by_title($bakery_cafe_blog_title); if ($bakery_cafe_blog_check == 1) { $bakery_cafe_blog = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'pages', 'post_content' => '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."', ); $bakery_cafe_blog_id = wp_insert_post($bakery_cafe_blog); if (!is_wp_error($bakery_cafe_blog_id)) { // update_option('page_for_posts', $bakery_cafe_blog_id); } } // Create a Posts Page $bakery_cafe_blog_title = 'COLLECTION'; $bakery_cafe_blog_check = get_page_id_by_title($bakery_cafe_blog_title); if ($bakery_cafe_blog_check == 1) { $bakery_cafe_blog = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'collections', 'post_content' => '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."', ); $bakery_cafe_blog_id = wp_insert_post($bakery_cafe_blog); if (!is_wp_error($bakery_cafe_blog_id)) { // update_option('page_for_posts', $bakery_cafe_blog_id); } } // Create a Posts Page $bakery_cafe_blog_title = 'SHOP'; $bakery_cafe_blog_check = get_page_id_by_title($bakery_cafe_blog_title); if ($bakery_cafe_blog_check == 1) { $bakery_cafe_blog = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'shop', 'post_content' => '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."', ); $bakery_cafe_blog_id = wp_insert_post($bakery_cafe_blog); if (!is_wp_error($bakery_cafe_blog_id)) { // update_option('page_for_posts', $bakery_cafe_blog_id); } } // Create a Posts Page $bakery_cafe_blog_title = 'BLOG'; $bakery_cafe_blog_check = get_page_id_by_title($bakery_cafe_blog_title); if ($bakery_cafe_blog_check == 1) { $bakery_cafe_blog = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'blog', 'post_content' => '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."', ); $bakery_cafe_blog_id = wp_insert_post($bakery_cafe_blog); if (!is_wp_error($bakery_cafe_blog_id)) { // update_option('page_for_posts', $bakery_cafe_blog_id); } } // Create a Posts Page $bakery_cafe_blog_title = 'SPECIAL MENU'; $bakery_cafe_blog_check = get_page_id_by_title($bakery_cafe_blog_title); if ($bakery_cafe_blog_check == 1) { $bakery_cafe_blog = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'special-menu', 'post_content' => '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."', ); $bakery_cafe_blog_id = wp_insert_post($bakery_cafe_blog); if (!is_wp_error($bakery_cafe_blog_id)) { // update_option('page_for_posts', $bakery_cafe_blog_id); } } // Create a Posts Page $bakery_cafe_blog_title = 'ELEMENTS'; $bakery_cafe_blog_check = get_page_id_by_title($bakery_cafe_blog_title); if ($bakery_cafe_blog_check == 1) { $bakery_cafe_blog = array( 'post_type' => 'page', 'post_title' => $bakery_cafe_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'elements', 'post_content' => '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."', ); $bakery_cafe_blog_id = wp_insert_post($bakery_cafe_blog); if (!is_wp_error($bakery_cafe_blog_id)) { // update_option('page_for_posts', $bakery_cafe_blog_id); } } //---Header--// set_theme_mod('bakery_cafe_social_links_settings', array( array( "link_text" => "fab fa-facebook-f", "link_url" => "#" ), array( "link_text" => "fab fa-twitter", "link_url" => "#" ), array( "link_text" => "fab fa-instagram", "link_url" => "#" ), array( "link_text" => "fab fa-pinterest", "link_url" => "#" ), array( "link_text" => "fab fa-youtube", "link_url" => "#" ) )); set_theme_mod( 'bakery_cafe_register_text', 'REGISTER'); set_theme_mod( 'bakery_cafe_register_link', '#'); set_theme_mod( 'bakery_cafe_login_text', 'LOGIN'); set_theme_mod( 'bakery_cafe_login_link', '#'); set_theme_mod( 'bakery_cafe_search_box_enable', true); set_theme_mod( 'bakery_cafe_cart_box_enable', true); //-----Slider-----// set_theme_mod( 'bakery_cafe_blog_box_enable', true); set_theme_mod( 'bakery_cafe_blog_slide_number', '3' ); $bakery_cafe_latest_post_category = wp_create_category('Slider Post'); set_theme_mod( 'bakery_cafe_blog_slide_category', 'Slider Post' ); for($i=1; $i<=3; $i++) { $content = 'Lorem Ipsum has been the industrys 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.'; $title=array('Coffee Heaven', 'Heaven for coffee', 'Coffee Paradise'); // Create post object $bakery_cafe_my_post = array( 'post_title' => wp_strip_all_tags( $title[$i-1] ), 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array($bakery_cafe_latest_post_category) ); // Insert the post into the database $bakery_cafe_post_id = wp_insert_post( $bakery_cafe_my_post ); $bakery_cafe_image_url = get_template_directory_uri().'/assets/images/slider'.$i.'.png'; $bakery_cafe_image_name= 'slider'.$i.'.png'; $bakery_cafe_upload_dir = wp_upload_dir(); // Set upload folder $bakery_cafe_image_data = file_get_contents($bakery_cafe_image_url); // Get image data $bakery_cafe_unique_file_name = wp_unique_filename( $bakery_cafe_upload_dir['path'], $bakery_cafe_image_name ); // Generate unique name $filename= basename( $bakery_cafe_unique_file_name ); // Create image file name // Check folder permission and define file location if( wp_mkdir_p( $bakery_cafe_upload_dir['path'] ) ) { $file = $bakery_cafe_upload_dir['path'] . '/' . $filename; } else { $file = $bakery_cafe_upload_dir['basedir'] . '/' . $filename; } if ( ! function_exists( 'WP_Filesystem' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } WP_Filesystem(); global $wp_filesystem; if ( ! $wp_filesystem->put_contents( $file, $bakery_cafe_image_data, FS_CHMOD_FILE ) ) { wp_die( 'Error saving file!' ); } $bakery_cafe_wp_filetype = wp_check_filetype( $filename, null ); $bakery_cafe_attachment = array( 'post_mime_type' => $bakery_cafe_wp_filetype['type'], 'post_title' => sanitize_file_name( $filename ), 'post_content' => '', 'post_type' => 'post', 'post_status' => 'inherit' ); $bakery_cafe_attach_id = wp_insert_attachment( $bakery_cafe_attachment, $file, $bakery_cafe_post_id ); require_once(ABSPATH . 'wp-admin/includes/image.php'); $bakery_cafe_attach_data = wp_generate_attachment_metadata( $bakery_cafe_attach_id, $file ); wp_update_attachment_metadata( $bakery_cafe_attach_id, $bakery_cafe_attach_data ); set_post_thumbnail( $bakery_cafe_post_id, $bakery_cafe_attach_id ); } //--------------Story Section-----------// set_theme_mod( 'bakery_cafe_our_story_enable', true); set_theme_mod( 'bakery_cafe_our_story_image1', get_template_directory_uri() . '/assets/images/story1.png' ); set_theme_mod( 'bakery_cafe_our_story_image2', get_template_directory_uri() . '/assets/images/story2.png' ); set_theme_mod( 'bakery_cafe_our_story_heading_text', 'FEW WORDS ABOUT US'); set_theme_mod( 'bakery_cafe_our_story_section_title', 'Our Story'); $bakery_cafe_banner_title = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'; $bakery_cafe_banner_content = 'Lorem Ipsum has been the industrys 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. It has survived not typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset.'; // Create post object // Create post object $my_post = array( 'post_title' => wp_strip_all_tags( $bakery_cafe_banner_title ), 'post_content' => $bakery_cafe_banner_content, 'post_status' => 'publish', 'post_type' => 'page', ); // Insert the post into the database $bakery_cafe_post_id = wp_insert_post( $my_post ); if ($bakery_cafe_post_id) { // Set the theme mod for the slider page set_theme_mod('bakery_cafe_our_story', $bakery_cafe_post_id); } } } // Instantiate the class and call its methods $demo_importer = new BakeryCafeDemoImporter(); $demo_importer->setup_widgets(); $demo_importer->bakery_cafe_customizer_primary_menu(); } ?>