Plugin Directory

Changeset 3125940


Ignore:
Timestamp:
07/26/2024 12:20:39 PM (20 months ago)
Author:
themewinter
Message:

Adding version 2.2.29

Location:
wp-cafe
Files:
2 added
2 deleted
10 edited
21 copied

Legend:

Unmodified
Added
Removed
  • wp-cafe/tags/2.2.29/bootstrap.php

    r2982187 r3125940  
    108108
    109109        // register gutenberg blocks
    110         if( file_exists( \Wpcafe::plugin_dir() . 'core/modules/guten-block/inc/init.php' )){
    111             include_once \Wpcafe::plugin_dir() . 'core/modules/guten-block/inc/init.php';
    112         }
    113 
     110        \WpCafe\Core\Modules\Guten_Block\Inc\Register_Blocks::instance()->init();
     111       
    114112        if ( is_admin() ){
    115113            \WpCafe\Core\Core::instance()->init();
  • wp-cafe/tags/2.2.29/core/modules/guten-block/inc/blocks/food-list.php

    r3112563 r3125940  
    11<?php
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
     3
     4defined( "ABSPATH" ) || exit;
     5
    26use WpCafe\Utils\Wpc_Utilities;
    37
    4 //register food list block
    5 function register_food_list_block(){
    6     register_block_type(
    7         'wpc/food-menu-list', array(
    8             // Enqueue blocks.style.build.css on both frontend & backend.
    9             'style'         => 'wpc-block-style-css',
    10             // Enqueue blocks.editor.build.css in the editor only.
    11             'editor_style'  => 'wpc-block-editor-style-css',
    12             // Enqueue blocks.build.js in the editor only.
    13             'editor_script' => 'wpc-block-js',
    14             'render_callback'   => 'wpc_food_menu_list_callback',
    15             'api_version' => 1,
    16             'attributes' => array(
    17                 'food_menu_style' => array(
    18                     'type' => 'string',
    19                     'default'   => 'style-1'
    20                 ),
    21                 'show_thumbnail' => array(
    22                     'type' => 'string',
    23                     'default'   => 'yes'
    24                 ),
    25                 'wpc_menu_cat' => array(
    26                     'type' => 'array',
    27                     'default'   => []
    28                 ),
    29                 'wpc_desc_limit' => array(
    30                     'type' => 'integer',
    31                     'default'   => 20
    32                 ),
    33                 'wpc_show_desc' => array(
    34                     'type' => 'string',
    35                     'default'   => 'yes'
    36                 ),
    37                 'wpc_cart_button_show' => array(
    38                     'type' => 'string',
    39                     'default'   => 'yes'
    40                 ),
    41                 'title_link_show' => array(
    42                     'type' => 'string',
    43                     'default'   => 'yes'
    44                 ),
    45                 'show_item_status' => array(
    46                     'type' => 'string',
    47                     'default'   => 'yes'
    48                 ),
    49                 'wpc_price_show' => array(
    50                     'type' => 'string',
    51                     'default'   => 'yes'
    52                 ),
    53                 'wpc_menu_count' => array(
    54                     'type' => 'integer',
    55                     'default'   => 20
    56                 ),
    57                 'wpc_menu_order' => array(
    58                     'type' => 'string',
    59                     'default' => 'DESC'
    60                 ),
    61                 'wpc_show_vendor' => array(
    62                     'type' => 'string',
    63                     'default'   => 'yes'
     8class Food_List {
     9   
     10    use \WpCafe\Traits\Wpc_Singleton;
     11
     12    function init() {
     13        add_action('init', [$this, 'register_food_list_block']);
     14    }
     15
     16    function register_food_list_block(){
     17        register_block_type(
     18            'wpc/food-menu-list', array(
     19                // Enqueue blocks.style.build.css on both frontend & backend.
     20                'style'         => 'wpc-block-style-css',
     21                // Enqueue blocks.editor.build.css in the editor only.
     22                'editor_style'  => 'wpc-block-editor-style-css',
     23                // Enqueue blocks.build.js in the editor only.
     24                'editor_script' => 'wpc-block-js',
     25                'render_callback'   => [$this, 'wpc_food_menu_list_callback'],
     26                'api_version' => 1,
     27                'attributes' => array(
     28                    'food_menu_style' => array(
     29                        'type' => 'string',
     30                        'default'   => 'style-1'
     31                    ),
     32                    'show_thumbnail' => array(
     33                        'type' => 'string',
     34                        'default'   => 'yes'
     35                    ),
     36                    'wpc_menu_cat' => array(
     37                        'type' => 'array',
     38                        'default'   => []
     39                    ),
     40                    'wpc_desc_limit' => array(
     41                        'type' => 'integer',
     42                        'default'   => 20
     43                    ),
     44                    'wpc_show_desc' => array(
     45                        'type' => 'string',
     46                        'default'   => 'yes'
     47                    ),
     48                    'wpc_cart_button_show' => array(
     49                        'type' => 'string',
     50                        'default'   => 'yes'
     51                    ),
     52                    'title_link_show' => array(
     53                        'type' => 'string',
     54                        'default'   => 'yes'
     55                    ),
     56                    'show_item_status' => array(
     57                        'type' => 'string',
     58                        'default'   => 'yes'
     59                    ),
     60                    'wpc_price_show' => array(
     61                        'type' => 'string',
     62                        'default'   => 'yes'
     63                    ),
     64                    'wpc_menu_count' => array(
     65                        'type' => 'integer',
     66                        'default'   => 20
     67                    ),
     68                    'wpc_menu_order' => array(
     69                        'type' => 'string',
     70                        'default' => 'DESC'
     71                    ),
     72                    'wpc_show_vendor' => array(
     73                        'type' => 'string',
     74                        'default'   => 'yes'
     75                    )
    6476                )
    6577            )
    66         )
    67     );
    68 }
    69 add_action('init', 'register_food_list_block');
     78        );
     79    }
    7080
    71 // food menu list block callback
    72 function wpc_food_menu_list_callback($settings){
    73     //check if woocommerce exists
    74     if (!class_exists('Woocommerce')) { return; }
     81    // food menu list block callback
     82    function wpc_food_menu_list_callback($settings){
     83        $unique_id = md5(md5(microtime()));
    7584
    76     $unique_id = md5(md5(microtime()));
     85        $style               = $settings["food_menu_style"];
     86        $show_item_status    = $settings["show_item_status"];
     87        $show_thumbnail      = $settings["show_thumbnail"];
     88        $title_link_show     = $settings["title_link_show"];
     89        $wpc_cart_button     = $settings["wpc_cart_button_show"];
     90        $wpc_show_desc       = $settings["wpc_show_desc"];
     91        $wpc_desc_limit      = $settings["wpc_desc_limit"];
     92        $wpc_menu_cat        = $settings["wpc_menu_cat"];
     93        $wpc_menu_count      = $settings["wpc_menu_count"];
     94        $wpc_menu_order      = $settings["wpc_menu_order"];
     95        $show_thumbnail      = $settings["show_thumbnail"];
     96        $wpc_price_show      = $settings["wpc_price_show"];
     97        $wpc_show_vendor     = $settings["wpc_show_vendor"];
     98       
     99        apply_filters( 'elementor/control/search_data' , $settings , $unique_id , 'wpc-menus-list' );
    77100
    78     $style               = $settings["food_menu_style"];
    79     $show_item_status    = $settings["show_item_status"];
    80     $show_thumbnail      = $settings["show_thumbnail"];
    81     $title_link_show     = $settings["title_link_show"];
    82     $wpc_cart_button     = $settings["wpc_cart_button_show"];
    83     $wpc_show_desc       = $settings["wpc_show_desc"];
    84     $wpc_desc_limit      = $settings["wpc_desc_limit"];
    85     $wpc_menu_cat        = $settings["wpc_menu_cat"];
    86     $wpc_menu_count      = $settings["wpc_menu_count"];
    87     $wpc_menu_order      = $settings["wpc_menu_order"];
    88     $show_thumbnail      = $settings["show_thumbnail"];
    89     $wpc_price_show      = $settings["wpc_price_show"];
    90     $wpc_show_vendor     = $settings["wpc_show_vendor"];
    91    
    92     apply_filters( 'elementor/control/search_data' , $settings , $unique_id , 'wpc-menus-list' );
     101        $allowed_file_names = [
     102            'style-1',
     103            'style-2',
     104            'style-3'
     105        ];
    93106
    94     $allowed_file_names = [
    95         'style-1',
    96     'style-2',
    97     'style-3'
    98     ];
     107        if( in_array($style, $allowed_file_names)){
     108            $template_file = esc_html($style);
     109        }else{
     110            $template_file = $allowed_file_names[0];
     111        }
    99112
    100     if( in_array($style, $allowed_file_names)){
    101         $template_file = esc_html($style);
    102     }else{
    103         $template_file = $allowed_file_names[0];
    104     }
     113        ob_start();
     114        ?>
     115        <div class="main_wrapper_<?php echo esc_html($unique_id)?>">
     116            <div class="list_template_<?php echo esc_html($unique_id) ?> wpc-nav-shortcode wpc-widget-wrapper"  data-id="<?php echo esc_attr($unique_id)?>">
     117                <?php
     118                $food_list_args = array(
     119                    'post_type'     => 'product',
     120                    'no_of_product' => $wpc_menu_count,
     121                    'wpc_cat'       => $wpc_menu_cat,
     122                    'order'         => $wpc_menu_order,
     123                );
     124                $products = Wpc_Utilities::product_query( $food_list_args );
     125                include \Wpcafe::plugin_dir() . "widgets/wpc-menus-list/style/{$template_file}.php";
     126                ?>
     127            </div>
     128        </div>
     129        <?php
    105130
    106     ob_start();
    107     ?>
    108     <div class="main_wrapper_<?php echo esc_html($unique_id)?>">
    109         <div class="list_template_<?php echo esc_html($unique_id) ?> wpc-nav-shortcode wpc-widget-wrapper"  data-id="<?php echo esc_attr($unique_id)?>">
    110             <?php
    111             $food_list_args = array(
    112                 'post_type'     => 'product',
    113                 'no_of_product' => $wpc_menu_count,
    114                 'wpc_cat'       => $wpc_menu_cat,
    115                 'order'         => $wpc_menu_order,
    116             );
    117             $products = Wpc_Utilities::product_query( $food_list_args );
    118             include \Wpcafe::plugin_dir() . "widgets/wpc-menus-list/style/{$template_file}.php";
    119             ?>
    120         </div>
    121     </div>
    122     <?php
     131        return ob_get_clean();
    123132
    124     return ob_get_clean();
     133    }
    125134
    126135}
  • wp-cafe/tags/2.2.29/core/modules/guten-block/inc/blocks/food-tab.php

    r3112563 r3125940  
    11<?php
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
     3
     4defined( "ABSPATH" ) || exit;
     5
    26use WpCafe\Utils\Wpc_Utilities;
    37
    4 //register food tab block
    5 function register_food_tab_block(){
    6     register_block_type(
    7         'wpc/food-menu-tab', array(
    8             // Enqueue blocks.style.build.css on both frontend & backend.
    9             'style'         => 'wpc-block-style-css',
    10             // Enqueue blocks.editor.build.css in the editor only.
    11             'editor_style'  => 'wpc-block-editor-style-css',
    12             // Enqueue blocks.build.js in the editor only.
    13             'editor_script' => 'wpc-block-js',
    14             'render_callback'   => 'wpc_food_menu_tab_callback',
    15             'api_version' => 1,
    16             'attributes' => array(
    17                 'food_menu_style' => array(
    18                     'type' => 'string',
    19                     'default'   => 'style-1'
    20                 ),
    21                 'wpc_food_categories' => array(
    22                     'type' => 'array',
    23                     'default'   => []
    24                 ),
    25                 'show_thumbnail' => array(
    26                     'type' => 'string',
    27                     'default'   => 'yes'
    28                 ),
    29                 'wpc_desc_limit' => array(
    30                     'type' => 'integer',
    31                     'default'   => 20
    32                 ),
    33                 'wpc_show_desc' => array(
    34                     'type' => 'string',
    35                     'default'   => 'yes'
    36                 ),
    37                 'wpc_cart_button' => array(
    38                     'type' => 'string',
    39                     'default'   => 'yes'
    40                 ),
    41                 'title_link_show' => array(
    42                     'type' => 'string',
    43                     'default'   => 'yes'
    44                 ),
    45                 'show_item_status' => array(
    46                     'type' => 'string',
    47                     'default'   => 'yes'
    48                 ),
    49                 'wpc_price_show' => array(
    50                     'type' => 'string',
    51                     'default'   => 'yes'
    52                 ),
    53                 'wpc_menu_count' => array(
    54                     'type' => 'integer',
    55                     'default'   => 20
    56                 ),
    57                 'wpc_menu_order' => array(
    58                     'type' => 'string',
    59                     'default' => 'DESC'
    60                 ),
    61                 'wpc_show_vendor' => array(
    62                     'type' => 'string',
    63                     'default'   => 'yes'
     8class Food_Tab {
     9   
     10    use \WpCafe\Traits\Wpc_Singleton;
     11
     12    function init() {
     13        add_action('init', [$this, 'register_food_tab_block']);
     14    }
     15
     16    function register_food_tab_block(){
     17        register_block_type(
     18            'wpc/food-menu-tab', array(
     19                // Enqueue blocks.style.build.css on both frontend & backend.
     20                'style'         => 'wpc-block-style-css',
     21                // Enqueue blocks.editor.build.css in the editor only.
     22                'editor_style'  => 'wpc-block-editor-style-css',
     23                // Enqueue blocks.build.js in the editor only.
     24                'editor_script' => 'wpc-block-js',
     25                'render_callback'   => [$this, 'wpc_food_menu_tab_callback'],
     26                'api_version' => 1,
     27                'attributes' => array(
     28                    'food_menu_style' => array(
     29                        'type' => 'string',
     30                        'default'   => 'style-1'
     31                    ),
     32                    'wpc_food_categories' => array(
     33                        'type' => 'array',
     34                        'default'   => []
     35                    ),
     36                    'show_thumbnail' => array(
     37                        'type' => 'string',
     38                        'default'   => 'yes'
     39                    ),
     40                    'wpc_desc_limit' => array(
     41                        'type' => 'integer',
     42                        'default'   => 20
     43                    ),
     44                    'wpc_show_desc' => array(
     45                        'type' => 'string',
     46                        'default'   => 'yes'
     47                    ),
     48                    'wpc_cart_button' => array(
     49                        'type' => 'string',
     50                        'default'   => 'yes'
     51                    ),
     52                    'title_link_show' => array(
     53                        'type' => 'string',
     54                        'default'   => 'yes'
     55                    ),
     56                    'show_item_status' => array(
     57                        'type' => 'string',
     58                        'default'   => 'yes'
     59                    ),
     60                    'wpc_price_show' => array(
     61                        'type' => 'string',
     62                        'default'   => 'yes'
     63                    ),
     64                    'wpc_menu_count' => array(
     65                        'type' => 'integer',
     66                        'default'   => 20
     67                    ),
     68                    'wpc_menu_order' => array(
     69                        'type' => 'string',
     70                        'default' => 'DESC'
     71                    ),
     72                    'wpc_show_vendor' => array(
     73                        'type' => 'string',
     74                        'default'   => 'yes'
     75                    )
    6476                )
    6577            )
    66         )
    67     );
    68 }
    69 add_action('init', 'register_food_tab_block');
     78        );
     79    }
    7080
    71 // food menu tab block callback
    72 function wpc_food_menu_tab_callback($settings){
    73     //check if woocommerce exists
    74     if (!class_exists('Woocommerce')) { return; }
     81    // food menu tab block callback
     82    function wpc_food_menu_tab_callback($settings){
     83        //check if woocommerce exists
     84        if (!class_exists('Woocommerce')) { return; }
    7585
    76     $unique_id = md5(md5(microtime()));
     86        $unique_id = md5(md5(microtime()));
    7787
    78     $style = $settings['food_menu_style'];
    79     $wpc_menu_order = $settings['wpc_menu_order'];
    80     $wpc_desc_limit = $settings['wpc_desc_limit'];
    81     $wpc_cart_button = $settings['wpc_cart_button'];
    82     $show_item_status = $settings['show_item_status'];
    83     $wpc_price_show = $settings["wpc_price_show"];
    84     $wpc_show_vendor    = $settings["wpc_show_vendor"];
     88        $style = $settings['food_menu_style'];
     89        $wpc_menu_order = $settings['wpc_menu_order'];
     90        $wpc_desc_limit = $settings['wpc_desc_limit'];
     91        $wpc_cart_button = $settings['wpc_cart_button'];
     92        $show_item_status = $settings['show_item_status'];
     93        $wpc_price_show = $settings["wpc_price_show"];
     94        $wpc_show_vendor    = $settings["wpc_show_vendor"];
    8595
    86     $wpc_cat_arr  = $settings['wpc_food_categories'];
    87    
    88     $food_menu_tabs = [];
    89     if (count($wpc_cat_arr) > 0) {
    90         foreach ($wpc_cat_arr as $key => $value) {
    91             if ($wpc_cat = get_term_by('id', $value, 'product_cat')) {
    92                 $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true);
    93                 $wpc_cat    = get_term_by('id', $value, 'product_cat');
    94                 $cat_name   = ($wpc_cat && $wpc_cat->name ) ? $wpc_cat->name : "";
    95                 $tab_data   = array('post_cats'=>[$value],'tab_title' => $cat_name);
    96                 if ($wpc_get_menu_order == '') {
    97                     $food_menu_tabs[$key] = $tab_data;
    98                 } else {
    99                     $food_menu_tabs[$wpc_get_menu_order] = $tab_data;
     96        $wpc_cat_arr  = $settings['wpc_food_categories'];
     97       
     98        $food_menu_tabs = [];
     99        if (count($wpc_cat_arr) > 0) {
     100            foreach ($wpc_cat_arr as $key => $value) {
     101                if ($wpc_cat = get_term_by('id', $value, 'product_cat')) {
     102                    $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true);
     103                    $wpc_cat    = get_term_by('id', $value, 'product_cat');
     104                    $cat_name   = ($wpc_cat && $wpc_cat->name ) ? $wpc_cat->name : "";
     105                    $tab_data   = array('post_cats'=>[$value],'tab_title' => $cat_name);
     106                    if ($wpc_get_menu_order == '') {
     107                        $food_menu_tabs[$key] = $tab_data;
     108                    } else {
     109                        $food_menu_tabs[$wpc_get_menu_order] = $tab_data;
     110                    }
    100111                }
    101112            }
     113        }else{
     114            return "<p>Select at least one category.</p>";
    102115        }
    103     }else{
    104         return "<p>Select at least one category.</p>";
     116
     117        if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
     118            $wpc_menu_count = is_array($settings) && isset($settings['wpc_menu_count']) ? $settings['wpc_menu_count'] : 5;
     119            $wpc_show_desc  = is_array($settings) && isset($settings['wpc_show_desc']) ? $settings['wpc_show_desc'] : 'yes';
     120            $show_thumbnail = is_array($settings) && isset($settings['show_thumbnail']) ? $settings['show_thumbnail'] : 'yes';
     121            $title_link_show= is_array($settings) && isset($settings['title_link_show']) ? $settings['title_link_show'] : 'yes';
     122            $class = ($title_link_show=='yes')? '' : 'wpc-no-link';
     123
     124            $allowed_file_names = [
     125                'style-1',
     126                'style-2'
     127            ];
     128       
     129            if( in_array($style, $allowed_file_names)){
     130                $template_file = esc_html($style);
     131            }else{
     132                $template_file = $allowed_file_names[0];
     133            }
     134
     135            ob_start();
     136            ?>
     137            <div class="wpc-food-tab-wrapper wpc-nav-shortcode main_wrapper_<?php echo esc_html($unique_id)?>" data-id="<?php echo esc_attr($unique_id)?>">
     138                <ul class="wpc-nav">
     139                    <?php
     140                    if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
     141                        foreach ($food_menu_tabs as $tab_key => $value) {
     142                            $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
     143                            $cat_id       = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
     144                            ?>
     145                            <li>
     146                                <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($tab_key); ?>'
     147                                   data-cat_id='<?php echo esc_attr( $cat_id ); ?>'>
     148                                    <span><?php echo esc_html($value['tab_title']); ?></span>
     149                                </a>
     150                            </li>
     151                            <?php
     152                        }
     153                    }
     154                    ?>
     155                </ul>
     156                <div class="wpc-tab-content wpc-widget-wrapper">
     157                    <?php
     158                    foreach ($food_menu_tabs as $content_key => $value) {
     159                        if(isset( $value['post_cats'][0] )){
     160                            $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
     161                            $cat_id = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
     162                            ?>
     163                            <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($content_key); ?>'
     164                                 data-cat_id='<?php echo  esc_attr($cat_id);?>'>
     165                                <div class="tab_template_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>"></div>
     166                                <div class="template_data_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>">
     167                                    <?php
     168                                    $food_tab_args = array(
     169                                        'post_type'     => 'product',
     170                                        'no_of_product' => $wpc_menu_count,
     171                                        'wpc_cat'       => $value['post_cats'],
     172                                        'order'         => $wpc_menu_order,
     173                                    );
     174                                    $products = Wpc_Utilities::product_query( $food_tab_args );
     175                                    include \Wpcafe::plugin_dir() . "widgets/wpc-food-menu-tab/style/{$template_file}.php";
     176                                    ?>
     177                                </div>
     178                            </div><!-- Tab pane 1 end -->
     179                            <?php
     180                        }
     181                    }
     182                    ?>
     183                </div><!-- Tab content-->
     184            </div>
     185            <?php
     186        }
     187        return ob_get_clean();
     188
    105189    }
    106190
    107     if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
    108         $wpc_menu_count = is_array($settings) && isset($settings['wpc_menu_count']) ? $settings['wpc_menu_count'] : 5;
    109         $wpc_show_desc  = is_array($settings) && isset($settings['wpc_show_desc']) ? $settings['wpc_show_desc'] : 'yes';
    110         $show_thumbnail = is_array($settings) && isset($settings['show_thumbnail']) ? $settings['show_thumbnail'] : 'yes';
    111         $title_link_show= is_array($settings) && isset($settings['title_link_show']) ? $settings['title_link_show'] : 'yes';
    112         $class = ($title_link_show=='yes')? '' : 'wpc-no-link';
    113 
    114         $allowed_file_names = [
    115             'style-1',
    116                 'style-2'
    117         ];
    118    
    119         if( in_array($style, $allowed_file_names)){
    120             $template_file = esc_html($style);
    121         }else{
    122             $template_file = $allowed_file_names[0];
    123         }
    124 
    125         ob_start();
    126         ?>
    127         <div class="wpc-food-tab-wrapper wpc-nav-shortcode main_wrapper_<?php echo esc_html($unique_id)?>" data-id="<?php echo esc_attr($unique_id)?>">
    128             <ul class="wpc-nav">
    129                 <?php
    130                 if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
    131                     foreach ($food_menu_tabs as $tab_key => $value) {
    132                         $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
    133                         $cat_id       = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
    134                         ?>
    135                         <li>
    136                             <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($tab_key); ?>'
    137                                data-cat_id='<?php echo esc_attr( $cat_id ); ?>'>
    138                                 <span><?php echo esc_html($value['tab_title']); ?></span>
    139                             </a>
    140                         </li>
    141                         <?php
    142                     }
    143                 }
    144                 ?>
    145             </ul>
    146             <div class="wpc-tab-content wpc-widget-wrapper">
    147                 <?php
    148                 foreach ($food_menu_tabs as $content_key => $value) {
    149                     if(isset( $value['post_cats'][0] )){
    150                         $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
    151                         $cat_id = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
    152                         ?>
    153                         <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($content_key); ?>'
    154                              data-cat_id='<?php echo  esc_attr($cat_id);?>'>
    155                             <div class="tab_template_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>"></div>
    156                             <div class="template_data_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>">
    157                                 <?php
    158                                 $food_tab_args = array(
    159                                     'post_type'     => 'product',
    160                                     'no_of_product' => $wpc_menu_count,
    161                                     'wpc_cat'       => $value['post_cats'],
    162                                     'order'         => $wpc_menu_order,
    163                                 );
    164                                 $products = Wpc_Utilities::product_query( $food_tab_args );
    165                                 include \Wpcafe::plugin_dir() . "widgets/wpc-food-menu-tab/style/{$template_file}.php";
    166                                 ?>
    167                             </div>
    168                         </div><!-- Tab pane 1 end -->
    169                         <?php
    170                     }
    171                 }
    172                 ?>
    173             </div><!-- Tab content-->
    174         </div>
    175         <?php
    176     }
    177     return ob_get_clean();
    178 
    179191}
  • wp-cafe/tags/2.2.29/core/modules/guten-block/inc/blocks/location.php

    r3112563 r3125940  
    11<?php
    2 //register location checkout page block
    3 function register_location_block(){
    4     register_block_type(
    5         'wpc/location', array(
    6             'editor_script' => 'wpc-block-js',
    7             'render_callback'   => 'wpc_location_callback',
    8             'api_version'       => 1,
    9             'attributes'        => array()
    10         )
    11     );
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
    123
    13     if(is_checkout()){
    14         wp_enqueue_script('frontend-js-block-location', \Wpcafe::assets_url() . 'js/wpc-block-location.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
    15     }
     4defined( "ABSPATH" ) || exit;
     5
     6class Location {
     7   
     8    use \WpCafe\Traits\Wpc_Singleton;
     9
     10    function init() {
     11        add_action('init', [$this, 'register_location_block']);
     12    }
     13
     14    function register_location_block(){
     15        register_block_type(
     16            'wpc/location', array(
     17                'editor_script' => 'wpc-block-js',
     18                'render_callback'   => [$this, 'wpc_location_callback'],
     19                'api_version'       => 1,
     20                'attributes'        => array()
     21            )
     22        );
     23
     24        $this->register_location_block_scripts();
     25
     26    }
     27
     28    function register_location_block_scripts(){
     29        wp_register_script('frontend-js-block-location', \Wpcafe::assets_url() . 'js/wpc-block-location.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
     30    }
     31
     32
     33    function wpc_location_callback() {
     34        //check if the location module is active
     35        $settings  = \WpCafe\Core\Base\Wpc_Settings_Field::instance()->get_settings_option();
     36
     37        if( ! isset( $settings['wpcafe_food_location']) ){
     38            return;
     39        }
     40
     41        if(is_checkout() ){
     42            wp_enqueue_script( 'frontend-js-block-location' );
     43        }
     44
     45        return do_shortcode( '[wpc_location_checkout]' );
     46    }
    1647
    1748}
    18 add_action('init', 'register_location_block');
    19 
    20 // pickup delivery checkout page block callback
    21 function wpc_location_callback() {
    22     //check if woocommerce exists
    23     if ( ! class_exists( 'Woocommerce' ) ) { return; }
    24 
    25     return do_shortcode( '[wpc_location_checkout]' );
    26 }
  • wp-cafe/tags/2.2.29/core/modules/guten-block/inc/blocks/pickup-delivery.php

    r3112563 r3125940  
    11<?php
    2 //register pickup delivery checkout page block
    3 function register_pickup_delivery_block(){
    4     register_block_type(
    5         'wpc/pickup-delivery', array(
    6             'editor_script' => 'wpc-block-js',
    7             'render_callback'   => 'wpc_pickup_delivery_callback',
    8             'api_version'       => 1,
    9             'attributes'        => array()
    10         )
    11     );
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
    123
    13     if(is_checkout()){
    14         wp_enqueue_script('frontend-js-block-pickup', \Wpcafe::assets_url() . 'js/wpc-block-pickup.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
    15     }   
     4defined( "ABSPATH" ) || exit;
     5
     6class Pickup_Delivery {
     7   
     8    use \WpCafe\Traits\Wpc_Singleton;
     9
     10    function init() {
     11        add_action('init', [$this, 'register_pickup_delivery_block']);
     12    }
     13
     14    function register_pickup_delivery_block(){
     15        register_block_type(
     16            'wpc/pickup-delivery', array(
     17                'editor_script' => 'wpc-block-js',
     18                'render_callback'   => [$this, 'wpc_pickup_delivery_callback'],
     19                'api_version'       => 1,
     20                'attributes'        => array()
     21            )
     22        );
     23
     24        $this->register_pickup_delivery_block_scripts();
     25    }
     26
     27    function register_pickup_delivery_block_scripts(){
     28        wp_register_script('frontend-js-block-pickup', \Wpcafe::assets_url() . 'js/wpc-block-pickup.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
     29    }
     30
     31    // pickup delivery checkout page block callback
     32    function wpc_pickup_delivery_callback() {
     33        //check if the pickup/delivery module is active
     34        $allowed_options = [
     35            'Both',
     36            'Delivery',
     37            'Pickup'
     38        ];
     39
     40        $settings  = \WpCafe\Core\Base\Wpc_Settings_Field::instance()->get_settings_option();
     41
     42        if( ! in_array($settings['wpc_pro_allow_order_for'], $allowed_options)){
     43            return;
     44        }
     45
     46        if(is_checkout() ){
     47            wp_enqueue_script( 'frontend-js-block-pickup' );
     48        }
     49
     50        return do_shortcode( '[wpc_pickup_delivery_checkout]' );
     51    }
    1652
    1753}
    18 add_action('init', 'register_pickup_delivery_block');
    19 
    20 // pickup delivery checkout page block callback
    21 function wpc_pickup_delivery_callback() {
    22     //check if woocommerce exists
    23     if ( ! class_exists( 'Woocommerce' ) ) { return; }
    24    
    25     return do_shortcode( '[wpc_pickup_delivery_checkout]' );
    26 }
  • wp-cafe/tags/2.2.29/core/shortcodes/hook.php

    r3112563 r3125940  
    8484        global $product;
    8585
    86         if (!$product->is_type('external')) {
     86        if (isset($product) && !$product->is_type('external')) {
    8787            ?>
    8888            <script type="text/javascript">
     
    331331            $atts
    332332        ));
     333
     334        $allowed_file_names = [
     335            'style-1',
     336            'style-2',
     337            'style-3'
     338        ];
     339   
     340        if( in_array($style, $allowed_file_names)){
     341            $template_file = esc_html($style);
     342        }else{
     343            $template_file = $allowed_file_names[0];
     344        }
     345
    333346        ob_start();
    334347        // category sorting from backend
     
    342355            $unique_id = md5(md5(microtime()));
    343356            $settings = array();
    344             $settings["food_menu_style"]        = $style;
     357            $settings["food_menu_style"]        = $template_file;
    345358            $settings["show_thumbnail"]         = $product_thumbnail;
    346359            $settings["wpc_price_show"]         = $wpc_price_show;
  • wp-cafe/tags/2.2.29/readme.txt

    r3112563 r3125940  
    44Requires at least: 5.2
    55Tested up to: 6.5.5
    6 Stable tag: 2.2.28
     6Stable tag: 2.2.29
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    397397== Changelog ==
    398398
     399= 2.2.29 ( July 25, 2024 ) =
     400
     401Fix             : WooCommerce dependency error
     402Fix             : Shortcode generation issue fix
     403Tweak           : Patch LFI security for Food Menu List widget
     404Tweak           : Improved Gutenberg blocks
     405
    399406= 2.2.28 ( July 4, 2024 ) =
    400407
     
    403410Fix             : Single product add to cart issue fix
    404411
     412
    405413= 2.2.27 ( June 13, 2024 ) =
    406414
    407 Update: Improved security for reservation
    408 New: Pickup/Delivery Gutenberg checkout block
    409 Fix: QR Reservation table name not appearing
     415Tweak           : Improved security for reservation
     416New             : Pickup/Delivery Gutenberg checkout block
     417Fix             : QR Reservation table name not appearing
    410418
    411419= 2.2.26 ( May 30, 2024 ) =
  • wp-cafe/tags/2.2.29/utils/wpc-utilities.php

    r3112563 r3125940  
    210210                'class'       => [],
    211211                'multiple'    => array(),
     212                'data-cat'    => []
    212213               
    213214            ],
  • wp-cafe/tags/2.2.29/wpcafe.php

    r3112563 r3125940  
    99 * Plugin URI:         https://product.themewinter.com/wpcafe
    1010 * Description:        WordPress Restaurant solution plugin to launch Restaurant Websites.
    11  * Version:            2.2.28
     11 * Version:            2.2.29
    1212 * Author:             Themewinter
    1313 * Author URI:         http://themewinter.com/
     
    3030     */
    3131    static function version() {
    32         return '2.2.28';
     32        return '2.2.29';
    3333    }
    3434
  • wp-cafe/trunk/bootstrap.php

    r2982187 r3125940  
    108108
    109109        // register gutenberg blocks
    110         if( file_exists( \Wpcafe::plugin_dir() . 'core/modules/guten-block/inc/init.php' )){
    111             include_once \Wpcafe::plugin_dir() . 'core/modules/guten-block/inc/init.php';
    112         }
    113 
     110        \WpCafe\Core\Modules\Guten_Block\Inc\Register_Blocks::instance()->init();
     111       
    114112        if ( is_admin() ){
    115113            \WpCafe\Core\Core::instance()->init();
  • wp-cafe/trunk/core/modules/guten-block/inc/blocks/food-list.php

    r3112563 r3125940  
    11<?php
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
     3
     4defined( "ABSPATH" ) || exit;
     5
    26use WpCafe\Utils\Wpc_Utilities;
    37
    4 //register food list block
    5 function register_food_list_block(){
    6     register_block_type(
    7         'wpc/food-menu-list', array(
    8             // Enqueue blocks.style.build.css on both frontend & backend.
    9             'style'         => 'wpc-block-style-css',
    10             // Enqueue blocks.editor.build.css in the editor only.
    11             'editor_style'  => 'wpc-block-editor-style-css',
    12             // Enqueue blocks.build.js in the editor only.
    13             'editor_script' => 'wpc-block-js',
    14             'render_callback'   => 'wpc_food_menu_list_callback',
    15             'api_version' => 1,
    16             'attributes' => array(
    17                 'food_menu_style' => array(
    18                     'type' => 'string',
    19                     'default'   => 'style-1'
    20                 ),
    21                 'show_thumbnail' => array(
    22                     'type' => 'string',
    23                     'default'   => 'yes'
    24                 ),
    25                 'wpc_menu_cat' => array(
    26                     'type' => 'array',
    27                     'default'   => []
    28                 ),
    29                 'wpc_desc_limit' => array(
    30                     'type' => 'integer',
    31                     'default'   => 20
    32                 ),
    33                 'wpc_show_desc' => array(
    34                     'type' => 'string',
    35                     'default'   => 'yes'
    36                 ),
    37                 'wpc_cart_button_show' => array(
    38                     'type' => 'string',
    39                     'default'   => 'yes'
    40                 ),
    41                 'title_link_show' => array(
    42                     'type' => 'string',
    43                     'default'   => 'yes'
    44                 ),
    45                 'show_item_status' => array(
    46                     'type' => 'string',
    47                     'default'   => 'yes'
    48                 ),
    49                 'wpc_price_show' => array(
    50                     'type' => 'string',
    51                     'default'   => 'yes'
    52                 ),
    53                 'wpc_menu_count' => array(
    54                     'type' => 'integer',
    55                     'default'   => 20
    56                 ),
    57                 'wpc_menu_order' => array(
    58                     'type' => 'string',
    59                     'default' => 'DESC'
    60                 ),
    61                 'wpc_show_vendor' => array(
    62                     'type' => 'string',
    63                     'default'   => 'yes'
     8class Food_List {
     9   
     10    use \WpCafe\Traits\Wpc_Singleton;
     11
     12    function init() {
     13        add_action('init', [$this, 'register_food_list_block']);
     14    }
     15
     16    function register_food_list_block(){
     17        register_block_type(
     18            'wpc/food-menu-list', array(
     19                // Enqueue blocks.style.build.css on both frontend & backend.
     20                'style'         => 'wpc-block-style-css',
     21                // Enqueue blocks.editor.build.css in the editor only.
     22                'editor_style'  => 'wpc-block-editor-style-css',
     23                // Enqueue blocks.build.js in the editor only.
     24                'editor_script' => 'wpc-block-js',
     25                'render_callback'   => [$this, 'wpc_food_menu_list_callback'],
     26                'api_version' => 1,
     27                'attributes' => array(
     28                    'food_menu_style' => array(
     29                        'type' => 'string',
     30                        'default'   => 'style-1'
     31                    ),
     32                    'show_thumbnail' => array(
     33                        'type' => 'string',
     34                        'default'   => 'yes'
     35                    ),
     36                    'wpc_menu_cat' => array(
     37                        'type' => 'array',
     38                        'default'   => []
     39                    ),
     40                    'wpc_desc_limit' => array(
     41                        'type' => 'integer',
     42                        'default'   => 20
     43                    ),
     44                    'wpc_show_desc' => array(
     45                        'type' => 'string',
     46                        'default'   => 'yes'
     47                    ),
     48                    'wpc_cart_button_show' => array(
     49                        'type' => 'string',
     50                        'default'   => 'yes'
     51                    ),
     52                    'title_link_show' => array(
     53                        'type' => 'string',
     54                        'default'   => 'yes'
     55                    ),
     56                    'show_item_status' => array(
     57                        'type' => 'string',
     58                        'default'   => 'yes'
     59                    ),
     60                    'wpc_price_show' => array(
     61                        'type' => 'string',
     62                        'default'   => 'yes'
     63                    ),
     64                    'wpc_menu_count' => array(
     65                        'type' => 'integer',
     66                        'default'   => 20
     67                    ),
     68                    'wpc_menu_order' => array(
     69                        'type' => 'string',
     70                        'default' => 'DESC'
     71                    ),
     72                    'wpc_show_vendor' => array(
     73                        'type' => 'string',
     74                        'default'   => 'yes'
     75                    )
    6476                )
    6577            )
    66         )
    67     );
    68 }
    69 add_action('init', 'register_food_list_block');
     78        );
     79    }
    7080
    71 // food menu list block callback
    72 function wpc_food_menu_list_callback($settings){
    73     //check if woocommerce exists
    74     if (!class_exists('Woocommerce')) { return; }
     81    // food menu list block callback
     82    function wpc_food_menu_list_callback($settings){
     83        $unique_id = md5(md5(microtime()));
    7584
    76     $unique_id = md5(md5(microtime()));
     85        $style               = $settings["food_menu_style"];
     86        $show_item_status    = $settings["show_item_status"];
     87        $show_thumbnail      = $settings["show_thumbnail"];
     88        $title_link_show     = $settings["title_link_show"];
     89        $wpc_cart_button     = $settings["wpc_cart_button_show"];
     90        $wpc_show_desc       = $settings["wpc_show_desc"];
     91        $wpc_desc_limit      = $settings["wpc_desc_limit"];
     92        $wpc_menu_cat        = $settings["wpc_menu_cat"];
     93        $wpc_menu_count      = $settings["wpc_menu_count"];
     94        $wpc_menu_order      = $settings["wpc_menu_order"];
     95        $show_thumbnail      = $settings["show_thumbnail"];
     96        $wpc_price_show      = $settings["wpc_price_show"];
     97        $wpc_show_vendor     = $settings["wpc_show_vendor"];
     98       
     99        apply_filters( 'elementor/control/search_data' , $settings , $unique_id , 'wpc-menus-list' );
    77100
    78     $style               = $settings["food_menu_style"];
    79     $show_item_status    = $settings["show_item_status"];
    80     $show_thumbnail      = $settings["show_thumbnail"];
    81     $title_link_show     = $settings["title_link_show"];
    82     $wpc_cart_button     = $settings["wpc_cart_button_show"];
    83     $wpc_show_desc       = $settings["wpc_show_desc"];
    84     $wpc_desc_limit      = $settings["wpc_desc_limit"];
    85     $wpc_menu_cat        = $settings["wpc_menu_cat"];
    86     $wpc_menu_count      = $settings["wpc_menu_count"];
    87     $wpc_menu_order      = $settings["wpc_menu_order"];
    88     $show_thumbnail      = $settings["show_thumbnail"];
    89     $wpc_price_show      = $settings["wpc_price_show"];
    90     $wpc_show_vendor     = $settings["wpc_show_vendor"];
    91    
    92     apply_filters( 'elementor/control/search_data' , $settings , $unique_id , 'wpc-menus-list' );
     101        $allowed_file_names = [
     102            'style-1',
     103            'style-2',
     104            'style-3'
     105        ];
    93106
    94     $allowed_file_names = [
    95         'style-1',
    96     'style-2',
    97     'style-3'
    98     ];
     107        if( in_array($style, $allowed_file_names)){
     108            $template_file = esc_html($style);
     109        }else{
     110            $template_file = $allowed_file_names[0];
     111        }
    99112
    100     if( in_array($style, $allowed_file_names)){
    101         $template_file = esc_html($style);
    102     }else{
    103         $template_file = $allowed_file_names[0];
    104     }
     113        ob_start();
     114        ?>
     115        <div class="main_wrapper_<?php echo esc_html($unique_id)?>">
     116            <div class="list_template_<?php echo esc_html($unique_id) ?> wpc-nav-shortcode wpc-widget-wrapper"  data-id="<?php echo esc_attr($unique_id)?>">
     117                <?php
     118                $food_list_args = array(
     119                    'post_type'     => 'product',
     120                    'no_of_product' => $wpc_menu_count,
     121                    'wpc_cat'       => $wpc_menu_cat,
     122                    'order'         => $wpc_menu_order,
     123                );
     124                $products = Wpc_Utilities::product_query( $food_list_args );
     125                include \Wpcafe::plugin_dir() . "widgets/wpc-menus-list/style/{$template_file}.php";
     126                ?>
     127            </div>
     128        </div>
     129        <?php
    105130
    106     ob_start();
    107     ?>
    108     <div class="main_wrapper_<?php echo esc_html($unique_id)?>">
    109         <div class="list_template_<?php echo esc_html($unique_id) ?> wpc-nav-shortcode wpc-widget-wrapper"  data-id="<?php echo esc_attr($unique_id)?>">
    110             <?php
    111             $food_list_args = array(
    112                 'post_type'     => 'product',
    113                 'no_of_product' => $wpc_menu_count,
    114                 'wpc_cat'       => $wpc_menu_cat,
    115                 'order'         => $wpc_menu_order,
    116             );
    117             $products = Wpc_Utilities::product_query( $food_list_args );
    118             include \Wpcafe::plugin_dir() . "widgets/wpc-menus-list/style/{$template_file}.php";
    119             ?>
    120         </div>
    121     </div>
    122     <?php
     131        return ob_get_clean();
    123132
    124     return ob_get_clean();
     133    }
    125134
    126135}
  • wp-cafe/trunk/core/modules/guten-block/inc/blocks/food-tab.php

    r3112563 r3125940  
    11<?php
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
     3
     4defined( "ABSPATH" ) || exit;
     5
    26use WpCafe\Utils\Wpc_Utilities;
    37
    4 //register food tab block
    5 function register_food_tab_block(){
    6     register_block_type(
    7         'wpc/food-menu-tab', array(
    8             // Enqueue blocks.style.build.css on both frontend & backend.
    9             'style'         => 'wpc-block-style-css',
    10             // Enqueue blocks.editor.build.css in the editor only.
    11             'editor_style'  => 'wpc-block-editor-style-css',
    12             // Enqueue blocks.build.js in the editor only.
    13             'editor_script' => 'wpc-block-js',
    14             'render_callback'   => 'wpc_food_menu_tab_callback',
    15             'api_version' => 1,
    16             'attributes' => array(
    17                 'food_menu_style' => array(
    18                     'type' => 'string',
    19                     'default'   => 'style-1'
    20                 ),
    21                 'wpc_food_categories' => array(
    22                     'type' => 'array',
    23                     'default'   => []
    24                 ),
    25                 'show_thumbnail' => array(
    26                     'type' => 'string',
    27                     'default'   => 'yes'
    28                 ),
    29                 'wpc_desc_limit' => array(
    30                     'type' => 'integer',
    31                     'default'   => 20
    32                 ),
    33                 'wpc_show_desc' => array(
    34                     'type' => 'string',
    35                     'default'   => 'yes'
    36                 ),
    37                 'wpc_cart_button' => array(
    38                     'type' => 'string',
    39                     'default'   => 'yes'
    40                 ),
    41                 'title_link_show' => array(
    42                     'type' => 'string',
    43                     'default'   => 'yes'
    44                 ),
    45                 'show_item_status' => array(
    46                     'type' => 'string',
    47                     'default'   => 'yes'
    48                 ),
    49                 'wpc_price_show' => array(
    50                     'type' => 'string',
    51                     'default'   => 'yes'
    52                 ),
    53                 'wpc_menu_count' => array(
    54                     'type' => 'integer',
    55                     'default'   => 20
    56                 ),
    57                 'wpc_menu_order' => array(
    58                     'type' => 'string',
    59                     'default' => 'DESC'
    60                 ),
    61                 'wpc_show_vendor' => array(
    62                     'type' => 'string',
    63                     'default'   => 'yes'
     8class Food_Tab {
     9   
     10    use \WpCafe\Traits\Wpc_Singleton;
     11
     12    function init() {
     13        add_action('init', [$this, 'register_food_tab_block']);
     14    }
     15
     16    function register_food_tab_block(){
     17        register_block_type(
     18            'wpc/food-menu-tab', array(
     19                // Enqueue blocks.style.build.css on both frontend & backend.
     20                'style'         => 'wpc-block-style-css',
     21                // Enqueue blocks.editor.build.css in the editor only.
     22                'editor_style'  => 'wpc-block-editor-style-css',
     23                // Enqueue blocks.build.js in the editor only.
     24                'editor_script' => 'wpc-block-js',
     25                'render_callback'   => [$this, 'wpc_food_menu_tab_callback'],
     26                'api_version' => 1,
     27                'attributes' => array(
     28                    'food_menu_style' => array(
     29                        'type' => 'string',
     30                        'default'   => 'style-1'
     31                    ),
     32                    'wpc_food_categories' => array(
     33                        'type' => 'array',
     34                        'default'   => []
     35                    ),
     36                    'show_thumbnail' => array(
     37                        'type' => 'string',
     38                        'default'   => 'yes'
     39                    ),
     40                    'wpc_desc_limit' => array(
     41                        'type' => 'integer',
     42                        'default'   => 20
     43                    ),
     44                    'wpc_show_desc' => array(
     45                        'type' => 'string',
     46                        'default'   => 'yes'
     47                    ),
     48                    'wpc_cart_button' => array(
     49                        'type' => 'string',
     50                        'default'   => 'yes'
     51                    ),
     52                    'title_link_show' => array(
     53                        'type' => 'string',
     54                        'default'   => 'yes'
     55                    ),
     56                    'show_item_status' => array(
     57                        'type' => 'string',
     58                        'default'   => 'yes'
     59                    ),
     60                    'wpc_price_show' => array(
     61                        'type' => 'string',
     62                        'default'   => 'yes'
     63                    ),
     64                    'wpc_menu_count' => array(
     65                        'type' => 'integer',
     66                        'default'   => 20
     67                    ),
     68                    'wpc_menu_order' => array(
     69                        'type' => 'string',
     70                        'default' => 'DESC'
     71                    ),
     72                    'wpc_show_vendor' => array(
     73                        'type' => 'string',
     74                        'default'   => 'yes'
     75                    )
    6476                )
    6577            )
    66         )
    67     );
    68 }
    69 add_action('init', 'register_food_tab_block');
     78        );
     79    }
    7080
    71 // food menu tab block callback
    72 function wpc_food_menu_tab_callback($settings){
    73     //check if woocommerce exists
    74     if (!class_exists('Woocommerce')) { return; }
     81    // food menu tab block callback
     82    function wpc_food_menu_tab_callback($settings){
     83        //check if woocommerce exists
     84        if (!class_exists('Woocommerce')) { return; }
    7585
    76     $unique_id = md5(md5(microtime()));
     86        $unique_id = md5(md5(microtime()));
    7787
    78     $style = $settings['food_menu_style'];
    79     $wpc_menu_order = $settings['wpc_menu_order'];
    80     $wpc_desc_limit = $settings['wpc_desc_limit'];
    81     $wpc_cart_button = $settings['wpc_cart_button'];
    82     $show_item_status = $settings['show_item_status'];
    83     $wpc_price_show = $settings["wpc_price_show"];
    84     $wpc_show_vendor    = $settings["wpc_show_vendor"];
     88        $style = $settings['food_menu_style'];
     89        $wpc_menu_order = $settings['wpc_menu_order'];
     90        $wpc_desc_limit = $settings['wpc_desc_limit'];
     91        $wpc_cart_button = $settings['wpc_cart_button'];
     92        $show_item_status = $settings['show_item_status'];
     93        $wpc_price_show = $settings["wpc_price_show"];
     94        $wpc_show_vendor    = $settings["wpc_show_vendor"];
    8595
    86     $wpc_cat_arr  = $settings['wpc_food_categories'];
    87    
    88     $food_menu_tabs = [];
    89     if (count($wpc_cat_arr) > 0) {
    90         foreach ($wpc_cat_arr as $key => $value) {
    91             if ($wpc_cat = get_term_by('id', $value, 'product_cat')) {
    92                 $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true);
    93                 $wpc_cat    = get_term_by('id', $value, 'product_cat');
    94                 $cat_name   = ($wpc_cat && $wpc_cat->name ) ? $wpc_cat->name : "";
    95                 $tab_data   = array('post_cats'=>[$value],'tab_title' => $cat_name);
    96                 if ($wpc_get_menu_order == '') {
    97                     $food_menu_tabs[$key] = $tab_data;
    98                 } else {
    99                     $food_menu_tabs[$wpc_get_menu_order] = $tab_data;
     96        $wpc_cat_arr  = $settings['wpc_food_categories'];
     97       
     98        $food_menu_tabs = [];
     99        if (count($wpc_cat_arr) > 0) {
     100            foreach ($wpc_cat_arr as $key => $value) {
     101                if ($wpc_cat = get_term_by('id', $value, 'product_cat')) {
     102                    $wpc_get_menu_order = get_term_meta($wpc_cat->term_id, 'wpc_menu_order_priority', true);
     103                    $wpc_cat    = get_term_by('id', $value, 'product_cat');
     104                    $cat_name   = ($wpc_cat && $wpc_cat->name ) ? $wpc_cat->name : "";
     105                    $tab_data   = array('post_cats'=>[$value],'tab_title' => $cat_name);
     106                    if ($wpc_get_menu_order == '') {
     107                        $food_menu_tabs[$key] = $tab_data;
     108                    } else {
     109                        $food_menu_tabs[$wpc_get_menu_order] = $tab_data;
     110                    }
    100111                }
    101112            }
     113        }else{
     114            return "<p>Select at least one category.</p>";
    102115        }
    103     }else{
    104         return "<p>Select at least one category.</p>";
     116
     117        if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
     118            $wpc_menu_count = is_array($settings) && isset($settings['wpc_menu_count']) ? $settings['wpc_menu_count'] : 5;
     119            $wpc_show_desc  = is_array($settings) && isset($settings['wpc_show_desc']) ? $settings['wpc_show_desc'] : 'yes';
     120            $show_thumbnail = is_array($settings) && isset($settings['show_thumbnail']) ? $settings['show_thumbnail'] : 'yes';
     121            $title_link_show= is_array($settings) && isset($settings['title_link_show']) ? $settings['title_link_show'] : 'yes';
     122            $class = ($title_link_show=='yes')? '' : 'wpc-no-link';
     123
     124            $allowed_file_names = [
     125                'style-1',
     126                'style-2'
     127            ];
     128       
     129            if( in_array($style, $allowed_file_names)){
     130                $template_file = esc_html($style);
     131            }else{
     132                $template_file = $allowed_file_names[0];
     133            }
     134
     135            ob_start();
     136            ?>
     137            <div class="wpc-food-tab-wrapper wpc-nav-shortcode main_wrapper_<?php echo esc_html($unique_id)?>" data-id="<?php echo esc_attr($unique_id)?>">
     138                <ul class="wpc-nav">
     139                    <?php
     140                    if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
     141                        foreach ($food_menu_tabs as $tab_key => $value) {
     142                            $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
     143                            $cat_id       = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
     144                            ?>
     145                            <li>
     146                                <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($tab_key); ?>'
     147                                   data-cat_id='<?php echo esc_attr( $cat_id ); ?>'>
     148                                    <span><?php echo esc_html($value['tab_title']); ?></span>
     149                                </a>
     150                            </li>
     151                            <?php
     152                        }
     153                    }
     154                    ?>
     155                </ul>
     156                <div class="wpc-tab-content wpc-widget-wrapper">
     157                    <?php
     158                    foreach ($food_menu_tabs as $content_key => $value) {
     159                        if(isset( $value['post_cats'][0] )){
     160                            $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
     161                            $cat_id = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
     162                            ?>
     163                            <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($content_key); ?>'
     164                                 data-cat_id='<?php echo  esc_attr($cat_id);?>'>
     165                                <div class="tab_template_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>"></div>
     166                                <div class="template_data_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>">
     167                                    <?php
     168                                    $food_tab_args = array(
     169                                        'post_type'     => 'product',
     170                                        'no_of_product' => $wpc_menu_count,
     171                                        'wpc_cat'       => $value['post_cats'],
     172                                        'order'         => $wpc_menu_order,
     173                                    );
     174                                    $products = Wpc_Utilities::product_query( $food_tab_args );
     175                                    include \Wpcafe::plugin_dir() . "widgets/wpc-food-menu-tab/style/{$template_file}.php";
     176                                    ?>
     177                                </div>
     178                            </div><!-- Tab pane 1 end -->
     179                            <?php
     180                        }
     181                    }
     182                    ?>
     183                </div><!-- Tab content-->
     184            </div>
     185            <?php
     186        }
     187        return ob_get_clean();
     188
    105189    }
    106190
    107     if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
    108         $wpc_menu_count = is_array($settings) && isset($settings['wpc_menu_count']) ? $settings['wpc_menu_count'] : 5;
    109         $wpc_show_desc  = is_array($settings) && isset($settings['wpc_show_desc']) ? $settings['wpc_show_desc'] : 'yes';
    110         $show_thumbnail = is_array($settings) && isset($settings['show_thumbnail']) ? $settings['show_thumbnail'] : 'yes';
    111         $title_link_show= is_array($settings) && isset($settings['title_link_show']) ? $settings['title_link_show'] : 'yes';
    112         $class = ($title_link_show=='yes')? '' : 'wpc-no-link';
    113 
    114         $allowed_file_names = [
    115             'style-1',
    116                 'style-2'
    117         ];
    118    
    119         if( in_array($style, $allowed_file_names)){
    120             $template_file = esc_html($style);
    121         }else{
    122             $template_file = $allowed_file_names[0];
    123         }
    124 
    125         ob_start();
    126         ?>
    127         <div class="wpc-food-tab-wrapper wpc-nav-shortcode main_wrapper_<?php echo esc_html($unique_id)?>" data-id="<?php echo esc_attr($unique_id)?>">
    128             <ul class="wpc-nav">
    129                 <?php
    130                 if( is_array( $food_menu_tabs ) && count( $food_menu_tabs )>0 ){
    131                     foreach ($food_menu_tabs as $tab_key => $value) {
    132                         $active_class = (($tab_key == array_keys($food_menu_tabs)[0]) ? 'wpc-active' : ' ');
    133                         $cat_id       = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
    134                         ?>
    135                         <li>
    136                             <a href='#' class='wpc-tab-a <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($tab_key); ?>'
    137                                data-cat_id='<?php echo esc_attr( $cat_id ); ?>'>
    138                                 <span><?php echo esc_html($value['tab_title']); ?></span>
    139                             </a>
    140                         </li>
    141                         <?php
    142                     }
    143                 }
    144                 ?>
    145             </ul>
    146             <div class="wpc-tab-content wpc-widget-wrapper">
    147                 <?php
    148                 foreach ($food_menu_tabs as $content_key => $value) {
    149                     if(isset( $value['post_cats'][0] )){
    150                         $active_class = (($content_key == array_keys($food_menu_tabs)[0]) ? 'tab-active' : ' ');
    151                         $cat_id = isset($value['post_cats'][0] ) ? intval( $value['post_cats'][0] ) : 0 ;
    152                         ?>
    153                         <div class='wpc-tab <?php echo esc_attr($active_class); ?>' data-id='tab_<?php echo intval($content_key); ?>'
    154                              data-cat_id='<?php echo  esc_attr($cat_id);?>'>
    155                             <div class="tab_template_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>"></div>
    156                             <div class="template_data_<?php echo esc_attr( $cat_id.'_'.$unique_id );?>">
    157                                 <?php
    158                                 $food_tab_args = array(
    159                                     'post_type'     => 'product',
    160                                     'no_of_product' => $wpc_menu_count,
    161                                     'wpc_cat'       => $value['post_cats'],
    162                                     'order'         => $wpc_menu_order,
    163                                 );
    164                                 $products = Wpc_Utilities::product_query( $food_tab_args );
    165                                 include \Wpcafe::plugin_dir() . "widgets/wpc-food-menu-tab/style/{$template_file}.php";
    166                                 ?>
    167                             </div>
    168                         </div><!-- Tab pane 1 end -->
    169                         <?php
    170                     }
    171                 }
    172                 ?>
    173             </div><!-- Tab content-->
    174         </div>
    175         <?php
    176     }
    177     return ob_get_clean();
    178 
    179191}
  • wp-cafe/trunk/core/modules/guten-block/inc/blocks/location.php

    r3112563 r3125940  
    11<?php
    2 //register location checkout page block
    3 function register_location_block(){
    4     register_block_type(
    5         'wpc/location', array(
    6             'editor_script' => 'wpc-block-js',
    7             'render_callback'   => 'wpc_location_callback',
    8             'api_version'       => 1,
    9             'attributes'        => array()
    10         )
    11     );
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
    123
    13     if(is_checkout()){
    14         wp_enqueue_script('frontend-js-block-location', \Wpcafe::assets_url() . 'js/wpc-block-location.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
    15     }
     4defined( "ABSPATH" ) || exit;
     5
     6class Location {
     7   
     8    use \WpCafe\Traits\Wpc_Singleton;
     9
     10    function init() {
     11        add_action('init', [$this, 'register_location_block']);
     12    }
     13
     14    function register_location_block(){
     15        register_block_type(
     16            'wpc/location', array(
     17                'editor_script' => 'wpc-block-js',
     18                'render_callback'   => [$this, 'wpc_location_callback'],
     19                'api_version'       => 1,
     20                'attributes'        => array()
     21            )
     22        );
     23
     24        $this->register_location_block_scripts();
     25
     26    }
     27
     28    function register_location_block_scripts(){
     29        wp_register_script('frontend-js-block-location', \Wpcafe::assets_url() . 'js/wpc-block-location.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
     30    }
     31
     32
     33    function wpc_location_callback() {
     34        //check if the location module is active
     35        $settings  = \WpCafe\Core\Base\Wpc_Settings_Field::instance()->get_settings_option();
     36
     37        if( ! isset( $settings['wpcafe_food_location']) ){
     38            return;
     39        }
     40
     41        if(is_checkout() ){
     42            wp_enqueue_script( 'frontend-js-block-location' );
     43        }
     44
     45        return do_shortcode( '[wpc_location_checkout]' );
     46    }
    1647
    1748}
    18 add_action('init', 'register_location_block');
    19 
    20 // pickup delivery checkout page block callback
    21 function wpc_location_callback() {
    22     //check if woocommerce exists
    23     if ( ! class_exists( 'Woocommerce' ) ) { return; }
    24 
    25     return do_shortcode( '[wpc_location_checkout]' );
    26 }
  • wp-cafe/trunk/core/modules/guten-block/inc/blocks/pickup-delivery.php

    r3112563 r3125940  
    11<?php
    2 //register pickup delivery checkout page block
    3 function register_pickup_delivery_block(){
    4     register_block_type(
    5         'wpc/pickup-delivery', array(
    6             'editor_script' => 'wpc-block-js',
    7             'render_callback'   => 'wpc_pickup_delivery_callback',
    8             'api_version'       => 1,
    9             'attributes'        => array()
    10         )
    11     );
     2namespace WpCafe\Core\Modules\Guten_Block\Inc\Blocks;
    123
    13     if(is_checkout()){
    14         wp_enqueue_script('frontend-js-block-pickup', \Wpcafe::assets_url() . 'js/wpc-block-pickup.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
    15     }   
     4defined( "ABSPATH" ) || exit;
     5
     6class Pickup_Delivery {
     7   
     8    use \WpCafe\Traits\Wpc_Singleton;
     9
     10    function init() {
     11        add_action('init', [$this, 'register_pickup_delivery_block']);
     12    }
     13
     14    function register_pickup_delivery_block(){
     15        register_block_type(
     16            'wpc/pickup-delivery', array(
     17                'editor_script' => 'wpc-block-js',
     18                'render_callback'   => [$this, 'wpc_pickup_delivery_callback'],
     19                'api_version'       => 1,
     20                'attributes'        => array()
     21            )
     22        );
     23
     24        $this->register_pickup_delivery_block_scripts();
     25    }
     26
     27    function register_pickup_delivery_block_scripts(){
     28        wp_register_script('frontend-js-block-pickup', \Wpcafe::assets_url() . 'js/wpc-block-pickup.js', [ 'jquery', 'wpc-pro-widgets-modal-script', 'jquery-timepicker', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n' ], \Wpcafe::version());
     29    }
     30
     31    // pickup delivery checkout page block callback
     32    function wpc_pickup_delivery_callback() {
     33        //check if the pickup/delivery module is active
     34        $allowed_options = [
     35            'Both',
     36            'Delivery',
     37            'Pickup'
     38        ];
     39
     40        $settings  = \WpCafe\Core\Base\Wpc_Settings_Field::instance()->get_settings_option();
     41
     42        if( ! in_array($settings['wpc_pro_allow_order_for'], $allowed_options)){
     43            return;
     44        }
     45
     46        if(is_checkout() ){
     47            wp_enqueue_script( 'frontend-js-block-pickup' );
     48        }
     49
     50        return do_shortcode( '[wpc_pickup_delivery_checkout]' );
     51    }
    1652
    1753}
    18 add_action('init', 'register_pickup_delivery_block');
    19 
    20 // pickup delivery checkout page block callback
    21 function wpc_pickup_delivery_callback() {
    22     //check if woocommerce exists
    23     if ( ! class_exists( 'Woocommerce' ) ) { return; }
    24    
    25     return do_shortcode( '[wpc_pickup_delivery_checkout]' );
    26 }
  • wp-cafe/trunk/core/shortcodes/hook.php

    r3112563 r3125940  
    8484        global $product;
    8585
    86         if (!$product->is_type('external')) {
     86        if (isset($product) && !$product->is_type('external')) {
    8787            ?>
    8888            <script type="text/javascript">
     
    331331            $atts
    332332        ));
     333
     334        $allowed_file_names = [
     335            'style-1',
     336            'style-2',
     337            'style-3'
     338        ];
     339   
     340        if( in_array($style, $allowed_file_names)){
     341            $template_file = esc_html($style);
     342        }else{
     343            $template_file = $allowed_file_names[0];
     344        }
     345
    333346        ob_start();
    334347        // category sorting from backend
     
    342355            $unique_id = md5(md5(microtime()));
    343356            $settings = array();
    344             $settings["food_menu_style"]        = $style;
     357            $settings["food_menu_style"]        = $template_file;
    345358            $settings["show_thumbnail"]         = $product_thumbnail;
    346359            $settings["wpc_price_show"]         = $wpc_price_show;
  • wp-cafe/trunk/readme.txt

    r3112563 r3125940  
    44Requires at least: 5.2
    55Tested up to: 6.5.5
    6 Stable tag: 2.2.28
     6Stable tag: 2.2.29
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    397397== Changelog ==
    398398
     399= 2.2.29 ( July 25, 2024 ) =
     400
     401Fix             : WooCommerce dependency error
     402Fix             : Shortcode generation issue fix
     403Tweak           : Patch LFI security for Food Menu List widget
     404Tweak           : Improved Gutenberg blocks
     405
    399406= 2.2.28 ( July 4, 2024 ) =
    400407
     
    403410Fix             : Single product add to cart issue fix
    404411
     412
    405413= 2.2.27 ( June 13, 2024 ) =
    406414
    407 Update: Improved security for reservation
    408 New: Pickup/Delivery Gutenberg checkout block
    409 Fix: QR Reservation table name not appearing
     415Tweak           : Improved security for reservation
     416New             : Pickup/Delivery Gutenberg checkout block
     417Fix             : QR Reservation table name not appearing
    410418
    411419= 2.2.26 ( May 30, 2024 ) =
  • wp-cafe/trunk/utils/wpc-utilities.php

    r3112563 r3125940  
    210210                'class'       => [],
    211211                'multiple'    => array(),
     212                'data-cat'    => []
    212213               
    213214            ],
  • wp-cafe/trunk/wpcafe.php

    r3112563 r3125940  
    99 * Plugin URI:         https://product.themewinter.com/wpcafe
    1010 * Description:        WordPress Restaurant solution plugin to launch Restaurant Websites.
    11  * Version:            2.2.28
     11 * Version:            2.2.29
    1212 * Author:             Themewinter
    1313 * Author URI:         http://themewinter.com/
     
    3030     */
    3131    static function version() {
    32         return '2.2.28';
     32        return '2.2.29';
    3333    }
    3434
Note: See TracChangeset for help on using the changeset viewer.