' . esc_html__('Your demo import has been completed successfully.', 'advance-education') . '';
echo '' . esc_html__('VIEW SITE', 'advance-education') . '';
}
if (isset($_POST['submit'])) {
// --- Menu ---
$advance_education_primary_menu_name = 'Main Menu';
$advance_education_primary_menu_location = 'primary';
$advance_education_primary_menu_exists = wp_get_nav_menu_object($advance_education_primary_menu_name);
if (!$advance_education_primary_menu_exists) {
// Create the left menu
$advance_education_primary_menu_id = wp_create_nav_menu($advance_education_primary_menu_name);
// Create and assign the Home page
$advance_education_home_page_id = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'Home',
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'home'
));
// Assign template and set as front page
add_post_meta($advance_education_home_page_id, '_wp_page_template', 'page-template/custom-front-page.php');
update_option('page_on_front', $advance_education_home_page_id);
update_option('show_on_front', 'page');
// Add Home page to the left menu
wp_update_nav_menu_item($advance_education_primary_menu_id, 0, array(
'menu-item-title' => __('Home', 'advance-education'),
'menu-item-classes' => 'home',
'menu-item-url' => home_url('/'),
'menu-item-status' => 'publish',
'menu-item-object-id' => $advance_education_home_page_id,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
));
// Create and assign the About Us page
$advance_education_about_us_page_id = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'About Us',
'post_content' => 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.',
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'about-us'
));
// Add About Us page to the left menu
wp_update_nav_menu_item($advance_education_primary_menu_id, 0, array(
'menu-item-title' => __('About Us', 'advance-education'),
'menu-item-classes' => 'about-us',
'menu-item-url' => home_url('/about-us/'),
'menu-item-status' => 'publish',
'menu-item-object-id' => $advance_education_about_us_page_id,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
));
// Create and assign the Courses page
$advance_education_about_us_page_id = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'Courses',
'post_content' => 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.',
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'about-us'
));
// Add Courses page to the left menu
wp_update_nav_menu_item($advance_education_primary_menu_id, 0, array(
'menu-item-title' => __('Courses', 'advance-education'),
'menu-item-classes' => 'about-us',
'menu-item-url' => home_url('/about-us/'),
'menu-item-status' => 'publish',
'menu-item-object-id' => $advance_education_about_us_page_id,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
));
// Create and assign the Gallery page
$advance_education_about_us_page_id = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'Gallery',
'post_content' => 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.',
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'about-us'
));
// Add Gallery page to the left menu
wp_update_nav_menu_item($advance_education_primary_menu_id, 0, array(
'menu-item-title' => __('Gallery', 'advance-education'),
'menu-item-classes' => 'about-us',
'menu-item-url' => home_url('/about-us/'),
'menu-item-status' => 'publish',
'menu-item-object-id' => $advance_education_about_us_page_id,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
));
// Create and assign the Events page
$advance_education_about_us_page_id = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'Events',
'post_content' => 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.',
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'about-us'
));
// Add Events page to the left menu
wp_update_nav_menu_item($advance_education_primary_menu_id, 0, array(
'menu-item-title' => __('Events', 'advance-education'),
'menu-item-classes' => 'about-us',
'menu-item-url' => home_url('/about-us/'),
'menu-item-status' => 'publish',
'menu-item-object-id' => $advance_education_about_us_page_id,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
));
// Create and assign the Contact Us page
$advance_education_about_us_page_id = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'Contact Us',
'post_content' => 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which dont look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isnt anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.',
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'about-us'
));
// Add Contact Us page to the left menu
wp_update_nav_menu_item($advance_education_primary_menu_id, 0, array(
'menu-item-title' => __('Contact Us', 'advance-education'),
'menu-item-classes' => 'about-us',
'menu-item-url' => home_url('/about-us/'),
'menu-item-status' => 'publish',
'menu-item-object-id' => $advance_education_about_us_page_id,
'menu-item-object' => 'page',
'menu-item-type' => 'post_type',
));
// Assign left menu to its location
$advance_education_locations = get_theme_mod('nav_menu_locations', array());
$advance_education_locations[$advance_education_primary_menu_location] = $advance_education_primary_menu_id;
set_theme_mod('nav_menu_locations', $advance_education_locations);
}
// Set the demo import completion flag
update_option('advance_education_demo_import_completed', true);
// Display success message and "View Site" button
echo '' . esc_html__('Your demo import has been completed successfully.', 'advance-education') . '
';
echo '' . esc_html__('VIEW SITE', 'advance-education') . '';
//end
// Topbar Section
set_theme_mod( 'advance_education_time', 'Open Hours: 8.00-18.00 Mon-Sat' );
set_theme_mod( 'advance_education_phone1', '(00) 123 456 789' );
set_theme_mod( 'advance_education_mail1', 'educationexp@example.com' );
// Slider
for($advance_education_i=1;$advance_education_i<=4;$advance_education_i++){
$advance_education_slider_title = 'LOREM IPSUM DOLOR SIT AMET CONSECTETUR ADIPISCING ELIT';
$advance_education_slider_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Quis ipsum suspendisse ultrices gravida.';
// Create post object
$advance_education_my_post = array(
'post_title' => wp_strip_all_tags( $advance_education_slider_title ),
'post_content' => $advance_education_slider_content,
'post_status' => 'publish',
'post_type' => 'page',
);
// Insert the post into the database
$advance_education_post_id = wp_insert_post( $advance_education_my_post );
if ($advance_education_post_id) {
// Set the theme mod for the slider page
set_theme_mod('advance_education_slider_page' . $advance_education_i, $advance_education_post_id);
$advance_education_image_url = get_template_directory_uri().'/images/slider'.$advance_education_i.'.png';
$advance_education_image_id = media_sideload_image($advance_education_image_url, $advance_education_post_id, null, 'id');
if (!is_wp_error($advance_education_image_id)) {
// Set the downloaded image as the post's featured image
set_post_thumbnail($advance_education_post_id, $advance_education_image_id);
}
}
}
// How it works Section
set_theme_mod( 'advance_education_title', 'POPULAR COURSES' );
// Post Category
set_theme_mod( 'advance_education_popular_courses_category', 'category1' );
// Define post category names and post titles
$advance_education_category_names = array('category1', 'category2', 'category3');
$advance_education_title_array = array(
array("Courses Title 1", "Courses Title 2", "Courses Title 3"),
array("Courses Title 1", "Courses Title 2", "Courses Title 3"),
array("Courses Title 1", "Courses Title 2", "Courses Title 3")
);
foreach ($advance_education_category_names as $advance_education_index => $advance_education_category_name) {
// Create or retrieve the post category term ID
$advance_education_term = term_exists($advance_education_category_name, 'category');
if ($advance_education_term === 0 || $advance_education_term === null) {
// If the term does not exist, create it
$advance_education_term = wp_insert_term($advance_education_category_name, 'category');
}
if (is_wp_error($advance_education_term)) {
error_log('Error creating category: ' . $advance_education_term->get_error_message());
continue; // Skip to the next iteration if category creation fails
}
for ($advance_education_i = 0; $advance_education_i < 3; $advance_education_i++) {
// Create post content
$advance_education_title = $advance_education_title_array[$advance_education_index][$advance_education_i];
$advance_education_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_education_my_post = array(
'post_title' => wp_strip_all_tags($advance_education_title),
'post_content' => $advance_education_content,
'post_status' => 'publish',
'post_type' => 'post', // Post type set to 'post'
);
// Insert the post into the database
$advance_education_post_id = wp_insert_post($advance_education_my_post);
if (is_wp_error($advance_education_post_id)) {
error_log('Error creating post: ' . $advance_education_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_education_post_id, array((int)$advance_education_term['term_id']));
// Handle the featured image using media_sideload_image
$advance_education_image_url = get_template_directory_uri() . '/images/image' . ($advance_education_i + 1) . '.png';
$advance_education_image_id = media_sideload_image($advance_education_image_url, $advance_education_post_id, null, 'id');
if (is_wp_error($advance_education_image_id)) {
error_log('Error downloading image: ' . $advance_education_image_id->get_error_message());
continue; // Skip to the next post if image download fails
}
// Assign featured image to post
set_post_thumbnail($advance_education_post_id, $advance_education_image_id);
}
}
}
?>