' . esc_html__('Your demo import has been completed successfully.', 'advance-fitness-gym') . '
'; echo '' . esc_html__('VIEW SITE', 'advance-fitness-gym') . ''; //end // Topbar Section set_theme_mod( 'advance_fitness_gym_contact', '1(868) 225-6155' ); set_theme_mod( 'advance_fitness_gym_email', 'xyz123@example.com' ); // Social Icons set_theme_mod( 'advance_fitness_gym_cont_facebook', '#' ); set_theme_mod( 'advance_fitness_gym_cont_twitter', '#' ); set_theme_mod( 'advance_fitness_gym_instagram', '#' ); set_theme_mod( 'advance_fitness_gym_linkedin', '#' ); // Slider for($advance_fitness_gym_i=1;$advance_fitness_gym_i<=4;$advance_fitness_gym_i++){ $advance_fitness_gym_slider_title = 'BUILD YOUR BODY Transform your life'; $advance_fitness_gym_slider_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever.'; // Create post object $advance_fitness_gym_my_post = array( 'post_title' => wp_strip_all_tags( $advance_fitness_gym_slider_title ), 'post_content' => $advance_fitness_gym_slider_content, 'post_status' => 'publish', 'post_type' => 'page', ); // Insert the post into the database $advance_fitness_gym_post_id = wp_insert_post( $advance_fitness_gym_my_post ); if ($advance_fitness_gym_post_id) { // Set the theme mod for the slider page set_theme_mod('advance_fitness_gym_slider_page' . $advance_fitness_gym_i, $advance_fitness_gym_post_id); $advance_fitness_gym_image_url = get_template_directory_uri().'/images/slider'.$advance_fitness_gym_i.'.png'; $advance_fitness_gym_image_id = media_sideload_image($advance_fitness_gym_image_url, $advance_fitness_gym_post_id, null, 'id'); if (!is_wp_error($advance_fitness_gym_image_id)) { // Set the downloaded image as the post's featured image set_post_thumbnail($advance_fitness_gym_post_id, $advance_fitness_gym_image_id); } } } // Services Section set_theme_mod( 'advance_fitness_gym_product_service', 'category1' ); // Define post category names and post titles $advance_fitness_gym_category_names = array('category1', 'category2', 'category3'); $advance_fitness_gym_title_array = array( array("YOGA", "WEIGHT LIFTING", "RUNNING", "MEDICATION"), array("YOGA", "WEIGHT LIFTING", "RUNNING", "MEDICATION"), array("YOGA", "WEIGHT LIFTING", "RUNNING", "MEDICATION") ); foreach ($advance_fitness_gym_category_names as $advance_fitness_gym_index => $advance_fitness_gym_category_name) { // Create or retrieve the post category term ID $advance_fitness_gym_term = term_exists($advance_fitness_gym_category_name, 'category'); if ($advance_fitness_gym_term === 0 || $advance_fitness_gym_term === null) { // If the term does not exist, create it $advance_fitness_gym_term = wp_insert_term($advance_fitness_gym_category_name, 'category'); } if (is_wp_error($advance_fitness_gym_term)) { error_log('Error creating category: ' . $advance_fitness_gym_term->get_error_message()); continue; // Skip to the next iteration if category creation fails } for ($advance_fitness_gym_i = 0; $advance_fitness_gym_i < 4; $advance_fitness_gym_i++) { // Create post content $advance_fitness_gym_title = $advance_fitness_gym_title_array[$advance_fitness_gym_index][$advance_fitness_gym_i]; $advance_fitness_gym_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever.'; // Create post post object $advance_fitness_gym_my_post = array( 'post_title' => wp_strip_all_tags($advance_fitness_gym_title), 'post_content' => $advance_fitness_gym_content, 'post_status' => 'publish', 'post_type' => 'post', // Post type set to 'post' ); // Insert the post into the database $advance_fitness_gym_post_id = wp_insert_post($advance_fitness_gym_my_post); if (is_wp_error($advance_fitness_gym_post_id)) { error_log('Error creating post: ' . $advance_fitness_gym_post_id->get_error_message()); continue; // Skip to the next post if creation fails } // Assign the category to the post wp_set_post_categories($advance_fitness_gym_post_id, array((int)$advance_fitness_gym_term['term_id'])); // Handle the featured image using media_sideload_image $advance_fitness_gym_image_url = get_template_directory_uri() . '/images/image' . ($advance_fitness_gym_i + 1) . '.png'; $advance_fitness_gym_image_id = media_sideload_image($advance_fitness_gym_image_url, $advance_fitness_gym_post_id, null, 'id'); if (is_wp_error($advance_fitness_gym_image_id)) { error_log('Error downloading image: ' . $advance_fitness_gym_image_id->get_error_message()); continue; // Skip to the next post if image download fails } // Assign featured image to post set_post_thumbnail($advance_fitness_gym_post_id, $advance_fitness_gym_image_id); } } // Welcome Section $advance_fitness_gym_post_title = 'WELCOME TO THE ADVANCE FITNESS GYM'; $advance_fitness_gym_post_content = 'Lorem ipsum dolor sit amet, consectetur adipisicing 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 exn reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.'; // Create post object $advance_fitness_gym_my_post = array( 'post_title' => wp_strip_all_tags($advance_fitness_gym_post_title), 'post_content' => $advance_fitness_gym_post_content, 'post_status' => 'publish', 'post_type' => 'post', ); // Insert the post into the database $advance_fitness_gym_post_id = wp_insert_post($advance_fitness_gym_my_post); // Check if the post was successfully created if (!is_wp_error($advance_fitness_gym_post_id)) { // Set the theme mod for the post ID set_theme_mod('advance_fitness_gym_single_post', $advance_fitness_gym_post_id); // Fetch the image URL $advance_fitness_gym_image_url = get_template_directory_uri() . '/images/post-img.png'; // Media sideload the image $advance_fitness_gym_image_id = media_sideload_image($advance_fitness_gym_image_url, $advance_fitness_gym_post_id, null, 'id'); // Check if the image was successfully uploaded if (!is_wp_error($advance_fitness_gym_image_id)) { // Set the downloaded image as the post's featured image set_post_thumbnail($advance_fitness_gym_post_id, $advance_fitness_gym_image_id); } else { // Handle the error if the image upload failed error_log('Image upload failed: ' . $advance_fitness_gym_image_id->get_error_message()); } } else { // Handle the error if the post creation failed error_log('Post creation failed: ' . $advance_fitness_gym_post_id->get_error_message()); } } ?>