MOON
Server: Apache
System: Linux server.netcommlabs.in 3.10.0-1160.83.1.el7.x86_64 #1 SMP Wed Jan 25 16:41:43 UTC 2023 x86_64
User: dermova (1051)
PHP: 5.4.45
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/dermova/www/india/wp-content/plugins/rit-core/inc/shortcode/product.php
<?php
/**
 * RIT Core Plugin
 * @package     RIT Core
 * @version     0.1
 * @author      CleverSoft
 * @link        http://cleversoft.co
 * @copyright   Copyright (c) 2015 CleverSoft
 * @license     GPL v2
 */
if (!function_exists('rit_shortcode_products')) {
    function rit_shortcode_products($atts, $content)
    {
        $atts = shortcode_atts(array(
            'title' => '',
            'post_type' => 'product',
            'pagination' => 'simple',
            'column' => 'columns6',
            'posts_per_page' => 4,
            'category'=>'',
            'products_type' => 'products_carousel',
            'products_img_size' => 'shop_thumbnail',
            'paged' => 1,
            'ignore_sticky_posts' => 1,
            'show' => '',
            'orderby' => 'date',
            'element_custom_class' => '',
            'padding_bottom_module' => '50px',
            'show_filter' => 1,
            'show_loadmore' => 1
        ), $atts);


        $meta_query = WC()->query->get_meta_query();


        $wc_attr = array(
            'post_type' => 'product',
            'posts_per_page' => $atts['posts_per_page'],
            'paged' => $atts['paged'],
            'orderby' => $atts['orderby'],
            'ignore_sticky_posts' => $atts['ignore_sticky_posts'],
        );

        if ($atts['show'] == 'featured') {


            $meta_query[] = array(
                'key' => '_featured',
                'value' => 'yes'
            );

            $wc_attr['meta_key'] = $meta_query;

        } elseif ($atts['show'] == 'onsale') {

            $product_ids_on_sale = wc_get_product_ids_on_sale();

            $wc_attr['post__in'] = $product_ids_on_sale;

            $wc_attr['meta_query'] = $meta_query;

        } elseif ($atts['show'] == 'best-selling') {

            $wc_attr['meta_key'] = 'total_sales';

            $wc_attr['meta_query'] = $meta_query;

        } elseif ($atts['show'] == 'latest'){

            $wc_attr['orderby'] = 'date';

            $wc_attr['order'] = 'DESC';

        } elseif ($atts['show'] == 'toprate'){

            add_filter('posts_clauses', array( 'WC_Shortcodes', 'order_by_rating_post_clauses'));

        } elseif ($atts['show'] == 'price'){

            $wc_attr['orderby']  = "meta_value_num {$wpdb->posts}.ID";
            $wc_attr['order']    = 'ASC';
            $wc_attr['meta_key'] = '_price';

        } elseif ($atts['show'] == 'price-desc'){

            $wc_attr['orderby']  = "meta_value_num {$wpdb->posts}.ID";
            $wc_attr['order']    = 'DESC';
            $wc_attr['meta_key'] = '_price';

        }


        $atts['wc_attr'] = $wc_attr;


        return rit_get_template_part('shortcode', 'product', array('atts' => $atts));

    }
}
if (!function_exists('products_carousel_script')) {
    function products_carousel_script()
    {
        wp_enqueue_script('owlCarousel', RIT_PLUGIN_URL . '/assets/js/owl.carousel.min.js', false, false, true);
    }
}

add_shortcode('rit_products', 'rit_shortcode_products');

add_action('vc_before_init', 'rit_product_integrate_vc');

