'contact-form-7', 'file' => 'contact-form-7/wp-contact-form-7.php', 'url' => 'https://downloads.wordpress.org/plugin/contact-form-7.latest-stable.zip' ), ); // Include required files for plugin installation include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); include_once(ABSPATH . 'wp-admin/includes/file.php'); include_once(ABSPATH . 'wp-admin/includes/misc.php'); include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); // Loop through each plugin foreach ($plugins as $plugin) { $plugin_file = WP_PLUGIN_DIR . '/' . $plugin['file']; // Check if the plugin is installed if (!file_exists($plugin_file)) { // If the plugin is not installed, download and install it $upgrader = new Plugin_Upgrader(); $result = $upgrader->install($plugin['url']); // Check for installation errors if (is_wp_error($result)) { error_log('Plugin installation failed: ' . $plugin['slug'] . ' - ' . $result->get_error_message()); echo 'Error installing plugin: ' . esc_html($plugin['slug']) . ' - ' . esc_html($result->get_error_message()); continue; } } // If the plugin exists but is not active, activate it if (file_exists($plugin_file) && !is_plugin_active($plugin['file'])) { $result = activate_plugin($plugin['file']); // Check for activation errors if (is_wp_error($result)) { error_log('Plugin activation failed: ' . $plugin['slug'] . ' - ' . $result->get_error_message()); echo 'Error activating plugin: ' . esc_html($plugin['slug']) . ' - ' . esc_html($result->get_error_message()); } } } } // Call the import function amusement_park_import_demo_content(); // ------- Create Nav Menu -------- $amusement_park_menuname = 'Main Menus'; $amusement_park_bpmenulocation = 'primary-menu'; $amusement_park_menu_exists = wp_get_nav_menu_object($amusement_park_menuname); if (!$amusement_park_menu_exists) { $amusement_park_menu_id = wp_create_nav_menu($amusement_park_menuname); // Create Home Page $amusement_park_home_title = 'Home'; $amusement_park_home = array( 'post_type' => 'page', 'post_title' => $amusement_park_home_title, 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'home' ); $amusement_park_home_id = wp_insert_post($amusement_park_home); // Assign Home Page Template add_post_meta($amusement_park_home_id, '_wp_page_template', 'page-template/front-page.php'); // Update options to set Home Page as the front page update_option('page_on_front', $amusement_park_home_id); update_option('show_on_front', 'page'); // Add Home Page to Menu wp_update_nav_menu_item($amusement_park_menu_id, 0, array( 'menu-item-title' => __('Home', 'amusement-park'), 'menu-item-classes' => 'home', 'menu-item-url' => home_url('/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $amusement_park_home_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Create About Us Page with Dummy Content $amusement_park_about_title = 'About Us'; $amusement_park_about_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...
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.
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.'; $amusement_park_about = array( 'post_type' => 'page', 'post_title' => $amusement_park_about_title, 'post_content' => $amusement_park_about_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'about-us' ); $amusement_park_about_id = wp_insert_post($amusement_park_about); // Add About Us Page to Menu wp_update_nav_menu_item($amusement_park_menu_id, 0, array( 'menu-item-title' => __('About Us', 'amusement-park'), 'menu-item-classes' => 'about-us', 'menu-item-url' => home_url('/about-us/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $amusement_park_about_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Create Services Page with Dummy Content $amusement_park_services_title = 'Services'; $amusement_park_services_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...
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.
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.'; $amusement_park_services = array( 'post_type' => 'page', 'post_title' => $amusement_park_services_title, 'post_content' => $amusement_park_services_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'services' ); $amusement_park_services_id = wp_insert_post($amusement_park_services); // Add Services Page to Menu wp_update_nav_menu_item($amusement_park_menu_id, 0, array( 'menu-item-title' => __('Services', 'amusement-park'), 'menu-item-classes' => 'services', 'menu-item-url' => home_url('/services/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $amusement_park_services_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Create Pages Page with Dummy Content $amusement_park_pages_title = 'Pages'; $amusement_park_pages_content = '

