' . esc_html__('Your demo import has been completed successfully.', 'anime-stream') . '
'; echo '' . esc_html__('View Site', 'anime-stream') . ''; //end // Header set_theme_mod( 'anime_stream_collection_button_text', 'My Collection' ); set_theme_mod( 'anime_stream_collection_button_url', '#' ); set_theme_mod( 'anime_stream_collection_button_icon', 'fa-solid fa-file' ); set_theme_mod( 'anime_stream_recent_button_text', 'Recents' ); set_theme_mod( 'anime_stream_recent_button_url', '#' ); set_theme_mod( 'anime_stream_recent_button_icon', 'fa-solid fa-clock' ); set_theme_mod( 'anime_stream_favourites_button_text', 'Favourites' ); set_theme_mod( 'anime_stream_favourites_button_url', '#' ); set_theme_mod( 'anime_stream_favourites_button_icon', 'fa-solid fa-star' ); set_theme_mod( 'anime_stream_sign_in_button_text', 'Sign In / Sign Up' ); set_theme_mod( 'anime_stream_sign_in_button_url', '#' ); set_theme_mod( 'anime_stream_sign_in_button_icon', 'fa-solid fa-user' ); // Create demo categories if not exist $anime_stream_demo_categories = array('Anime', 'Manga', 'Movies'); foreach ($anime_stream_demo_categories as $anime_stream_cat_name) { if (!term_exists($anime_stream_cat_name, 'category')) { wp_insert_term($anime_stream_cat_name, 'category'); } } // Set theme mod for customizer dropdowns set_theme_mod('anime_stream_header_top_category1', 'Anime'); set_theme_mod('anime_stream_header_top_category2', 'Manga'); set_theme_mod('anime_stream_header_top_category3', 'Movies'); // Slider set_theme_mod('anime_stream_slider_category', 'Project1'); $anime_stream_category_names = array('Project1', 'Project2'); $anime_stream_title_array = array( array("Dragon Ball Z: Battle of Gods", "Dragon Ball Z: Broly – The Legendary Super Saiyan", "Dragon Ball Z: Fusion Reborn"), array("Dragon Ball Z: Resurrection 'F'", "Dragon Ball Z: The Return of Cooler", "Dragon Ball Z: Wrath of the Dragon"), ); foreach ($anime_stream_category_names as $anime_stream_index => $anime_stream_category_name) { // Create or retrieve the category $anime_stream_term = term_exists($anime_stream_category_name, 'category'); if ($anime_stream_term === 0 || $anime_stream_term === null) { $anime_stream_term = wp_insert_term($anime_stream_category_name, 'category'); } if (is_wp_error($anime_stream_term)) { error_log('Error creating category: ' . $anime_stream_term->get_error_message()); continue; } for ($anime_stream_i = 0; $anime_stream_i < 3; $anime_stream_i++) { $anime_stream_title = $anime_stream_title_array[$anime_stream_index][$anime_stream_i]; // Use unique or common YouTube URLs $anime_stream_video_url = 'https://www.youtube.com/embed/9xwazD5SyVg'; // ✅ Embed video using iframe directly $anime_stream_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.
'; $anime_stream_content .= ''; // Create post array $anime_stream_my_post = array( 'post_title' => wp_strip_all_tags($anime_stream_title), 'post_content' => $anime_stream_content, 'post_status' => 'publish', 'post_type' => 'post', ); // Insert post $anime_stream_post_id = wp_insert_post($anime_stream_my_post); if (is_wp_error($anime_stream_post_id)) { error_log('Error creating post: ' . $anime_stream_post_id->get_error_message()); continue; } // Assign category wp_set_post_categories($anime_stream_post_id, array((int)$anime_stream_term['term_id'])); // Set featured image $anime_stream_image_url = get_template_directory_uri() . '/assets/images/slider' . ($anime_stream_i + 1) . '.png'; $anime_stream_image_id = media_sideload_image($anime_stream_image_url, $anime_stream_post_id, null, 'id'); if (!is_wp_error($anime_stream_image_id)) { set_post_thumbnail($anime_stream_post_id, $anime_stream_image_id); } else { error_log('Image error: ' . $anime_stream_image_id->get_error_message()); } } } // Top Charts set_theme_mod( 'anime_stream_chart_section_title', 'Top Charts' ); set_theme_mod('anime_stream_top_chart_category', 'Top Chart1'); // Define post category names and post titles $anime_stream_category_names = array('Top Chart1', 'Top Chart2'); $anime_stream_title_array = array( array("Demon Slayer", "Demon Slayer", "Demon Slayer"), array("Demon Slayer", "Demon Slayer", "Demon Slayer"), array("Demon Slayer", "Demon Slayer", "Demon Slayer"), ); foreach ($anime_stream_category_names as $anime_stream_index => $anime_stream_category_name) { // Create or retrieve the post category term ID $anime_stream_term = term_exists($anime_stream_category_name, 'category'); if ($anime_stream_term === 0 || $anime_stream_term === null) { // If the term does not exist, create it $anime_stream_term = wp_insert_term($anime_stream_category_name, 'category'); } if (is_wp_error($anime_stream_term)) { error_log('Error creating category: ' . $anime_stream_term->get_error_message()); continue; // Skip to the next iteration if category creation fails } for ($anime_stream_j = 0; $anime_stream_j < 3; $anime_stream_j++) { // Create post content $anime_stream_title = $anime_stream_title_array[$anime_stream_index][$anime_stream_j]; // Use unique or common YouTube URLs $anime_stream_video_url = 'https://www.youtube.com/embed/9xwazD5SyVg'; // ✅ Embed video using iframe directly $anime_stream_content = 'It is the Taisho Period in Japan. Tanjiro, a kindhearted boy who sells charcoal for a living, finds his family slaughtered by a demon. To make matters worse, his younger sister Nezuko, the sole survivor, has been transformed into a demon herself. Though devastated by this grim reality, Tanjiro resolves to become a “demon slayer” so that he can turn his sister back into a human, and kill the demon that massacred his family.
'; $anime_stream_content .= ''; // Create post post object $anime_stream_my_post = array( 'post_title' => wp_strip_all_tags($anime_stream_title), 'post_content' => $anime_stream_content, 'post_status' => 'publish', 'post_type' => 'post', // Post type set to 'post' ); // Insert the post into the database $anime_stream_post_id = wp_insert_post($anime_stream_my_post); if (is_wp_error($anime_stream_post_id)) { error_log('Error creating post: ' . $anime_stream_post_id->get_error_message()); continue; // Skip to the next post if creation fails } // Assign the category to the post wp_set_post_categories($anime_stream_post_id, array((int)$anime_stream_term['term_id'])); // Handle the featured image using media_sideload_image $anime_stream_image_url = get_template_directory_uri() . '/assets/images/chart' . ($anime_stream_j + 1) . '.png'; $anime_stream_image_id = media_sideload_image($anime_stream_image_url, $anime_stream_post_id, null, 'id'); if (is_wp_error($anime_stream_image_id)) { error_log('Error downloading image: ' . $anime_stream_image_id->get_error_message()); continue; // Skip to the next post if image download fails } // Assign featured image to post set_post_thumbnail($anime_stream_post_id, $anime_stream_image_id); } } // Right Sidebar set_theme_mod( 'anime_stream_right_sidebar_hide_show', true ); set_theme_mod( 'anime_stream_right_top_cards_title', 'Top Charts' ); set_theme_mod( 'anime_stream_select_cards_number', '6' ); // select Post Box $anime_stream_title_array = array("Post title 1", "Post title 2", "Post title 3", "Post title 4", "Post title 5", "Post title 6"); for ($anime_stream_k = 1; $anime_stream_k <= 6; $anime_stream_k++) { set_theme_mod( 'anime_stream_add_card_text'.$anime_stream_k, '3.3k watching' ); // Create post $anime_stream_title = $anime_stream_title_array[$anime_stream_k - 1]; $anime_stream_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting.'; $anime_stream_my_post = array( 'post_title' => wp_strip_all_tags($anime_stream_title), 'post_content' => $anime_stream_content, 'post_status' => 'publish', 'post_type' => 'post', ); $anime_stream_post_id = wp_insert_post($anime_stream_my_post); set_theme_mod('anime_stream_select_card_name' . $anime_stream_k, $anime_stream_post_id); // Get image URL $anime_stream_image_url = get_template_directory_uri() . '/assets/images/post' . $anime_stream_k . '.png'; $anime_stream_image_data = wp_remote_get($anime_stream_image_url); if (!is_wp_error($anime_stream_image_data)) { $anime_stream_image_body = wp_remote_retrieve_body($anime_stream_image_data); $anime_stream_upload_dir = wp_upload_dir(); $anime_stream_image_name = 'post' . $anime_stream_k . '.png'; $anime_stream_uploaded_file = wp_upload_bits($anime_stream_image_name, null, $anime_stream_image_body); if (!$anime_stream_uploaded_file['error']) { // Set attachment data $attachment = array( 'post_mime_type' => $anime_stream_uploaded_file['type'], 'post_title' => sanitize_file_name($anime_stream_image_name), 'post_content' => '', 'post_status' => 'inherit', ); $anime_stream_attach_id = wp_insert_attachment($attachment, $anime_stream_uploaded_file['file'], $anime_stream_post_id); require_once(ABSPATH . 'wp-admin/includes/image.php'); $anime_stream_attach_data = wp_generate_attachment_metadata($anime_stream_attach_id, $anime_stream_uploaded_file['file']); wp_update_attachment_metadata($anime_stream_attach_id, $anime_stream_attach_data); set_post_thumbnail($anime_stream_post_id, $anime_stream_attach_id); } } } // Right middle set_theme_mod( 'anime_stream_right_sidebar_title', 'Top Charts' ); for($anime_stream_image=1; $anime_stream_image<=3; $anime_stream_image++) { set_theme_mod( 'anime_stream_top_charts_slider_img'.$anime_stream_image, get_template_directory_uri().'/assets/images/right-img' . $anime_stream_image . '.png' ); } // right bottom set_theme_mod( 'anime_stream_right_sidebar_wallpaper_title', 'Wallpaper' ); for($anime_stream_k=1; $anime_stream_k<=3; $anime_stream_k++) { set_theme_mod( 'anime_stream_right_sidebar_wallpaper_img'.$anime_stream_k, get_template_directory_uri().'/assets/images/wallpaper-img' . $anime_stream_k . '.png' ); } set_theme_mod( 'anime_stream_gallery_button_text', 'Explore More' ); set_theme_mod( 'anime_stream_gallery_button_url', '#' ); } ?>