if (!function_exists('rit_product_integrate_vc')) {
    function rit_product_integrate_vc()
    {
        vc_map(
            array(
                'name' => esc_html__('RIT Products', RIT_TEXT_DOMAIN),
                'base' => 'rit_products',
                'icon' => 'icon-rit',
                'category' => esc_html__('RIT', RIT_TEXT_DOMAIN),
                'description' => esc_html__('Show multiple products by ID or SKU.', RIT_TEXT_DOMAIN),
                'params' => array(
                    array(
                        'type' => 'textfield',
                        'heading' => esc_html__('Title', RIT_TEXT_DOMAIN),
                        'value' => '',
                        'param_name' => 'title',
                        'description' => esc_html__('Enter text used as shortcode title (Note: located above content element)', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        'type' => 'dropdown',
                        'heading' => esc_html__('Layout type', RIT_TEXT_DOMAIN),
                        'value' => array(
                            esc_html__('Carousel', RIT_TEXT_DOMAIN) => 'products_carousel',
                            esc_html__('Grid', RIT_TEXT_DOMAIN) => 'products_grid',
                            esc_html__('List', RIT_TEXT_DOMAIN) => 'products_list'
                        ),
                        'param_name' => 'products_type',
                        'description' => esc_html__('Select layout type for display product', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        'type' => 'dropdown',
                        'heading' => esc_html__('Image size', RIT_TEXT_DOMAIN),
                        'value' => array(
                            esc_html__('Thumbnail', RIT_TEXT_DOMAIN) => 'shop_thumbnail',
                            esc_html__('Catalog Images', RIT_TEXT_DOMAIN) => 'shop_catalog',
                            esc_html__('Single Product Image', RIT_TEXT_DOMAIN) => 'shop_single'
                        ),
                        'param_name' => 'products_img_size',
                        'description' => esc_html__('Select image size follow size in woocommerce product image size', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        'type' => 'dropdown',
                        'heading' => esc_html__('Column number', RIT_TEXT_DOMAIN),
                        'value' => array(
                            esc_html__('1 Columns', RIT_TEXT_DOMAIN) => 'columns1',
                            esc_html__('2 Columns', RIT_TEXT_DOMAIN) => 'columns2',
                            esc_html__('3 Columns', RIT_TEXT_DOMAIN) => 'columns3',
                            esc_html__('4 Columns', RIT_TEXT_DOMAIN) => 'columns4',
                            esc_html__('5 Columns', RIT_TEXT_DOMAIN) => 'columns5',
                            esc_html__('6 Columns', RIT_TEXT_DOMAIN) => 'columns6'
                        ),
                        'std' => 'columns3',
                        'param_name' => 'column',
                        'description' => esc_html__('Display product with the number of column', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        'type' => 'dropdown',
                        'heading' => esc_html__('"Asset type', RIT_TEXT_DOMAIN),
                        'value' => array(
                            esc_html__('All', RIT_TEXT_DOMAIN) => '',
                            esc_html__('Featured product', RIT_TEXT_DOMAIN) => 'featured',
                            esc_html__('Onsale product', RIT_TEXT_DOMAIN) => 'onsale',
                            esc_html__('Best Selling', RIT_TEXT_DOMAIN) => 'best-selling',
                            esc_html__('Latest product', RIT_TEXT_DOMAIN) => 'latest',
                            esc_html__('Top rate product', RIT_TEXT_DOMAIN) => 'toprate ',
                            esc_html__('Sort by price: low to high', RIT_TEXT_DOMAIN) => 'price',
                            esc_html__('Sort by price: high to low', RIT_TEXT_DOMAIN) => 'price-desc',
                        ),
                        'std' => '',
                        'param_name' => 'show',
                        'description' => esc_html__('Select asset type of products', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        'type' => 'dropdown',
                        'heading' => esc_html__('Order by', RIT_TEXT_DOMAIN),
                        'value' => array(
                            esc_html__('Date', RIT_TEXT_DOMAIN) => 'date',
                            esc_html__('Menu order', RIT_TEXT_DOMAIN) => 'menu_order',
                            esc_html__('Title', RIT_TEXT_DOMAIN) => 'title',
                        ),
                        'std' => 'date',
                        'param_name' => 'orderby',
                    ),
                    array(
                        'type' => 'textfield',
                        'heading' => esc_html__('Number of product', RIT_TEXT_DOMAIN),
                        'value' => 6,
                        'param_name' => 'posts_per_page',
                        'description' => esc_html__('Number of product showing', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        "type" => "dropdown",
                        "heading" => esc_html__("Ignore sticky posts", RIT_TEXT_DOMAIN),
                        "param_name" => "ignore_sticky_posts",
                        'std' => 1,
                        "value" => array(
                            esc_html__('No', RIT_TEXT_DOMAIN ) => 0,
                            esc_html__('Yes', RIT_TEXT_DOMAIN ) => 1,
                        ),
                    ),
                    array(
                        'type' => 'textfield',
                        'heading' => esc_html__('Custom Class', RIT_TEXT_DOMAIN),
                        'value' => '',
                        'param_name' => 'element_custom_class',
                        'description' => esc_html__('Style particular content element differently - add a class name and refer to it in custom CSS.', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        'type' => 'textfield',
                        'heading' => esc_html__('Bottom padding for the module', RIT_TEXT_DOMAIN),
                        'value' => '50px',
                        'param_name' => 'padding_bottom_module',
                        'description' => esc_html__('The space in bottom. Default is 50px', RIT_TEXT_DOMAIN),
                    ),
                    array(
                        "type" => "dropdown",
                        "heading" => esc_html__("Show Filter", RIT_TEXT_DOMAIN),
                        "param_name" => "show_filter",
                        'std' => 1,
                        "value" => array(
                            esc_html__('No', RIT_TEXT_DOMAIN ) => 0,
                            esc_html__('Yes', RIT_TEXT_DOMAIN ) => 1,
                        ),
                    ),
                    array(
                        "type" => "dropdown",
                        "heading" => esc_html__("Show Load More button", RIT_TEXT_DOMAIN),
                        "param_name" => "show_loadmore",
                        'std' => 1,
                        "value" => array(
                            esc_html__('No', RIT_TEXT_DOMAIN ) => 0,
                            esc_html__('Yes', RIT_TEXT_DOMAIN ) => 1,
                        ),
                    ),
                )
            )
        );
    }
}