Our Pages

Explore all the pages we have on our website. Find information about our services, company, and more.

'; $amusement_park_pages = array( 'post_type' => 'page', 'post_title' => $amusement_park_pages_title, 'post_content' => $amusement_park_pages_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'pages' ); $amusement_park_pages_id = wp_insert_post($amusement_park_pages); // Add Pages Page to Menu wp_update_nav_menu_item($amusement_park_menu_id, 0, array( 'menu-item-title' => __('Pages', 'amusement-park'), 'menu-item-classes' => 'pages', 'menu-item-url' => home_url('/pages/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $amusement_park_pages_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Create Contact Page with Dummy Content $amusement_park_contact_title = 'Contact'; $amusement_park_contact_content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam...
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.
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.'; $amusement_park_contact = array( 'post_type' => 'page', 'post_title' => $amusement_park_contact_title, 'post_content' => $amusement_park_contact_content, 'post_status' => 'publish', 'post_author' => 1, 'post_slug' => 'contact' ); $amusement_park_contact_id = wp_insert_post($amusement_park_contact); // Add Contact Page to Menu wp_update_nav_menu_item($amusement_park_menu_id, 0, array( 'menu-item-title' => __('Contact', 'amusement-park'), 'menu-item-classes' => 'contact', 'menu-item-url' => home_url('/contact/'), 'menu-item-status' => 'publish', 'menu-item-object-id' => $amusement_park_contact_id, 'menu-item-object' => 'page', 'menu-item-type' => 'post_type' )); // Set the menu location if it's not already set if (!has_nav_menu($amusement_park_bpmenulocation)) { $locations = get_theme_mod('nav_menu_locations'); // Use 'nav_menu_locations' to get locations array if (empty($locations)) { $locations = array(); } $locations[$amusement_park_bpmenulocation] = $amusement_park_menu_id; set_theme_mod('nav_menu_locations', $locations); } } // Slider Section set_theme_mod('amusement_park_slider_arrows', true); set_theme_mod('amusement_park_park_timing', '09:00 AM ________7:00 PM'); for ($i = 1; $i <= 4; $i++) { $amusement_park_title = 'LOOKING FOR ADVENTURE?'; // Create post object $my_post = array( 'post_title' => wp_strip_all_tags($amusement_park_title), 'post_status' => 'publish', 'post_type' => 'page', ); // Insert the post into the database $post_id = wp_insert_post($my_post); if ($post_id) { // Set the theme mod for the slider page set_theme_mod('amusement_park_slider_page' . $i, $post_id); $image_url = get_template_directory_uri() . '/assets/images/slider-img.png'; $image_id = media_sideload_image($image_url, $post_id, null, 'id'); if (!is_wp_error($image_id)) { // Set the downloaded image as the post's featured image set_post_thumbnail($post_id, $image_id); } } } // Set default shortcodes for each form (replace these with your actual form shortcodes) set_theme_mod('amusement_park_banner_form_shortcode', ''); // Set default values for the contact form settings for Amusement Park Contact Form $cf7title = 'Amusement Park Contact Form'; // Modify the title as needed $cf7content = '
[text kids-quantity id:kids-quantity readonly "1"]
[text adults-quantity id:adults-quantity readonly "1"]
'; // Insert the contact form post $cf7_post = array( 'post_title' => wp_strip_all_tags($cf7title), 'post_content' => $cf7content, 'post_status' => 'publish', 'post_type' => 'wpcf7_contact_form', ); // Insert post and get post ID $cf7post_id = wp_insert_post($cf7_post); // Check if the post insertion was successful if (!is_wp_error($cf7post_id)) { // Add form content to the post meta add_post_meta($cf7post_id, "_form", $cf7content); // Prepare email settings for the contact form $cf7mail_data = array( 'subject' => '[_site_title] "[your-subject]"', 'sender' => '[_site_title] ', 'body' => 'From: [your-name] <[your-email]>\nSubject: [your-subject]\nMessage Body:\n[your-message]\n\n--\nThis e-mail was sent from a contact form on [_site_title] ([_site_url])', 'recipient' => '[_site_admin_email]', 'additional_headers' => 'Reply-To: [your-email]', 'attachments' => '', 'use_html' => 0, 'exclude_blank' => 0 ); // Add email data to the post meta add_post_meta($cf7post_id, "_mail", $cf7mail_data); // Generate the contact form shortcode $cf7shortcode = '[contact-form-7 id="' . $cf7post_id . '" title="' . $cf7title . '"]'; // Save the shortcode in the theme settings set_theme_mod('amusement_park_banner_form_shortcode', $cf7shortcode); } else { // Handle errors, if any echo 'Error creating the form post: ' . $cf7post_id->get_error_message(); } // Display the contact form using the saved shortcode $cf7_shortcode = get_theme_mod('amusement_park_banner_form_shortcode'); // Check if the shortcode exists in the theme settings if ($cf7_shortcode) { echo 'Generated shortcode: ' . $cf7_shortcode . '
'; echo do_shortcode($cf7_shortcode); // Output the contact form using the shortcode } else { echo 'Error: Contact form shortcode not found in theme mod.'; } // About Section set_theme_mod('amusement_park_about_short_heading', 'ABOUT US'); set_theme_mod('amusement_park_image_text', '14+'); set_theme_mod('amusement_park_customer_review', '9,58,520'); set_theme_mod('amusement_park_customer_rating', '5'); // Create About page and set the featured image $amusement_park_abt_title = 'ABOUT US PAGE'; $amusement_park_abt_content = 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.'; $my_post = array( 'post_title' => wp_strip_all_tags($amusement_park_abt_title), 'post_content' => $amusement_park_abt_content, 'post_status' => 'publish', 'post_type' => 'page', ); $post_id = wp_insert_post($my_post); if ($post_id) { set_theme_mod('amusement_park_about_page', $post_id); $image_url = get_template_directory_uri() . '/assets/images/about-img.png'; $image_id = media_sideload_image($image_url, $post_id, null, 'id'); if (!is_wp_error($image_id)) { set_post_thumbnail($post_id, $image_id); } } // Define post category names $amusement_park_category_names = array('postcategory1'); set_theme_mod('amusement_park_about_catData', 'postcategory1'); foreach ($amusement_park_category_names as $amusement_park_category_name) { // Check if the category exists, and insert if necessary $amusement_park_term = term_exists($amusement_park_category_name, 'category'); if (!$amusement_park_term) { $amusement_park_term = wp_insert_term($amusement_park_category_name, 'category'); } // Handle term insertion errors if (is_wp_error($amusement_park_term)) { error_log('Error creating category: ' . $amusement_park_term->get_error_message()); continue; } // Ensure the term ID is retrieved correctly $amusement_park_term_id = is_array($amusement_park_term) ? $amusement_park_term['term_id'] : $amusement_park_term; // Loop for creating posts under the category for ($amusement_park_i = 0; $amusement_park_i < 6; $amusement_park_i++) { $amusement_park_my_post = array( 'post_title' => 'Post ' . ($amusement_park_i + 1), 'post_content' => 'This is the content for post ' . ($amusement_park_i + 1), 'post_status' => 'publish', 'post_type' => 'post', ); $amusement_park_post_id = wp_insert_post($amusement_park_my_post); if (is_wp_error($amusement_park_post_id)) { error_log('Error creating post: ' . $amusement_park_post_id->get_error_message()); continue; } // Assign the category to the post wp_set_post_categories($amusement_park_post_id, array($amusement_park_term_id)); // Handle featured image $amusement_park_image_url = get_template_directory_uri() . '/assets/images/post-img' . ($amusement_park_i + 1) . '.png'; $amusement_park_image_id = media_sideload_image($amusement_park_image_url, $amusement_park_post_id, null, 'id'); if (!is_wp_error($amusement_park_image_id)) { set_post_thumbnail($amusement_park_post_id, $amusement_park_image_id); } } } } ?>