Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960 with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
'; $apartment_rental_services_pages = array( 'post_type' => 'page', 'post_title' => $apartment_rental_services_pages_title, 'post_content' => $apartment_rental_services_pages_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'pages' ); $apartment_rental_services_pages_id = wp_insert_post($apartment_rental_services_pages); // Add Pages Page to Menu wp_update_nav_menu_item($apartment_rental_services_menu_id, 0, array( 'menu-item-title' => __('Pages', 'apartment-rental-services'), 'menu-item-classes' => 'pages', 'menu-item-url' => home_url('/pages/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $apartment_rental_services_pages_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Create About Us Page with Dummy Content $apartment_rental_services_about_title = 'About Us'; $apartment_rental_services_about_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960 with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
'; $apartment_rental_services_about = array( 'post_type' => 'page', 'post_title' => $apartment_rental_services_about_title, 'post_content' => $apartment_rental_services_about_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'about-us' ); $apartment_rental_services_about_id = wp_insert_post($apartment_rental_services_about); // Add About Us Page to Menu wp_update_nav_menu_item($apartment_rental_services_menu_id, 0, array( 'menu-item-title' => __('About Us', 'apartment-rental-services'), 'menu-item-classes' => 'about-us', 'menu-item-url' => home_url('/about-us/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $apartment_rental_services_about_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Assign the menu to the primary location if not already set if ( ! has_nav_menu( $apartment_rental_services_bpmenulocation ) ) { $apartment_rental_services_locations = get_theme_mod( 'nav_menu_locations' ); if ( empty( $apartment_rental_services_locations ) ) { $apartment_rental_services_locations = array(); } $apartment_rental_services_locations[ $apartment_rental_services_bpmenulocation ] = $apartment_rental_services_menu_id; set_theme_mod( 'nav_menu_locations', $apartment_rental_services_locations ); } } //Header Section set_theme_mod( 'apartment_rental_services_the_custom_logo', esc_url( get_template_directory_uri().'/images/Logo.png')); set_theme_mod( 'apartment_rental_services_header_btn_text', 'Ask A Question' ); set_theme_mod( 'apartment_rental_services_header_btn_url', '#' ); // Slider settings set_theme_mod('apartment_rental_services_button_text', 'EXPLORE APARTMENT'); set_theme_mod('apartment_rental_services_button_link_slider', '#'); set_theme_mod('apartment_rental_services_button_text2', 'TAKE A LOOK AT VR'); set_theme_mod('apartment_rental_services_button_link_slider2', '#'); // Helper function to import an image from a URL function apartment_rental_services_import_image($apartment_rental_services_image_url, $apartment_rental_services_post_id) { $apartment_rental_services_image_name = basename($apartment_rental_services_image_url); $apartment_rental_services_upload_dir = wp_upload_dir(); // Download image data using file_get_contents $apartment_rental_services_image_data = @file_get_contents($apartment_rental_services_image_url); if ($apartment_rental_services_image_data === false) { return new WP_Error('image_download_error', 'Failed to download image: ' . $apartment_rental_services_image_url); } // Use wp_upload_bits to handle the file saving $apartment_rental_services_result = wp_upload_bits($apartment_rental_services_image_name, null, $apartment_rental_services_image_data); if ($apartment_rental_services_result['error']) { return new WP_Error('image_write_error', 'Failed to write image to uploads: ' . $apartment_rental_services_result['error']); } // Insert the image into the media library $apartment_rental_services_attachment = array( 'post_mime_type' => wp_check_filetype($apartment_rental_services_image_name, null)['type'], 'post_title' => sanitize_file_name($apartment_rental_services_image_name), 'post_content' => '', 'post_status' => 'inherit' ); $apartment_rental_services_attach_id = wp_insert_attachment($apartment_rental_services_attachment, $apartment_rental_services_result['file'], $apartment_rental_services_post_id); if (is_wp_error($apartment_rental_services_attach_id)) { return new WP_Error('attachment_error', 'Failed to create attachment: ' . $apartment_rental_services_attach_id->get_error_message()); } require_once(ABSPATH . 'wp-admin/includes/image.php'); $apartment_rental_services_attach_data = wp_generate_attachment_metadata($apartment_rental_services_attach_id, $apartment_rental_services_result['file']); wp_update_attachment_metadata($apartment_rental_services_attach_id, $apartment_rental_services_attach_data); return $apartment_rental_services_attach_id; } // Create a category for the slider $apartment_rental_services_category_id = wp_create_category('Apartment'); if (is_wp_error($apartment_rental_services_category_id)) { error_log('Error creating category: ' . $apartment_rental_services_category_id->get_error_message()); return; } // Fetch and set the category image $category_image_url = get_template_directory_uri() . '/images/slider.png'; $category_image_id = apartment_rental_services_import_image($category_image_url, 0); if (is_wp_error($category_image_id)) { error_log('Error importing category image: ' . $category_image_id->get_error_message()); } else { set_theme_mod('apartment_rental_services_category_image', wp_get_attachment_url($category_image_id)); } $apartment_rental_services_post_titles = array( 'Where Convenience Meets Opulence', 'Perfect Blend of Comfort and Elegance', 'Unique Fusion of Convenience and Luxury' ); $apartment_rental_services_images = [ get_template_directory_uri() . '/images/slider-img/slider1.png', get_template_directory_uri() . '/images/slider-img/slider2.png', get_template_directory_uri() . '/images/slider-img/slider3.png', ]; for ($apartment_rental_services_i = 0; $apartment_rental_services_i < 3; $apartment_rental_services_i++) { $apartment_rental_services_post_title = $apartment_rental_services_post_titles[$apartment_rental_services_i]; // Correct index $apartment_rental_services_post_id = wp_insert_post(array( 'post_title' => $apartment_rental_services_post_title, 'post_content' => 'This is the demo content for the slider.', 'post_status' => 'publish', 'post_category' => array($apartment_rental_services_category_id), )); if (is_wp_error($apartment_rental_services_post_id)) { error_log('Error creating post: ' . $apartment_rental_services_post_id->get_error_message()); continue; } // Attach images to the post foreach ($apartment_rental_services_images as $apartment_rental_services_j => $apartment_rental_services_image_url) { $apartment_rental_services_image_id = apartment_rental_services_import_image($apartment_rental_services_image_url, $apartment_rental_services_post_id); if (is_wp_error($apartment_rental_services_image_id)) { error_log('Error importing image: ' . $apartment_rental_services_image_id->get_error_message()); continue; } // Set each image in customizer settings set_theme_mod('apartment_rental_services_slider_img' . $apartment_rental_services_post_id . '_' . ($apartment_rental_services_j + 1), wp_get_attachment_url($apartment_rental_services_image_id)); } } set_theme_mod('apartment_rental_services_slider_cat', get_category($apartment_rental_services_category_id)->slug); //Service Section set_theme_mod( 'apartment_rental_services_service_title', 'Apartment Services' ); set_theme_mod( 'apartment_rental_services_service_text', 'simply dummy text of the printing and typesetting industry' ); $apartment_rental_services_featured_category_id = wp_create_category('Services'); set_theme_mod('apartment_rental_services_posts', 'Services'); $apartment_rental_services_titles = array('Innovative Spaces', 'Crafted Rooms', '24/7 Reception'); $apartment_rental_services_content = 'Veniam sed quis nostrud ulamc'; for ($apartment_rental_services_i = 0; $apartment_rental_services_i < 3; $apartment_rental_services_i++) { set_theme_mod('apartment_rental_services_title' . ($apartment_rental_services_i + 1), $apartment_rental_services_titles[$apartment_rental_services_i]); $apartment_rental_services_my_post = array( 'post_title' => wp_strip_all_tags($apartment_rental_services_titles[$apartment_rental_services_i]), 'post_content' => $apartment_rental_services_content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array($apartment_rental_services_featured_category_id), ); $apartment_rental_services_post_id = wp_insert_post($apartment_rental_services_my_post); if (!is_wp_error($apartment_rental_services_post_id)) { $apartment_rental_services_image_url = get_template_directory_uri() . '/images/services/service' . ($apartment_rental_services_i + 1) . '.png'; $apartment_rental_services_image_id = media_sideload_image($apartment_rental_services_image_url, $apartment_rental_services_post_id, null, 'id'); if (!is_wp_error($apartment_rental_services_image_id)) { set_post_thumbnail($apartment_rental_services_post_id, $apartment_rental_services_image_id); } else { error_log('Failed to set post thumbnail for post ID: ' . $apartment_rental_services_post_id); } } else { error_log('Failed to create post: ' . print_r($apartment_rental_services_post_id, true)); } } //Footer Copyright Text set_theme_mod( 'apartment_rental_services_copyright_line', 'Apartment WordPress Theme' ); // Show success message and the "View Site" button echo '