Make WordPress Themes

Changeset 308050


Ignore:
Timestamp:
01/09/2026 06:56:35 AM (9 months ago)
Author:
themedropbox
Message:

New version of Barbecue Cafeteria - 0.4.7

Location:
barbecue-cafeteria/0.4.7
Files:
4 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • barbecue-cafeteria/0.4.7/functions.php

    r304694 r308050  
    1313
    1414        if ( ! defined( 'RESTAURANT_ZONE_URL' ) ) {
    15             define( 'FREE_MNSSP_API_URL', 'https://license.themagnifico.net/api/general/' );
    1615            define( 'RESTAURANT_ZONE_URL', esc_url( 'https://www.themagnifico.net/products/barbecue-wordpress-theme', 'barbecue-cafeteria') );
    1716        }
    … …  
    9493
    9594    $wp_customize->add_setting('barbecue_cafeteria_popular_setting', array(
    96         'default' => false,
     95        'default' => true,
    9796        'sanitize_callback' => 'restaurant_zone_sanitize_checkbox'
    9897    ));
    … …  
    364363    die();
    365364}
     365
     366// Ensure WordPress is loaded
     367if (!defined('ABSPATH')) {
     368    exit;
     369}
     370
     371// Add admin menu page to trigger theme import
     372add_action('admin_menu', 'barbecue_cafeteria_demo_importer_admin_page');
     373
     374function barbecue_cafeteria_demo_importer_admin_page() {
     375    add_theme_page(
     376        'Demo Theme Importer',     // Page title
     377        'Theme Importer',          // Menu title
     378        'manage_options',          // Capability
     379        'theme-importer',          // Menu slug
     380        'barbecue_cafeteria_demo_importer_page',      // Callback function
     381    );
     382}
     383
     384// Display the page content with the button
     385function barbecue_cafeteria_demo_importer_page() {
     386    ?>
     387    <div class="wrap-main-box">
     388        <div class="main-box">
     389            <h2><?php echo esc_html('Welcome to Real Estate Escrow','barbecue-cafeteria'); ?></h2>
     390            <h3><?php echo esc_html('Create your website in just one click','barbecue-cafeteria'); ?></h3>
     391            <hr>
     392            <p><?php echo esc_html('The "Begin Installation" helps you quickly set up your website by importing sample content that mirrors the demo version of the theme. This tool provides you with a ready-made layout and structure, so you can easily see how your site will look and start customizing it right away. It\'s a straightforward way to get your site up and running with minimal effort.','barbecue-cafeteria'); ?></p>
     393            <p><?php echo esc_html('Click the button below to install the demo content.','barbecue-cafeteria'); ?></p>
     394            <hr>
     395            <button id="import-theme-mods" class="button button-primary"><?php echo esc_html('Begin Installation','barbecue-cafeteria'); ?></button>
     396            <div id="import-response"></div>
     397        </div>
     398    </div>
     399    <?php
     400}
     401
     402// Add the AJAX action to trigger theme mods import
     403add_action('wp_ajax_import_theme_mods', 'barbecue_cafeteria_demo_importer_ajax_handler');
     404
     405// Handle the AJAX request
     406function barbecue_cafeteria_demo_importer_ajax_handler() {
     407    // Sample data to import
     408    $theme_mods_data = array(
     409        'header_textcolor' => '000000',  // Example: change header text color
     410        'background_color' => 'ffffff',  // Example: change background color
     411        'custom_logo'      => 123,       // Example: set a custom logo by attachment ID
     412        'footer_text'      => 'Custom Footer Text', // Example: custom footer text
     413    );
     414
     415    // Call the function to import theme mods
     416    if (barbecue_cafeteria_demo_theme_importer($theme_mods_data)) {
     417        // After importing theme mods, create the menu
     418        barbecue_cafeteria_create_demo_menu();
     419        wp_send_json_success(array(
     420            'msg' => 'Theme mods imported successfully.',
     421            'redirect' => home_url()
     422        ));
     423    } else {
     424        wp_send_json_error('Failed to import theme mods.');
     425    }
     426
     427    wp_die();
     428}
     429
     430// Function to set theme mods
     431function barbecue_cafeteria_demo_theme_importer($import_data) {
     432    if (is_array($import_data)) {
     433        foreach ($import_data as $mod_name => $mod_value) {
     434            set_theme_mod($mod_name, $mod_value);
     435        }
     436        return true;
     437    } else {
     438        return false;
     439    }
     440}
     441
     442// Function to create demo menu
     443function barbecue_cafeteria_create_demo_menu() {
     444
     445    $menu_structure = [
     446
     447        [
     448            'title' => 'Home',
     449            'slug'  => 'home',
     450            'template' => 'page-template/custom-front-page.php',
     451        ],
     452        [
     453            'title' => 'Polular',
     454            'slug'  => 'polular',
     455            'content' => "
     456                <p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     457            "
     458        ],
     459        [
     460            'title' => 'Category',
     461            'slug'  => 'category',
     462            'content' => "
     463                <p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     464            "
     465        ],
     466        [
     467            'title' => 'About Us',
     468            'slug'  => 'about us',
     469            'content' => "
     470                <p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     471            "
     472        ],
     473   
     474        [
     475            'title' => 'Book Now',
     476            'slug'  => 'book now',
     477            'content' => "<p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     478            "
     479        ],
     480        [
     481            'title' => 'Chef',
     482            'slug'  => 'chef',
     483            'content' => "<p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     484            "
     485        ],
     486        [
     487            'title' => 'Testimonial',
     488            'slug'  => 'testimonial',
     489            'content' => "<p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     490            "
     491        ],
     492        [
     493            'title' => 'Blog',
     494            'slug'  => 'blog',
     495            'content' => "<p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     496            "
     497        ],
     498        [
     499            'title' => 'Contact Us',
     500            'slug'  => 'contact us',
     501            'content' => "<p>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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s 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. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. 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 don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't 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.</p>
     502            "
     503        ],
     504    ];
     505
     506    // ----------------------------------------------------
     507    // Do not modify below this line unless needed
     508    // ----------------------------------------------------
     509
     510    $created_pages = [];
     511
     512    $menu_name = 'Primary Menu';
     513    $location  = 'primary';
     514    $menu = wp_get_nav_menu_object($menu_name);
     515
     516    $menu_id = (!$menu) ? wp_create_nav_menu($menu_name) : $menu->term_id;
     517
     518    $create_page_and_menu = function($item, $parent_menu_id = 0, $parent_page_id = 0)
     519        use (&$create_page_and_menu, &$created_pages, $menu_id) {
     520
     521        $page = get_page_by_title($item['title']);
     522
     523        if (!$page) {
     524            $page_id = wp_insert_post([
     525                'post_title'   => $item['title'],
     526                'post_type'    => 'page',
     527                'post_status'  => 'publish',
     528                'post_name'    => $item['slug'],
     529                'post_parent'  => $parent_page_id,
     530                'post_content' => !empty($item['content']) ? $item['content'] : '',
     531            ]);
     532
     533            if (!empty($item['template'])) {
     534                update_post_meta($page_id, '_wp_page_template', $item['template']);
     535            }
     536
     537        } else {
     538            $page_id = $page->ID;
     539        }
     540
     541        $created_pages[$item['title']] = $page_id;
     542
     543        $menu_item_id = wp_update_nav_menu_item($menu_id, 0, [
     544            'menu-item-title'     => $item['title'],
     545            'menu-item-object'    => 'page',
     546            'menu-item-object-id' => $page_id,
     547            'menu-item-type'      => 'post_type',
     548            'menu-item-parent-id' => $parent_menu_id,
     549            'menu-item-status'    => 'publish'
     550        ]);
     551
     552        if (!empty($item['children'])) {
     553            foreach ($item['children'] as $child) {
     554                $create_page_and_menu($child, $menu_item_id, $page_id);
     555            }
     556        }
     557    };
     558
     559    foreach ($menu_structure as $item) {
     560        $create_page_and_menu($item);
     561    }
     562
     563    if (!empty($created_pages['Home'])) {
     564        update_option('page_on_front', $created_pages['Home']);
     565        update_option('show_on_front', 'page');
     566    }
     567
     568    if (!empty($created_pages['Blog'])) {
     569        update_option('page_for_posts', $created_pages['Blog']);
     570    }
     571
     572    $locations = get_theme_mod('nav_menu_locations');
     573    $locations[$location] = $menu_id;
     574    set_theme_mod('nav_menu_locations', $locations);
     575
     576    //Top Header
     577
     578    set_theme_mod( 'restaurant_zone_phone_number_icon', 'fas fa-phone-square' );
     579    set_theme_mod( 'restaurant_zone_phone_number_info', '1324567890' );
     580
     581    set_theme_mod( 'restaurant_zone_email_icon', 'fas fa-envelope-square' );
     582    set_theme_mod( 'restaurant_zone_email_info', 'email@exapmle.com' );
     583
     584    set_theme_mod( 'restaurant_zone_facebook_icon', 'fab fa-facebook-f' );
     585    set_theme_mod( 'restaurant_zone_facebook_url', '#' );
     586    set_theme_mod( 'restaurant_zone_twitter_icon', 'fab fa-twitter' );
     587    set_theme_mod( 'restaurant_zone_twitter_url', '#' );
     588    set_theme_mod( 'restaurant_zone_intagram_icon', 'fab fa-instagram' );
     589    set_theme_mod( 'restaurant_zone_intagram_url', '#' );
     590    set_theme_mod( 'restaurant_zone_linkedin_icon', 'fab fa-linkedin-in' );
     591    set_theme_mod( 'restaurant_zone_linkedin_url', '#' );
     592    set_theme_mod( 'restaurant_zone_pintrest_icon', 'fab fa-pinterest-p' );
     593    set_theme_mod( 'restaurant_zone_pintrest_url', '#' );
     594
     595    set_theme_mod( 'restaurant_zone_top_header_setting', 'true' );
     596
     597    set_theme_mod( 'restaurant_zone_reservation_button', '#' );
     598
     599    //Slider
     600
     601    for($i=1;$i<=3;$i++){
     602         $title = 'The Unique Restaurant';
     603         $content = 'Lorem Ipsum has been the industrys standard dummy text ever since the 1500';
     604            // Create post object
     605         $my_post = array(
     606         'post_title'    => wp_strip_all_tags( $title ),
     607         'post_content'  => $content,
     608         'post_status'   => 'publish',
     609         'post_type'     => 'page',
     610         );
     611
     612         // Insert the post into the database
     613         $post_id = wp_insert_post( $my_post );
     614
     615         if ($post_id) {
     616            // Set the theme mod for the slider page
     617            set_theme_mod('restaurant_zone_top_slider_page' . $i, $post_id);
     618
     619            $image_url = get_stylesheet_directory_uri().'/assets/img/slider.png';
     620
     621            $image_id = media_sideload_image($image_url, $post_id, null, 'id');
     622
     623                if (!is_wp_error($image_id)) {
     624                    // Set the downloaded image as the post's featured image
     625                    set_post_thumbnail($post_id, $image_id);
     626                }
     627        }
     628    }
     629
     630    set_theme_mod( 'restaurant_zone_slider_button_text', 'View More' );
     631
     632    // Products
     633    set_theme_mod( 'restaurant_zone_title', 'Our Popular Items' );
     634
     635    set_theme_mod( 'restaurant_zone_menu_items', 'Popular' );
     636   
     637     $title = 'Breakfast';
     638     $content = 'Lorem Ipsum has been the industrys standard dummy text ever since the 1500';
     639        // Create post object
     640     $my_post = array(
     641     'post_title'    => wp_strip_all_tags( $title ),
     642     'post_content'  => $content,
     643     'post_status'   => 'publish',
     644     'post_type'     => 'page',
     645     );
     646
     647     // Insert the post into the database
     648     $post_id = wp_insert_post( $my_post );
     649
     650    if ($post_id) {
     651        // Set the theme mod for the slider page
     652        set_theme_mod('barbecue_cafeteria_image_page', $post_id);
     653
     654        $image_url = get_stylesheet_directory_uri().'/assets/img/popular-item.png';
     655
     656        $image_id = media_sideload_image($image_url, $post_id, null, 'id');
     657
     658            if (!is_wp_error($image_id)) {
     659                // Set the downloaded image as the post's featured image
     660                set_post_thumbnail($post_id, $image_id);
     661            }
     662    }
     663
     664
     665    set_theme_mod('barbecue_cafeteria_home_product', 'productcat1');
     666    set_theme_mod('barbecue_cafeteria_title', 'Our Popular Items');
     667
     668    // Define product category names and product titles
     669    $barbecue_cafeteria_procategory_names = array('productcat1');
     670    $barbecue_cafeteria_protitle_array = array(
     671        array("Breakfast", "Breakfast","Breakfast", "Breakfast"),
     672
     673    );
     674
     675    foreach ($barbecue_cafeteria_procategory_names as $barbecue_cafeteria_index => $barbecue_cafeteria_category_name) {
     676        // Create or retrieve the product category term ID
     677        $barbecue_cafeteria_term = term_exists($barbecue_cafeteria_category_name, 'product_cat');
     678        if ($barbecue_cafeteria_term === 0 || $barbecue_cafeteria_term === null) {
     679            // If the term does not exist, create it
     680            $barbecue_cafeteria_term = wp_insert_term($barbecue_cafeteria_category_name, 'product_cat');
     681        }
     682
     683        if (is_wp_error($barbecue_cafeteria_term)) {
     684            error_log('Error creating category: ' . $barbecue_cafeteria_term->get_error_message());
     685            continue; // Skip to the next iteration if category creation fails
     686        }
     687
     688        // Loop to create 4 products for each category
     689        for ($barbecue_cafeteria_i = 0; $barbecue_cafeteria_i < 4; $barbecue_cafeteria_i++) {
     690            // Create product content
     691            $barbecue_cafeteria_title = $barbecue_cafeteria_protitle_array[$barbecue_cafeteria_index][$barbecue_cafeteria_i];
     692            $barbecue_cafeteria_content = '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. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s.';
     693
     694            // Create product post object
     695            $barbecue_cafeteria_my_post = array(
     696                'post_title'    => wp_strip_all_tags($barbecue_cafeteria_title),
     697                'post_content'  => $barbecue_cafeteria_content,
     698                'post_status'   => 'publish',
     699                'post_type'     => 'product', // Post type set to 'product'
     700            );
     701
     702            // Insert the product into the database
     703            $barbecue_cafeteria_post_id = wp_insert_post($barbecue_cafeteria_my_post);
     704
     705            if (is_wp_error($barbecue_cafeteria_post_id)) {
     706                error_log('Error creating product: ' . $barbecue_cafeteria_post_id->get_error_message());
     707                continue; // Skip to the next product if creation fails
     708            }
     709
     710            // Assign the category to the product
     711            wp_set_object_terms($barbecue_cafeteria_post_id, (int)$barbecue_cafeteria_term['term_id'], 'product_cat');
     712
     713            // Add product meta (price, etc.)
     714            update_post_meta($barbecue_cafeteria_post_id, '_regular_price', '95'); // Regular price
     715            update_post_meta($barbecue_cafeteria_post_id, '_sale_price', '42.00'); // Sale price
     716            update_post_meta($barbecue_cafeteria_post_id, '_price', '42.00'); // Active price
     717
     718            // Handle the featured image using media_sideload_image
     719            $barbecue_cafeteria_image_url = get_stylesheet_directory_uri() . '/assets/img/post' . ($barbecue_cafeteria_i + 1) . '.png';
     720            $barbecue_cafeteria_image_id = media_sideload_image($barbecue_cafeteria_image_url, $barbecue_cafeteria_post_id, null, 'id');
     721
     722            if (is_wp_error($barbecue_cafeteria_image_id)) {
     723                error_log('Error downloading image: ' . $barbecue_cafeteria_image_id->get_error_message());
     724                continue; // Skip to the next product if image download fails
     725            }
     726
     727            // Assign featured image to product
     728            set_post_thumbnail($barbecue_cafeteria_post_id, $barbecue_cafeteria_image_id);
     729
     730        }
     731    }
     732
     733}
     734
     735// Enqueue necessary scripts
     736add_action('admin_enqueue_scripts', 'barbecue_cafeteria_demo_importer_enqueue_scripts');
     737
     738function barbecue_cafeteria_demo_importer_enqueue_scripts() {
     739    wp_enqueue_script(
     740        'demo-theme-importer',
     741        get_template_directory_uri() . '/assets/js/theme-importer.js', // Path to your JS file
     742        array('jquery'),
     743        null,
     744        true
     745    );
     746
     747    wp_enqueue_style('demo-importer-style', get_template_directory_uri() . '/assets/css/importer.css', array(), '');
     748
     749    // Localize script to pass AJAX URL to JS
     750    wp_localize_script(
     751        'demo-theme-importer',
     752        'demoImporter',
     753        array(
     754            'ajax_url' => admin_url('admin-ajax.php'),
     755            'nonce'    => wp_create_nonce('theme_importer_nonce')
     756        )
     757    );
     758}
  • barbecue-cafeteria/0.4.7/inc/theme-installation/theme-installation.php

    r304694 r308050  
    273273                            $theme_screenshot  = $theme->get_screenshot();
    274274                            ?>
    275                            
     275                            <div class="impoter-box-main">
     276                                <div class="wrap-main-box">
     277                                    <div class="main-box">
     278                                        <h2><?php echo esc_html('Welcome to Barbecue Cafeteria','barbecue-cafeteria'); ?></h2>
     279                                        <h3><?php echo esc_html('Create your website in just one click','barbecue-cafeteria'); ?></h3>
     280                                        <p><?php echo esc_html('The "Begin Installation" helps you quickly set up your website by importing sample content that mirrors the demo version of the theme. This tool provides you with a ready-made layout and structure, so you can easily see how your site will look and start customizing it right away. It\'s a straightforward way to get your site up and running with minimal effort.','barbecue-cafeteria'); ?></p>
     281                                        <p><?php echo esc_html('Click the button below to install the demo content.','barbecue-cafeteria'); ?></p>
     282                                        <button id="import-theme-mods" class="button button-primary"><?php echo esc_html('Begin Installation','barbecue-cafeteria'); ?></button>
     283                                        <div id="import-response"></div>
     284                                    </div>
     285                                </div>
     286                            </div>
    276287                            <div class="impoter-left">
    277288                                <div class="importer-description">
    … …  
    10321043        'Classic Widgets' => array(
    10331044            'slug' => 'classic-widgets'
     1045        ),
     1046        'WooCommerce' => array(
     1047            'slug' => 'woocommerce'
    10341048        )
    10351049    ),
  • barbecue-cafeteria/0.4.7/page-template/custom-front-page.php

    r256538 r308050  
    88<main id="skip-content">
    99  <section id="top-slider">
    10     <?php if(get_theme_mod('restaurant_zone_slider_setting') != ''){ ?>
     10    <?php if(get_theme_mod('restaurant_zone_slider_setting',true) == 1){ ?>
    1111    <?php $restaurant_zone_slide_pages = array();
    1212      for ( $restaurant_zone_count = 1; $restaurant_zone_count <= 3; $restaurant_zone_count++ ) {
    … …  
    5555  </section>
    5656
    57   <?php if(get_theme_mod('barbecue_cafeteria_popular_setting') != ''){ ?>
     57  <?php if(get_theme_mod('barbecue_cafeteria_popular_setting',true) == 1){ ?>
    5858  <section id="items-section">
    5959    <div class="container">
  • barbecue-cafeteria/0.4.7/readme.txt

    r304694 r308050  
    44Requires PHP: 7.2
    55Requires at least: 5.0
    6 Stable tag: 0.4.6
     6Stable tag: 0.4.7
    77License: GNU General Public License v3.0
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
    … …  
    264264* Resolved error for global color.
    265265
     266= 0.4.7
     267
     268* Added demo import.
     269
    266270== Theme Changes ==
    267271
  • barbecue-cafeteria/0.4.7/style.css

    r304694 r308050  
    66Author URI: https://www.themagnifico.net/
    77Description: Barbeque Cafeteria is a dynamic website template designed for barbeque restaurants, cafeterias, and culinary enthusiasts. It captures the essence of barbeque culture with its warm and inviting design, featuring succulent grilled dishes that instantly set the mood and evoke the flavors of the grill. This theme is all about sizzling flavors, smoky aromas, and savory delights. With a clean and responsive design, the theme ensures that your website appears enticing and functions flawlessly on various devices. It offers a host of benefits, making it easy for both technical experts and novices to create a visually appealing and functional online environment for their barbeque businesses. Whether you're a grill master, restaurant owner, or food blogger, this theme caters to everyone. The Barbeque Cafeteria WordPress Theme enhances the user experience with a range of features and functionalities. It allows you to showcase your menu, share mouthwatering recipes, and enable online reservations, driving customer interaction. Its user-friendly interface ensures that visitors can navigate your website with ease, creating a delightful online journey. This theme is all about igniting your online presence with the flavors and traditions of barbeque. Whether you're grilling up a storm or sharing your culinary passion, the Barbeque Cafeteria WordPress Theme is the secret sauce to create an enticing and sizzling online presence, making it a powerful tool for showcasing your dishes and driving your barbeque business to new heights.
    8 Version: 0.4.6
     8Version: 0.4.7
    99Tested up to: 6.9
    1010Requires PHP: 7.2
Note: See TracChangeset for help on using the changeset viewer.