install( 'https://downloads.wordpress.org/plugin/classic-blog-grid.latest-stable.zip' ); } // Activate the Classic Blog Grid plugin after installation (if needed) activate_plugin( $business_school_plugin_file ); } } // ------- Create Main Menu -------- $business_school_menuname = 'Primary Menu'; $business_school_bpmenulocation = 'primary'; $business_school_menu_exists = wp_get_nav_menu_object( $business_school_menuname ); if (!$business_school_menu_exists) { // Create a new menu $business_school_menu_id = wp_create_nav_menu($business_school_menuname); // Define pages to be created $business_school_pages = array( 'home' => array( 'title' => 'Home', 'template' => '/templates/template-home-page.php' ), 'about-us' => array( 'title' => 'About Us', '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.

' ), 'pages' => array( 'title' => 'Pages', '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.

' ), 'blogs' => array( 'title' => 'Blogs', 'content' => '' ), ); $business_school_page_ids = array(); // Loop through the pages and create them if they don’t exist foreach ($business_school_pages as $business_school_slug => $business_school_data) { $business_school_existing_page = get_page_by_path($business_school_slug); if ($business_school_existing_page) { // If the page already exists, use its ID $business_school_page_id = $business_school_existing_page->ID; } else { // Create a new page $business_school_page_data = array( 'post_type' => 'page', 'post_title' => $business_school_data['title'], 'post_content' => isset($business_school_data['content']) ? $business_school_data['content'] : '', 'post_status' => 'publish', 'post_author' => get_current_user_id(), // Set author dynamically 'post_name' => $business_school_slug, ); $business_school_page_id = wp_insert_post($business_school_page_data); // Assign custom page template if specified if (!empty($business_school_data['template'])) { update_post_meta($business_school_page_id, '_wp_page_template', $business_school_data['template']); } } // Store the page IDs $business_school_page_ids[$business_school_slug] = $business_school_page_id; } // Set homepage and blog page update_option('page_for_posts', $business_school_page_ids['blogs']); update_option('page_on_front', $business_school_page_ids['home']); update_option('show_on_front', 'page'); // Define menu items $business_school_menu_items = array( 'home', 'about-us', 'pages', 'blogs', ); // Add menu items dynamically foreach ($business_school_menu_items as $business_school_slug) { wp_update_nav_menu_item($business_school_menu_id, 0, array( 'menu-item-title' => esc_html($business_school_pages[$business_school_slug]['title']), 'menu-item-url' => get_permalink($business_school_page_ids[$business_school_slug]), 'menu-item-status' => 'publish', 'menu-item-object-id' => $business_school_page_ids[$business_school_slug], 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', )); } // Assign menu to theme location $business_school_locations = get_theme_mod('nav_menu_locations', array()); $business_school_locations[$business_school_bpmenulocation] = $business_school_menu_id; set_theme_mod('nav_menu_locations', $business_school_locations); } //Logo set_theme_mod( 'business_school_the_custom_logo', esc_url( get_template_directory_uri().'/images/Logo.png')); //Header Section set_theme_mod( 'business_school_top_bar', true); set_theme_mod( 'business_school_phone_number', '+123 456 7890'); set_theme_mod( 'business_school_email_address', 'business@example.com'); set_theme_mod( 'business_school_contact_us_text', 'Contact Us'); //Social Media Section set_theme_mod( 'business_school_fb_link', 'https://www.facebook.com'); set_theme_mod( 'business_school_insta_link', 'https://www.instagram.com'); set_theme_mod( 'business_school_googleplus_link', 'https://www.googleplus.com'); set_theme_mod( 'business_school_youtube_link', 'https://www.youtube.com'); //Slider Section set_theme_mod( 'business_school_slider', true); set_theme_mod( 'business_school_slider_top_text', 'LEARN FROM TODAY'); set_theme_mod( 'business_school_button_text', 'Get Started'); $business_school_slider_category_id = wp_create_category('Slider'); // Set the category in theme mods for the slider section set_theme_mod('business_school_slider_cat', 'Slider'); // Update with correct category ID // Titles for the three posts $business_school_titles = array( 'Education Creates a Better Future', 'Empowering Students Every Day', 'Modern Learning with Classic Values' ); // Create three demo posts and assign them to the 'Slider' category for ($business_school_i = 1; $business_school_i <= 3; $business_school_i++) { $business_school_title = $business_school_titles[$business_school_i - 1]; $business_school_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.'; // Prepare the post object $business_school_my_post = array( 'post_title' => wp_strip_all_tags($business_school_title), 'post_content' => $business_school_content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array($business_school_slider_category_id), ); // Insert the post into the database $business_school_post_id = wp_insert_post($business_school_my_post); // If the post was successfully created, set the featured image if ($business_school_post_id && !is_wp_error($business_school_post_id)) { // Set the image URL based on the current slider index $business_school_image_url = esc_url(get_stylesheet_directory_uri() . '/images/slider' . $business_school_i . '.png'); $business_school_upload_dir = wp_upload_dir(); // Download the image data using wp_remote_get() $business_school_response = wp_remote_get($business_school_image_url); if (!is_wp_error($business_school_response)) { $business_school_image_data = wp_remote_retrieve_body($business_school_response); if (!empty($business_school_image_data)) { // Handle the file upload process $business_school_image_name = 'slider' . $business_school_i . '.png'; $business_school_unique_file_name = wp_unique_filename($business_school_upload_dir['path'], $business_school_image_name); $business_school_file = $business_school_upload_dir['path'] . '/' . $business_school_unique_file_name; // Save the image file to the uploads directory global $wp_filesystem; WP_Filesystem(); $wp_filesystem->put_contents($business_school_file, $business_school_image_data); // Check file type and prepare for attachment $business_school_wp_filetype = wp_check_filetype($business_school_unique_file_name, null); $business_school_attachment = array( 'post_mime_type' => $business_school_wp_filetype['type'], 'post_title' => sanitize_file_name($business_school_unique_file_name), 'post_content' => '', 'post_status' => 'inherit', ); // Insert the image into the media library and set it as the post's featured image $business_school_attach_id = wp_insert_attachment($business_school_attachment, $business_school_file, $business_school_post_id); $business_school_attach_data = wp_generate_attachment_metadata($business_school_attach_id, $business_school_file); wp_update_attachment_metadata($business_school_attach_id, $business_school_attach_data); set_post_thumbnail($business_school_post_id, $business_school_attach_id); } } } } //About Section set_theme_mod( 'business_school_disabled_pgboxes', true); set_theme_mod( 'business_school_about_title', 'About Our University'); set_theme_mod( 'business_school_abt_image_first', esc_url( get_template_directory_uri().'/images/about1.png')); set_theme_mod( 'business_school_abt_image_second', esc_url( get_template_directory_uri().'/images/about2.png')); $business_school_about_texts = array( 1 => 'Dramatically re-engineer value added systems via mission', 2 => 'Access more then 100K online courses', 3 => 'Learn the high-impact skills that top companies want' ); for ($business_school_i = 1; $business_school_i <= 3; $business_school_i++) { set_theme_mod('business_school_about_sentence' . $business_school_i, $business_school_about_texts[$business_school_i]); } // Function to fetch or create a page using WP_Query function get_or_create_page_by_title( $business_school_page_title, $business_school_page_content = '' ) { $business_school_args = array( 'post_type' => 'page', 'title' => $business_school_page_title, 'post_status' => 'publish', 'posts_per_page' => 1, 'fields' => 'ids' ); $business_school_query = new WP_Query( $business_school_args ); if ( ! empty( $business_school_query->posts ) ) { return $business_school_query->posts[0]; } else { // Create the page if it doesn't exist $business_school_page_id = wp_insert_post( array( 'post_type' => 'page', 'post_title' => $business_school_page_title, 'post_content' => $business_school_page_content, 'post_status' => 'publish', 'post_author' => 1 )); return $business_school_page_id; } } // Create Page $business_school_page_title = 'Welcome to Business School.'; $business_school_page_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt labore et dolore magna aliqua. Quis ipsum suspendisse ultrices gravida. Risus commodo viverra maecenas accumsan lacus vel facilisis.'; $business_school_page_id = get_or_create_page_by_title( $business_school_page_title, $business_school_page_content ); if ( $business_school_page_id ) { set_theme_mod( 'business_school_about_pageboxes', $business_school_page_id ); } else { error_log('Failed to create or fetch the "Welcome to Corporate Business Theme" page.'); } $business_school_image_url = get_template_directory_uri().'/images/about.png'; $business_school_image_id = media_sideload_image($business_school_image_url, $business_school_page_id, null, 'id'); if (!is_wp_error($business_school_image_id)) { // Set the downloaded image as the post's featured image set_post_thumbnail($business_school_page_id, $business_school_image_id); } // Show success message and the "View Site" button echo '
Demo Import Successful
'; } ?>
'; } ?>