__('Home', 'arcade-games'), 'menu-item-classes' => 'home', 'menu-item-url' => home_url('/'), 'menu-item-status' => 'publish', )); wp_update_nav_menu_item($arcade_games_menu_id, 0, array( 'menu-item-title' => __('Blog','arcade-games'), 'menu-item-classes' => 'blog', 'menu-item-url' => get_permalink(arcade_games_get_page_id_by_title('blog')), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($arcade_games_menu_id, 0, array( 'menu-item-title' => __('Contact','arcade-games'), 'menu-item-classes' => 'contact', 'menu-item-url' => get_permalink(arcade_games_get_page_id_by_title('contact')), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($arcade_games_menu_id, 0, array( 'menu-item-title' => __('Pages','arcade-games'), 'menu-item-classes' => 'contact', 'menu-item-url' => get_permalink(arcade_games_get_page_id_by_title('pages')), 'menu-item-status' => 'publish')); wp_update_nav_menu_item($arcade_games_menu_id, 0, array( 'menu-item-title' => __('Shop','arcade-games'), 'menu-item-classes' => 'shop', 'menu-item-url' => get_permalink(arcade_games_get_page_id_by_title('shop')), 'menu-item-status' => 'publish')); if (!has_nav_menu($arcade_games_bpmenulocation)) { $locations = get_theme_mod('nav_menu_locations'); $locations[$arcade_games_bpmenulocation] = $arcade_games_menu_id; set_theme_mod('nav_menu_locations', $locations); } } } public function setup_widgets() { $arcade_games_home_id=''; $arcade_games_home_content = ''; $arcade_games_home_title = 'Home'; $arcade_games_home = array( 'post_type' => 'page', 'post_title' => $arcade_games_home_title, 'post_content' => $arcade_games_home_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'home' ); $arcade_games_home_id = wp_insert_post($arcade_games_home); add_post_meta( $arcade_games_home_id, '_wp_page_template', 'frontpage.php' ); update_option( 'page_on_front', $arcade_games_home_id ); update_option( 'show_on_front', 'page' ); // Create a Posts Page $arcade_games_blog_title = 'About Us'; $arcade_games_blog_check = arcade_games_get_page_id_by_title($arcade_games_blog_title); if ($arcade_games_blog_check == 1) { $arcade_games_blog = array( 'post_type' => 'page', 'post_title' => $arcade_games_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'jobs', '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."', ); $arcade_games_blog_id = wp_insert_post($arcade_games_blog); if (!is_wp_error($arcade_games_blog_id)) { // update_option('page_for_posts', $arcade_games_blog_id); } } // Create a Posts Page $arcade_games_blog_title = 'Pages'; $arcade_games_blog_check = arcade_games_get_page_id_by_title($arcade_games_blog_title); if ($arcade_games_blog_check == 1) { $arcade_games_blog = array( 'post_type' => 'page', 'post_title' => $arcade_games_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."', ); $arcade_games_blog_id = wp_insert_post($arcade_games_blog); if (!is_wp_error($arcade_games_blog_id)) { // update_option('page_for_posts', $arcade_games_blog_id); } } // Create a Posts Page $arcade_games_blog_title = 'Shop'; $arcade_games_blog_check = arcade_games_get_page_id_by_title($arcade_games_blog_title); if ($arcade_games_blog_check == 1) { $arcade_games_blog = array( 'post_type' => 'page', 'post_title' => $arcade_games_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'pricing', '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."', ); $arcade_games_blog_id = wp_insert_post($arcade_games_blog); if (!is_wp_error($arcade_games_blog_id)) { // update_option('page_for_posts', $arcade_games_blog_id); } } // Create a Posts Page $arcade_games_blog_title = 'Blogs'; $arcade_games_blog_check = arcade_games_get_page_id_by_title($arcade_games_blog_title); if ($arcade_games_blog_check == 1) { $arcade_games_blog = array( 'post_type' => 'page', 'post_title' => $arcade_games_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'blogs', '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."', ); $arcade_games_blog_id = wp_insert_post($arcade_games_blog); if (!is_wp_error($arcade_games_blog_id)) { // update_option('page_for_posts', $arcade_games_blog_id); } } // Create a Posts Page $arcade_games_blog_title = 'Contact Us'; $arcade_games_blog_check = arcade_games_get_page_id_by_title($arcade_games_blog_title); if ($arcade_games_blog_check == 1) { $arcade_games_blog = array( 'post_type' => 'page', 'post_title' => $arcade_games_blog_title, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'contact', '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."', ); $arcade_games_blog_id = wp_insert_post($arcade_games_blog); if (!is_wp_error($arcade_games_blog_id)) { // update_option('page_for_posts', $arcade_games_blog_id); } } //-----Header-----// set_theme_mod( 'arcade_games_header_announcement_text', 'Welcome to war game studio' ); set_theme_mod('arcade_games_social_links_settings', array( array( "link_text" => "fab fa-facebook-f", "link_url" => "#" ), array( "link_text" => "fab fa-twitter-square", "link_url" => "#" ), array( "link_text" => "fab fa-linkedin", "link_url" => "#" ), array( "link_text" => "fab fa-instagram", "link_url" => "#" ), array( "link_text" => "fab fa-pinterest-p", "link_url" => "#" ) )); set_theme_mod( 'arcade_games_sign_up_text', 'Sign Up' ); set_theme_mod( 'arcade_games_sign_up_url', '#' ); set_theme_mod( 'arcade_games_sign_in_text', ' Sign In' ); set_theme_mod( 'arcade_games_sign_in_url', '#' ); //-----Slider-----// set_theme_mod( 'arcade_games_blog_box_enable', true); set_theme_mod( 'arcade_games_slider_short_heading', ' Are You Ready For New Battle' ); set_theme_mod( 'arcade_games_blog_slide_number', '3' ); $arcade_games_latest_post_category = wp_create_category('Slider Post'); set_theme_mod( 'arcade_games_blog_slide_category', 'Slider Post' ); for($i=1; $i<=3; $i++) { $title = 'Play Fun Game Arcade with Gamezo !'; $content = 'Lorem Ipsum has been the industrys standard dummy text ever since the 1500s when an unknown printer took a galley.'; // Create post object $arcade_games_my_post = array( 'post_title' => wp_strip_all_tags( $title ), 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array($arcade_games_latest_post_category) ); // Insert the post into the database $arcade_games_post_id = wp_insert_post( $arcade_games_my_post ); $arcade_games_image_url = get_template_directory_uri().'/assets/images/banner.png'; $arcade_games_image_name= 'banner.png'; $arcade_games_upload_dir = wp_upload_dir(); // Set upload folder $arcade_games_image_data = file_get_contents($arcade_games_image_url); // Get image data $arcade_games_unique_file_name = wp_unique_filename( $arcade_games_upload_dir['path'], $arcade_games_image_name ); // Generate unique name $filename= basename( $arcade_games_unique_file_name ); // Create image file name // Check folder permission and define file location if( wp_mkdir_p( $arcade_games_upload_dir['path'] ) ) { $file = $arcade_games_upload_dir['path'] . '/' . $filename; } else { $file = $arcade_games_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, $arcade_games_image_data, FS_CHMOD_FILE ) ) { wp_die( 'Error saving file!' ); } $arcade_games_wp_filetype = wp_check_filetype( $filename, null ); $arcade_games_attachment = array( 'post_mime_type' => $arcade_games_wp_filetype['type'], 'post_title' => sanitize_file_name( $filename ), 'post_content' => '', 'post_type' => 'post', 'post_status' => 'inherit' ); $arcade_games_attach_id = wp_insert_attachment( $arcade_games_attachment, $file, $arcade_games_post_id ); require_once(ABSPATH . 'wp-admin/includes/image.php'); $arcade_games_attach_data = wp_generate_attachment_metadata( $arcade_games_attach_id, $file ); wp_update_attachment_metadata( $arcade_games_attach_id, $arcade_games_attach_data ); set_post_thumbnail( $arcade_games_post_id, $arcade_games_attach_id ); } //-----Categories-----// set_theme_mod( 'arcade_games_products_section_enable', true); set_theme_mod( 'arcade_games_products_short_heading', 'Top Games'); set_theme_mod( 'arcade_games_products_main_heading', 'Our Latest Game'); set_theme_mod( 'arcade_games_projects_number', '4' ); $arcade_games_latest_post_category = wp_create_category('Product'); 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( 'arcade_games_products_category', 'Awesome Product' ); if ( class_exists( 'WooCommerce' ) ) { for($i=1;$i<=4;$i++) { $title = 'Game Name 01'; $content = 'Lorem ipsum dolor sit amit.'; // 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().'/assets/images/products'.$i.'.png'; $image_name= 'products'.$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 if ( ! function_exists( 'WP_Filesystem' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } WP_Filesystem(); global $wp_filesystem; if ( ! $wp_filesystem->put_contents( $file, $image_data, FS_CHMOD_FILE ) ) { wp_die( 'Error saving file!' ); } // 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 ); } } } } // Instantiate the class and call its methods $demo_importer = new ArcadeGamesDemoImporter(); $demo_importer->setup_widgets(); $demo_importer->arcade_games_customizer_primary_menu(); } ?>