Plugin Directory

Changeset 3202079


Ignore:
Timestamp:
12/04/2024 06:11:53 AM (12 months ago)
Author:
cubewp1211
Message:

New tag update 1.1.23

Location:
cubewp-framework/trunk/cube
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • cubewp-framework/trunk/cube/assets/admin/js/cubewp-admin.js

    r3155340 r3202079  
    179179                            alert(response.msg);
    180180                        }else{
     181                            var export_post_cards = false;
     182                            if ( jQuery('.export-form').find('#cwp_post_cards').length > 0 ) {
     183                                if ( jQuery('.export-form').find('#cwp_post_cards').is(':checked') ) {
     184                                    export_post_cards = true;
     185                                }
     186                            }
    181187                            var export_custom_forms = false;
    182188                            if ( jQuery('.export-form').find('#custom-forms-fields').length > 0 ) {
     
    186192                            }
    187193                            var _ajax_data = 'action=cwp_user_data&export=success&nonce='+cwp_vars_params.nonce;
     194                            if (export_post_cards) {
     195                                _ajax_data += '&export_post_cards=true';
     196                            }
    188197                            if (export_custom_forms) {
    189198                                _ajax_data += '&download_now=false';
     
    199208                                    }else{
    200209                                        if (export_custom_forms) {
     210                                            var custom_form_data = 'action=cwp_custom_forms&export=success&nonce='+cwp_vars_params.nonce;
     211                                            if (export_post_cards) {
     212                                                custom_form_data += '&export_post_cards=true';
     213                                            }
    201214                                            jQuery.ajax({
    202215                                                type: 'POST',
    203216                                                url: cwp_vars_params.ajax_url,
    204                                                 data: 'action=cwp_custom_forms&export=success&nonce='+cwp_vars_params.nonce,
     217                                                data: custom_form_data,
    205218                                                dataType: 'json',
    206219                                                success: function (response) {
  • cubewp-framework/trunk/cube/assets/frontend/css/cubewp-styles.css

    r2824477 r3202079  
    712712    margin: 0 0 0 0;
    713713}
     714
     715/* CSS For CubeWP Post Slider */
     716
     717/* slider style */
     718.cubewp-post-slider {
     719    position: relative;
     720}
     721
     722.cubewp-post-slider .slick-arrow {
     723    display: flex;
     724    align-items: center;
     725    justify-content: center;
     726    position: absolute;
     727    width: auto;
     728    height: fit-content;
     729    z-index: 999;
     730}
     731
     732/* slick dots style */
     733.cubewp-post-slider .slick-dots {
     734    padding: 0;
     735    margin: 0;
     736    width: fit-content;
     737    height: fit-content;
     738}
     739
     740.cubewp-post-slider .slick-dots li {
     741    list-style-type: none;
     742    display: flex;
     743    align-items: center;
     744}
     745
     746.cubewp-post-slider .slick-dots li button {
     747    padding: 0px;
     748    border: none;
     749    background: none;
     750    font-size: 0px;
     751    outline: none;
     752}
     753
     754/* progress bar */
     755.slick-progress {
     756    width: 100%;
     757    border-radius: 50px;
     758    position: relative;
     759}
     760
     761.slick-progress .slick-progress-bar {
     762    width: 0;
     763    border-radius: 50px;
     764    transition: width 0.3s ease;
     765}
  • cubewp-framework/trunk/cube/assets/frontend/js/cubewp-alerts.js

    r3165528 r3202079  
    66            if ($parent.hasClass("cwp-js-alert")) {
    77                $parent.hide();
    8             }else {
     8            } else {
    99                $parent.remove();
    1010            }
     
    4646        });
    4747    }
     48    //JQuery For CubeWP Post Slider
     49    if (jQuery('.cubewp-post-slider').length > 0) {
     50        jQuery('.cubewp-post-slider').each(function () {
     51            var sliderElement = jQuery(this);
     52            var prevArrowHtml = sliderElement.data('prev-arrow');
     53            var nextArrowHtml = sliderElement.data('next-arrow');
     54            var previcon_type = sliderElement.data('prev-icon-type');
     55            var nexticon_type = sliderElement.data('next-icon-type');
     56            var slidesToShow = sliderElement.data('slides-to-show');
     57            var slidesToScroll = sliderElement.data('slides-to-scroll');
     58            var slidesToShowTablet = sliderElement.data('slides-to-show-tablet');
     59            var slidesToShowTabletPortrait = sliderElement.data('slides-show-tablet-portrait');
     60            var slidesToShowMobile = sliderElement.data('slides-to-show-mobile');
     61            var slidesToScrollTablet = sliderElement.data('slides-to-scroll-tablet');
     62            var slidesToScrollTabletPortrait = sliderElement.data('slides-scroll-tablet-portrait');
     63            var slidesToScrollMobile = sliderElement.data('slides-to-scroll-mobile');
     64            var autoplay = sliderElement.data('autoplay') === true || sliderElement.data('autoplay') === 'true';
     65            var autoplaySpeed = sliderElement.data('autoplay-speed');
     66            var Speed = sliderElement.data('speed');
     67            var infinite = sliderElement.data('infinite') === true || sliderElement.data('infinite') === 'true';
     68            var variableWidth = sliderElement.data('variable-width') === true || sliderElement.data('variable-width') === 'true';
     69
     70            if (previcon_type) {
     71                var prevArrowButton = '<button type="button" class="slick-prev"><i class="' + prevArrowHtml + '"></i></button>';
     72            } else {
     73                var prevArrowButton = '<button type="button" class="slick-prev">' + prevArrowHtml + '</button>';
     74            }
     75            if (nexticon_type) {
     76                var nextArrowButton = '<button type="button" class="slick-next"><i class="' + nextArrowHtml + '"></i></button>';
     77            } else {
     78                var nextArrowButton = '<button type="button" class="slick-next">sadsads' + nextArrowHtml + '</button>';
     79            }
     80            var CustomArrows = sliderElement.data('custom-arrows') === true || sliderElement.data('custom-arrows') === 'true';
     81            var CustomDots = sliderElement.data('custom-dots') === true || sliderElement.data('custom-dots') === 'true';
     82            var enableProgressBar = sliderElement.data('enable-progress-bar') === true || sliderElement.data('enable-progress-bar') === 'true';
     83
     84            sliderElement.slick({
     85                slidesToShow: slidesToShow,
     86                slidesToScroll: slidesToScroll,
     87                autoplay: autoplay,
     88                autoplaySpeed: autoplaySpeed,
     89                speed: Speed,
     90                infinite: infinite,
     91                variableWidth: variableWidth,
     92                prevArrow: prevArrowButton,
     93                nextArrow: nextArrowButton,
     94                arrows: CustomArrows,
     95                dots: CustomDots,
     96                responsive: [{
     97                        breakpoint: 1025,
     98                        settings: {
     99                            slidesToShow: slidesToShowTablet,
     100                            slidesToScroll: slidesToScrollTablet
     101                        }
     102                    },
     103                    {
     104                        breakpoint: 768,
     105                        settings: {
     106                            slidesToShow: slidesToShowTabletPortrait,
     107                            slidesToScroll: slidesToScrollTabletPortrait
     108                        }
     109                    },
     110                    {
     111                        breakpoint: 481,
     112                        settings: {
     113                            slidesToShow: slidesToShowMobile,
     114                            slidesToScroll: slidesToScrollMobile
     115                        }
     116                    }
     117                ]
     118            });
     119            if (enableProgressBar == true) {
     120                sliderElement.after(
     121                    '<div class="slick-progress"><div class="slick-progress-bar"></div></div>'
     122                );
     123                var totalSlides = sliderElement.slick("getSlick").slideCount;
     124                sliderElement.on("afterChange", function (event, slick, currentSlide) {
     125                    var progress = ((currentSlide + 1) / totalSlides) * 100;
     126                    sliderElement.next('.slick-progress').find('.slick-progress-bar').css("width", progress + "%");
     127                });
     128            }
     129        });
     130    }
    48131});
    49132
     
    52135        $alert_class = '',
    53136        $cwp_alert_content = $cwp_alert.find('.cwp-alert-content');
    54        
     137
    55138    if ($cwp_alert.is(":visible") && $cwp_alert_content.html() === notification_content) {
    56139        return false;
     
    59142        $cwp_alert.find('.cwp-alert-close').trigger("click");
    60143    }
    61     if ( notification_type === 'success' ) {
     144    if (notification_type === 'success') {
    62145        $alert_class = 'cwp-alert-success';
    63     } else if ( notification_type === 'warning' ) {
     146    } else if (notification_type === 'warning') {
    64147        $alert_class = 'cwp-alert-warning';
    65     } else if ( notification_type === 'info' ) {
     148    } else if (notification_type === 'info') {
    66149        $alert_class = 'cwp-alert-info';
    67     } else if ( notification_type === 'error' ) {
     150    } else if (notification_type === 'error') {
    68151        $alert_class = 'cwp-alert-danger';
    69152    }
     
    90173        url: cwp_alert_ui_params.ajax_url,
    91174        type: 'POST',
    92         data : 'action=cubewp_save_post&post-id='+ pid + '&nonce=' + cwp_alert_ui_params.nonce,
     175        data: 'action=cubewp_save_post&post-id=' + pid + '&nonce=' + cwp_alert_ui_params.nonce,
    93176        dataType: "json",
    94177        success: function (response) {
    95178            cwp_notification_ui(response.type, response.msg);
    96             if( typeof response.text != 'undefined' && response.text != '' ){
     179            if (typeof response.text != 'undefined' && response.text != '') {
    97180                thisObj.addClass('cwp-saved-post');
    98181                thisObj.removeClass('cwp-save-post');
     
    111194        url: cwp_alert_ui_params.ajax_url,
    112195        type: 'POST',
    113         data : 'action=cubewp_remove_saved_posts&post-id='+ pid + '&nonce=' + cwp_alert_ui_params.nonce,
     196        data: 'action=cubewp_remove_saved_posts&post-id=' + pid + '&nonce=' + cwp_alert_ui_params.nonce,
    114197        dataType: "json",
    115198        success: function (response) {
    116199            cwp_notification_ui(response.type, response.msg);
    117             if( typeof response.text != 'undefined' && response.text != '' ){
    118                 if(action == 'remove'){
     200            if (typeof response.text != 'undefined' && response.text != '') {
     201                if (action == 'remove') {
    119202                    thisObj.closest('tr').remove();
    120203                }
  • cubewp-framework/trunk/cube/classes/class-cubewp-add-ons.php

    r3167922 r3202079  
    11<?php
    22
    3 if ( ! defined( 'ABSPATH' ) ) {
    4     exit; // Exit if accessed directly.
     3if (! defined('ABSPATH')) {
     4    exit; // Exit if accessed directly.
    55}
    6 class CubeWp_Add_Ons {
     6class CubeWp_Add_Ons
     7{
    78
    89    // API route
    910    public $route   = 'https://cubewp.com';
    1011
    11     // store URL
     12    // store URL
    1213    public $purchase_url   = 'https://cubewp.com/store';
    1314
     
    3031    public static $action   = 'edd_action';
    3132
    32     public function __construct() {
     33    public function __construct()
     34    {
    3335        //license system
    34         add_action( 'admin_init', array( $this, 'check_license' ) );
    35         add_action('admin_init', array( $this, 'updates_enable_for_free_addon'));
    36         add_action( 'admin_init', array( $this, 'check_for_plugin_update'), 0 );
    37         add_action( self::CUBEWP.'/'.self::ADDON.'/'.self::ACTI.self::VATION, array($this,'_plugins'), 9, 1 );
    38     }
    39 
    40     /**
    41      * all Add ons
    42      * @since 1.0
    43      * @version 1.1.8
    44      */
    45     public static function cubewp_add_ons() {
    46 
    47         return array(
    48             'cubewp-addon-frontend-pro' => array(
    49                 'item_name' => 'CubeWP Frontend Pro',
    50                 'slug' => 'cubewp-addon-frontend-pro',
    51                 'author' => 'Emraan Cheema',
    52                 'base' => 'cubewp-addon-frontend-pro/cubewp-frontend.php',
    53                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-frontend-pro/cube/',
    54                 'load' => CUBEWP.'_Frontend_Load',
    55             ),
    56             'cubewp-addon-payments' => array(
    57                 'item_name' => 'CubeWP Payments',
    58                 'slug' => 'cubewp-addon-payments',
    59                 'author' => 'Emraan Cheema',
    60                 'base' => 'cubewp-addon-payments/cubewp-payments.php',
    61                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-payments/cube/',
    62                 'load' => CUBEWP.'_Payments_Load',
    63             ),
    64             'cubewp-addon-inbox' => array(
    65                 'item_name' => 'CubeWP Inbox',
    66                 'slug' => 'cubewp-addon-inbox',
    67                 'author' => 'Emraan Cheema',
    68                 'base' => 'cubewp-addon-inbox/cubewp-inbox.php',
    69                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-inbox/cube/',
    70                 'load' => CUBEWP.'_Inbox_Load',
    71             ),
    72             'cubewp-addon-reviews' => array(
    73                 'item_name' => 'CubeWP Reviews',
    74                 'slug' => 'cubewp-addon-reviews',
    75                 'author' => 'Emraan Cheema',
    76                 'base' => 'cubewp-addon-reviews/cubewp-reviews.php',
    77                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-reviews/cube/',
    78                 'load' => CUBEWP.'_Reviews_Load',
    79             ),
    80             'cubewp-addon-booster' => array(
    81                 'item_name' => 'CubeWP Booster',
    82                 'slug' => 'cubewp-addon-booster',
    83                 'author' => 'Emraan Cheema',
    84                 'base' => 'cubewp-addon-booster/cubewp-booster.php',
    85                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-booster/cube/',
    86                 'load' => CUBEWP.'_Booster_Load',
    87             ),
    88             'cubewp-addon-claim' => array(
    89                 'item_name' => 'CubeWP Post Claim',
    90                 'slug' => 'cubewp-addon-claim',
    91                 'author' => 'Emraan Cheema',
    92                 'base' => 'cubewp-addon-claim/cubewp-claim.php',
    93                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-claim/cube/',
    94                 'load' => CUBEWP.'_Claim_Load',
    95                 'license_type' => 'free',
    96                 'key'   => '35a2833bea9bbf02ee48cb5fcce2e2cf',
    97             ),
    98             'cubewp-addon-social-login' => array(
    99                 'item_name' => 'CubeWP Social Login',
    100                 'slug' => 'cubewp-addon-social-login',
    101                 'author' => 'Emraan Cheema',
    102                 'base' => 'cubewp-addon-social-logins/cubewp-social-logins.php',
    103                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-social-logins/cube/',
    104                 'load' => CUBEWP.'_Social_Logins_Load',
    105                 'license_type' => 'free',
    106                 'key'   => '9663701ddf66d0f23096c3fb186726c5',
    107             ),
    108             'cubewp-addon-classified' => array(
    109                 'item_name' => 'CubeWP Classified',
    110                 'slug' => 'cubewp-addon-classified',
    111                 'author' => 'Emraan Cheema',
    112                 'base' => 'cubewp-addon-classified/cubewp-classified.php',
    113                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-classified/cube/',
    114                 'load' => CUBEWP.'_Classified_Load',
    115             ),
    116             'cubewp-addon-booking' => array(
    117                 'item_name' => 'CubeWP Booking',
    118                 'slug' => 'cubewp-addon-booking',
    119                 'author' => 'Emraan Cheema',
    120                 'base' => 'cubewp-addon-booking/cubewp-booking.php',
    121                 'path' => plugin_dir_path( dirname(dirname(__DIR__)) ).'cubewp-addon-booking/cube/',
    122                 'load' => CUBEWP.'_Booking_Load',
    123             )
    124         );
    125 
     36        add_action('admin_init', array($this, 'check_license'));
     37        add_action('admin_init', array($this, 'updates_enable_for_free_addon'));
     38        add_action('admin_init', array($this, 'check_for_plugin_update'), 0);
     39        add_action(self::CUBEWP . '/' . self::ADDON . '/' . self::ACTI . self::VATION, array($this, '_plugins'), 9, 1);
    12640    }
    12741
     
    13145     * @version 1.0
    13246     */
    133     public function _plugins($plugin) {
    134        
     47    public function _plugins($plugin)
     48    {
     49
    13550        global $wpdb;
    13651
     
    14055        $wp_version = $GLOBALS['wp_version'];
    14156
    142         if ( version_compare( $wp_version, '5.8', '<' ) )
    143             $message[] = __( 'This CubeWP Add-on requires WordPress 4.0 or higher. Version detected:', 'cubewp-frontend' ) . ' ' . $wp_version;
     57        if (version_compare($wp_version, '5.8', '<'))
     58            $message[] = __('This CubeWP Add-on requires WordPress 4.0 or higher. Version detected:', 'cubewp-frontend') . ' ' . $wp_version;
    14459
    14560        // PHP check
    14661        $php_version = phpversion();
    147         if ( version_compare( $php_version, '5.3', '<' ) )
    148             $message[] = __( 'This CubeWP Add-on requires PHP 5.3 or higher. Version detected: ', 'cubewp-frontend' ) . ' ' . $php_version;
     62        if (version_compare($php_version, '5.3', '<'))
     63            $message[] = __('This CubeWP Add-on requires PHP 5.3 or higher. Version detected: ', 'cubewp-frontend') . ' ' . $php_version;
    14964
    15065        // SQL check
    15166        $sql_version = $wpdb->db_version();
    152         if ( version_compare( $sql_version, '5.0', '<' ) )
    153             $message[] = __( 'This CubeWP Add-on requires SQL 5.0 or higher. Version detected: ', 'cubewp-frontend' ) . ' ' . $sql_version;
     67        if (version_compare($sql_version, '5.0', '<'))
     68            $message[] = __('This CubeWP Add-on requires SQL 5.0 or higher. Version detected: ', 'cubewp-frontend') . ' ' . $sql_version;
    15469
    15570        // Not empty $message means there are issues
    156         if ( ! empty( $message ) ) {
    157 
    158             $error_message = implode( "\n", $message );
    159             die( __( 'Sorry but your WordPress installation does not reach the minimum requirements for running this add-on. The following errors were given:', 'cubewp-frontend' ) . "\n" . $error_message );
    160 
     71        if (! empty($message)) {
     72
     73            $error_message = implode("\n", $message);
     74            die(__('Sorry but your WordPress installation does not reach the minimum requirements for running this add-on. The following errors were given:', 'cubewp-frontend') . "\n" . $error_message);
    16175        }
    16276
    16377        return $this->add_on_management($plugin);
    164 
    16578    }
    16679
     
    17184     */
    17285
    173     public function add_on_management($plugin) {
    174 
    175         $add_ons = self::cubewp_add_ons();
    176         if(function_exists('CWP')){
     86    public function add_on_management($plugin)
     87    {
     88
     89        $add_ons = CWP()->cubewp_get_modules();
     90        if (function_exists('CWP')) {
    17791
    17892            $not_our_plugin = mb_convert_encoding("\x53\x6f\x72\x72\x79\x21\x20\x54\x68\x69\x73\x20\x69\x73\x20\x6e\x6f\x74\x20\x22\x43\x75\x62\x65\x57\x50\x22\x20\x70\x6c\x75\x67\x69\x6e", 'UTF-8', 'ASCII');
    17993
    180             if(isset($add_ons[$plugin])){
     94            if (isset($add_ons[$plugin])) {
    18195
    18296                $path = $add_ons[$plugin]['path'];
    18397                $item_name = $add_ons[$plugin]['item_name'];
    18498                $slug = $add_ons[$plugin]['slug'];
    185                 $license_type = isset($add_ons[$plugin]['license_type']) ? $add_ons[$plugin]['license_type']: '';
     99                $license_type = isset($add_ons[$plugin]['license_type']) ? $add_ons[$plugin]['license_type'] : '';
    186100                $file = $path . "config.txt";
    187101
    188                 if(empty(CWP()->cubewp_options($slug))){
    189                    
     102                if (empty(CWP()->cubewp_options($slug))) {
     103
    190104                    $lic_is_not_valid = mb_convert_encoding("\x53\x6f\x72\x72\x79\x21\x20\x59\x6f\x75\x72\x20\x6c\x69\x63\x65\x6e\x73\x65\x20\x69\x73\x20\x6e\x6f\x74\x20\x76\x61\x6c\x69\x64\x2c\x20\x45\x72\x72\x6f\x72\x20\x63\x6f\x64\x65\x20\x69\x73\x3a", 'UTF-8', 'ASCII');
    191105                    $file_is_not_valid = mb_convert_encoding("\x53\x6f\x72\x72\x79\x21\x20\x54\x68\x69\x73\x20\x70\x6c\x75\x67\x69\x6e\x20\x66\x69\x6c\x65\x20\x69\x73\x20\x6e\x6f\x74\x20\x76\x61\x6c\x69\x64", 'UTF-8', 'ASCII');
     
    193107
    194108
    195                     if ( file_exists ( $file ) ) {
    196 
    197                         $key = file_get_contents ( $file );
     109                    if (file_exists($file)) {
     110
     111                        $key = file_get_contents($file);
    198112
    199113                        // If plugin is free
    200                         if($license_type == 'free'){
    201                             CWP()->update_cubewp_options($slug.'_key', $key);
    202                             unlink ( $file );
     114                        if ($license_type == 'free') {
     115                            CWP()->update_cubewp_options($slug . '_key', $key);
     116                            unlink($file);
    203117                            return;
    204118                        }
    205119
    206                         // data to send in our API request
    207                         $api_params = array(
    208                             'edd_action'=> 'activate_license',
    209                             'license'   => $key,
    210                             'item_name' => urlencode( $item_name ),
    211                             'url'       => home_url()
    212                         );
    213            
    214                         // Call the custom API.
    215                         $response = wp_remote_post( $this->route, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
     120                        // data to send in our API request
     121                        $api_params = array(
     122                            'edd_action' => 'activate_license',
     123                            'license'   => $key,
     124                            'item_name' => urlencode($item_name),
     125                            'url'       => home_url()
     126                        );
     127
     128                        // Call the custom API.
     129                        $response = wp_remote_post($this->route, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
    216130                        // make sure the response came back okay
    217                         if ( is_wp_error( $response ) ) {
    218                             die($file_is_not_valid);
    219                         }
    220                         // decode the license data
    221                         $response_data = json_decode( wp_remote_retrieve_body( $response ) );
    222                        
    223                         if(isset($response_data->license)){
    224                             if ( 'valid' != $response_data->license ) {
     131                        if (is_wp_error($response)) {
     132                            die($file_is_not_valid);
     133                        }
     134                        // decode the license data
     135                        $response_data = json_decode(wp_remote_retrieve_body($response));
     136
     137                        if (isset($response_data->license)) {
     138                            if ('valid' != $response_data->license) {
    225139                                die($lic_is_not_valid);
    226                             }else{
     140                            } else {
    227141                                CWP()->update_cubewp_options($slug, $response_data);
    228                                 CWP()->update_cubewp_options($slug.'_key', $key);
    229                                 CWP()->update_cubewp_options($slug.'-status', $response_data->license);
     142                                CWP()->update_cubewp_options($slug . '_key', $key);
     143                                CWP()->update_cubewp_options($slug . '-status', $response_data->license);
    230144                            }
    231                         }else{
     145                        } else {
    232146                            die($lic_is_not_valid);
    233147                        }
    234                         unlink ( $file );
    235                     }else{
     148                        unlink($file);
     149                    } else {
    236150                        //file not good
    237                         die($need_fresh_file);
     151                        die($need_fresh_file);
    238152                    }
    239153                }
    240 
    241             }else{
     154            } else {
    242155                //Plugin not good
    243                 die($not_our_plugin);
    244             }
    245         }
    246        
     156                die($not_our_plugin);
     157            }
     158        }
    247159    }
    248160
     
    252164     * @version 1.1
    253165     */
    254     public function check_for_plugin_update( ) {
    255 
    256         $add_ons = self::cubewp_add_ons();
    257         foreach($add_ons as $key => $add_on){
    258             $item_name = $add_on['item_name'];
    259             $author = $add_on['author'];
    260             $slug = $add_on['slug'];
    261             $base = $add_on['base'];
    262             $Lkey = CWP()->cubewp_options($slug.'_key');
    263             $Lstatus = CWP()->cubewp_options($slug.'-status');
    264             if($Lkey && is_plugin_active($base) ){
    265                 $plugin = get_plugin_data( plugin_dir_path( dirname(dirname(__DIR__)) ).$base, false, false );
    266                 // setup the updater
    267                 new CubeWp_Plugin_Updater( $this->route, $base, array(
    268                         'version' => $plugin['Version'],
    269                         'license' => $Lkey,
    270                         'item_name' => $item_name,
    271                         'author' => $author
    272                     ),
    273                     array(
    274                         'license_status' => $Lstatus,
    275                         'admin_page_url' => admin_url( 'admin.php?page=cube_wp_dashboard' ),
    276                         'purchase_url' => $this->purchase_url,
    277                         'plugin_title' => 'Dashboard'
    278                     )
    279                 );
    280             }
    281         }
    282     }
    283 
    284     public function check_license() {
     166    public function check_for_plugin_update()
     167    {
     168        $add_ons = CWP()->cubewp_get_modules();
     169        foreach ($add_ons as $key => $add_on) {
     170            $item_name = $add_on['item_name'];
     171            $author = $add_on['author'];
     172            $slug = $add_on['slug'];
     173            $base = $add_on['base'];
     174            $Lkey = CWP()->cubewp_options($slug . '_key');
     175            $Lstatus = CWP()->cubewp_options($slug . '-status');
     176
     177            // Check if the transient exists
     178            if (get_transient($slug . '_update_check')) {
     179                continue; // Skip if transient exists
     180            }
     181            if ($Lkey && is_plugin_active($base)) {
     182                $plugin = get_plugin_data(plugin_dir_path(dirname(dirname(__DIR__))) . $base, false, false);
     183                // Set up the updater
     184                new CubeWp_Plugin_Updater(
     185                    $this->route,
     186                    $base,
     187                    array(
     188                        'version'    => $plugin['Version'],
     189                        'license'    => $Lkey,
     190                        'item_name'  => $item_name,
     191                        'author'     => $author,
     192                    ),
     193                    array(
     194                        'license_status' => $Lstatus,
     195                        'admin_page_url' => admin_url('admin.php?page=cube_wp_dashboard'),
     196                        'purchase_url'   => $this->purchase_url,
     197                        'plugin_title'   => 'Dashboard',
     198                    )
     199                );
     200                set_transient(
     201                    $slug . '_update_check',
     202                    true,
     203                    24 * HOUR_IN_SECONDS
     204                );
     205            }
     206        }
     207    }
     208
     209    public function check_license()
     210    {
    285211        $transient = false;
    286         $add_ons = self::cubewp_add_ons();
    287         foreach($add_ons as $key => $add_on){
    288             $item_name = $add_on['item_name'];
    289             $author = $add_on['author'];
    290             $slug = $add_on['slug'];
    291             $base = $add_on['base'];
    292             if ( get_transient( $slug . '_checking' ) ){
     212        $add_ons = CWP()->cubewp_get_modules();
     213        foreach ($add_ons as $key => $add_on) {
     214            $item_name = $add_on['item_name'];
     215            $author = $add_on['author'];
     216            $slug = $add_on['slug'];
     217            $base = $add_on['base'];
     218            if (get_transient($slug . '_checking')) {
    293219                $transient = true;
    294220            }
    295             if(is_plugin_active($base) && $transient == false){
    296                 $Lkey = CWP()->cubewp_options($slug.'_key');
    297                 if($Lkey){
     221            if (is_plugin_active($base) && $transient == false) {
     222                $Lkey = CWP()->cubewp_options($slug . '_key');
     223                if ($Lkey) {
    298224                    $api_params = array(
    299225                        'edd_action' => 'check_license',
    300226                        'license' => $Lkey,
    301                         'item_name' => urlencode( $item_name ),
    302                         'url'       => get_bloginfo( 'url' ),
     227                        'item_name' => urlencode($item_name),
     228                        'url'       => get_bloginfo('url'),
    303229                    );
    304230
     
    312238                        )
    313239                    );
    314                    
    315                     if ( is_wp_error( $response ) )
     240
     241                    if (is_wp_error($response))
    316242                        return false;
    317            
     243
    318244                    $license_data = json_decode(
    319                         wp_remote_retrieve_body( $response )
     245                        wp_remote_retrieve_body($response)
    320246                    );
    321247
    322                     if ( isset($license_data->license)){
    323                         if ( $license_data->license != 'valid' ) {
     248                    if (isset($license_data->license)) {
     249                        if ($license_data->license != 'valid') {
    324250                            $this->update_plugin_data($slug, $license_data->license);
    325                         }else{
    326                             CWP()->update_cubewp_options($slug.'-status', $license_data->license);
     251                        } else {
     252                            CWP()->update_cubewp_options($slug . '-status', $license_data->license);
    327253                            CWP()->update_cubewp_options($slug, $license_data);
    328254                        }
    329255                    }
    330            
     256
    331257                    // Set to check again in 12 hours
    332258                    set_transient(
    333259                        $slug . '_checking',
    334260                        $license_data,
    335                         ( 60 * 60 * 12 )
     261                        (60 * 60 * 24)
    336262                    );
    337                    
    338263                }
    339264            }
    340         }
    341     }
    342 
    343 
    344     private function update_plugin_data($slug, $status){
    345         if(empty($slug))
    346         return false;
    347 
    348         if($status == 'invalid') {
     265        }
     266    }
     267
     268
     269    private function update_plugin_data($slug, $status)
     270    {
     271        if (empty($slug))
    349272            return false;
    350         }
    351        
    352         if($status == 'expired'){
    353             CWP()->update_cubewp_options($slug.'-status', 'expired');
    354         }
    355 
    356         if($status == self::DIS){
    357             CWP()->update_cubewp_options($slug.'-status', self::DIS);
     273
     274        if ($status == 'invalid') {
     275            return false;
     276        }
     277
     278        if ($status == 'expired') {
     279            CWP()->update_cubewp_options($slug . '-status', 'expired');
     280        }
     281
     282        if ($status == self::DIS) {
     283            CWP()->update_cubewp_options($slug . '-status', self::DIS);
    358284            CWP()->update_cubewp_options($slug, '');
    359285            return false;
     
    361287    }
    362288
    363     public function updates_enable_for_free_addon() {
     289    public function updates_enable_for_free_addon()
     290    {
    364291        //cwp_pre(get_option('cubewp-addon-social-logins_key'));
    365292        //delete_option('cubewp-addon-social-logins_key');
    366293
    367         $add_ons = self::cubewp_add_ons();
     294        $add_ons = CWP()->cubewp_get_modules();
    368295        $all_plugins = array('cubewp-addon-claim');
    369         foreach($all_plugins as $plugin){
    370             if(isset($add_ons[$plugin])){
     296        foreach ($all_plugins as $plugin) {
     297            if (isset($add_ons[$plugin])) {
    371298                $path = $add_ons[$plugin]['path'];
    372299                $slug = $add_ons[$plugin]['slug'];
    373                 $license_type = isset($add_ons[$plugin]['license_type']) ? $add_ons[$plugin]['license_type']: '';
     300                $license_type = isset($add_ons[$plugin]['license_type']) ? $add_ons[$plugin]['license_type'] : '';
    374301                $file = $path . "config.txt";
    375                 $existing_key = get_option($slug.'_key');
     302                $existing_key = get_option($slug . '_key');
    376303                if (empty($existing_key) && $license_type == 'free') {
    377304                    // If file exists
    378                     if(file_exists($file)){
    379                         $key = file_get_contents ( $file );
    380                         CWP()->update_cubewp_options($slug.'_key', $key);
    381                         unlink ( $file );
     305                    if (file_exists($file)) {
     306                        $key = file_get_contents($file);
     307                        CWP()->update_cubewp_options($slug . '_key', $key);
     308                        unlink($file);
    382309                        return;
    383                     }else{
    384                         $key = isset($add_ons[$plugin]['key']) ? $add_ons[$plugin]['key']: '';
    385                         CWP()->update_cubewp_options($slug.'_key', $key);
     310                    } else {
     311                        $key = isset($add_ons[$plugin]['key']) ? $add_ons[$plugin]['key'] : '';
     312                        CWP()->update_cubewp_options($slug . '_key', $key);
    386313                        return;
    387314                    }
    388 
    389315                }
    390316            }
     
    392318    }
    393319
    394     public static function init() {
    395         $CubeClass = __CLASS__;
    396         new $CubeClass;
    397     }
     320    public static function init()
     321    {
     322        $CubeClass = __CLASS__;
     323        new $CubeClass;
     324    }
    398325}
  • cubewp-framework/trunk/cube/classes/class-cubewp-enqueue.php

    r3155340 r3202079  
    182182                'version' => CUBEWP_VERSION,
    183183            ),
     184            'cubewp-slick'             => array(
     185                'src'     => CWP_PLUGIN_URI . 'cube/assets/lib/slick/slick.js',
     186                'deps'    => array( 'jquery' ),
     187                'version' => CUBEWP_VERSION,
     188            ),
    184189        );
    185190        $register_scripts = apply_filters( 'frontend/script/register', $register_scripts );
     
    263268            'cubewp-pretty-photo'  => array(
    264269                'src'     => CWP_PLUGIN_URI . 'cube/assets/lib/pretty-photo/css/prettyPhoto.css',
     270                'deps'    => array(),
     271                'version' => CUBEWP_VERSION,
     272                'media'   => 'all',
     273                'has_rtl' => false,
     274            ),
     275            'cubewp-slick'  => array(
     276                'src'     =>  CWP_PLUGIN_URI . 'cube/assets/lib/slick/slick.css',
    265277                'deps'    => array(),
    266278                'version' => CUBEWP_VERSION,
  • cubewp-framework/trunk/cube/classes/class-cubewp-export.php

    r3155340 r3202079  
    183183                       value="cwp_settings" checked="checked">
    184184                <label for="cwp_settings"><?php esc_html_e('CubeWP Settings', 'cubewp-framework'); ?></label>
     185            </div>
     186            <div class="cubewp-export-option">
     187                <input type="checkbox" id="cwp_post_cards" name="cwp_export_content_type[]"
     188                    value="cwp_post_cards" checked="checked">
     189                <label for="cwp_post_cards"><?php esc_html_e('CubeWP Post Cards', 'cubewp-framework'); ?></label>
    185190            </div>
    186191        </div>
     
    381386    }
    382387
    383     private function cwp_create_zip_file($final = false){
    384 
     388    private function cwp_create_zip_file($final = false)
     389    {
    385390        $files = self::cwp_file_names();
    386391        $zip = new ZipArchive();
    387392
    388         $DelFilePath = $files['file_name'].".zip";
     393        $DelFilePath = $files['file_name'] . ".zip";
    389394        $upload_dir = wp_upload_dir();
    390         if(file_exists($upload_dir['path'] . '/cubewp/export/'.$DelFilePath)) {
    391 
    392             unlink ($upload_dir['path'] . '/cubewp/export/'.$DelFilePath);
    393 
    394         }
    395         if ($zip->open($upload_dir['path'] . '/cubewp/export/'.$DelFilePath, ZIPARCHIVE::CREATE) != TRUE) {
    396                 die ("Could not open archive");
    397         }
    398             $zip->addFile($files['setup_file'],'cwp-setup.json');
    399             $zip->addFile($files['cwp_post_groups'],'cwp_post_groups.json');
    400             $zip->addFile($files['cwp_user_groups'],'cwp_user_groups.json');
    401             $zip->addFile($files['cwp_custom_forms'],'cwp_custom_forms.json');
    402         // close and save archive
    403 
     395        $export_path = $upload_dir['path'] . '/cubewp/export/';
     396        $post_cards_dir = $upload_dir['basedir'] . '/cubewp-post-cards';
     397
     398        if (!is_dir($export_path)) {
     399            mkdir($export_path, 0755, true); // Ensure export directory exists
     400        }
     401
     402        if (file_exists($export_path . $DelFilePath)) {
     403            unlink($export_path . $DelFilePath);
     404        }
     405
     406        if ($zip->open($export_path . $DelFilePath, ZIPARCHIVE::CREATE) !== TRUE) {
     407            die("Could not open archive");
     408        }
     409
     410        // Add files to the zip archive
     411        $zip->addFile($files['setup_file'], 'cwp-setup.json');
     412        $zip->addFile($files['cwp_post_groups'], 'cwp_post_groups.json');
     413        $zip->addFile($files['cwp_user_groups'], 'cwp_user_groups.json');
     414        $zip->addFile($files['cwp_custom_forms'], 'cwp_custom_forms.json');
     415
     416        $export_post_cards = isset($_POST['export_post_cards']) ? sanitize_text_field($_POST['export_post_cards']) : 'false';
     417        // Add "cubewp-post-cards" to the zip archive
     418        if ($export_post_cards == 'true' && is_dir($post_cards_dir)) {
     419            $this->add_post_cards_folder_to_zip($post_cards_dir, $zip, 'cubewp-post-cards');
     420        }
     421
     422        // Close and save archive
    404423        $zip->close();
    405         unlink ($files['setup_file']);
    406         unlink ($files['cwp_post_groups']);
    407         unlink ($files['cwp_user_groups']);
    408         unlink ($files['cwp_custom_forms']);
    409 
    410     }
     424
     425        // Cleanup temporary files
     426        unlink($files['setup_file']);
     427        unlink($files['cwp_post_groups']);
     428        unlink($files['cwp_user_groups']);
     429        unlink($files['cwp_custom_forms']);
     430    }
     431
     432    /**
     433     * Recursively add a folder and its contents to a zip archive.
     434     *
     435     * @param string $folder Source folder path.
     436     * @param ZipArchive $zip ZipArchive instance.
     437     * @param string $parent_folder Parent folder path inside the zip file.
     438     */
     439    private function add_post_cards_folder_to_zip($folder, $zip, $parent_folder = '')
     440    {
     441        $files = scandir($folder);
     442        foreach ($files as $file) {
     443            if ($file === '.' || $file === '..') {
     444                continue;
     445            }
     446
     447            $file_path = $folder . '/' . $file;
     448            $zip_path = $parent_folder ? $parent_folder . '/' . $file : $file;
     449
     450            if (is_dir($file_path)) {
     451                // Add directory and its contents
     452                $zip->addEmptyDir($zip_path);
     453                $this->add_post_cards_folder_to_zip($file_path, $zip, $zip_path);
     454            } else {
     455                // Add file to zip
     456                $zip->addFile($file_path, $zip_path);
     457            }
     458        }
     459    }
     460
    411461    /**
    412462     * Method cwp_file_force_contents
  • cubewp-framework/trunk/cube/classes/class-cubewp-import.php

    r3155340 r3202079  
    11<?php
     2
    23/**
    34 * CubeWp Import to import only cubewp related data.
     
    78 */
    89
    9 if ( ! defined( 'ABSPATH' ) ) {
    10     exit;
     10if (! defined('ABSPATH')) {
     11    exit;
    1112}
    1213
     
    1516 * CubeWp_Import
    1617 */
    17 class CubeWp_Import {
     18class CubeWp_Import
     19{
    1820    public static $terms = array();
    19     public function __construct(){
     21    public function __construct()
     22    {
    2023        add_action('cubewp_import', array($this, 'manage_import'));
    2124        add_action('wp_ajax_cwp_import_data', array($this, 'cwp_import_data_callback'));
    2225        add_action('wp_ajax_cwp_import_dummy_data', array($this, 'cwp_import_dummy_data_callback'));
    23         if(isset($_GET['import']) && $_GET['import'] == 'success') {
     26        if (isset($_GET['import']) && $_GET['import'] == 'success') {
    2427            new CubeWp_Admin_Notice("cubewp-import-success", esc_html__('Data Imported Successfully', 'cubewp-framework'), 'success', false);
    2528        }
    2629    }
    27        
     30
    2831    /**
    2932     * Method init
     
    3134     * @return void
    3235     */
    33     public static function init() {
     36    public static function init()
     37    {
    3438        $CubeClass = __CLASS__;
    3539        new $CubeClass;
    3640    }
    37        
     41
    3842    /**
    3943     * Method manage_import
     
    4145     * @since  1.0.0
    4246     */
    43     public function manage_import(){
    44         if(isset($_GET['import']) && $_GET['import'] == 'success' && isset($_SESSION['terms'])){
    45             $this->cwp_import_terms( cubewp_core_data($_SESSION['terms']) );
     47    public function manage_import()
     48    {
     49        if (isset($_GET['import']) && $_GET['import'] == 'success' && isset($_SESSION['terms'])) {
     50            $this->cwp_import_terms(cubewp_core_data($_SESSION['terms']));
    4651            session_destroy();
    4752        }
    48        ?>
     53?>
    4954        <div id="cubewp-import" class="imp-exp">
    5055            <div class="cubewp-page-header">
     
    5762            <form id="import_form" method="post" action="" enctype="multipart/form-data">
    5863                <input type="hidden" name="action" value="cwp_import_data">
    59                 <input type="hidden" name="cwp_import_nonce" value="<?php echo wp_create_nonce( 'cwp_import_data_nonce' ); ?>">
     64                <input type="hidden" name="cwp_import_nonce" value="<?php echo wp_create_nonce('cwp_import_data_nonce'); ?>">
    6065                <div class="cubewp-import-box-container">
    6166                    <div class="cubewp-import-box">
     
    9499            </form>
    95100        </div>
    96         <?php
    97     }   
     101<?php
     102    }
    98103    /**
    99104     * Method rmdir_recursive
     
    104109     * @since  1.0.0
    105110     */
    106     public function rmdir_recursive($dir) {
    107         foreach(scandir($dir) as $file) {
    108            if ('.' === $file || '..' === $file) continue;
    109            if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
    110            else unlink("$dir/$file");
    111        }
    112 
    113        rmdir($dir);
    114     }   
     111    public function rmdir_recursive($dir)
     112    {
     113        if (!is_dir($dir)) {
     114            return false; // Return false if $dir is not a directory
     115        }
     116
     117        foreach (scandir($dir) as $file) {
     118            if ($file === '.' || $file === '..') {
     119                continue; // Skip special entries
     120            }
     121
     122            $file_path = "$dir/$file";
     123            if (is_dir($file_path)) {
     124                $this->rmdir_recursive($file_path); // Recursive call
     125            } else {
     126                unlink($file_path); // Delete file
     127            }
     128        }
     129
     130        return rmdir($dir); // Remove directory and return result
     131    }
    115132    /**
    116133     * Method cwp_import_data_callback
     
    119136     * @since  1.0.0
    120137     */
    121     public function cwp_import_data_callback(){
    122         if ( ! current_user_can( 'manage_options' ) ) {
    123             // User doesn't have the required capabilities
    124             wp_send_json( array( 'success' => 'false', 'msg' => esc_html__( "You do not have permission to perform this action.", 'cubewp-framework' ) ) );
    125         }
    126         if ( isset( $_FILES["file"]["name"] ) && isset( $_POST['cwp_import_nonce'] ) && wp_verify_nonce( $_POST['cwp_import_nonce'], 'cwp_import_data_nonce' ) ) {
     138    public function cwp_import_data_callback()
     139    {
     140        if (! current_user_can('manage_options')) {
     141            // User doesn't have the required capabilities
     142            wp_send_json(array('success' => 'false', 'msg' => esc_html__("You do not have permission to perform this action.", 'cubewp-framework')));
     143        }
     144        if (isset($_FILES["file"]["name"]) && isset($_POST['cwp_import_nonce']) && wp_verify_nonce($_POST['cwp_import_nonce'], 'cwp_import_data_nonce')) {
    127145            $import_file = $_FILES;
    128146            $filename = sanitize_file_name($import_file["file"]["name"]);
     
    132150            $name = explode(".", $filename);
    133151            $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
    134             foreach($accepted_types as $mime_type) {
    135                 if($mime_type == $type) {
     152            foreach ($accepted_types as $mime_type) {
     153                if ($mime_type == $type) {
    136154                    $okay = true;
    137155                    break;
    138                 } 
     156                }
    139157            }
    140158
    141159            $continue = strtolower($name[1]) == 'zip' ? true : false;
    142             if(!$continue) {
    143                 wp_send_json( array( 'success' => 'false', 'msg' => esc_html__("The file you are trying to upload is not a .zip file. Please try again.", 'cubewp-framework')) );
     160            if (!$continue) {
     161                wp_send_json(array('success' => 'false', 'msg' => esc_html__("The file you are trying to upload is not a .zip file. Please try again.", 'cubewp-framework')));
    144162            }
    145163
     
    147165            $upload_dir = wp_upload_dir();
    148166            $path  = $upload_dir['path'] . '/cubewp/import/';  // absolute path to the directory where zipper.php is in
    149             if ( ! is_dir($path)) {
     167            if (! is_dir($path)) {
    150168                mkdir($path, 0777, true);
    151169            }
    152             $filenoext = basename ($filename, '.zip');  // absolute path to the directory where zipper.php is in (lowercase)
    153             $filenoext = basename ($filenoext, '.ZIP');  // absolute path to the directory where zipper.php is in (when uppercase)
     170            $filenoext = basename($filename, '.zip');  // absolute path to the directory where zipper.php is in (lowercase)
     171            $filenoext = basename($filenoext, '.ZIP');  // absolute path to the directory where zipper.php is in (when uppercase)
    154172
    155173            $targetdir = $path . $filenoext; // target directory
     
    159177            /* target directory is same as filename without extension */
    160178
    161             if (is_dir($targetdir))  $this->rmdir_recursive ( $targetdir);
     179            if (is_dir($targetdir))  $this->rmdir_recursive($targetdir);
    162180
    163181            mkdir($targetdir, 0777);
     
    165183            /* here it is really happening */
    166184
    167             if(move_uploaded_file($source, $targetzip)) {
     185            if (move_uploaded_file($source, $targetzip)) {
    168186                $zip = new ZipArchive();
    169187                $x = $zip->open($targetzip);  // open the zip file to extract
     
    171189                    $zip->extractTo($targetdir); // place in the directory with same name 
    172190                    $zip->close();
    173 
    174191                    unlink($targetzip);
    175192                }
    176193                $moved = true;
    177             } else {   
     194            } else {
    178195                $moved = false;
    179                 wp_send_json( array( 'success' => 'false', 'msg' => esc_html__("There is something wrong, Maybe your directory permission is an issue.", 'cubewp-framework')) );
    180             }
    181             if($moved == true && $targetdir != ''){
    182                
     196                wp_send_json(array('success' => 'false', 'msg' => esc_html__("There is something wrong, Maybe your directory permission is an issue.", 'cubewp-framework')));
     197            }
     198            if ($moved == true && $targetdir != '') {
    183199                $setup_file = $this->cwp_import_files(true);
    184                 if(file_exists($targetdir.$setup_file)){
     200                if (file_exists($targetdir . $setup_file)) {
    185201                    self::cwp_import_cubewp_data($targetdir, $setup_file);
    186202                }
    187203
    188204                $content_files = $this->cwp_import_files();
    189                 if(is_array($content_files)){
    190                     foreach($content_files as $content_file){
    191                         if(file_exists($targetdir.$content_file)){
     205                if (is_array($content_files)) {
     206                    foreach ($content_files as $content_file) {
     207                        if (file_exists($targetdir . $content_file)) {
    192208                            $message = self::cwp_import_wordpress_content($targetdir, $content_file);
    193209                        }
    194210                    }
    195211                }
     212                $post_card_dir = $targetdir  . '/cubewp-post-cards';
     213                $post_card_php = $post_card_dir  . '/cubewp-post-cards.php';
     214                $post_card_css = $post_card_dir  . '/cubewp-post-cards.css';
     215                if (is_dir($post_card_dir)) {
     216                    if (file_exists($post_card_php) && file_exists($post_card_css)) {
     217                        $this->copy_cubewp_post_cards($post_card_dir);
     218                    }
     219                }
    196220                $message = !empty($message) ? $message : esc_html__('Data imported successfull.', 'cubewp-framework');
    197                 $this->rmdir_recursive ( $targetdir);
    198                 wp_send_json( array( 'success' => 'true', 'msg' => $message, 'redirectURL' => admin_url('admin.php?page=cubewp-import&import=success') ) );
    199             }
    200            
     221                $this->rmdir_recursive($targetdir);
     222                wp_send_json(array('success' => 'true', 'msg' => $message, 'redirectURL' => admin_url('admin.php?page=cubewp-import&import=success')));
     223            }
     224
    201225            wp_die();
    202         }else {
    203             wp_send_json( array( 'success' => 'false', 'msg' => esc_html__("Please upload a zip file to import data.", 'cubewp-framework')) );
     226        } else {
     227            wp_send_json(array('success' => 'false', 'msg' => esc_html__("Please upload a zip file to import data.", 'cubewp-framework')));
    204228        }
    205229    }
     
    211235     * @since  1.0.0
    212236     */
    213     public function cwp_import_dummy_data_callback(){
    214         if ( !current_user_can('manage_options') ) {
    215             wp_send_json( array( 'success' => 'false', 'msg' => esc_html__('You do not have permission to perform this action.', 'cubewp-framework') ) );
     237    public function cwp_import_dummy_data_callback()
     238    {
     239        if (!current_user_can('manage_options')) {
     240            wp_send_json(array('success' => 'false', 'msg' => esc_html__('You do not have permission to perform this action.', 'cubewp-framework')));
    216241            wp_die();
    217242        }
    218         if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'cubewp-admin-nonce') ) {
    219             wp_send_json( array( 'success' => 'false', 'msg' => esc_html__('Invalid nonce. You are not authorized to perform this action.', 'cubewp-framework') ) );
     243        if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'cubewp-admin-nonce')) {
     244            wp_send_json(array('success' => 'false', 'msg' => esc_html__('Invalid nonce. You are not authorized to perform this action.', 'cubewp-framework')));
    220245            wp_die();
    221246        }
    222         if(isset($_POST['data_type']) && $_POST['data_type'] == 'dummy'){
     247        if (isset($_POST['data_type']) && $_POST['data_type'] == 'dummy') {
    223248            $plugin_targetdir = CWP_PLUGIN_PATH . 'cube/includes/setup/';
    224             $targetdir = apply_filters( 'cubewp/import/content/path', $plugin_targetdir );
     249            $targetdir = apply_filters('cubewp/import/content/path', $plugin_targetdir);
    225250            $content = 'false';
    226             if(!isset($_POST['content'])){
     251            if (!isset($_POST['content'])) {
    227252                $setup_file = $this->cwp_import_files(true);
    228                 if(file_exists($targetdir.$setup_file)){
     253                if (file_exists($targetdir . $setup_file)) {
    229254                    self::cwp_import_cubewp_data($targetdir, $setup_file);
    230255                }
    231256
    232257                $content_files = $this->cwp_import_files();
    233                 if(is_array($content_files)){
    234                     foreach($content_files as $content_file){
    235                         if(file_exists($targetdir.$content_file)){
     258                if (is_array($content_files)) {
     259                    foreach ($content_files as $content_file) {
     260                        if (file_exists($targetdir . $content_file)) {
    236261                            $message = self::cwp_import_wordpress_content($targetdir, $content_file);
    237262                        }
    238263                    }
    239264                }
    240                 $contents = $this->cwp_import_files(false,true);
    241                 if(file_exists($targetdir.$contents)){
     265                $post_card_dir = $targetdir  . '/cubewp-post-cards';
     266                $post_card_php = $post_card_dir  . '/cubewp-post-cards.php';
     267                $post_card_css = $post_card_dir  . '/cubewp-post-cards.css';
     268                if (is_dir($post_card_dir)) {
     269                    if (file_exists($post_card_php) && file_exists($post_card_css)) {
     270                        $this->copy_cubewp_post_cards($post_card_dir);
     271                    }
     272                }
     273                $contents = $this->cwp_import_files(false, true);
     274                if (file_exists($targetdir . $contents)) {
    242275                    $content = 'true';
    243276                }
    244             }else{
    245                 $contents = $this->cwp_import_files(false,true);
    246                 if(file_exists($targetdir.$contents)){
     277            } else {
     278                $contents = $this->cwp_import_files(false, true);
     279                if (file_exists($targetdir . $contents)) {
    247280                    $message = self::cwp_import_wordpress_content($targetdir, $contents);
    248281                }
     
    250283            do_action('cwp_actions_after_demo_imported');
    251284            $message = !empty($message) ? $message : esc_html__('Dummy data imported successfully.', 'cubewp-framework');
    252             $redirectURL = apply_filters( 'cubewp/after/import/redirect', admin_url('admin.php?page=cubewp-import&import=success') );
    253             $success = apply_filters( 'cubewp/after/import/success_message', '' );
     285            $redirectURL = apply_filters('cubewp/after/import/redirect', admin_url('admin.php?page=cubewp-import&import=success'));
     286            $success = apply_filters('cubewp/after/import/success_message', '');
    254287            $successMessage = '';
    255             if(is_array($success) && isset($success['selecter']) && isset($success['message'])){
     288            if (is_array($success) && isset($success['selecter']) && isset($success['message'])) {
    256289                $successMessage = $success;
    257290            }
    258             wp_send_json( array( 'success' => 'true', 'content' => $content, 'success_message' => $successMessage , 'msg' => $message, 'redirectURL' => $redirectURL ) );
    259            
     291            wp_send_json(array('success' => 'true', 'content' => $content, 'success_message' => $successMessage, 'msg' => $message, 'redirectURL' => $redirectURL));
     292
    260293            wp_die();
    261294        }
    262295    }
    263296
     297
    264298    /**
    265299     * Method cwp_import_dummy_content
     
    268302     * @since  1.0.0
    269303     */
    270     public function cwp_import_files($setup = false,$content = false){
    271         if($setup == true){
     304    public function cwp_import_files($setup = false, $content = false)
     305    {
     306        if ($setup == true) {
    272307            return '/cwp-setup.json';
    273         }else if($content == true){
     308        } else if ($content == true) {
    274309            return '/content.xml';
    275310        }
     
    280315        );
    281316    }
    282    
     317
     318    public function copy_cubewp_post_cards($source_dir)
     319    {
     320        // Uploads directory path
     321        $uploads_dir = wp_upload_dir();
     322        $destination_dir = $uploads_dir['basedir'] . '/cubewp-post-cards';
     323
     324        // Check if the source directory exists
     325        if (!is_dir($source_dir)) {
     326            return false;
     327        }
     328
     329        // Create the destination directory if it doesn't exist
     330        if (!file_exists($destination_dir)) {
     331            if (!wp_mkdir_p($destination_dir)) {
     332                return false;
     333            }
     334        } else {
     335            // Clear destination directory if it exists
     336            $this->remove_directory($destination_dir);
     337            if (!wp_mkdir_p($destination_dir)) {
     338                return false;
     339            }
     340        }
     341
     342        // Attempt to copy directory
     343        return $this->copy_directory($source_dir, $destination_dir);
     344    }
     345
     346    private function copy_directory($source, $destination)
     347    {
     348        if (is_dir($source)) {
     349            // Create destination directory if it doesn't exist
     350            @mkdir($destination);
     351            $directory = dir($source);
     352            while (false !== ($readdirectory = $directory->read())) {
     353                if ($readdirectory == '.' || $readdirectory == '..') {
     354                    continue;
     355                }
     356                $pathDir = $source . '/' . $readdirectory;
     357                if (is_dir($pathDir)) {
     358                    $this->copy_directory($pathDir, $destination . '/' . $readdirectory);
     359                    continue;
     360                }
     361                copy($pathDir, $destination . '/' . $readdirectory);
     362            }
     363            $directory->close();
     364        } else {
     365            copy($source, $destination);
     366        }
     367        return true;
     368    }
     369
     370    private function remove_directory($dir)
     371    {
     372        if (!is_dir($dir)) {
     373            return;
     374        }
     375        $files = array_diff(scandir($dir), array('.', '..'));
     376        foreach ($files as $file) {
     377            (is_dir("$dir/$file")) ? $this->remove_directory("$dir/$file") : unlink("$dir/$file");
     378        }
     379        return rmdir($dir);
     380    }
     381
    283382    /**
    284383     * Method cwp_import_cubewp_data
     
    288387     * @return void
    289388     */
    290     public function cwp_import_cubewp_data($targetdir = '', $file = ''){
    291 
    292         if($targetdir != '' && $file != ''){
     389    public function cwp_import_cubewp_data($targetdir = '', $file = '')
     390    {
     391
     392        if ($targetdir != '' && $file != '') {
    293393
    294394            $file = $targetdir . $file;
    295             $file_content   = file_get_contents( $file );
     395            $file_content   = file_get_contents($file);
    296396            $import_content = json_decode($file_content, true);
    297            
    298             foreach( $import_content as $content_type => $import_data ){
    299                 switch($content_type){
     397
     398            foreach ($import_content as $content_type => $import_data) {
     399                switch ($content_type) {
    300400                    case 'post_types':
    301                         $this->cwp_import_post_types( $import_data );
    302                     break;
     401                        $this->cwp_import_post_types($import_data);
     402                        break;
    303403                    case 'taxonomies':
    304                         $this->cwp_import_taxonomies( $import_data );
    305                     break;
     404                        $this->cwp_import_taxonomies($import_data);
     405                        break;
    306406                    case 'custom_fields':
    307                         $this->cwp_import_custom_fields( $import_data );
    308                     break;
     407                        $this->cwp_import_custom_fields($import_data);
     408                        break;
    309409                    case 'tax_custom_fields':
    310                         $this->cwp_import_taxonomies_custom_fields( $import_data );
    311                     break;
     410                        $this->cwp_import_taxonomies_custom_fields($import_data);
     411                        break;
    312412                    case 'user_custom_fields':
    313                         $this->cwp_import_user_custom_fields( $import_data );
    314                     break;
     413                        $this->cwp_import_user_custom_fields($import_data);
     414                        break;
    315415                    case 'terms':
    316416                        $_SESSION['terms'] = $import_data;
    317                     break;
     417                        break;
    318418                    case 'post_type_forms':
    319                         $this->cwp_import_post_type_forms( $import_data );
    320                     break;
     419                        $this->cwp_import_post_type_forms($import_data);
     420                        break;
    321421                    case 'loop_builder_forms':
    322                         $this->cwp_import_loop_builder_forms( $import_data );
    323                     break;
     422                        $this->cwp_import_loop_builder_forms($import_data);
     423                        break;
    324424                    case 'custom_forms_fields':
    325                         $this->cwp_import_custom_forms_fields( $import_data );
    326                     break;
     425                        $this->cwp_import_custom_forms_fields($import_data);
     426                        break;
    327427                    case 'search_forms':
    328                         $this->cwp_import_search_forms( $import_data );
    329                     break;
     428                        $this->cwp_import_search_forms($import_data);
     429                        break;
    330430                    case 'filter_forms':
    331                         $this->cwp_import_filter_forms( $import_data );
    332                     break;
     431                        $this->cwp_import_filter_forms($import_data);
     432                        break;
    333433                    case 'user_reg_forms':
    334                         $this->cwp_import_user_reg_forms( $import_data );
    335                     break;
     434                        $this->cwp_import_user_reg_forms($import_data);
     435                        break;
    336436                    case 'user_profile_forms':
    337                         $this->cwp_import_user_profile_forms( $import_data );
    338                     break;
     437                        $this->cwp_import_user_profile_forms($import_data);
     438                        break;
    339439                    case 'single_layout':
    340                         $this->cwp_import_single_layout_forms( $import_data );
    341                     break;
     440                        $this->cwp_import_single_layout_forms($import_data);
     441                        break;
    342442                    case 'user_dashboard':
    343                         $this->cwp_import_user_dashboard_forms( $import_data );
    344                     break;
     443                        $this->cwp_import_user_dashboard_forms($import_data);
     444                        break;
    345445                    case 'cwp_settings':
    346                         $this->cwp_import_settings( $import_data );
    347                     break;
     446                        $this->cwp_import_settings($import_data);
     447                        break;
    348448                }
    349449            }
     
    353453    }
    354454
    355    
     455
    356456    /**
    357457     * Method cwp_import_wordpress_content
     
    361461     * @return void
    362462     */
    363     public function cwp_import_wordpress_content($targetdir = '', $file = ''){
    364         if($targetdir != '' && $file != ''){
     463    public function cwp_import_wordpress_content($targetdir = '', $file = '')
     464    {
     465        if ($targetdir != '' && $file != '') {
    365466            $file = $targetdir . $file;
    366467            if (!defined('WP_LOAD_IMPORTERS')) {
     
    389490            } else {
    390491                if (!is_file($file)) {
    391                     return "The XML file containing the content is not available or could not be read .. You might want to try to set the file permission to chmod 755.<br/>If this doesn't work please contact to community or email us for more help.";
     492                    return "The XML file containing the content is not available or could not be read. You might want to try to set the file permission to chmod 755.<br/>If this doesn't work, please contact the community or email us for more help.";
    392493                } else {
     494                    // Step 1: Import content without fetching attachments
    393495                    ob_start();
    394496                    $wp_import = new WP_Import();
    395497                    $wp_import->fetch_attachments = true;
    396                     $wp_import->import( $file );
     498                    $wp_import->import($file);
    397499                    ob_end_clean();
    398500                }
     
    400502        }
    401503    }
    402    
    403        
     504
     505
    404506    /**
    405507     * Method cwp_import_post_types
     
    410512     * @since  1.0.0
    411513     */
    412     public function cwp_import_post_types( $import_data = array() ){
    413        
    414         if(isset($import_data) && !empty($import_data)){
     514    public function cwp_import_post_types($import_data = array())
     515    {
     516
     517        if (isset($import_data) && !empty($import_data)) {
    415518            $cwp_custom_types = CWP_types();
    416519            $cwp_custom_types = $cwp_custom_types == '' ? array() : $cwp_custom_types;
    417             foreach($import_data as $post_type => $post_type_data){
    418                 if(!isset($cwp_custom_types[$post_type])){
     520            foreach ($import_data as $post_type => $post_type_data) {
     521                if (!isset($cwp_custom_types[$post_type])) {
    419522                    $cwp_custom_types[$post_type] = $post_type_data;
    420523                }
     
    422525            update_option('cwp_custom_types', $cwp_custom_types);
    423526        }
    424        
    425     }
    426        
     527    }
     528
    427529    /**
    428530     * Method cwp_import_taxonomies
     
    433535     * @since  1.0.0
    434536     */
    435     public function cwp_import_taxonomies( $import_data = array() ){
    436        
    437         if(isset($import_data) && !empty($import_data)){
     537    public function cwp_import_taxonomies($import_data = array())
     538    {
     539
     540        if (isset($import_data) && !empty($import_data)) {
    438541            $cwp_custom_taxonomies = get_option('cwp_custom_taxonomies');
    439542            $cwp_custom_taxonomies = $cwp_custom_taxonomies == '' ? array() : $cwp_custom_taxonomies;
    440             foreach($import_data as $taxonomy_name => $taxonomy_data){
    441                 if(!isset($cwp_custom_taxonomies[$taxonomy_name])){
     543            foreach ($import_data as $taxonomy_name => $taxonomy_data) {
     544                if (!isset($cwp_custom_taxonomies[$taxonomy_name])) {
    442545                    $cwp_custom_taxonomies[$taxonomy_name] = $taxonomy_data;
    443546                }
     
    445548            update_option('cwp_custom_taxonomies', $cwp_custom_taxonomies);
    446549        }
    447        
    448     }
    449        
     550    }
     551
    450552    /**
    451553     * Method cwp_import_terms
     
    456558     * @since  1.0.0
    457559     */
    458     public function cwp_import_terms( $import_data = array() ){
    459        
    460         if(isset($import_data) && !empty($import_data)){
    461             foreach ( $import_data as $taxonomy=>$allterms) {
    462                 if(!empty($allterms) && is_array($allterms)){
    463                     foreach ( $allterms as $terms) {
    464                         if(!empty($terms) && count($terms) > 0){
     560    public function cwp_import_terms($import_data = array())
     561    {
     562
     563        if (isset($import_data) && !empty($import_data)) {
     564            foreach ($import_data as $taxonomy => $allterms) {
     565                if (!empty($allterms) && is_array($allterms)) {
     566                    foreach ($allterms as $terms) {
     567                        if (!empty($terms) && count($terms) > 0) {
    465568                            $id = wp_insert_term(
    466569                                $terms['name'],
    467                                 $terms['taxonomy'], 
     570                                $terms['taxonomy'],
    468571                                array(
    469572                                    'slug'   => $terms['slug'],
     
    477580            return $id;
    478581        }
    479        
    480     }
    481        
     582    }
     583
    482584    /**
    483585     * Method cwp_import_custom_fields
     
    488590     * @since  1.0.0
    489591     */
    490     public function cwp_import_custom_fields( $import_data = array() ){
    491        
    492         if(isset($import_data) && !empty($import_data)){
     592    public function cwp_import_custom_fields($import_data = array())
     593    {
     594
     595        if (isset($import_data) && !empty($import_data)) {
    493596            $cwp_custom_fields = CWP()->get_custom_fields('post_types');
    494597            $cwp_custom_fields = $cwp_custom_fields == '' ? array() : $cwp_custom_fields;
    495             if(!empty($import_data) && count($import_data) > 0){
    496                 foreach($import_data as $field_slug => $field_options){
    497                     if(!isset($cwp_custom_fields[$field_slug])){
     598            if (!empty($import_data) && count($import_data) > 0) {
     599                foreach ($import_data as $field_slug => $field_options) {
     600                    if (!isset($cwp_custom_fields[$field_slug])) {
    498601                        $cwp_custom_fields[$field_slug] = $field_options;
    499602                    }
     
    502605            }
    503606        }
    504        
    505     }
    506    
    507     public function cwp_import_taxonomies_custom_fields( $import_data = array() ){
    508        
    509         if(isset($import_data) && !empty($import_data)){
     607    }
     608
     609    public function cwp_import_taxonomies_custom_fields($import_data = array())
     610    {
     611
     612        if (isset($import_data) && !empty($import_data)) {
    510613            $cwp_tax_custom_fields = CWP()->get_custom_fields('taxonomy');
    511614            $cwp_tax_custom_fields = $cwp_tax_custom_fields == '' ? array() : $cwp_tax_custom_fields;
    512             if(!empty($import_data) && count($import_data) > 0){
    513                 foreach($import_data as $taxonomy_name => $taxonomy_custom_fields){
    514                     if(!isset($cwp_tax_custom_fields[$taxonomy_name])){
     615            if (!empty($import_data) && count($import_data) > 0) {
     616                foreach ($import_data as $taxonomy_name => $taxonomy_custom_fields) {
     617                    if (!isset($cwp_tax_custom_fields[$taxonomy_name])) {
    515618                        $cwp_tax_custom_fields[$taxonomy_name] = $taxonomy_custom_fields;
    516619                    }
     
    519622            }
    520623        }
    521        
    522     }
    523        
     624    }
     625
    524626    /**
    525627     * Method cwp_import_user_custom_fields
     
    530632     * @since  1.0.0
    531633     */
    532     public function cwp_import_user_custom_fields( $import_data = array() ){
    533        
    534         if(isset($import_data) && !empty($import_data)){
     634    public function cwp_import_user_custom_fields($import_data = array())
     635    {
     636
     637        if (isset($import_data) && !empty($import_data)) {
    535638            $cwp_user_custom_fields = CWP()->get_custom_fields('user');
    536639            $cwp_user_custom_fields = $cwp_user_custom_fields == '' ? array() : $cwp_user_custom_fields;
    537             if(!empty($import_data) && count($import_data) > 0){
    538                 foreach($import_data as $user_role => $user_custom_fields){
    539                     if(!isset($cwp_user_custom_fields[$user_role])){
     640            if (!empty($import_data) && count($import_data) > 0) {
     641                foreach ($import_data as $user_role => $user_custom_fields) {
     642                    if (!isset($cwp_user_custom_fields[$user_role])) {
    540643                        $cwp_user_custom_fields[$user_role] = $user_custom_fields;
    541644                    }
     
    544647            }
    545648        }
    546        
    547     }
    548        
     649    }
     650
    549651    /**
    550652     * Method cwp_import_post_type_forms
     
    555657     * @since  1.0.0
    556658     */
    557     public function cwp_import_post_type_forms( $import_data = array() ){
    558         if(isset($import_data) && !empty($import_data)){
     659    public function cwp_import_post_type_forms($import_data = array())
     660    {
     661        if (isset($import_data) && !empty($import_data)) {
    559662            $cwp_post_type_forms = CWP()->get_form('post_type');
    560663            $cwp_post_type_forms = $cwp_post_type_forms == '' ? array() : $cwp_post_type_forms;
    561             if(!empty($import_data) && count($import_data) > 0){
    562                 foreach($import_data as $post_type => $form_data){
    563                     if(!isset($cwp_post_type_forms[$post_type])){
     664            if (!empty($import_data) && count($import_data) > 0) {
     665                foreach ($import_data as $post_type => $form_data) {
     666                    if (!isset($cwp_post_type_forms[$post_type])) {
    564667                        $cwp_post_type_forms[$post_type] = $form_data;
    565668                    }
     
    578681     * @since  1.0.0
    579682     */
    580     public function cwp_import_loop_builder_forms( $import_data = array() ){
    581         if(isset($import_data) && !empty($import_data)){
     683    public function cwp_import_loop_builder_forms($import_data = array())
     684    {
     685        if (isset($import_data) && !empty($import_data)) {
    582686            $cwp_loop_builder_forms = CWP()->get_form('loop_builder');
    583687            $cwp_loop_builder_forms = $cwp_loop_builder_forms == '' ? array() : $cwp_loop_builder_forms;
    584             if(!empty($import_data) && count($import_data) > 0){
    585                 foreach($import_data as $post_type => $form_data){
    586                     if(!isset($cwp_loop_builder_forms[$post_type])){
     688            if (!empty($import_data) && count($import_data) > 0) {
     689                foreach ($import_data as $post_type => $form_data) {
     690                    if (!isset($cwp_loop_builder_forms[$post_type])) {
    587691                        $cwp_loop_builder_forms[$post_type] = $form_data;
    588692                    }
     
    601705     * @since  1.1.4
    602706     */
    603     public function cwp_import_custom_forms_fields( $import_data = array() ){
    604         if(isset($import_data) && !empty($import_data)){
     707    public function cwp_import_custom_forms_fields($import_data = array())
     708    {
     709        if (isset($import_data) && !empty($import_data)) {
    605710            $cwp_custom_fields = CWP()->get_custom_fields('custom_forms');
    606711            $cwp_custom_fields = $cwp_custom_fields == '' ? array() : $cwp_custom_fields;
    607             if(!empty($import_data) && count($import_data) > 0){
    608                 foreach($import_data as $field_slug => $field_options){
    609                     if(!isset($cwp_custom_fields[$field_slug])){
     712            if (!empty($import_data) && count($import_data) > 0) {
     713                foreach ($import_data as $field_slug => $field_options) {
     714                    if (!isset($cwp_custom_fields[$field_slug])) {
    610715                        $cwp_custom_fields[$field_slug] = $field_options;
    611716                    }
     
    615720        }
    616721    }
    617        
     722
    618723    /**
    619724     * Method cwp_import_search_forms
     
    624729     * @since  1.0.0
    625730     */
    626     public function cwp_import_search_forms( $import_data = array() ){
    627         if(isset($import_data) && !empty($import_data)){
     731    public function cwp_import_search_forms($import_data = array())
     732    {
     733        if (isset($import_data) && !empty($import_data)) {
    628734            $cwp_search_forms = CWP()->get_form('search_fields');
    629735            $cwp_search_forms = $cwp_search_forms == '' ? array() : $cwp_search_forms;
    630             if(!empty($import_data) && count($import_data) > 0){
    631                 foreach($import_data as $post_type => $form_data){
    632                     if(!isset($cwp_search_forms[$post_type])){
     736            if (!empty($import_data) && count($import_data) > 0) {
     737                foreach ($import_data as $post_type => $form_data) {
     738                    if (!isset($cwp_search_forms[$post_type])) {
    633739                        $cwp_search_forms[$post_type] = $form_data;
    634740                    }
     
    638744        }
    639745    }
    640        
     746
    641747    /**
    642748     * Method cwp_import_filter_forms
     
    647753     * @since  1.0.0
    648754     */
    649     public function cwp_import_filter_forms( $import_data = array() ){
    650         if(isset($import_data) && !empty($import_data)){
     755    public function cwp_import_filter_forms($import_data = array())
     756    {
     757        if (isset($import_data) && !empty($import_data)) {
    651758            $cwp_filter_forms = CWP()->get_form('search_filters');
    652759            $cwp_filter_forms = $cwp_filter_forms == '' ? array() : $cwp_filter_forms;
    653             if(!empty($import_data) && count($import_data) > 0){
    654                 foreach($import_data as $post_type => $form_data){
    655                     if(!isset($cwp_filter_forms[$post_type])){
     760            if (!empty($import_data) && count($import_data) > 0) {
     761                foreach ($import_data as $post_type => $form_data) {
     762                    if (!isset($cwp_filter_forms[$post_type])) {
    656763                        $cwp_filter_forms[$post_type] = $form_data;
    657764                    }
     
    661768        }
    662769    }
    663        
     770
    664771    /**
    665772     * Method cwp_import_user_reg_forms
     
    670777     * @since  1.0.0
    671778     */
    672     public function cwp_import_user_reg_forms( $import_data = array() ){
    673         if(isset($import_data) && !empty($import_data)){
     779    public function cwp_import_user_reg_forms($import_data = array())
     780    {
     781        if (isset($import_data) && !empty($import_data)) {
    674782            $cwp_user_forms = CWP()->get_form('user_register');
    675783            $cwp_user_forms = $cwp_user_forms == '' ? array() : $cwp_user_forms;
    676             if(!empty($import_data) && count($import_data) > 0){
    677                 foreach($import_data as $user_role => $form_data){
    678                     if(!isset($cwp_user_forms[$user_role])){
     784            if (!empty($import_data) && count($import_data) > 0) {
     785                foreach ($import_data as $user_role => $form_data) {
     786                    if (!isset($cwp_user_forms[$user_role])) {
    679787                        $cwp_user_forms[$user_role] = $form_data;
    680788                    }
     
    684792        }
    685793    }
    686        
     794
    687795    /**
    688796     * Method cwp_import_user_profile_forms
     
    693801     * @since  1.0.0
    694802     */
    695     public function cwp_import_user_profile_forms( $import_data = array() ){
    696         if(isset($import_data) && !empty($import_data)){
     803    public function cwp_import_user_profile_forms($import_data = array())
     804    {
     805        if (isset($import_data) && !empty($import_data)) {
    697806            $cwp_user_forms = CWP()->get_form('user_profile');
    698807            $cwp_user_forms = $cwp_user_forms == '' ? array() : $cwp_user_forms;
    699             if(!empty($import_data) && count($import_data) > 0){
    700                 foreach($import_data as $user_role => $form_data){
    701                     if(!isset($cwp_user_forms[$user_role])){
     808            if (!empty($import_data) && count($import_data) > 0) {
     809                foreach ($import_data as $user_role => $form_data) {
     810                    if (!isset($cwp_user_forms[$user_role])) {
    702811                        $cwp_user_forms[$user_role] = $form_data;
    703812                    }
     
    707816        }
    708817    }
    709        
     818
    710819    /**
    711820     * Method cwp_import_single_layout_forms
     
    716825     * @since  1.0.0
    717826     */
    718     public function cwp_import_single_layout_forms( $import_data = array() ){
    719         if(isset($import_data) && !empty($import_data)){
     827    public function cwp_import_single_layout_forms($import_data = array())
     828    {
     829        if (isset($import_data) && !empty($import_data)) {
    720830            $cwp_single_layout_forms = CWP()->get_form('single_layout');
    721831            $cwp_single_layout_forms = $cwp_single_layout_forms == '' ? array() : $cwp_single_layout_forms;
    722             if(!empty($import_data) && count($import_data) > 0){
    723                 foreach($import_data as $user_role => $form_data){
    724                     if(!isset($cwp_user_forms[$user_role])){
     832            if (!empty($import_data) && count($import_data) > 0) {
     833                foreach ($import_data as $user_role => $form_data) {
     834                    if (!isset($cwp_user_forms[$user_role])) {
    725835                        $cwp_single_layout_forms[$user_role] = $form_data;
    726836                    }
     
    739849     * @since  1.0.0
    740850     */
    741     public function cwp_import_user_dashboard_forms( $import_data = array() ){
    742         if(isset($import_data) && !empty($import_data)){
     851    public function cwp_import_user_dashboard_forms($import_data = array())
     852    {
     853        if (isset($import_data) && !empty($import_data)) {
    743854            $cwp_userdash = CWP()->cubewp_options('cwp_userdash');
    744855            $cwp_userdash = $cwp_userdash == '' ? array() : $cwp_userdash;
    745             if(!empty($import_data) && count($import_data) > 0){
    746                 foreach($import_data as $key => $form_data){
    747                     if(!isset($cwp_userdash[$key])){
     856            if (!empty($import_data) && count($import_data) > 0) {
     857                foreach ($import_data as $key => $form_data) {
     858                    if (!isset($cwp_userdash[$key])) {
    748859                        $cwp_userdash[$key] = $form_data;
    749860                    }
     
    762873     * @since  1.0.0
    763874     */
    764     public function cwp_import_settings( $import_data = array() ){
    765         if(isset($import_data) && !empty($import_data)){
     875    public function cwp_import_settings($import_data = array())
     876    {
     877        if (isset($import_data) && !empty($import_data)) {
    766878            $cwp_settings = CWP()->cubewp_options('cwp_settings');
    767879            $cwp_settings = $cwp_settings == '' ? array() : $cwp_settings;
    768             if(!empty($import_data) && count($import_data) > 0){
    769                 foreach($import_data as $key => $form_data){
    770                     if(!isset($cwp_settings[$key])){
     880            if (!empty($import_data) && count($import_data) > 0) {
     881                foreach ($import_data as $key => $form_data) {
     882                    if (!isset($cwp_settings[$key])) {
    771883                        $cwp_settings[$key] = $form_data;
    772884                    }
     
    776888        }
    777889    }
    778 
    779890}
    780891session_write_close();
  • cubewp-framework/trunk/cube/classes/class-cubewp-load.php

    r3187693 r3202079  
    2121     * @var string
    2222     */
    23     public static $CubeWp_version = '1.1.22';
     23    public static $CubeWp_version = '1.1.23';
    2424   
    2525    /**
     
    152152        // Set Cubewp settings.
    153153        self::cwp_get_option();
     154    }
     155
     156    /**
     157     * cubewp_get_modules
     158     *
     159     * @return array
     160     * @since 1.1.23
     161     */
     162    public function cubewp_get_modules()
     163    {
     164        // Define the path to the addons.json file
     165        $file_path = CUBEWP_FILES . 'modules/modules.json';
     166
     167        // Check if the file exists
     168        if (!file_exists($file_path)) {
     169            return [];
     170        }
     171
     172        // Read the file contents
     173        $json_content = file_get_contents($file_path);
     174
     175        // Decode the JSON content
     176        $modules = json_decode($json_content, true);
     177
     178        if (!$modules) {
     179            return [];
     180        }
     181
     182        // Dynamically update the `path` values for each module
     183        foreach ($modules as $key => &$module) {
     184            if (isset($module['base'])) {
     185                // Extract directory name from the 'base' value
     186                $base_dir = dirname($module['base']);
     187                $module['path'] = plugin_dir_path(dirname(dirname(__DIR__))) . $base_dir . '/cube/';
     188            }
     189        }
     190
     191        return $modules;
    154192    }
    155193   
  • cubewp-framework/trunk/cube/classes/class-cubewp-single-cpt.php

    r2984614 r3202079  
    11<?php
     2
    23/**
    34 * CubeWp single cpt contains all function to show single post page content
     
    78 */
    89
    9 if ( ! defined( 'ABSPATH' ) ) {
    10     exit;
     10if (! defined('ABSPATH')) {
     11    exit;
    1112}
    1213
     
    1415 * CubeWp_Single_Cpt
    1516 */
    16 class CubeWp_Single_Cpt {
    17 
    18     use CubeWp_Single_Page_Trait;
    19 
    20     public static $post_id;
    21     public static $post_type;
    22     public static $author_id;
    23     public static $groups;
    24     public static $Load = null;
    25 
    26    
     17class CubeWp_Single_Cpt
     18{
     19
     20    use CubeWp_Single_Page_Trait;
     21
     22    public static $post_id;
     23    public static $post_type;
     24    public static $author_id;
     25    public static $groups;
     26    public static $Load = null;
     27
     28
    2729    /**
    2830     * Method instance
     
    3133     * @since  1.0.0
    3234     */
    33     public static function instance() {
    34         if ( is_null( self::$Load ) ) {
    35             self::$Load = new self();
    36         }
    37         return self::$Load;
    38     }
    39     public function __construct() {
    40         self::set_post_args();
    41         add_shortcode( 'cubewp_post_save', array($this, 'get_post_save_button'));
    42         add_shortcode( 'cubewp_post_share', array($this, 'get_post_share_button'));
    43     }
    44    
    45     /**
    46      * Method set_post_args
    47      *
    48      * @return void
    49      * @since  1.0.0
    50      */
    51     public static function set_post_args() {
    52         self::$post_id   = get_the_ID();
    53         self::$post_type = get_post_type( self::$post_id );
    54         self::$author_id = get_post_field( 'post_author', self::$post_id );
    55         self::$groups = cwp_get_groups_by_post_type( self::$post_type );
    56     }
    57        
     35    public static function instance()
     36    {
     37        if (is_null(self::$Load)) {
     38            self::$Load = new self();
     39        }
     40        return self::$Load;
     41    }
     42    public function __construct()
     43    {
     44        self::set_post_args();
     45        add_shortcode('cubewp_post_save', array($this, 'get_post_save_button'));
     46        add_shortcode('cubewp_post_share', array($this, 'get_post_share_button'));
     47    }
     48
     49    /**
     50     * Method set_post_args
     51     *
     52     * @return void
     53     * @since  1.0.0
     54     */
     55    public static function set_post_args()
     56    {
     57        self::$post_id   = get_the_ID();
     58        self::$post_type = get_post_type(self::$post_id);
     59        self::$author_id = get_post_field('post_author', self::$post_id);
     60        self::$groups = cwp_get_groups_by_post_type(self::$post_type);
     61    }
     62
    5863    /**
    5964     * Method cubewp_post_metas
     
    6469     * @since  1.0.0
    6570     */
    66     public static function cubewp_post_metas($postid='', $rest_data = false) {
     71    public static function cubewp_post_metas($postid = '', $rest_data = false)
     72    {
    6773        if (!empty($postid)) self::$post_id = $postid;
    68         $args = array();
     74        $args = array();
    6975        $groups = !isset(self::$groups) || empty(self::$groups) ? cwp_get_groups_by_post_id(self::$post_id) : self::$groups;
    7076        if (is_array($groups)) $groups = array_reverse($groups);
    71         foreach ($groups as $group) {
    72             $fields = cwp_get_fields_by_group_id( $group );
    73             if (!empty($fields) && is_array($fields)) {
    74                 foreach ($fields as $field) {
    75                     $field = get_field_options($field);
    76                     $field_rest_permission = $rest_data == true && isset( $field["rest_api"] ) ? $field["rest_api"] : 0;
    77                     if($field_rest_permission || $rest_data == false){
    78                         $field_type = isset( $field["type"] ) ? $field["type"] : "";
    79                         $meta_key   = isset( $field["name"] ) ? $field["name"] : "";
    80                         if($field_type == 'taxonomy'){
    81                             if(isset($field) && count($field)>0 && !empty($field['filter_taxonomy'])){
    82                                 $field_type = 'terms';
     77        if (is_array($groups) && !empty($groups)) {
     78            foreach ($groups as $group) {
     79                $fields = cwp_get_fields_by_group_id($group);
     80                if (!empty($fields) && is_array($fields)) {
     81                    foreach ($fields as $field) {
     82                        $field = get_field_options($field);
     83                        $field_rest_permission = $rest_data == true && isset($field["rest_api"]) ? $field["rest_api"] : 0;
     84                        if ($field_rest_permission || $rest_data == false) {
     85                            $field_type = isset($field["type"]) ? $field["type"] : "";
     86                            $meta_key   = isset($field["name"]) ? $field["name"] : "";
     87                            if ($field_type == 'taxonomy') {
     88                                if (isset($field) && count($field) > 0 && !empty($field['filter_taxonomy'])) {
     89                                    $field_type = 'terms';
     90                                }
    8391                            }
     92                            if (empty($field_type) || empty($meta_key)) continue;
     93                            $label = isset($field["label"]) ? $field["label"] : "";
     94                            $value = self::get_single_meta_value($meta_key, $field_type);
     95                            $args[$meta_key] = array(
     96                                'type'                  =>    $field_type,
     97                                'meta_key'              =>    $meta_key,
     98                                'meta_value'            =>    $value,
     99                                'label'                 =>    $label,
     100                            );
    84101                        }
    85                         if (empty($field_type) || empty($meta_key)) continue;
    86                         $label = isset( $field["label"] ) ? $field["label"] : "";
    87                         $value = self::get_single_meta_value($meta_key,$field_type);
    88                         $args[$meta_key] = array(
    89                             'type'                  =>    $field_type,
    90                             'meta_key'              =>    $meta_key,
    91                             'meta_value'            =>    $value,
    92                             'label'                 =>    $label,
    93                         );
    94102                    }
    95103                }
     
    98106        return $args;
    99107    }
    100        
    101     /**
    102      * Method get_post_featured_image
    103      *
    104      * @return string html/null
    105      * @since  1.0.0
    106      */
    107     public static function get_post_featured_image() {
    108         if ( has_post_thumbnail( self::$post_id ) ) {
    109             return '<div class="cwp-single-fet-img"><img src="' . esc_url( get_the_post_thumbnail_url( self::$post_id, array( 1250, 500 ) ) ) . '" alt="' . get_the_title( self::$post_id ) . '"></div>';
    110         } else {
    111             return null;
    112         }
    113     }
    114    
    115     /**
    116      * Method get_post_breadcrumb_tags
    117      *
    118      * @param string $call
    119      *
    120      * @return string html
    121      * @since  1.0.0
    122      */
    123     public static function get_post_breadcrumb_tags( $call ) {
    124         $output     = null;
    125         $class      = null;
    126         $post_terms = self::get_post_terms();
    127         if ( "breadcrumb" === $call ) {
    128             $class = 'cwp-cpt-single-post-terms';
    129         } elseif ( "tags" === $call ) {
    130             $class = 'cwp-single-category-widget-inner';
    131         }
    132         if ( isset( $post_terms ) && ! empty( $post_terms ) && is_array( $post_terms ) ) {
    133             $output .= '<ul class="' . $class . '">';
    134             foreach ( $post_terms as $terms ) {
    135                 foreach ( $terms as $term ) {
    136                     $output .= '<li>
    137                         <a href="' . get_term_link( $term ) . '">
     108
     109    /**
     110     * Method get_post_featured_image
     111     *
     112     * @return string html/null
     113     * @since  1.0.0
     114     */
     115    public static function get_post_featured_image()
     116    {
     117        if (has_post_thumbnail(self::$post_id)) {
     118            return '<div class="cwp-single-fet-img"><img src="' . esc_url(get_the_post_thumbnail_url(self::$post_id, array(1250, 500))) . '" alt="' . get_the_title(self::$post_id) . '"></div>';
     119        } else {
     120            return null;
     121        }
     122    }
     123
     124    /**
     125     * Method get_post_breadcrumb_tags
     126     *
     127     * @param string $call
     128     *
     129     * @return string html
     130     * @since  1.0.0
     131     */
     132    public static function get_post_breadcrumb_tags($call)
     133    {
     134        $output     = null;
     135        $class      = null;
     136        $post_terms = self::get_post_terms();
     137        if ("breadcrumb" === $call) {
     138            $class = 'cwp-cpt-single-post-terms';
     139        } elseif ("tags" === $call) {
     140            $class = 'cwp-single-category-widget-inner';
     141        }
     142        if (isset($post_terms) && ! empty($post_terms) && is_array($post_terms)) {
     143            $output .= '<ul class="' . $class . '">';
     144            foreach ($post_terms as $terms) {
     145                foreach ($terms as $term) {
     146                    $output .= '<li>
     147                        <a href="' . get_term_link($term) . '">
    138148                            <p>' . $term->name . '</p>
    139149                        </a>
    140150                    </li>';
    141                 }
    142             }
    143             $output .= '</ul>';
    144         }
    145 
    146         return $output;
    147     }
    148    
    149     /**
    150      * Method get_post_terms
    151      *
    152      * @return array
    153      * @since  1.0.0
    154      */
    155     public static function get_post_terms() {
    156         $post_terms = array();
    157         $taxonomies = get_object_taxonomies( self::$post_type );
    158         if ( ! empty( $taxonomies ) && is_array( $taxonomies ) ) {
    159             foreach ( $taxonomies as $taxonomy ) {
    160                 $post_terms[] = get_the_terms( self::$post_id, $taxonomy );
    161             }
    162         }
    163 
    164         return isset( $post_terms ) && ! empty( $post_terms ) ? array_filter( $post_terms ) : array();
    165     }
    166    
     151                }
     152            }
     153            $output .= '</ul>';
     154        }
     155
     156        return $output;
     157    }
     158
     159    /**
     160     * Method get_post_terms
     161     *
     162     * @return array
     163     * @since  1.0.0
     164     */
     165    public static function get_post_terms()
     166    {
     167        $post_terms = array();
     168        $taxonomies = get_object_taxonomies(self::$post_type);
     169        if (! empty($taxonomies) && is_array($taxonomies)) {
     170            foreach ($taxonomies as $taxonomy) {
     171                $post_terms[] = get_the_terms(self::$post_id, $taxonomy);
     172            }
     173        }
     174
     175        return isset($post_terms) && ! empty($post_terms) ? array_filter($post_terms) : array();
     176    }
     177
    167178    /**
    168179     * Method get_post_save_button
     
    171182     * @since  1.0.0
    172183     */
    173     public static function get_post_save_button() {
     184    public static function get_post_save_button()
     185    {
    174186        $isSaved = '';
    175         if(class_exists('CubeWp_Saved')){
    176             $SavedText = CubeWp_Saved::is_cubewp_post_saved(self::$post_id,false,false);
    177             $SavedClass = CubeWp_Saved::is_cubewp_post_saved(self::$post_id,false,true);
    178         }else{
    179             $SavedText = esc_html__("Save", "cubewp-framework" );
     187        if (class_exists('CubeWp_Saved')) {
     188            $SavedText = CubeWp_Saved::is_cubewp_post_saved(self::$post_id, false, false);
     189            $SavedClass = CubeWp_Saved::is_cubewp_post_saved(self::$post_id, false, true);
     190        } else {
     191            $SavedText = esc_html__("Save", "cubewp-framework");
    180192            $SavedClass = 'cwp-save-post';
    181193        }
    182194        echo '<div class="cwp-single-save-btns cwp-single-widget">
    183          <span class="cwp-main '.esc_attr($SavedClass).'" data-pid="'.esc_attr(self::$post_id).'">
     195         <span class="cwp-main ' . esc_attr($SavedClass) . '" data-pid="' . esc_attr(self::$post_id) . '">
    184196         <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
    185197               <path d="m8 2.748-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
     
    188200               <path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
    189201         </svg>
    190             <span class="cwp-saved-text">'.esc_html($SavedText).'</span>
     202            <span class="cwp-saved-text">' . esc_html($SavedText) . '</span>
    191203        </span>
    192204        </div>';
    193205    }
    194    
    195     /**
    196      * Method field_author
    197      *
    198      * @return string html
    199      * @since  1.0.0
    200      */
    201     public static function field_author() {
     206
     207    /**
     208     * Method field_author
     209     *
     210     * @return string html
     211     * @since  1.0.0
     212     */
     213    public static function field_author()
     214    {
    202215        $user_id = self::$author_id;
    203216        return get_user_details($user_id);
    204217    }
    205    
    206     /**
    207      * Method get_post_sidebar_tags
    208      *
    209      * @return string html
    210      * @since  1.0.0
    211      */
    212     public static function get_post_sidebar_tags() {
     218
     219    /**
     220     * Method get_post_sidebar_tags
     221     *
     222     * @return string html
     223     * @since  1.0.0
     224     */
     225    public static function get_post_sidebar_tags()
     226    {
    213227        $post_tags = self::get_post_breadcrumb_tags('tags');
    214        
    215         if(!empty($post_tags)){
    216         return '<div class="cwp-single-category-widget cwp-single-widget">
    217             <h5 class="cwp-widget-title">' . esc_html__( "Tags", "cubewp-framework" ) . '</h5>
     228
     229        if (!empty($post_tags)) {
     230            return '<div class="cwp-single-category-widget cwp-single-widget">
     231            <h5 class="cwp-widget-title">' . esc_html__("Tags", "cubewp-framework") . '</h5>
    218232            ' . self::get_post_breadcrumb_tags('tags') . '
    219233        </div>';
    220         }else{
     234        } else {
    221235            return '';
    222236        }
    223237    }
    224    
     238
    225239    /**
    226240     * Method get_post_sidebar
     
    229243     * @since  1.0.0
    230244     */
    231     public static function get_post_sidebar() {
    232         $output='<div class="cwp-single-left-side">
     245    public static function get_post_sidebar()
     246    {
     247        $output = '<div class="cwp-single-left-side">
    233248            ' . self::field_author() . '
    234249            </div>';
    235         if(!empty(self::get_post_sidebar_tags())){
    236             $output .='<div class="cwp-single-left-side">
     250        if (!empty(self::get_post_sidebar_tags())) {
     251            $output .= '<div class="cwp-single-left-side">
    237252                ' . self::get_post_sidebar_tags() . '
    238253            </div>';
    239254        }
    240         return $output;
    241     }
    242    
    243     /**
    244      * Method get_post_group_fields_callback
    245      *
    246      * @param array $fields
    247      *
    248      * @return string html
    249      * @since  1.0.0
    250      */
    251     public static function get_post_group_fields_callback($fields) {
     255        return $output;
     256    }
     257
     258    /**
     259     * Method get_post_group_fields_callback
     260     *
     261     * @param array $fields
     262     *
     263     * @return string html
     264     * @since  1.0.0
     265     */
     266    public static function get_post_group_fields_callback($fields)
     267    {
    252268        $output = null;
    253         foreach ($fields as $field) {
    254             $options = get_field_options($field);
    255             $field_type = isset($options['type']) ? $options['type'] : '';
     269        foreach ($fields as $field) {
     270            $options = get_field_options($field);
     271            $field_type = isset($options['type']) ? $options['type'] : '';
    256272            $meta_key = isset($options['name']) ? $options['name'] : '';
    257             if (empty($field_type) || empty($meta_key)) continue;
    258             if($field_type == 'taxonomy'){
    259                 if(isset($options) && count($options)>0 && !empty($options['filter_taxonomy'])){
     273            if (empty($field_type) || empty($meta_key)) continue;
     274            if ($field_type == 'taxonomy') {
     275                if (isset($options) && count($options) > 0 && !empty($options['filter_taxonomy'])) {
    260276                    $field_type = 'terms';
    261277                }
    262278            }
    263             $value = self::get_single_meta_value($meta_key,$field_type);
     279            $value = self::get_single_meta_value($meta_key, $field_type);
    264280            $options['value'] = $value;
    265             $options = apply_filters( 'cubewp/custom/cube/field/options', $options );
    266             if(function_exists('cube_' . $field_type)){
     281            $options = apply_filters('cubewp/custom/cube/field/options', $options);
     282            if (function_exists('cube_' . $field_type)) {
    267283                $output .= call_user_func('cube_' . $field_type, $options);
    268             }else if (method_exists(__CLASS__, 'field_' . $field_type)) {
    269                 $output .= call_user_func( array( __CLASS__, 'field_' . $field_type ), $options);
    270             }else {
    271                 $output .= '<p style="color: #ff0000">' . sprintf(esc_html__("Invalid Field Type: %s", "cubewp-framework"), $field_type) . '</p>';
    272             }
    273         }
     284            } else if (method_exists(__CLASS__, 'field_' . $field_type)) {
     285                $output .= call_user_func(array(__CLASS__, 'field_' . $field_type), $options);
     286            } else {
     287                $output .= '<p style="color: #ff0000">' . sprintf(esc_html__("Invalid Field Type: %s", "cubewp-framework"), $field_type) . '</p>';
     288            }
     289        }
    274290        return $output;
    275291    }
    276        
     292
    277293    /**
    278294     * Method get_single_meta_value
     
    284300     * @since  1.0.0
    285301     */
    286     public static function get_single_meta_value($meta_key='',$field_type=''){
    287        
    288         if($meta_key == 'the_title' || $meta_key == 'the_content' || $meta_key == 'the_excerpt' || $meta_key == 'featured_image'){
     302    public static function get_single_meta_value($meta_key = '', $field_type = '')
     303    {
     304
     305        if ($meta_key == 'the_title' || $meta_key == 'the_content' || $meta_key == 'the_excerpt' || $meta_key == 'featured_image') {
    289306            return '';
    290         }elseif($field_type == 'taxonomy'){
    291             $value = get_the_terms( self::$post_id, $meta_key );
    292         }elseif($field_type == 'dropdown' || $field_type == 'radio' || $field_type == 'checkbox'){
    293             $value = get_post_meta( self::$post_id, $meta_key, true );
     307        } elseif ($field_type == 'taxonomy') {
     308            $value = get_the_terms(self::$post_id, $meta_key);
     309        } elseif ($field_type == 'dropdown' || $field_type == 'radio' || $field_type == 'checkbox') {
     310            $value = get_post_meta(self::$post_id, $meta_key, true);
    294311            $value = render_multi_value($meta_key, $value);
    295         }elseif($field_type == 'repeating_field'){
    296             $values = get_post_meta( self::$post_id, $meta_key, true );
     312        } elseif ($field_type == 'repeating_field') {
     313            $values = get_post_meta(self::$post_id, $meta_key, true);
    297314            if (is_array($values)) {
    298315                $value  = self::get_repeating_Fields_value($values);
    299316            }
    300         }else{
    301             $value = get_post_meta( self::$post_id, $meta_key, true );
     317        } else {
     318            $value = get_post_meta(self::$post_id, $meta_key, true);
    302319            if ("google_address" === $field_type) {
    303                 $lat = get_post_meta( self::$post_id, $meta_key. '_lat', true );
    304                 $lng = get_post_meta( self::$post_id, $meta_key. '_lng', true );
     320                $lat = get_post_meta(self::$post_id, $meta_key . '_lat', true);
     321                $lng = get_post_meta(self::$post_id, $meta_key . '_lng', true);
    305322                $value = array(
    306323                    'address' => $value,
     
    310327            }
    311328        }
    312         if(empty($value)){
     329        if (empty($value)) {
    313330            return '';
    314331        }
    315         return apply_filters( 'cubewp/single/page/field/value', $value, self::$post_id, $meta_key, $field_type );
    316     }
    317        
    318     /**
    319      * Method get_repeating_Fields_value
    320      *
    321      * @param array $values
    322      *
    323      * @return array
    324      * @since  1.0.0
    325      */
    326     private static function get_repeating_Fields_value($values) {
     332        return apply_filters('cubewp/single/page/field/value', $value, self::$post_id, $meta_key, $field_type);
     333    }
     334
     335    /**
     336     * Method get_repeating_Fields_value
     337     *
     338     * @param array $values
     339     *
     340     * @return array
     341     * @since  1.0.0
     342     */
     343    private static function get_repeating_Fields_value($values)
     344    {
    327345        $value = array();
    328         if(isset($values) && !empty($values)){
    329             for($i = 0; $i < count($values); $i++){
    330                
    331                 foreach ($values[$i] as $k=> $subValue) {
     346        if (isset($values) && !empty($values)) {
     347            for ($i = 0; $i < count($values); $i++) {
     348
     349                foreach ($values[$i] as $k => $subValue) {
    332350                    $options = get_field_options($k);
    333                     if(count($options)>0){
     351                    if (count($options) > 0) {
    334352                        $field_type = $options['type'];
    335353                        $field_label = $options['label'];
    336354                        $field_class = $options['class'];
    337355                        if ("google_address" === $field_type) {
    338                             $lat = $values[$i][$k. '_lat'];
    339                             $lng = $values[$i][$k. '_lng'];
    340                            
     356                            $lat = $values[$i][$k . '_lat'];
     357                            $lng = $values[$i][$k . '_lng'];
     358
    341359                            $subValue = array(
    342360                                'address' => $subValue,
     
    344362                                'lng' => $lng
    345363                            );
    346                         }elseif($field_type == 'dropdown' || $field_type == 'radio' || $field_type == 'checkbox'){
     364                        } elseif ($field_type == 'dropdown' || $field_type == 'radio' || $field_type == 'checkbox') {
    347365                            $subValue = render_multi_value($k, $subValue);
    348366                        }
     
    360378        }
    361379    }
    362    
    363         /**
    364      * Method get_post_groups_callback
    365      *
    366      * @return string html
    367      * @since  1.0.0
    368      */
    369     public static function get_post_groups_callback() {
    370         $output = null;
     380
     381    /**
     382     * Method get_post_groups_callback
     383     *
     384     * @return string html
     385     * @since  1.0.0
     386     */
     387    public static function get_post_groups_callback()
     388    {
     389        $output = null;
    371390        if (is_array(self::$groups)) self::$groups = array_reverse(self::$groups);
    372391        foreach (self::$groups as $group) {
    373             $fields = cwp_get_fields_by_group_id( $group );
     392            $fields = cwp_get_fields_by_group_id($group);
    374393            if (!empty($fields) && is_array($fields)) {
    375394                $fields_ui = self::get_post_group_fields_callback($fields);
    376                 if(!empty($fields_ui)){
     395                if (!empty($fields_ui)) {
    377396                    $output .= '<div class="cwp-single-group">';
    378397                    $output .= $fields_ui;
    379                     $output .= '</div>';
     398                    $output .= '</div>';
    380399                }
    381400            }
     
    384403    }
    385404
    386    
     405
    387406    /**
    388407     * Method get_single_sidebar_area
     
    391410     * @since  1.0.0
    392411     */
    393     public static function get_single_sidebar_area() {
     412    public static function get_single_sidebar_area()
     413    {
    394414        echo self::get_post_sidebar();
    395 
    396     }   
     415    }
    397416    /**
    398417     * Method get_single_content_area
     
    400419     * @since  1.0.0
    401420     */
    402     public static function get_single_content_area() {
     421    public static function get_single_content_area()
     422    {
    403423        echo self::get_post_content();
    404424    }
    405    
     425
    406426    /**
    407427     * Method get_sections_data_of
     
    412432     * @since  1.0.0
    413433     */
    414     public static function get_sections_data_of($of='') {
     434    public static function get_sections_data_of($of = '')
     435    {
    415436        $section = array();
    416         if (is_array(self::$groups)){
     437        if (is_array(self::$groups)) {
    417438            foreach (self::$groups as $group) {
    418439                $section[$group]['title']  = get_the_title($group);
    419                 $section[$group]['class']  = 'class-'.$group;
    420                 $section[$group]['id']     = 'id-'.$group;
     440                $section[$group]['class']  = 'class-' . $group;
     441                $section[$group]['id']     = 'id-' . $group;
    421442            }
    422443        }
    423444        return $section;
    424445    }
    425    
    426     /**
    427      * Method get_post_content
    428      *
    429      * @return string html
    430      * @since  1.0.0
    431      */
    432     public static function get_post_content() {
     446
     447    /**
     448     * Method get_post_content
     449     *
     450     * @return string html
     451     * @since  1.0.0
     452     */
     453    public static function get_post_content()
     454    {
    433455        return '<div class="cwp-single-right-side">
    434456            <div class="cwp-single-groups">
     
    437459        </div>';
    438460    }
    439 
    440461}
  • cubewp-framework/trunk/cube/classes/page-builders/elementor-widgets/class-cubewp-elementor-posts-widget.php

    r3161906 r3202079  
    11<?php
    2 defined( 'ABSPATH' ) || exit;
     2defined('ABSPATH') || exit;
    33
    44use Elementor\Controls_Manager;
     
    1313 * @since 1.0.0
    1414 */
    15 class CubeWp_Elementor_Posts_Widget extends Widget_Base {
     15class CubeWp_Elementor_Posts_Widget extends Widget_Base
     16{
    1617
    1718    private static $post_types = array();
    1819    private static $settings = array();
    1920
    20     public function get_name() {
     21    public function get_name()
     22    {
    2123        return 'cubewp_posts';
    2224    }
    2325
    24     public function get_title() {
    25         return esc_html__( 'CubeWP Posts', 'cubewp-framework' );
     26    public function get_title()
     27    {
     28        return esc_html__('CubeWP Posts', 'cubewp-framework');
    2629    }
    2730
    28     public function get_icon() {
     31    public function get_icon()
     32    {
    2933        return 'eicon-post-list';
    3034    }
    3135
    32     public function get_categories() {
    33         return array( 'cubewp' );
     36    public function get_categories()
     37    {
     38        return array('cubewp');
    3439    }
    3540
    36     public function get_keywords() {
     41    public function get_keywords()
     42    {
    3743        return array(
    3844            'cubewp',
     
    5359    }
    5460
    55     protected function register_controls() {
     61    protected function register_controls()
     62    {
    5663        self::get_post_types();
    5764
    58         $this->start_controls_section( 'cubewp_widgets_section', array(
    59             'label' => esc_html__( 'Query Options', 'cubewp-framework' ),
     65        $this->start_controls_section('cubewp_widgets_section', array(
     66            'label' => esc_html__('Query Options', 'cubewp-framework'),
    6067            'tab'   => Controls_Manager::TAB_CONTENT,
    61         ) );
    62        
     68        ));
     69
    6370        $this->add_post_type_controls();
    6471        $this->add_additional_controls();
    65        
    66 
    67         $this->add_control( 'orderby', array(
     72
     73
     74        $this->add_control('orderby', array(
    6875            'type'    => Controls_Manager::SELECT,
    69             'label'   => esc_html__( 'Order By', 'cubewp-framework' ),
     76            'label'   => esc_html__('Order By', 'cubewp-framework'),
    7077            'options' => array(
    71                 'title' => esc_html__( 'Title', 'cubewp-framework' ),
    72                 'date'  => esc_html__( 'Most Recent', 'cubewp-framework' ),
    73                 'rand'  => esc_html__( 'Random', 'cubewp-framework' ),
     78                'title' => esc_html__('Title', 'cubewp-framework'),
     79                'date'  => esc_html__('Most Recent', 'cubewp-framework'),
     80                'rand'  => esc_html__('Random', 'cubewp-framework'),
    7481            ),
    7582            'default' => 'date',
    76         ) );
    77         $this->add_control( 'order', array(
     83        ));
     84        $this->add_control('order', array(
    7885            'type'      => Controls_Manager::SELECT,
    79             'label'     => esc_html__( 'Order', 'cubewp-framework' ),
     86            'label'     => esc_html__('Order', 'cubewp-framework'),
    8087            'options'   => array(
    81                 'ASC'  => esc_html__( 'Ascending', 'cubewp-framework' ),
    82                 'DESC' => esc_html__( 'Descending', 'cubewp-framework' ),
     88                'ASC'  => esc_html__('Ascending', 'cubewp-framework'),
     89                'DESC' => esc_html__('Descending', 'cubewp-framework'),
    8390            ),
    8491            'default'   => 'DESC',
     
    8693                'orderby!' => 'rand',
    8794            ),
    88         ) );
    89         $this->add_control( 'number_of_posts', array(
     95        ));
     96        $this->add_control('number_of_posts', array(
    9097            'type'    => Controls_Manager::SELECT,
    91             'label'   => esc_html__( 'Number Of Posts', 'cubewp-framework' ),
     98            'label'   => esc_html__('Number Of Posts', 'cubewp-framework'),
    9299            'options' => array(
    93                 '-1' => esc_html__( 'All Posts', 'cubewp-framework' ),
    94                 '3'  => esc_html__( '3 Posts', 'cubewp-framework' ),
    95                 '4'  => esc_html__( '4 Posts', 'cubewp-framework' ),
    96                 '5'  => esc_html__( '5 Posts', 'cubewp-framework' ),
    97                 '6'  => esc_html__( '6 Posts', 'cubewp-framework' ),
    98                 '8'  => esc_html__( '8 Posts', 'cubewp-framework' ),
    99                 '9'  => esc_html__( '9 Posts', 'cubewp-framework' ),
    100                 '12' => esc_html__( '12 Posts', 'cubewp-framework' ),
    101                 '16' => esc_html__( '16 Posts', 'cubewp-framework' ),
    102                 '15' => esc_html__( '15 Posts', 'cubewp-framework' ),
    103                 '20' => esc_html__( '20 Posts', 'cubewp-framework' )
     100                '-1' => esc_html__('All Posts', 'cubewp-framework'),
     101                '1'  => esc_html__('1 Post', 'cubewp-framework'),
     102                '2'  => esc_html__('2 Posts', 'cubewp-framework'),
     103                '3'  => esc_html__('3 Posts', 'cubewp-framework'),
     104                '4'  => esc_html__('4 Posts', 'cubewp-framework'),
     105                '5'  => esc_html__('5 Posts', 'cubewp-framework'),
     106                '6'  => esc_html__('6 Posts', 'cubewp-framework'),
     107                '8'  => esc_html__('8 Posts', 'cubewp-framework'),
     108                '9'  => esc_html__('9 Posts', 'cubewp-framework'),
     109                '12' => esc_html__('12 Posts', 'cubewp-framework'),
     110                '16' => esc_html__('16 Posts', 'cubewp-framework'),
     111                '15' => esc_html__('15 Posts', 'cubewp-framework'),
     112                '20' => esc_html__('20 Posts', 'cubewp-framework')
    104113            ),
    105114            'default' => '3'
    106         ) );
    107         $this->add_control( 'load_more', array(
     115        ));
     116        $this->add_control('load_more', array(
    108117            'type'      => Controls_Manager::SWITCHER,
    109             'label'     => esc_html__( 'Load More Button', 'cubewp-framework' ),
     118            'label'     => esc_html__('Load More Button', 'cubewp-framework'),
    110119            'default'   => 'yes',
    111120            'condition' => array(
    112121                'number_of_posts' => '-1',
    113122            )
    114         ) );
    115         $this->add_control( 'posts_per_page', array(
     123        ));
     124        $this->add_control('posts_per_page', array(
    116125            'type'    => Controls_Manager::NUMBER,
    117             'label'   => esc_html__( 'Posts Per Page', 'cubewp-framework' ),
     126            'label'   => esc_html__('Posts Per Page', 'cubewp-framework'),
    118127            'default' => '6',
    119128            'condition' => array(
     
    121130                'load_more' => 'yes',
    122131            )
    123         ) );
    124        
    125         $this->add_control( 'layout', array(
     132        ));
     133
     134        $this->add_control('layout', array(
    126135            'type'    => Controls_Manager::SELECT,
    127             'label'   => esc_html__( 'Layout', 'cubewp-framework' ),
     136            'label'   => esc_html__('Layout', 'cubewp-framework'),
    128137            'options' => array(
    129                 'grid' => esc_html__( 'Grid View', 'cubewp-framework' ),
    130                 'list' => esc_html__( 'List View', 'cubewp-framework' )
     138                'grid' => esc_html__('Grid View', 'cubewp-framework'),
     139                'list' => esc_html__('List View', 'cubewp-framework')
    131140            ),
    132141            'default' => 'grid'
    133         ) );
     142        ));
     143
     144        $this->add_control('enable_scroll_on_small_devices', array(
     145            'type'      => Controls_Manager::SWITCHER,
     146            'label'     => esc_html__('Enable Scroll on Small Devices', 'cubewp-framework'),
     147            'default'   => '',
     148            'description' => esc_html__('Enable overflow scroll behaviour on small devices.', 'cubewp-framework'),
     149            'condition' => array(
     150                'cwp_enable_slider!' => 'yes',
     151            ),
     152        ));
    134153
    135154        $this->end_controls_section();
    136155
    137         $this->start_controls_section( 'cubewp_posts_widget_additional_setting_section', array(
    138             'label' => esc_html__( 'Filter By Meta / Custom Fields', 'cubewp-classifiad' ),
     156        $this->start_controls_section('cubewp_posts_widget_additional_setting_section', array(
     157            'label' => esc_html__('Filter By Meta / Custom Fields', 'cubewp-classifiad'),
    139158            'tab'   => Controls_Manager::TAB_CONTENT,
    140159            'condition' => array(
    141                 'posts_by'  => array('all','taxonomy'),
     160                'posts_by'  => array('all', 'taxonomy'),
    142161            ),
    143         ) );
    144         $this->add_control( 'filter_by_meta', array(
     162        ));
     163        $this->add_control('filter_by_meta', array(
    145164            'type'      => Controls_Manager::SWITCHER,
    146             'label'     => esc_html__( 'Filter By Meta / Custom Field', 'cubewp-framework' ),
     165            'label'     => esc_html__('Filter By Meta / Custom Field', 'cubewp-framework'),
    147166            'default'   => 'no',
    148         ) );
    149        
    150         $this->add_control( 'meta_relation', array(
     167        ));
     168
     169        $this->add_control('meta_relation', array(
    151170            'type'      => Controls_Manager::SELECT,
    152             'label'     => esc_html__( 'Select Relation', 'cubewp-classifiad' ),
    153             'description'   => esc_html__( "e.g. If you have multiple custom field's conditions and you set relation OR then system will get result if one of these conditions will be true.", "cubewp-framework" ),
     171            'label'     => esc_html__('Select Relation', 'cubewp-classifiad'),
     172            'description'   => esc_html__("e.g. If you have multiple custom field's conditions and you set relation OR then system will get result if one of these conditions will be true.", "cubewp-framework"),
    154173            'options'   => array(
    155                 'OR'  => esc_html__( 'OR', 'cubewp-classifiad' ),
    156                 'AND'  => esc_html__( "AND", 'cubewp-classifiad' ),
     174                'OR'  => esc_html__('OR', 'cubewp-classifiad'),
     175                'AND'  => esc_html__("AND", 'cubewp-classifiad'),
    157176            ),
    158177            'default'   => 'or',
     
    160179                'filter_by_meta'  => 'yes',
    161180            ),
    162         ) );
     181        ));
    163182
    164183        $repeater = new Repeater();
    165184
    166         $repeater->add_control( 'meta_key', array(
     185        $repeater->add_control('meta_key', array(
    167186            'type'      => Controls_Manager::SELECT2,
    168             'label'     => esc_html__( 'Select Custom Field', 'cubewp-framework' ),
    169             'options'   => get_fields_by_type(array('number','text','checkbox')),
     187            'label'     => esc_html__('Select Custom Field', 'cubewp-framework'),
     188            'options'   => get_fields_by_type(array('number', 'text', 'checkbox')),
    170189            'label_block' => true,
    171         ) );
    172 
    173         $repeater->add_control( 'meta_value', array(
     190        ));
     191
     192        $repeater->add_control('meta_value', array(
    174193            'type'      => Controls_Manager::TEXT,
    175             'label'     => esc_html__( 'Put here meta value', 'cubewp-framework' ),
    176             'placeholder'   => esc_html__( "e.g. APPLE", "cubewp-framework" ),
    177             'description'   => esc_html__( "e.g. If custom field is BRAND NAME, you can set value as APPLE to get all those posts who set this meta.", "cubewp-framework" ),
     194            'label'     => esc_html__('Put here meta value', 'cubewp-framework'),
     195            'placeholder'   => esc_html__("e.g. APPLE", "cubewp-framework"),
     196            'description'   => esc_html__("e.g. If custom field is BRAND NAME, you can set value as APPLE to get all those posts who set this meta.", "cubewp-framework"),
    178197            'label_block' => true,
    179         ) );
    180 
    181         $repeater->add_control( 'meta_compare', array(
     198        ));
     199
     200        $repeater->add_control('meta_compare', array(
    182201            'type'      => Controls_Manager::SELECT,
    183             'label'     => esc_html__( 'Select Operator to compare ', 'cubewp-classifiad' ),
    184             'description'   => esc_html__( "e.g. If going to select BETWEEN or NOT BETWEEN then add value like this [100, 200].", "cubewp-framework" ),
     202            'label'     => esc_html__('Select Operator to compare ', 'cubewp-classifiad'),
     203            'description'   => esc_html__("e.g. If going to select BETWEEN or NOT BETWEEN then add value like this [100, 200].", "cubewp-framework"),
    185204            'options'   => array(
    186                 '='  => esc_html__( 'Equal', 'cubewp-framework' ),
    187                 '!='  => esc_html__( 'Not Equal', 'cubewp-framework' ),
    188                 '>'  => esc_html__( 'Greater Than', 'cubewp-framework' ),
    189                 '>='  => esc_html__( 'Greater Than or Equal', 'cubewp-framework' ),
    190                 '<'  => esc_html__( 'Less Than', 'cubewp-framework' ),
    191                 '<='  => esc_html__( 'Less Than or Equal', 'cubewp-framework' ),
    192                 'LIKE'  => esc_html__( 'LIKE %', 'cubewp-framework' ),
    193                 'NOT LIKE'  => esc_html__( 'NOT LIKE', 'cubewp-framework' ),
    194                 'IN' => esc_html__( 'IN', 'cubewp-framework' ),
    195                 'NOT IN' => esc_html__( 'NOT IN', 'cubewp-framework' ),
    196                 'BETWEEN' => esc_html__( 'BETWEEN', 'cubewp-framework' ),
    197                 'NOT BETWEEN' => esc_html__( 'NOT BETWEEN', 'cubewp-framework' ),
    198                 'EXISTS' => esc_html__( 'EXISTS', 'cubewp-framework' ),
    199                 'NOT EXISTS' => esc_html__( 'NOT EXISTS', 'cubewp-framework' ),
     205                '='  => esc_html__('Equal', 'cubewp-framework'),
     206                '!='  => esc_html__('Not Equal', 'cubewp-framework'),
     207                '>'  => esc_html__('Greater Than', 'cubewp-framework'),
     208                '>='  => esc_html__('Greater Than or Equal', 'cubewp-framework'),
     209                '<'  => esc_html__('Less Than', 'cubewp-framework'),
     210                '<='  => esc_html__('Less Than or Equal', 'cubewp-framework'),
     211                'LIKE'  => esc_html__('LIKE %', 'cubewp-framework'),
     212                'NOT LIKE'  => esc_html__('NOT LIKE', 'cubewp-framework'),
     213                'IN' => esc_html__('IN', 'cubewp-framework'),
     214                'NOT IN' => esc_html__('NOT IN', 'cubewp-framework'),
     215                'BETWEEN' => esc_html__('BETWEEN', 'cubewp-framework'),
     216                'NOT BETWEEN' => esc_html__('NOT BETWEEN', 'cubewp-framework'),
     217                'EXISTS' => esc_html__('EXISTS', 'cubewp-framework'),
     218                'NOT EXISTS' => esc_html__('NOT EXISTS', 'cubewp-framework'),
    200219            ),
    201220            'default'   => 'LIKE',
     
    204223                'meta_value!' => '',
    205224            ),
    206         ) );
    207 
    208         $this->add_control( 'filter_by_custom_fields', array(
    209             'label'       => esc_html__( 'Add Conditions', 'cubewp-classifiad' ),
     225        ));
     226
     227        $this->add_control('filter_by_custom_fields', array(
     228            'label'       => esc_html__('Add Conditions', 'cubewp-classifiad'),
    210229            'type'        => Controls_Manager::REPEATER,
    211230            'fields'      => $repeater->get_controls(),
     
    215234                'posttype!' => '',
    216235            ),
    217            
    218         ) );
     236
     237        ));
    219238        $this->end_controls_section();
     239        $this->add_slider_controls();
    220240    }
    221241
    222     private static function get_post_types() {
     242    private static function get_post_types()
     243    {
    223244        $post_types = get_post_types(['public' => true], 'objects');
    224         $options = [];
    225         foreach ($post_types as $post_type) {
    226             $options[$post_type->name] = $post_type->label;
    227         }
    228         unset( $options['elementor_library'] );
    229         unset( $options['e-landing-page'] );
    230         unset( $options['attachment'] );
    231         unset( $options['page'] );
     245        $options = [];
     246        foreach ($post_types as $post_type) {
     247            $options[$post_type->name] = $post_type->label;
     248        }
     249        unset($options['elementor_library']);
     250        unset($options['e-landing-page']);
     251        unset($options['attachment']);
     252        unset($options['page']);
    232253
    233254        self::$post_types = $options;
    234255    }
    235    
    236     private function add_post_type_controls() {
     256
     257    private function add_post_type_controls()
     258    {
    237259        $post_types = self::$post_types;
    238         if ( is_array( $post_types ) && ! empty( $post_types ) ) {
    239             $this->add_control( 'posttype', array(
     260        if (is_array($post_types) && ! empty($post_types)) {
     261            $this->add_control('posttype', array(
    240262                'type'        => Controls_Manager::SELECT2,
    241263                'multiple'    => true,
    242                 'label'       => esc_html__( 'Select Post Types', 'cubewp-classifiad' ),
    243                 'description' => esc_html__( 'You can select one or multiple post types to show post cards.', 'cubewp-framework' ),
     264                'label'       => esc_html__('Select Post Types', 'cubewp-classifiad'),
     265                'description' => esc_html__('You can select one or multiple post types to show post cards.', 'cubewp-framework'),
    244266                'options'     => $post_types,
    245                 'default'     => array( 'post' ),
     267                'default'     => array('post'),
    246268                'label_block' => true,
    247             ) );
    248             foreach ( $post_types as $slug => $post_type ) {
    249                 $this->add_card_style_controls( $slug );
     269            ));
     270            foreach ($post_types as $slug => $post_type) {
     271                $this->add_card_style_controls($slug);
    250272            }
    251273        }
    252274    }
    253275
    254     private function add_card_style_controls($post_type) {
    255         if(class_exists('CubeWp_Frontend_Load')){
    256             if(!empty(cubewp_post_card_styles($post_type))){
    257                 $this->add_control( $post_type.'_card_style', array(
    258                     'type'        => Controls_Manager::SELECT,
    259                     'label'       => esc_html__( 'Card Style for '.self::get_post_type_name_by_slug($post_type), 'cubewp-framework' ),
    260                     'options'     => cubewp_post_card_styles($post_type),
    261                     'default'     => 'default_style',
    262                     'condition'   => array(
    263                         'posttype' => $post_type
    264                     )
    265                 ) );
    266             }
     276    private function add_card_style_controls($post_type)
     277    {
     278        if (!empty(cubewp_post_card_styles($post_type))) {
     279            $this->add_control($post_type . '_card_style', array(
     280                'type'        => Controls_Manager::SELECT,
     281                'label'       => esc_html__('Card Style for ' . self::get_post_type_name_by_slug($post_type), 'cubewp-framework'),
     282                'options'     => cubewp_post_card_styles($post_type),
     283                'default'     => 'default_style',
     284                'condition'   => array(
     285                    'posttype' => $post_type
     286                )
     287            ));
    267288        }
    268289    }
    269290
    270     private function add_additional_controls() {
    271        
     291    private function add_additional_controls()
     292    {
     293
    272294        $post_types = self::$post_types;
    273         if ( is_array( $post_types ) && ! empty( $post_types ) ) {
     295        if (is_array($post_types) && ! empty($post_types)) {
    274296            $options = array(
    275                 "all" => esc_html__( "All" ),
    276                 "taxonomy" => esc_html__( "By Taxonomy" ),
     297                "all" => esc_html__("All"),
     298                "taxonomy" => esc_html__("By Taxonomy"),
    277299                //"post_ids" => esc_html__( "By IDs" ),
    278300            );
    279             if(class_exists('CubeWp_Booster_Load')){
    280                 $options['boosted'] = esc_html__( "Boosted Only" );
     301            if (class_exists('CubeWp_Booster_Load')) {
     302                $options['boosted'] = esc_html__("Boosted Only");
    281303            }
    282             $this->add_control( 'posts_by', array(
     304            $this->add_control('posts_by', array(
    283305                'type'    => Controls_Manager::SELECT,
    284                 'label'   => esc_html__( 'Show Posts', 'cubewp-framework' ),
     306                'label'   => esc_html__('Show Posts', 'cubewp-framework'),
    285307                'options' => $options,
    286308                'condition' => array(
     
    288310                ),
    289311                'default' => 'all'
    290             ) );
    291             foreach ( $post_types as $slug => $post_type ) {
    292                 $this->add_taxonomy_controls( $slug );
    293                 $this->add_posttype_controls( $slug );
     312            ));
     313            foreach ($post_types as $slug => $post_type) {
     314                $this->add_taxonomy_controls($slug);
     315                $this->add_posttype_controls($slug);
    294316            }
    295317        }
    296318    }
    297319
    298     private function add_taxonomy_controls( $post_type ) {
    299         $taxonomies = get_object_taxonomies( $post_type );
    300         $taxonomies = array_combine( $taxonomies, $taxonomies );
    301         if ( is_array( $taxonomies ) && ! empty( $taxonomies ) ) {
    302             $this->add_control( 'taxonomy-' . $post_type, array(
     320    private function add_taxonomy_controls($post_type)
     321    {
     322        $taxonomies = get_object_taxonomies($post_type);
     323        $taxonomies = array_combine($taxonomies, $taxonomies);
     324        if (is_array($taxonomies) && ! empty($taxonomies)) {
     325            $this->add_control('taxonomy-' . $post_type, array(
    303326                'type'      => Controls_Manager::SELECT2,
    304                 'label'     => esc_html__( 'Select Terms for '.self::get_post_type_name_by_slug($post_type), 'cubewp-framework' ),
     327                'label'     => esc_html__('Select Terms for ' . self::get_post_type_name_by_slug($post_type), 'cubewp-framework'),
    305328                'description' => esc_html__('Leave empty if you want to display all posts.', 'cubewp-framework'),
    306329                'options'   => self::get_terms_by_post_type($post_type),
     
    311334                ),
    312335                'label_block' => true,
    313             ) );
     336            ));
    314337        }
    315338    }
    316339
    317     private function add_posttype_controls( $post_type ) {
     340    private function add_posttype_controls($post_type)
     341    {
    318342        //$posts = self::get_post_type_posts( $post_type );
    319        
    320         if ( ! empty( $posts ) ) {
    321             $this->add_control( $post_type . '_post__in', array(
     343
     344        if (! empty($posts)) {
     345            $this->add_control($post_type . '_post__in', array(
    322346                'type'        => Controls_Manager::SELECT2,
    323                 'label'       => esc_html__( 'Please Select Posts for '.self::get_post_type_name_by_slug($post_type), 'cubewp-framework' ),
     347                'label'       => esc_html__('Please Select Posts for ' . self::get_post_type_name_by_slug($post_type), 'cubewp-framework'),
    324348                'description' => esc_html__('Leave empty if you want to display all posts.', 'cubewp-framework'),
    325349                'options'     => $posts,
    326350                'multiple'    => true,
    327                 'placeholder' => esc_html__( 'Please Select Posts', 'cubewp-framework' ),
     351                'placeholder' => esc_html__('Please Select Posts', 'cubewp-framework'),
    328352                'condition'   => array(
    329353                    'posts_by' => "post_ids",
     
    331355                ),
    332356                'label_block' => true,
    333             ) );
     357            ));
    334358        }
    335359    }
    336360
    337     private static function get_post_type_posts( $post_types ) {
    338         $query  = new CubeWp_Query( array(
    339            'post_type'      => $post_types,
    340            'posts_per_page' => - 1
    341         ) );
     361    private static function get_post_type_posts($post_types)
     362    {
     363        $query  = new CubeWp_Query(array(
     364            'post_type'      => $post_types,
     365            'posts_per_page' => -1
     366        ));
    342367        $posts  = $query->cubewp_post_query();
    343368        $return = array();
    344         if ( $posts->have_posts() ) :
    345                 while ( $posts->have_posts() ) : $posts->the_post();
    346                     $return[ get_the_ID() ] = get_the_title() . ' [' . get_the_ID() . ']';
    347                 endwhile;
    348             endif;
    349      
     369        if ($posts->have_posts()) :
     370            while ($posts->have_posts()) : $posts->the_post();
     371                $return[get_the_ID()] = get_the_title() . ' [' . get_the_ID() . ']';
     372            endwhile;
     373        endif;
     374
    350375        return $return;
    351376    }
    352377
    353     private static function get_terms_by_post_type( $post_type ) {
     378    private static function get_terms_by_post_type($post_type)
     379    {
    354380        $object  = cubewp_terms_by_post_types($post_type);
    355381        $termArray = [];
    356         if(!empty($object)){
    357             foreach($object as $key => $terms){
    358                 $termArray['['.$terms['taxonomy'].']'.$key] = $terms['name'];
     382        if (!empty($object)) {
     383            foreach ($object as $key => $terms) {
     384                $termArray['[' . $terms['taxonomy'] . ']' . $key] = $terms['name'];
    359385            }
    360386        }
    361      
     387
    362388        return $termArray;
    363389    }
    364390
    365     private static function get_post_type_name_by_slug($post_type_slug) {
     391    private static function get_post_type_name_by_slug($post_type_slug)
     392    {
    366393        $post_type_object = get_post_type_object($post_type_slug);
    367394        // Check if the post type object exists and return its label (name)
     
    372399    }
    373400
    374     protected static function split_taxonomy_and_term($input) {
     401    protected static function split_taxonomy_and_term($input)
     402    {
    375403        if (preg_match('/\[(.*?)\](.*)/', $input, $matches)) {
    376404            return [
     
    379407            ];
    380408        }
    381    
     409
    382410        // Return null if the format is not matched
    383411        return null;
    384412    }
    385413
    386     private static function _meta_query($args){
    387         if(is_array($args) && isset($args['query']) && !empty($args['query'])){
     414    private static function _meta_query($args)
     415    {
     416        if (is_array($args) && isset($args['query']) && !empty($args['query'])) {
    388417            $meta_query = array();
    389418            $meta_query['relation'] = $args['relation'];
    390419            $numeric_comparisons = ['=', '!=', '>', '>=', '<', '<=', 'BETWEEN', 'NOT BETWEEN'];
    391             foreach($args['query'] as $index => $query){
     420            foreach ($args['query'] as $index => $query) {
    392421                $meta_query[$index] = array(
    393422                    'key'  => $query['meta_key'],
     
    401430            return $meta_query;
    402431        }
    403     }
    404 
    405     protected function render() {
     432    }
     433
     434    protected function render()
     435    {
    406436        $settings   = $this->get_settings_for_display();
    407437        $meta_query = array();
    408         $posts_by = isset( $settings[ 'posts_by' ] ) ? $settings[ 'posts_by' ] : '';
    409         $filter_by_meta = isset( $settings[ 'filter_by_meta' ] ) ? $settings[ 'filter_by_meta' ] : array();
    410        
     438        $posts_by = isset($settings['posts_by']) ? $settings['posts_by'] : '';
     439        $filter_by_meta = isset($settings['filter_by_meta']) ? $settings['filter_by_meta'] : array();
     440
     441        $widget_id = $this->get_id();
     442        if ($settings['enable_scroll_on_small_devices'] === 'yes') {
     443            echo '<style>
     444                @media (max-width: 767px) {
     445                    .elementor-element-' . $widget_id . ' .cwp-row {
     446                        overflow: scroll;
     447                        flex-wrap: nowrap;
     448                    }
     449                }
     450            </style>';
     451        }
     452
     453        $prev_icon = '';
     454        $prev_icon_type = false;
     455        if (!empty($settings['prev_icon']['value'])) {
     456            if ('svg' === $settings['prev_icon']['library']) {
     457                $prev_icon_url = esc_url($settings['prev_icon']['value']['url']);
     458                $prev_icon_content = file_get_contents($prev_icon_url);
     459                $prev_icon = $prev_icon_content;
     460            } else {
     461                $prev_icon = esc_attr($settings['prev_icon']['value']);
     462                $prev_icon_type = true;
     463            }
     464        }
     465        $next_icon = '';
     466        $next_icon_type = false;
     467        if (!empty($settings['next_icon']['value'])) {
     468            if ('svg' === $settings['next_icon']['library']) {
     469                $next_icon_url = esc_url($settings['next_icon']['value']['url']);
     470                $next_icon_content = file_get_contents($next_icon_url);
     471                $next_icon = $next_icon_content;
     472            } else {
     473                $next_icon =  esc_attr($settings['next_icon']['value']);
     474                $next_icon_type = true;
     475            }
     476        }
     477        $slides_to_show = $settings['slides_to_show'];
     478        $slides_to_scroll = $settings['slides_to_scroll'];
     479        $slides_to_show_tablet = $settings['slides_to_show_tablet'];
     480        $slides_to_show_tablet_portrait = $settings['slides_to_show_tablet_portrait'];
     481        $slides_to_show_mobile = $settings['slides_to_show_mobile'];
     482        $slides_to_scroll_tablet = $settings['slides_to_scroll_tablet'];
     483        $slides_to_scroll_tablet_portrait = $settings['slides_to_scroll_tablet_portrait'];
     484        $slides_to_scroll_mobile = $settings['slides_to_scroll_mobile'];
     485        $autoplay = $settings['autoplay'] === 'yes' ? true : false;
     486        $autoplay_speed = $settings['autoplay_speed'];
     487        $speed = $settings['speed'];
     488        $infinite = $settings['infinite'] === 'yes' ? true : false;
     489        $variable_width = $settings['variable_width'] === 'yes' ? true : false;
     490        $custom_arrows = $settings['custom_arrows'] === 'yes' ? true : false;
     491        $custom_dots = $settings['custom_dots'] === 'yes' ? true : false;
     492        $enable_progress_bar = $settings['enable_progress_bar'] === 'yes' ? true : false;
     493
    411494        $args = array(
    412495            'post_type'       => $settings['posttype'],
     
    421504            'boosted_only'   => 'no',
    422505            'paged'   => '1',
    423         );
    424 
    425         if(is_array($settings['posttype']) && ($posts_by !== 'boosted' || $posts_by !== 'all')){
    426             foreach($settings['posttype'] as $post_type){
    427 
    428                 if($posts_by == 'post_ids'){
    429 
    430                     $post_in = isset( $settings[ $post_type . '_post__in' ] ) ? $settings[ $post_type . '_post__in' ] : array();
    431                     if(!empty($post_in)){
    432                         $args['post__in'] = array_merge($args['post__in'],$post_in);
     506            'cwp_enable_slider' => $settings['cwp_enable_slider'] === 'yes' ? 'cubewp-post-slider' : '',
     507            'prev_icon' => $prev_icon,
     508            'next_icon' => $next_icon,
     509            'next_icon_type' => $next_icon_type,
     510            'prev_icon_type' => $prev_icon_type,
     511            'slides_to_show' => $slides_to_show,
     512            'slides_to_scroll' => $slides_to_scroll,
     513            'slides_to_show_tablet' => $slides_to_show_tablet,
     514            'slides_to_show_tablet_portrait' => $slides_to_show_tablet_portrait,
     515            'slides_to_show_mobile' => $slides_to_show_mobile,
     516            'slides_to_scroll_tablet' => $slides_to_scroll_tablet,
     517            'slides_to_scroll_tablet_portrait' => $slides_to_scroll_tablet_portrait,
     518            'slides_to_scroll_mobile' => $slides_to_scroll_mobile,
     519            'autoplay' => $autoplay,
     520            'autoplay_speed' => $autoplay_speed,
     521            'speed' => $speed,
     522            'infinite' => $infinite,
     523            'variable_width' => $variable_width,
     524            'custom_arrows' => $custom_arrows,
     525            'custom_dots' => $custom_dots,
     526            'enable_progress_bar' => $enable_progress_bar,
     527        );
     528
     529        if (is_array($settings['posttype']) && ($posts_by !== 'boosted' || $posts_by !== 'all')) {
     530            foreach ($settings['posttype'] as $post_type) {
     531
     532                if ($posts_by == 'post_ids') {
     533
     534                    $post_in = isset($settings[$post_type . '_post__in']) ? $settings[$post_type . '_post__in'] : array();
     535                    if (!empty($post_in)) {
     536                        $args['post__in'] = array_merge($args['post__in'], $post_in);
    433537                    }
    434 
    435                 }elseif($posts_by == 'taxonomy'){
    436 
    437                     $terms = isset($settings[ 'taxonomy-' . $post_type ]) ? $settings[ 'taxonomy-' . $post_type ]: array();
    438                     if(!empty($terms)){
    439                         foreach ( $terms as $term ) {
     538                } elseif ($posts_by == 'taxonomy') {
     539
     540                    $terms = isset($settings['taxonomy-' . $post_type]) ? $settings['taxonomy-' . $post_type] : array();
     541                    if (!empty($terms)) {
     542                        foreach ($terms as $term) {
    440543                            $result = self::split_taxonomy_and_term($term);
    441544                            if ($result) {
    442                                 $args['taxonomy'] = array_unique(array_merge($args['taxonomy'],array($result['taxonomy'])));
    443                                 $args[ $result['taxonomy'] . '-terms' ][] = $result['term_slug'];
     545                                $args['taxonomy'] = array_unique(array_merge($args['taxonomy'], array($result['taxonomy'])));
     546                                $args[$result['taxonomy'] . '-terms'][] = $result['term_slug'];
    444547                            }
    445548                        }
    446549                    }
    447 
    448550                }
    449                 $card_style = isset( $settings[ $post_type . '_card_style' ] ) ? $settings[ $post_type . '_card_style' ] : '';
    450                 if(!empty($card_style)){
     551                $card_style = isset($settings[$post_type . '_card_style']) ? $settings[$post_type . '_card_style'] : '';
     552                if (!empty($card_style)) {
    451553                    $args['card_style'][$post_type] = $card_style;
    452554                }
    453555            }
    454556        }
    455        
    456         if(class_exists('CubeWp_Booster_Load')){
    457             if($posts_by == 'boosted'){
    458                 $args['boosted_only'] = 'yes';
     557
     558        if (class_exists('CubeWp_Booster_Load')) {
     559            if ($posts_by == 'boosted') {
     560                $args['boosted_only'] = 'yes';
    459561            }
    460         }
    461 
    462         if($filter_by_meta == 'yes'){
    463             $meta_query['query'] = isset( $settings[ 'filter_by_custom_fields' ] ) ? $settings[ 'filter_by_custom_fields' ] : array();
    464             $meta_query['relation'] = isset( $settings[ 'meta_relation' ] ) ? $settings[ 'meta_relation' ] : 'OR';
     562        }
     563
     564        if ($filter_by_meta == 'yes') {
     565            $meta_query['query'] = isset($settings['filter_by_custom_fields']) ? $settings['filter_by_custom_fields'] : array();
     566            $meta_query['relation'] = isset($settings['meta_relation']) ? $settings['meta_relation'] : 'OR';
    465567            $args['meta_query'] = self::_meta_query($meta_query);
    466568        }
    467        
    468 
    469         echo apply_filters( 'cubewp_shortcode_posts_output','', $args );
     569
     570
     571        echo apply_filters('cubewp_shortcode_posts_output', '', $args);
    470572    }
    471573
     574    private function add_slider_controls()
     575    {
     576
     577        $this->start_controls_section(
     578            'slider_style_section',
     579            [
     580                'label' => esc_html__('Posts Slider', 'cubewp-framework'),
     581                'tab' => Controls_Manager::TAB_CONTENT,
     582            ]
     583        );
     584
     585        $this->add_control(
     586            'cwp_enable_slider',
     587            [
     588                'label'        => esc_html__('Enable Slider', 'cubewp-framework'),
     589                'type'         => Controls_Manager::SWITCHER,
     590                'label_on'     => esc_html__('Yes', 'cubewp-framework'),
     591                'label_off'    => esc_html__('No', 'cubewp-framework'),
     592                'return_value' => 'yes',
     593                'default'      => '',
     594                'condition'    => [
     595                    'layout' => 'grid',
     596                ],
     597            ]
     598        );
     599
     600
     601        $this->add_responsive_control(
     602            'slider_post_spacing',
     603            [
     604                'label'        => esc_html__('Post Spacing', 'cubewp-framework'),
     605                'type'         => Controls_Manager::DIMENSIONS,
     606                'size_units'   => ['px', 'em', '%'],
     607                'selectors'  => [
     608                    '{{WRAPPER}} .cubewp-post-slider .slick-slide>div ' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
     609                    '{{WRAPPER}} .cwp-row>div' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
     610                ],
     611            ]
     612        );
     613
     614        $this->add_control('slides_to_show', array(
     615            'type'    => Controls_Manager::NUMBER,
     616            'label'   => esc_html__('Slides To Show', 'cubewp-framework'),
     617            'default' => 3,
     618            'min'     => 1,
     619            'max'     => 10,
     620            'step'    => 1,
     621            'description' => esc_html__('Number of slides to show at once in the slider.', 'cubewp-framework'),
     622            'condition'   => [
     623                'cwp_enable_slider' => 'yes',
     624            ],
     625        ));
     626
     627        $this->add_control(
     628            'slides_to_scroll',
     629            [
     630                'type'    => Controls_Manager::NUMBER,
     631                'label'   => esc_html__('Slides To Scroll', 'cubewp-framework'),
     632                'default' => 1,
     633                'min'     => 1,
     634                'max'     => 10,
     635                'step'    => 1,
     636                'description' => esc_html__('Number of slides to scroll at once in the slider.', 'cubewp-framework'),
     637                'condition'   => [
     638                    'cwp_enable_slider' => 'yes',
     639                ],
     640            ]
     641        );
     642
     643        $this->add_control(
     644            'autoplay',
     645            [
     646                'type'    => Controls_Manager::SWITCHER,
     647                'label'   => esc_html__('Autoplay', 'cubewp-framework'),
     648                'default' => 'yes',
     649                'description' => esc_html__('Enable or disable autoplay for the slider.', 'cubewp-framework'),
     650                'condition'   => [
     651                    'cwp_enable_slider' => 'yes',
     652                ],
     653            ]
     654        );
     655
     656        $this->add_control(
     657            'autoplay_speed',
     658            [
     659                'type'    => Controls_Manager::NUMBER,
     660                'label'   => esc_html__('Autoplay Speed (ms)', 'cubewp-framework'),
     661                'default' => 2000,
     662                'min'     => 500,
     663                'max'     => 10000,
     664                'step'    => 500,
     665                'description' => esc_html__('Set the speed for autoplay in milliseconds.', 'cubewp-framework'),
     666                'condition'   => [
     667                    'cwp_enable_slider' => 'yes',
     668                    'autoplay'      => 'yes',
     669                ],
     670            ]
     671        );
     672
     673        $this->add_control(
     674            'speed',
     675            [
     676                'type'    => Controls_Manager::NUMBER,
     677                'label'   => esc_html__('Speed (ms)', 'cubewp-framework'),
     678                'default' => 500,
     679                'min'     => 100,
     680                'max'     => 5000,
     681                'step'    => 100,
     682                'description' => esc_html__('Set the speed for the slider transition in milliseconds.', 'cubewp-framework'),
     683                'condition'   => [
     684                    'cwp_enable_slider' => 'yes',
     685                    'autoplay!' => 'yes',
     686                ],
     687            ]
     688        );
     689
     690        $this->add_control(
     691            'infinite',
     692            [
     693                'type'    => Controls_Manager::SWITCHER,
     694                'label'   => esc_html__('Infinite Loop', 'cubewp-framework'),
     695                'default' => 'yes',
     696                'description' => esc_html__('Enable or disable infinite loop for the slider.', 'cubewp-framework'),
     697                'condition'   => [
     698                    'cwp_enable_slider' => 'yes',
     699                ],
     700            ]
     701        );
     702
     703        $this->add_control(
     704            'variable_width',
     705            [
     706                'label' => __('Variable Width', 'cubewp-framework'),
     707                'type' => \Elementor\Controls_Manager::SWITCHER,
     708                'label_on' => __('Yes', 'cubewp-framework'),
     709                'label_off' => __('No', 'cubewp-framework'),
     710                'return_value' => 'yes',
     711                'default' => 'no',
     712                'condition'   => [
     713                    'cwp_enable_slider' => 'yes',
     714                ],
     715            ]
     716        );
     717
     718        $this->add_control(
     719            'overflow_setting',
     720            [
     721                'label' => esc_html__('Overflow Setting', 'cubewp-framework'),
     722                'type' => Controls_Manager::SWITCHER,
     723                'condition' => [
     724                    'cwp_enable_slider' => 'yes',
     725                ],
     726                'selectors' => [
     727                    '{{WRAPPER}} .cubewp-post-slider .slick-list.draggable' => 'overflow: inherit;',
     728                ],
     729            ]
     730        );
     731
     732        $this->add_control(
     733            'enable_progress_bar',
     734            [
     735                'type' => Controls_Manager::SWITCHER,
     736                'label' => esc_html__('Enable Progress Bar', 'cubewp-framework'),
     737                'default' => '',
     738                'condition' => [
     739                    'cwp_enable_slider' => 'yes',
     740                ],
     741            ]
     742        );
     743
     744        $this->add_responsive_control(
     745            'progress_bar_height',
     746            [
     747                'label' => esc_html__('Progress Bar Height', 'cubewp-framework'),
     748                'type' => Controls_Manager::SLIDER,
     749                'size_units' => ['px'],
     750                'range' => [
     751                    'px' => [
     752                        'min' => 1,
     753                        'max' => 50,
     754                        'step' => 1,
     755                    ],
     756                ],
     757                'default' => [
     758                    'unit' => 'px',
     759                    'size' => 5,
     760                ],
     761                'selectors' => [
     762                    '{{WRAPPER}} .slick-progress, {{WRAPPER}} .slick-progress .slick-progress-bar' => 'height: {{SIZE}}{{UNIT}};',
     763                ],
     764                'condition' => [
     765                    'cwp_enable_slider' => 'yes',
     766                    'enable_progress_bar' => 'yes',
     767                ],
     768            ]
     769        );
     770
     771        $this->add_responsive_control(
     772            'progress_bar_back_color',
     773            [
     774                'label' => esc_html__('Progress Bar Background Color', 'cubewp-framework'),
     775                'type' => Controls_Manager::COLOR,
     776                'default' => '#000000',
     777                'selectors' => [
     778                    '{{WRAPPER}} .slick-progress' => 'background-color: {{VALUE}};',
     779                ],
     780                'condition' => [
     781                    'cwp_enable_slider' => 'yes',
     782                    'enable_progress_bar' => 'yes',
     783                ],
     784            ]
     785        );
     786
     787        $this->add_responsive_control(
     788            'progress_bar_color',
     789            [
     790                'label' => esc_html__('Progress Bar Fill Color', 'cubewp-framework'),
     791                'type' => Controls_Manager::COLOR,
     792                'default' => '#ddd',
     793                'selectors' => [
     794                    '{{WRAPPER}} .slick-progress .slick-progress-bar' => 'background-color: {{VALUE}};',
     795                ],
     796                'condition' => [
     797                    'cwp_enable_slider' => 'yes',
     798                    'enable_progress_bar' => 'yes',
     799                ],
     800            ]
     801        );
     802
     803        $this->add_responsive_control(
     804            'scroll_bar_margin_top',
     805            [
     806                'label' => esc_html__('Progress Bar Margin Top', 'cubewp-framework'),
     807                'type' => Controls_Manager::SLIDER,
     808                'range' => [
     809                    'px' => [
     810                        'min' => -100,
     811                        'max' => 100,
     812                        'step' => 1,
     813                    ],
     814                ],
     815                'default' => [
     816                    'size' => '',
     817                    'unit' => 'px',
     818                ],
     819                'selectors' => [
     820                    '{{WRAPPER}} .slick-progress' => 'margin-top: {{SIZE}}px;',
     821                ],
     822                'condition' => [
     823                    'cwp_enable_slider' => 'yes',
     824                    'enable_progress_bar' => 'yes',
     825                ],
     826            ]
     827        );
     828
     829        $this->add_control(
     830            'slider_dots_arrow_settings_divider',
     831            [
     832                'type' => Controls_Manager::DIVIDER,
     833                'style' => 'thick',
     834                'condition'   => [
     835                    'cwp_enable_slider' => 'yes',
     836                ],
     837            ]
     838        );
     839
     840        $this->add_control(
     841            'custom_arrows',
     842            [
     843                'type' => Controls_Manager::SWITCHER,
     844                'label' => esc_html__('Enable Arrows', 'cubewp-framework'),
     845                'default' => 'yes',
     846                'condition' => [
     847                    'cwp_enable_slider' => 'yes',
     848                ],
     849            ]
     850        );
     851
     852        $this->add_control(
     853            'prev_icon',
     854            [
     855                'label' => __('Previous Icon', 'cubewp-framework'),
     856                'type' => Controls_Manager::ICONS,
     857                'default' => [
     858                    'value' => 'fas fa-chevron-left',
     859                    'library' => 'fa-solid',
     860                ],
     861                'label_block' => true,
     862                'condition'   => [
     863                    'cwp_enable_slider' => 'yes',
     864                    'custom_arrows' => 'yes',
     865                ],
     866            ]
     867        );
     868
     869        $this->add_control(
     870            'next_icon',
     871            [
     872                'label' => __('Next Icon', 'cubewp-framework'),
     873                'type' => Controls_Manager::ICONS,
     874                'default' => [
     875                    'value' => 'fas fa-chevron-right',
     876                    'library' => 'fa-solid',
     877                ],
     878                'label_block' => true,
     879                'condition'   => [
     880                    'cwp_enable_slider' => 'yes',
     881                    'custom_arrows' => 'yes',
     882                ],
     883            ]
     884        );
     885
     886        $this->add_responsive_control(
     887            'icon_size',
     888            [
     889                'label' => esc_html__('Icon Size (px)', 'cubewp-framework'),
     890                'type' => Controls_Manager::SLIDER,
     891                'size_units' => ['px'],
     892                'range' => [
     893                    'px' => [
     894                        'min' => 5,
     895                        'max' => 100,
     896                        'step' => 1,
     897                    ],
     898                ],
     899                'default' => [
     900                    'unit' => 'px',
     901                    'size' => 20,
     902                ],
     903                'selectors' => [
     904                    '{{WRAPPER}} .cubewp-post-slider .slick-prev i, {{WRAPPER}} .cubewp-post-slider .slick-next i' => 'font-size: {{SIZE}}{{UNIT}};',
     905                ],
     906                'condition' => [
     907                    'cwp_enable_slider' => 'yes',
     908                    'custom_arrows' => 'yes',
     909                ],
     910            ]
     911        );
     912
     913        $this->add_responsive_control(
     914            'icon_color',
     915            [
     916                'label' => esc_html__('Icon Color', 'cubewp-framework'),
     917                'type' => Controls_Manager::COLOR,
     918                'default' => '#000000',
     919                'selectors' => [
     920                    '{{WRAPPER}} .cubewp-post-slider .slick-prev i, {{WRAPPER}} .cubewp-post-slider .slick-next i' => 'color: {{VALUE}};',
     921                ],
     922                'condition' => [
     923                    'cwp_enable_slider' => 'yes',
     924                    'custom_arrows' => 'yes',
     925                ],
     926            ]
     927        );
     928
     929        $this->add_responsive_control(
     930            'icon_hover_color',
     931            [
     932                'label' => esc_html__('Icon Hover Color', 'cubewp-framework'),
     933                'type' => Controls_Manager::COLOR,
     934                'default' => '#ffffff',
     935                'selectors' => [
     936                    '{{WRAPPER}} .cubewp-post-slider .slick-prev:hover i, {{WRAPPER}} .cubewp-post-slider .slick-next:hover i' => 'color: {{VALUE}};',
     937                ],
     938                'condition' => [
     939                    'cwp_enable_slider' => 'yes',
     940                    'custom_arrows' => 'yes',
     941                ],
     942            ]
     943        );
     944
     945        $this->add_responsive_control(
     946            'icon_background_color',
     947            [
     948                'label' => esc_html__('Icon & Svg Background Color', 'cubewp-framework'),
     949                'type' => Controls_Manager::COLOR,
     950                'default' => '#ffffff',
     951                'selectors' => [
     952                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'background-color: {{VALUE}};',
     953                ],
     954                'condition' => [
     955                    'cwp_enable_slider' => 'yes',
     956                    'custom_arrows' => 'yes',
     957                ],
     958            ]
     959        );
     960
     961        $this->add_responsive_control(
     962            'icon_hover_background_color',
     963            [
     964                'label' => esc_html__('Icon & Svg Hover Background Color', 'cubewp-framework'),
     965                'type' => Controls_Manager::COLOR,
     966                'default' => '#000000',
     967                'selectors' => [
     968                    '{{WRAPPER}} .cubewp-post-slider .slick-prev:hover, {{WRAPPER}} .cubewp-post-slider .slick-next:hover' => 'background-color: {{VALUE}};',
     969                ],
     970                'condition' => [
     971                    'cwp_enable_slider' => 'yes',
     972                    'custom_arrows' => 'yes',
     973                ],
     974            ]
     975        );
     976
     977        $this->add_responsive_control(
     978            'svg_color',
     979            [
     980                'label' => esc_html__('SVG Color', 'cubewp-framework'),
     981                'type' => Controls_Manager::COLOR,
     982                'default' => '#000000',
     983                'selectors' => [
     984                    '{{WRAPPER}} .cubewp-post-slider .slick-prev svg path, {{WRAPPER}} .cubewp-post-slider .slick-next svg path' => 'fill: {{VALUE}};',
     985                ],
     986                'condition' => [
     987                    'cwp_enable_slider' => 'yes',
     988                    'custom_arrows' => 'yes',
     989                ],
     990            ]
     991        );
     992
     993        $this->add_responsive_control(
     994            'svg_hover_color',
     995            [
     996                'label' => esc_html__('SVG Hover Color', 'cubewp-framework'),
     997                'type' => Controls_Manager::COLOR,
     998                'default' => '#FF0000',
     999                'selectors' => [
     1000                    '{{WRAPPER}} .cubewp-post-slider .slick-prev:hover svg path, {{WRAPPER}} .cubewp-post-slider .slick-next:hover svg path' => 'fill: {{VALUE}};',
     1001                ],
     1002                'condition' => [
     1003                    'cwp_enable_slider' => 'yes',
     1004                    'custom_arrows' => 'yes',
     1005                ],
     1006            ]
     1007        );
     1008
     1009        $this->add_responsive_control(
     1010            'svg_width',
     1011            [
     1012                'label' => esc_html__('SVG Width', 'cubewp-framework'),
     1013                'type' => \Elementor\Controls_Manager::SLIDER,
     1014                'default' => [
     1015                    'size' => 24,
     1016                    'unit' => 'px',
     1017                ],
     1018                'range' => [
     1019                    'px' => [
     1020                        'min' => 0,
     1021                        'max' => 100,
     1022                    ],
     1023                    'em' => [
     1024                        'min' => 1,
     1025                        'max' => 10,
     1026                    ],
     1027                ],
     1028                'selectors' => [
     1029                    '{{WRAPPER}} .cubewp-post-slider .slick-prev svg, {{WRAPPER}} .cubewp-post-slider .slick-next svg' => 'width: {{SIZE}}{{UNIT}};',
     1030                ],
     1031                'condition' => [
     1032                    'cwp_enable_slider' => 'yes',
     1033                    'custom_arrows' => 'yes',
     1034                ],
     1035            ]
     1036        );
     1037
     1038        $this->add_responsive_control(
     1039            'svg_height',
     1040            [
     1041                'label' => esc_html__('SVG Height', 'cubewp-framework'),
     1042                'type' => \Elementor\Controls_Manager::SLIDER,
     1043                'default' => [
     1044                    'size' => 24,
     1045                    'unit' => 'px',
     1046                ],
     1047                'range' => [
     1048                    'px' => [
     1049                        'min' => 0,
     1050                        'max' => 100,
     1051                    ],
     1052                    'em' => [
     1053                        'min' => 1,
     1054                        'max' => 10,
     1055                    ],
     1056                ],
     1057                'selectors' => [
     1058                    '{{WRAPPER}} .cubewp-post-slider .slick-prev svg, {{WRAPPER}} .cubewp-post-slider .slick-next svg' => 'height: {{SIZE}}{{UNIT}};',
     1059                ],
     1060                'condition' => [
     1061                    'cwp_enable_slider' => 'yes',
     1062                    'custom_arrows' => 'yes',
     1063                ],
     1064            ]
     1065        );
     1066
     1067        $this->add_responsive_control(
     1068            'icon_border',
     1069            [
     1070                'label' => esc_html__('Border', 'cubewp-framework'),
     1071                'type' => Controls_Manager::DIMENSIONS,
     1072                'size_units' => ['px', 'em', '%'],
     1073                'selectors' => [
     1074                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; border-style: solid;',
     1075                ],
     1076                'condition' => [
     1077                    'cwp_enable_slider' => 'yes',
     1078                    'custom_arrows' => 'yes',
     1079                ],
     1080            ]
     1081        );
     1082
     1083        $this->add_responsive_control(
     1084            'icon_border_radius',
     1085            [
     1086                'label' => esc_html__('Border Radius', 'cubewp-framework'),
     1087                'type' => Controls_Manager::SLIDER,
     1088                'size_units' => ['px', '%'],
     1089                'range' => [
     1090                    'px' => [
     1091                        'min' => 0,
     1092                        'max' => 200,
     1093                        'step' => 1,
     1094                    ],
     1095                    '%' => [
     1096                        'min' => 0,
     1097                        'max' => 100,
     1098                        'step' => 1,
     1099                    ],
     1100                ],
     1101                'default' => [
     1102                    'unit' => 'px',
     1103                    'size' => 5,
     1104                ],
     1105                'selectors' => [
     1106                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'border-radius: {{SIZE}}{{UNIT}};',
     1107                ],
     1108                'condition' => [
     1109                    'cwp_enable_slider' => 'yes',
     1110                    'custom_arrows' => 'yes',
     1111                ],
     1112            ]
     1113        );
     1114
     1115        $this->add_responsive_control(
     1116            'icon_border_color',
     1117            [
     1118                'label' => esc_html__('Border Color', 'cubewp-framework'),
     1119                'type' => Controls_Manager::COLOR,
     1120                'default' => '#000000',
     1121                'selectors' => [
     1122                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'border-color: {{VALUE}};',
     1123                ],
     1124                'condition' => [
     1125                    'cwp_enable_slider' => 'yes',
     1126                    'custom_arrows' => 'yes',
     1127                ],
     1128            ]
     1129        );
     1130
     1131        $this->add_responsive_control(
     1132            'icon_border_color_hover',
     1133            [
     1134                'label' => esc_html__('Border Color on Hover', 'cubewp-framework'),
     1135                'type' => Controls_Manager::COLOR,
     1136                'default' => '#ffffff',
     1137                'selectors' => [
     1138                    '{{WRAPPER}} .cubewp-post-slider .slick-prev:hover, {{WRAPPER}} .cubewp-post-slider .slick-next:hover' => 'border-color: {{VALUE}};',
     1139                ],
     1140                'condition' => [
     1141                    'cwp_enable_slider' => 'yes',
     1142                    'custom_arrows' => 'yes',
     1143                ],
     1144            ]
     1145        );
     1146
     1147        $this->add_control(
     1148            'icon_border_transition',
     1149            [
     1150                'label' => esc_html__('Transition Duration', 'cubewp-framework'),
     1151                'type' => Controls_Manager::SLIDER,
     1152                'default' => [
     1153                    'size' => 0.3,
     1154                ],
     1155                'range' => [
     1156                    'px' => [
     1157                        'min' => 0,
     1158                        'max' => 2,
     1159                        'step' => 0.1,
     1160                    ],
     1161                ],
     1162                'selectors' => [
     1163                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'transition: background-color {{SIZE}}s, color {{SIZE}}s, border-color {{SIZE}}s;',
     1164                ],
     1165                'condition' => [
     1166                    'cwp_enable_slider' => 'yes',
     1167                    'custom_arrows' => 'yes',
     1168                ],
     1169            ]
     1170        );
     1171
     1172        $this->add_responsive_control(
     1173            'icon_padding',
     1174            [
     1175                'label' => esc_html__('Icon & Svg Padding', 'cubewp-framework'),
     1176                'type' => Controls_Manager::DIMENSIONS,
     1177                'size_units' => ['px', 'em', '%'],
     1178                'selectors' => [
     1179                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
     1180                ],
     1181                'condition' => [
     1182                    'cwp_enable_slider' => 'yes',
     1183                    'custom_arrows' => 'yes',
     1184                ],
     1185            ]
     1186        );
     1187
     1188        $this->add_control(
     1189            'icon_position_divider_heading',
     1190            [
     1191                'label' => esc_html__('Set the Icons Positions', 'cubewp-framework'),
     1192                'type' => Controls_Manager::HEADING,
     1193                'separator' => 'before',
     1194                'condition'   => [
     1195                    'cwp_enable_slider' => 'yes',
     1196                    'custom_arrows' => 'yes',
     1197                ],
     1198            ]
     1199        );
     1200
     1201        $this->add_responsive_control(
     1202            'icon_top_position',
     1203            [
     1204                'label' => esc_html__('Top Position', 'cubewp-framework'),
     1205                'type' => Controls_Manager::SLIDER,
     1206                'size_units' => ['px', '%'],
     1207                'range' => [
     1208                    'px' => [
     1209                        'min' => -500,
     1210                        'max' => 2000,
     1211                        'step' => 1,
     1212                    ],
     1213                    '%' => [
     1214                        'min' => -100,
     1215                        'max' => 100,
     1216                    ],
     1217                ],
     1218                'default' => [
     1219                    'unit' => 'px',
     1220                    'size' => 50,
     1221                ],
     1222                'selectors' => [
     1223                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'top: {{SIZE}}{{UNIT}} !important;',
     1224                ],
     1225                'condition'    => [
     1226                    'cwp_enable_slider' => 'yes',
     1227                    'custom_arrows' => 'yes',
     1228                ],
     1229            ]
     1230        );
     1231
     1232        $this->add_responsive_control(
     1233            'icon_bottom_position',
     1234            [
     1235                'label' => esc_html__('Bottom Position', 'cubewp-framework'),
     1236                'type' => Controls_Manager::SLIDER,
     1237                'size_units' => ['px', '%'],
     1238                'range' => [
     1239                    'px' => [
     1240                        'min' => -500,
     1241                        'max' => 2000,
     1242                        'step' => 1,
     1243                    ],
     1244                    '%' => [
     1245                        'min' => -100,
     1246                        'max' => 100,
     1247                    ],
     1248                ],
     1249                'default' => [
     1250                    'unit' => 'px',
     1251                    'size' => 50,
     1252                ],
     1253                'selectors' => [
     1254                    '{{WRAPPER}} .cubewp-post-slider .slick-prev, {{WRAPPER}} .cubewp-post-slider .slick-next' => 'bottom: {{SIZE}}{{UNIT}} !important;',
     1255                ],
     1256                'condition'    => [
     1257                    'cwp_enable_slider' => 'yes',
     1258                    'custom_arrows' => 'yes',
     1259                ],
     1260            ]
     1261        );
     1262
     1263        $this->add_responsive_control(
     1264            'icon_prev_left_position',
     1265            [
     1266                'label' => esc_html__('Left Position', 'cubewp-framework'),
     1267                'type' => Controls_Manager::SLIDER,
     1268                'size_units' => ['px', '%'],
     1269                'range' => [
     1270                    'px' => [
     1271                        'min' => -500,
     1272                        'max' => 2000,
     1273                        'step' => 1,
     1274                    ],
     1275                    '%' => [
     1276                        'min' => -100,
     1277                        'max' => 100,
     1278                    ],
     1279                ],
     1280                'default' => [
     1281                    'unit' => 'px',
     1282                    'size' => 10,
     1283                ],
     1284                'selectors' => [
     1285                    '{{WRAPPER}} .cubewp-post-slider .slick-prev' => 'left: {{SIZE}}{{UNIT}} !important;',
     1286                ],
     1287                'condition'    => [
     1288                    'cwp_enable_slider' => 'yes',
     1289                    'custom_arrows' => 'yes',
     1290                ],
     1291            ]
     1292        );
     1293
     1294        $this->add_responsive_control(
     1295            'icon_next_right_position',
     1296            [
     1297                'label' => esc_html__('Right Position', 'cubewp-framework'),
     1298                'type' => Controls_Manager::SLIDER,
     1299                'size_units' => ['px', '%'],
     1300                'range' => [
     1301                    'px' => [
     1302                        'min' => -500,
     1303                        'max' => 2000,
     1304                        'step' => 1,
     1305                    ],
     1306                    '%' => [
     1307                        'min' => -100,
     1308                        'max' => 100,
     1309                    ],
     1310                ],
     1311                'default' => [
     1312                    'unit' => 'px',
     1313                    'size' => 10,
     1314                ],
     1315                'selectors' => [
     1316                    '{{WRAPPER}} .cubewp-post-slider .slick-next' => 'right: {{SIZE}}{{UNIT}} !important;',
     1317                ],
     1318                'condition'    => [
     1319                    'cwp_enable_slider' => 'yes',
     1320                    'custom_arrows' => 'yes',
     1321                ],
     1322            ]
     1323        );
     1324
     1325        $this->add_control(
     1326            'custom_dots',
     1327            [
     1328                'label' => esc_html__('Enable Dots', 'cubewp-framework'),
     1329                'type' => Controls_Manager::SWITCHER,
     1330                'label_on'     => esc_html__('Yes', 'cubewp-framework'),
     1331                'label_off'    => esc_html__('No', 'cubewp-framework'),
     1332                'return_value' => 'yes',
     1333                'default'      => '',
     1334                'condition' => [
     1335                    'cwp_enable_slider' => 'yes',
     1336                ],
     1337            ]
     1338        );
     1339
     1340        $this->add_responsive_control(
     1341            'dots_display_flex',
     1342            [
     1343                'label' => esc_html__('Dots Display', 'cubewp-framework'),
     1344                'type' => \Elementor\Controls_Manager::SELECT,
     1345                'options' => [
     1346                    'block' => esc_html__('Block', 'cubewp-framework'),
     1347                    'flex' => esc_html__('Flex', 'cubewp-framework'),
     1348                ],
     1349                'default' => 'flex',
     1350                'selectors' => [
     1351                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'display: {{VALUE}};',
     1352                ],
     1353                'condition' => [
     1354                    'cwp_enable_slider' => 'yes',
     1355                    'custom_dots' => 'yes',
     1356                ],
     1357            ]
     1358        );
     1359
     1360        $this->add_responsive_control(
     1361            'dots_flex_direction',
     1362            [
     1363                'label' => esc_html__('Dots Flex Direction', 'cubewp-framework'),
     1364                'type' => \Elementor\Controls_Manager::SELECT,
     1365                'options' => [
     1366                    'row' => esc_html__('Row', 'cubewp-framework'),
     1367                    'row-reverse' => esc_html__('Row Reverse', 'cubewp-framework'),
     1368                    'column' => esc_html__('Column', 'cubewp-framework'),
     1369                    'column-reverse' => esc_html__('Column Reverse', 'cubewp-framework'),
     1370                ],
     1371                'selectors' => [
     1372                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'flex-direction: {{VALUE}};',
     1373                ],
     1374                'condition' => [
     1375                    'custom_dots' => 'yes',
     1376                    'dots_display_flex' => 'flex',
     1377                    'cwp_enable_slider' => 'yes',
     1378                ],
     1379            ]
     1380        );
     1381
     1382        $this->add_responsive_control(
     1383            'dots_gap',
     1384            [
     1385                'label' => __('Dots Gap', 'cubewp-framework'),
     1386                'type' => \Elementor\Controls_Manager::SLIDER,
     1387                'size_units' => ['px'],
     1388                'range' => [
     1389                    'px' => [
     1390                        'min' => 0,
     1391                        'max' => 50,
     1392                        'step' => 1,
     1393                    ],
     1394                ],
     1395                'default' => [
     1396                    'unit' => 'px',
     1397                    'size' => 5,
     1398                ],
     1399                'selectors' => [
     1400                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'gap:{{SIZE}}{{UNIT}};',
     1401                ],
     1402                'condition'   => [
     1403                    'cwp_enable_slider' => 'yes',
     1404                    'custom_dots' => 'yes',
     1405                ],
     1406            ]
     1407        );
     1408
     1409        $this->add_responsive_control(
     1410            'dots_position_select',
     1411            [
     1412                'label' => esc_html__('Dots Position', 'cubewp-framework'),
     1413                'type' => \Elementor\Controls_Manager::SELECT,
     1414                'options' => [
     1415                    'static' => esc_html__('Static', 'cubewp-framework'),
     1416                    'absolute' => esc_html__('Absolute', 'cubewp-framework'),
     1417                    'relative' => esc_html__('Relative', 'cubewp-framework'),
     1418                    'fixed' => esc_html__('Fixed', 'cubewp-framework'),
     1419                ],
     1420                'default' => 'static',
     1421                'selectors' => [
     1422                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'position: {{VALUE}};',
     1423                ],
     1424                'condition' => [
     1425                    'cwp_enable_slider' => 'yes',
     1426                    'custom_dots' => 'yes',
     1427                ],
     1428            ]
     1429        );
     1430
     1431        $this->add_responsive_control(
     1432            'dots_top_position',
     1433            [
     1434                'label' => esc_html__('Dots Top Position', 'cubewp-framework'),
     1435                'type' => Controls_Manager::SLIDER,
     1436                'size_units' => ['px', '%'],
     1437                'range' => [
     1438                    'px' => [
     1439                        'min' => -500,
     1440                        'max' => 2000,
     1441                        'step' => 1,
     1442                    ],
     1443                    '%' => [
     1444                        'min' => -100,
     1445                        'max' => 100,
     1446                    ],
     1447                ],
     1448                'default' => [
     1449                    'unit' => 'px',
     1450                    'size' => 50,
     1451                ],
     1452                'selectors' => [
     1453                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'top: {{SIZE}}{{UNIT}} !important;',
     1454                ],
     1455                'condition' => [
     1456                    'custom_dots' => 'yes',
     1457                    'dots_position_select' => 'absolute',
     1458                    'cwp_enable_slider' => 'yes',
     1459                ],
     1460            ]
     1461        );
     1462
     1463        $this->add_responsive_control(
     1464            'dots_bottom_position',
     1465            [
     1466                'label' => esc_html__('Dots Bottom Position', 'cubewp-framework'),
     1467                'type' => Controls_Manager::SLIDER,
     1468                'size_units' => ['px', '%'],
     1469                'range' => [
     1470                    'px' => [
     1471                        'min' => -500,
     1472                        'max' => 2000,
     1473                        'step' => 1,
     1474                    ],
     1475                    '%' => [
     1476                        'min' => -100,
     1477                        'max' => 100,
     1478                    ],
     1479                ],
     1480                'default' => [
     1481                    'unit' => 'px',
     1482                    'size' => 50,
     1483                ],
     1484                'selectors' => [
     1485                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'bottom: {{SIZE}}{{UNIT}} !important;',
     1486                ],
     1487                'condition' => [
     1488                    'custom_dots' => 'yes',
     1489                    'dots_position_select' => 'absolute',
     1490                    'cwp_enable_slider' => 'yes',
     1491                ],
     1492            ]
     1493        );
     1494
     1495        $this->add_responsive_control(
     1496            'dots_left_position',
     1497            [
     1498                'label' => esc_html__('Dots Left Position', 'cubewp-framework'),
     1499                'type' => Controls_Manager::SLIDER,
     1500                'size_units' => ['px', '%'],
     1501                'range' => [
     1502                    'px' => [
     1503                        'min' => -500,
     1504                        'max' => 2000,
     1505                        'step' => 1,
     1506                    ],
     1507                    '%' => [
     1508                        'min' => -100,
     1509                        'max' => 100,
     1510                    ],
     1511                ],
     1512                'default' => [
     1513                    'unit' => 'px',
     1514                    'size' => 10,
     1515                ],
     1516                'selectors' => [
     1517                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'left: {{SIZE}}{{UNIT}} !important;',
     1518                ],
     1519                'condition' => [
     1520                    'custom_dots' => 'yes',
     1521                    'dots_position_select' => 'absolute',
     1522                    'cwp_enable_slider' => 'yes',
     1523                ],
     1524            ]
     1525        );
     1526
     1527        $this->add_responsive_control(
     1528            'dots_right_position',
     1529            [
     1530                'label' => esc_html__('Dots Right Position', 'cubewp-framework'),
     1531                'type' => Controls_Manager::SLIDER,
     1532                'size_units' => ['px', '%'],
     1533                'range' => [
     1534                    'px' => [
     1535                        'min' => -500,
     1536                        'max' => 2000,
     1537                        'step' => 1,
     1538                    ],
     1539                    '%' => [
     1540                        'min' => -100,
     1541                        'max' => 100,
     1542                    ],
     1543                ],
     1544                'default' => [
     1545                    'unit' => 'px',
     1546                    'size' => 10,
     1547                ],
     1548                'selectors' => [
     1549                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'right: {{SIZE}}{{UNIT}} !important;',
     1550                ],
     1551                'condition' => [
     1552                    'custom_dots' => 'yes',
     1553                    'dots_position_select' => 'absolute',
     1554                    'cwp_enable_slider' => 'yes',
     1555                ],
     1556            ]
     1557        );
     1558
     1559        $this->add_control(
     1560            'dots_position_z_index',
     1561            [
     1562                'label' => esc_html__('Dots Z-Index', 'cubewp-framework'),
     1563                'type' => \Elementor\Controls_Manager::NUMBER,
     1564                'min' => -9999,
     1565                'max' => 9999,
     1566                'selectors' => [
     1567                    '{{WRAPPER}} .cubewp-post-slider .slick-dots' => 'z-index: {{VALUE}} !important;',
     1568                ],
     1569                'condition' => [
     1570                    'custom_dots' => 'yes',
     1571                    'dots_position_select' => 'absolute',
     1572                    'cwp_enable_slider' => 'yes',
     1573                ],
     1574            ]
     1575        );
     1576
     1577        $this->add_responsive_control(
     1578            'dots_padding',
     1579            [
     1580                'label' => esc_html__('Dots Padding', 'cubewp-framework'),
     1581                'type' => Controls_Manager::DIMENSIONS,
     1582                'size_units' => ['px', 'em', '%'],
     1583                'selectors' => [
     1584                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
     1585                ],
     1586                'condition' => [
     1587                    'custom_dots' => 'yes',
     1588                    'cwp_enable_slider' => 'yes',
     1589                ],
     1590            ]
     1591        );
     1592
     1593        $this->add_responsive_control(
     1594            'dots_border_style',
     1595            [
     1596                'label' => __('Dots Border Style', 'cubewp-framework'),
     1597                'type' => \Elementor\Controls_Manager::SELECT,
     1598                'default' => 'None',
     1599                'options' => [
     1600                    'none' => __('None', 'cubewp-framework'),
     1601                    'solid' => __('Solid', 'cubewp-framework'),
     1602                    'dotted' => __('Dotted', 'cubewp-framework'),
     1603                    'dashed' => __('Dashed', 'cubewp-framework'),
     1604                ],
     1605                'selectors' => [
     1606                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li' => 'border-style: {{VALUE}};',
     1607                ],
     1608                'condition' => [
     1609                    'custom_dots' => 'yes',
     1610                    'cwp_enable_slider' => 'yes',
     1611                ],
     1612            ]
     1613        );
     1614
     1615        $this->add_responsive_control(
     1616            'dots_border_width',
     1617            [
     1618                'label' => __('Dots Border Width', 'cubewp-framework'),
     1619                'type' => \Elementor\Controls_Manager::DIMENSIONS,
     1620                'size_units' => ['px'],
     1621                'default' => [
     1622                    'top' => '',
     1623                    'right' => '',
     1624                    'bottom' => '',
     1625                    'left' => '',
     1626                    'unit' => 'px',
     1627                ],
     1628                'selectors' => [
     1629                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
     1630                ],
     1631                'condition' => [
     1632                    'custom_dots' => 'yes',
     1633                    'cwp_enable_slider' => 'yes',
     1634                    'dots_border_style!' => 'none',
     1635                ],
     1636            ]
     1637        );
     1638
     1639        $this->add_responsive_control(
     1640            'dots_outside_padding',
     1641            [
     1642                'label' => esc_html__('Dots Outside Padding', 'cubewp-framework'),
     1643                'type' => Controls_Manager::DIMENSIONS,
     1644                'size_units' => ['px', 'em', '%'],
     1645                'selectors' => [
     1646                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
     1647                ],
     1648                'condition' => [
     1649                    'custom_dots' => 'yes',
     1650                    'cwp_enable_slider' => 'yes',
     1651                ],
     1652            ]
     1653        );
     1654
     1655        $this->add_responsive_control(
     1656            'dots_outside_color',
     1657            [
     1658                'label' => esc_html__('Dots Outside Backgroud Color', 'cubewp-framework'),
     1659                'type' => \Elementor\Controls_Manager::COLOR,
     1660                'default' => '#ffffff',
     1661                'selectors' => [
     1662                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li' => 'background-color: {{VALUE}};',
     1663                ],
     1664                'condition' => [
     1665                    'custom_dots' => 'yes',
     1666                    'cwp_enable_slider' => 'yes',
     1667                ],
     1668            ]
     1669        );
     1670
     1671        $this->add_responsive_control(
     1672            'active_dot_outside_color',
     1673            [
     1674                'label' => esc_html__('Active Dot Outside Backgroud Color', 'cubewp-framework'),
     1675                'type' => \Elementor\Controls_Manager::COLOR,
     1676                'default' => '#000000',
     1677                'selectors' => [
     1678                    '{{WRAPPER}} .cubewp-post-slider .slick-dots .slick-active' => 'background-color: {{VALUE}};',
     1679                ],
     1680                'condition' => [
     1681                    'custom_dots' => 'yes',
     1682                    'cwp_enable_slider' => 'yes',
     1683                ],
     1684            ]
     1685        );
     1686
     1687        $this->add_responsive_control(
     1688            'dots_border_color',
     1689            [
     1690                'label' => __('Dots Border Color', 'cubewp-framework'),
     1691                'type' => \Elementor\Controls_Manager::COLOR,
     1692                'default' => '#000000',
     1693                'selectors' => [
     1694                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li' => 'border-color: {{VALUE}};',
     1695                ],
     1696                'condition' => [
     1697                    'custom_dots' => 'yes',
     1698                    'cwp_enable_slider' => 'yes',
     1699                ],
     1700            ]
     1701        );
     1702
     1703        $this->add_responsive_control(
     1704            'dots_active_border_color',
     1705            [
     1706                'label' => __('Active Dot Border Color', 'cubewp-framework'),
     1707                'type' => \Elementor\Controls_Manager::COLOR,
     1708                'default' => '#000000',
     1709                'selectors' => [
     1710                    '{{WRAPPER}} .cubewp-post-slider .slick-dots .slick-active' => 'border-color: {{VALUE}};',
     1711                ],
     1712                'condition' => [
     1713                    'custom_dots' => 'yes',
     1714                    'cwp_enable_slider' => 'yes',
     1715                ],
     1716            ]
     1717        );
     1718
     1719        $this->add_responsive_control(
     1720            'dots_border_radius',
     1721            [
     1722                'label' => __('Dots Border Radius', 'cubewp-framework'),
     1723                'type' => \Elementor\Controls_Manager::NUMBER,
     1724                'default' => 0,
     1725                'min' => 0,
     1726                'max' => 500,
     1727                'step' => 1,
     1728                'selectors' => [
     1729                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li,{{WRAPPER}} .cubewp-post-slider .slick-dots li button' => 'border-radius: {{VALUE}}px;',
     1730                ],
     1731                'condition' => [
     1732                    'custom_dots' => 'yes',
     1733                    'cwp_enable_slider' => 'yes',
     1734                ],
     1735            ]
     1736        );
     1737
     1738        $this->add_responsive_control(
     1739            'dots_background_color',
     1740            [
     1741                'label' => __('Dots Background Color', 'cubewp-framework'),
     1742                'type' => \Elementor\Controls_Manager::COLOR,
     1743                'default' => '#ffffff',
     1744                'selectors' => [
     1745                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li button' => 'background-color: {{VALUE}};',
     1746                ],
     1747                'condition' => [
     1748                    'custom_dots' => 'yes',
     1749                    'cwp_enable_slider' => 'yes',
     1750                ],
     1751            ]
     1752        );
     1753
     1754        $this->add_responsive_control(
     1755            'dots_active_background_color',
     1756            [
     1757                'label' => __('Active Dot Background Color', 'cubewp-framework'),
     1758                'type' => \Elementor\Controls_Manager::COLOR,
     1759                'default' => '#000000',
     1760                'selectors' => [
     1761                    '{{WRAPPER}} .cubewp-post-slider .slick-dots .slick-active button' => 'background-color: {{VALUE}};',
     1762                ],
     1763                'condition' => [
     1764                    'custom_dots' => 'yes',
     1765                    'cwp_enable_slider' => 'yes',
     1766                ],
     1767            ]
     1768        );
     1769
     1770        $this->add_responsive_control(
     1771            'dots_width',
     1772            [
     1773                'label' => __('Dots Width', 'cubewp-framework'),
     1774                'type' => \Elementor\Controls_Manager::NUMBER,
     1775                'default' => 10,
     1776                'min' => 1,
     1777                'max' => 100,
     1778                'step' => 1,
     1779                'selectors' => [
     1780                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li button' => 'width: {{VALUE}}px;',
     1781                ],
     1782                'condition' => [
     1783                    'custom_dots' => 'yes',
     1784                    'cwp_enable_slider' => 'yes',
     1785                ],
     1786            ]
     1787        );
     1788
     1789        $this->add_responsive_control(
     1790            'dots_height',
     1791            [
     1792                'label' => __('Dots Height', 'cubewp-framework'),
     1793                'type' => \Elementor\Controls_Manager::NUMBER,
     1794                'default' => 10,
     1795                'min' => 1,
     1796                'max' => 100,
     1797                'step' => 1,
     1798                'selectors' => [
     1799                    '{{WRAPPER}} .cubewp-post-slider .slick-dots li button' => 'height: {{VALUE}}px;',
     1800                ],
     1801                'condition' => [
     1802                    'custom_dots' => 'yes',
     1803                    'cwp_enable_slider' => 'yes',
     1804                ],
     1805            ]
     1806        );
     1807
     1808        $this->add_responsive_control(
     1809            'active_dot_width',
     1810            [
     1811                'label' => __('Active Dot Width', 'cubewp-framework'),
     1812                'type' => \Elementor\Controls_Manager::NUMBER,
     1813                'default' => 12,
     1814                'min' => 1,
     1815                'max' => 100,
     1816                'step' => 1,
     1817                'selectors' => [
     1818                    '{{WRAPPER}} .cubewp-post-slider .slick-dots .slick-active button' => 'width: {{VALUE}}px;',
     1819                ],
     1820                'condition' => [
     1821                    'custom_dots' => 'yes',
     1822                    'cwp_enable_slider' => 'yes',
     1823                ],
     1824            ]
     1825        );
     1826
     1827        $this->add_responsive_control(
     1828            'active_dot_height',
     1829            [
     1830                'label' => __('Active Dot Height', 'cubewp-framework'),
     1831                'type' => \Elementor\Controls_Manager::NUMBER,
     1832                'default' => 12,
     1833                'min' => 1,
     1834                'max' => 100,
     1835                'step' => 1,
     1836                'selectors' => [
     1837                    '{{WRAPPER}} .cubewp-post-slider .slick-dots .slick-active button' => 'height: {{VALUE}}px;',
     1838                ],
     1839                'condition' => [
     1840                    'custom_dots' => 'yes',
     1841                    'cwp_enable_slider' => 'yes',
     1842                ],
     1843            ]
     1844        );
     1845
     1846        $this->add_control(
     1847            'slider_responsive_settings_heading',
     1848            [
     1849                'label' => esc_html__('Responsive Settings For Slides To Show And Scroll', 'cubewp-framework'),
     1850                'type' => Controls_Manager::HEADING,
     1851                'separator' => 'before',
     1852                'condition'   => [
     1853                    'cwp_enable_slider' => 'yes',
     1854                ],
     1855            ]
     1856        );
     1857
     1858        $this->add_control(
     1859            'slides_to_show_tablet',
     1860            [
     1861                'label' => esc_html__('Slides To Show On (Tablet)', 'cubewp-framework'),
     1862                'type' => Controls_Manager::NUMBER,
     1863                'min' => 1,
     1864                'max' => 10,
     1865                'step' => 1,
     1866                'default' => 3,
     1867                'condition' => [
     1868                    'cwp_enable_slider' => 'yes',
     1869                ],
     1870            ]
     1871        );
     1872
     1873        $this->add_control(
     1874            'slides_to_show_tablet_portrait',
     1875            [
     1876                'label' => esc_html__('Slides To Show On (Tablet Portrait)', 'cubewp-framework'),
     1877                'type' => Controls_Manager::NUMBER,
     1878                'min' => 1,
     1879                'max' => 10,
     1880                'step' => 1,
     1881                'default' => 2,
     1882                'condition' => [
     1883                    'cwp_enable_slider' => 'yes',
     1884                ],
     1885            ]
     1886        );
     1887
     1888        $this->add_control(
     1889            'slides_to_show_mobile',
     1890            [
     1891                'label' => esc_html__('Slides To Show On (Mobile)', 'cubewp-framework'),
     1892                'type' => Controls_Manager::NUMBER,
     1893                'min' => 1,
     1894                'max' => 10,
     1895                'step' => 1,
     1896                'default' => 1,
     1897                'condition' => [
     1898                    'cwp_enable_slider' => 'yes',
     1899                ],
     1900            ]
     1901        );
     1902
     1903        $this->add_control(
     1904            'slider_responsive_settings_divider',
     1905            [
     1906                'type' => Controls_Manager::DIVIDER,
     1907                'style' => 'thick',
     1908                'condition'   => [
     1909                    'cwp_enable_slider' => 'yes',
     1910                ],
     1911            ]
     1912        );
     1913
     1914        $this->add_control(
     1915            'slides_to_scroll_tablet',
     1916            [
     1917                'label' => esc_html__('Slides To Scroll On (Tablet)', 'cubewp-framework'),
     1918                'type' => Controls_Manager::NUMBER,
     1919                'min' => 1,
     1920                'max' => 10,
     1921                'step' => 1,
     1922                'default' => 1,
     1923                'condition' => [
     1924                    'cwp_enable_slider' => 'yes',
     1925                ],
     1926            ]
     1927        );
     1928
     1929        $this->add_control(
     1930            'slides_to_scroll_tablet_portrait',
     1931            [
     1932                'label' => esc_html__('Slides To Scroll On (Tablet Portrait)', 'cubewp-framework'),
     1933                'type' => Controls_Manager::NUMBER,
     1934                'min' => 1,
     1935                'max' => 10,
     1936                'step' => 1,
     1937                'default' => 1,
     1938                'condition' => [
     1939                    'cwp_enable_slider' => 'yes',
     1940                ],
     1941            ]
     1942        );
     1943
     1944        $this->add_control(
     1945            'slides_to_scroll_mobile',
     1946            [
     1947                'label' => esc_html__('Slides To Scroll On (Mobile)', 'cubewp-framework'),
     1948                'type' => Controls_Manager::NUMBER,
     1949                'min' => 1,
     1950                'max' => 10,
     1951                'step' => 1,
     1952                'default' => 1,
     1953                'condition' => [
     1954                    'cwp_enable_slider' => 'yes',
     1955                ],
     1956            ]
     1957        );
     1958
     1959        $this->end_controls_section();
     1960    }
    4721961}
  • cubewp-framework/trunk/cube/classes/shortcodes/class-cubewp-shortcode-posts.php

    r3161906 r3202079  
    77 * @class CubeWp_Frontend_Posts_Shortcode
    88 */
    9 class CubeWp_Shortcode_Posts {
    10    
    11     public function __construct() {
     9class CubeWp_Shortcode_Posts
     10{
     11
     12    public function __construct()
     13    {
    1214        add_shortcode('cubewp_shortcode_posts', array($this, 'cubewp_shortcode_posts_callback'));
    1315        add_filter('cubewp_shortcode_posts_output', array($this, 'cubewp_posts'), 10, 2);
     
    1618    }
    1719
    18     public static function cubewp_posts($output, array $parameters) {
     20    public static function cubewp_posts($output, array $parameters)
     21    {
    1922        return self::cubewp_posts_output($parameters);
    2023    }
    2124
    22     public static function cubewp_posts_output($parameters) {
     25    public static function cubewp_posts_output($parameters)
     26    {
    2327
    2428        // AJAX CALL
     
    2832        }
    2933
     34        $cwp_enable_slider = isset($parameters['cwp_enable_slider']) ? $parameters['cwp_enable_slider'] : '';
     35        $prev_icon = isset($parameters['prev_icon']) ? $parameters['prev_icon'] : 'fas fa-chevron-left';
     36        $next_icon = isset($parameters['next_icon']) ? $parameters['next_icon'] : 'fas fa-chevron-right';
     37        $slides_to_show = isset($parameters['slides_to_show']) ? intval($parameters['slides_to_show']) : 3;
     38        $slides_to_scroll = isset($parameters['slides_to_scroll']) ? intval($parameters['slides_to_scroll']) : 1;
     39        $slides_to_show_tablet = isset($parameters['slides_to_show_tablet']) ? intval($parameters['slides_to_show_tablet']) : 3;
     40        $slides_to_show_tablet_portrait = isset($parameters['slides_to_show_tablet_portrait']) ? intval($parameters['slides_to_show_tablet_portrait']) : 2;
     41        $slides_to_show_mobile = isset($parameters['slides_to_show_mobile']) ? intval($parameters['slides_to_show_mobile']) : 1;
     42        $slides_to_scroll_tablet = isset($parameters['slides_to_scroll_tablet']) ? intval($parameters['slides_to_scroll_tablet']) : 1;
     43        $slides_to_scroll_tablet_portrait = isset($parameters['slides_to_scroll_tablet_portrait']) ? intval($parameters['slides_to_scroll_tablet_portrait']) : 1;
     44        $slides_to_scroll_mobile = isset($parameters['slides_to_scroll_mobile']) ? intval($parameters['slides_to_scroll_mobile']) : 1;
     45        $autoplay = isset($parameters['autoplay']) && $parameters['autoplay'] ? 'true' : 'false';
     46        $autoplay_speed = isset($parameters['autoplay_speed']) ? intval($parameters['autoplay_speed']) : 2000;
     47        $speed = isset($parameters['speed']) ? intval($parameters['speed']) : 500;
     48        $infinite = isset($parameters['infinite']) && $parameters['infinite'] ? 'true' : 'false';
     49        $variable_width = isset($parameters['variable_width']) && $parameters['variable_width'] ? 'true' : 'false';
     50        $custom_arrows = isset($parameters['custom_arrows']) && $parameters['custom_arrows'] ? 'true' : 'false';
     51        $custom_dots = isset($parameters['custom_dots']) && $parameters['custom_dots'] ? 'true' : 'false';
     52        $enable_progress_bar = isset($parameters['enable_progress_bar']) && $parameters['enable_progress_bar'] ? 'true' : 'false';
     53
     54       
     55        $next_icon_type = isset($parameters['next_icon_type']) && $parameters['next_icon_type'] ? 'true' : 'false';
     56        $prev_icon_type = isset($parameters['prev_icon_type']) && $parameters['prev_icon_type'] ? 'true' : 'false';
    3057
    3158        $args = array(
     
    3764        );
    3865
    39         if(isset($parameters['number_of_posts'])){
     66        if (isset($parameters['number_of_posts'])) {
    4067            $args['posts_per_page'] = $parameters['number_of_posts'];
    4168        }
    4269
    43         if(isset($parameters['posts_per_page'])){
     70        if (isset($parameters['posts_per_page'])) {
    4471            $args['posts_per_page'] = $parameters['posts_per_page'];
    4572        }
    4673
    47         if(isset($parameters['page_num'])){
     74        if (isset($parameters['page_num'])) {
    4875            $args['page_num'] = $parameters['page_num'];
    4976        }
    5077
    5178        $show_boosted_posts = '';
    52         if (class_exists('CubeWp_Booster_Load')) {
    53             $show_boosted_posts = $parameters['boosted_only'];
    54         }
     79        if (class_exists('CubeWp_Booster_Load')) {
     80            $show_boosted_posts = $parameters['boosted_only'];
     81        }
    5582        if (isset($parameters['post__in']) && ! empty($parameters['post__in']) && is_array($parameters['post__in'])) {
    5683            $args['post__in'] = $parameters['post__in'];
    57         }
     84        }
    5885        if (isset($parameters['taxonomy']) && ! empty($parameters['taxonomy']) && is_array($parameters['taxonomy'])) {
    5986            foreach ($parameters['taxonomy'] as $taxonomy) {
     
    7097        if ($layout == 'list') {
    7198            $col_class = 'cwp-col-12';
    72             $row_class = 'list-view';
     99            $row_class = 'list-view';
    73100        }
    74101        $query = new CubeWp_Query($args);
    75102        $posts = $query->cubewp_post_query();
    76103        $load_btn = $post_markup = '';
    77         $conatiner_open = '<div class="cubewp-posts-shortcode cwp-row">';
    78         $conatiner_close = '</div>';
    79        
     104        $slider_class = $cwp_enable_slider === 'cubewp-post-slider' ? 'cubewp-post-slider' : '';
     105        $container_open = '<div class="cubewp-posts-shortcode cwp-row ' . esc_attr($slider_class) . '"';
     106        $container_open .= ' data-prev-arrow="' . esc_attr($prev_icon) . '"';
     107        $container_open .= ' data-next-arrow="' . esc_attr($next_icon) . '"';
     108        $container_open .= ' data-prev-icon-type="' . esc_attr($prev_icon_type) . '"';
     109        $container_open .= ' data-next-icon-type="' . esc_attr($next_icon_type) . '"';
     110        $container_open .= ' data-slides-to-show="' . esc_attr($slides_to_show) . '"';
     111        $container_open .= ' data-slides-to-scroll="' . esc_attr($slides_to_scroll) . '"';
     112        $container_open .= ' data-slides-to-show-tablet="' . esc_attr($slides_to_show_tablet) . '"';
     113        $container_open .= ' data-slides-show-tablet-portrait="' . esc_attr($slides_to_show_tablet_portrait) . '"';
     114        $container_open .= ' data-slides-to-show-mobile="' . esc_attr($slides_to_show_mobile) . '"';
     115        $container_open .= ' data-slides-to-scroll-tablet="' . esc_attr($slides_to_scroll_tablet) . '"';
     116        $container_open .= ' data-slides-scroll-tablet-portrait="' . esc_attr($slides_to_scroll_tablet_portrait) . '"';
     117        $container_open .= ' data-slides-to-scroll-mobile="' . esc_attr($slides_to_scroll_mobile) . '"';
     118        $container_open .= ' data-autoplay="' . esc_attr($autoplay) . '"';
     119        $container_open .= ' data-autoplay-speed="' . esc_attr($autoplay_speed) . '"';
     120        $container_open .= ' data-speed="' . esc_attr($speed) . '"';
     121        $container_open .= ' data-infinite="' . esc_attr($infinite) . '"';
     122        $container_open .= ' data-variable-width="' . esc_attr($variable_width) . '"';
     123        $container_open .= ' data-custom-arrows="' . esc_attr($custom_arrows) . '"';
     124        $container_open .= ' data-custom-dots="' . esc_attr($custom_dots) . '"';
     125        $container_open .= ' data-enable-progress-bar="' . esc_attr($enable_progress_bar) . '"';
     126        $container_open .= '>';
     127        $container_close = '</div>';
     128
    80129        if ($posts->have_posts()) {
    81 
    82             if($show_boosted_posts == 'yes'){
    83                 if(class_exists('CubeWp_Booster_Load')){
    84                     while ($posts->have_posts()): $posts->the_post();
    85                     $post_type = get_post_type( get_the_ID() );
    86                     $style = isset($parameters['card_style'][$post_type]) ? $parameters['card_style'][$post_type]: '';
    87                     if (function_exists('is_boosted')) {
    88                         if (is_boosted(get_the_ID())) {
    89                             $post_markup .= CubeWp_frontend_grid_HTML(get_the_ID(), '', $style);
     130            CubeWp_Enqueue::enqueue_style('cubewp-slick');
     131            CubeWp_Enqueue::enqueue_script('cubewp-slick');
     132            if ($show_boosted_posts == 'yes') {
     133                if (class_exists('CubeWp_Booster_Load')) {
     134                    while ($posts->have_posts()): $posts->the_post();
     135                        $post_type = get_post_type(get_the_ID());
     136                        $style = isset($parameters['card_style'][$post_type]) ? $parameters['card_style'][$post_type] : '';
     137                        if (function_exists('is_boosted')) {
     138                            if (is_boosted(get_the_ID())) {
     139                                $post_markup .= CubeWp_frontend_grid_HTML(get_the_ID(), '', $style);
     140                            }
    90141                        }
    91                     }
    92                     endwhile;
    93                 }
    94             }else{
    95                 while ($posts->have_posts()): $posts->the_post();
    96                     $post_type = get_post_type( get_the_ID() );
    97                     $style = isset($parameters['card_style'][$post_type]) ? $parameters['card_style'][$post_type]: '';
    98                     $post_markup .= CubeWp_frontend_grid_HTML(get_the_ID(), '', $style);
     142                    endwhile;
     143                }
     144            } else {
     145                while ($posts->have_posts()): $posts->the_post();
     146                    $post_type = get_post_type(get_the_ID());
     147                    $style = isset($parameters['card_style'][$post_type]) ? $parameters['card_style'][$post_type] : '';
     148                    $post_markup .= CubeWp_frontend_grid_HTML(get_the_ID(), '', $style);
    99149                endwhile;
    100             }
    101             if(isset($parameters['load_more']) && $parameters['load_more'] == 'yes'){
    102                 if(isset($parameters['page_num'])){
     150            }
     151            if (isset($parameters['load_more']) && $parameters['load_more'] == 'yes') {
     152                if (isset($parameters['page_num'])) {
    103153                    $parameters['page_num'] = $parameters['page_num'] + 1;
    104                 }else{
     154                } else {
    105155                    $parameters['page_num'] = 2;
    106156                }
    107157                $has_more_posts = $args['page_num'] < $posts->max_num_pages;
    108158                $dataAttributes = json_encode($parameters);
    109                 CubeWp_Enqueue::enqueue_script( 'cwp-load-more' );
    110                
     159                CubeWp_Enqueue::enqueue_script('cwp-load-more');
     160
    111161
    112162                $load_btn .= '<div class="cubewp-load-more-conatiner">
    113                     <button class="cubewp-load-more-button" data-attributes="'.htmlspecialchars($dataAttributes, ENT_QUOTES, 'UTF-8').'">
    114                         '.esc_html__('Load More', 'cubewp-framework').'
     163                    <button class="cubewp-load-more-button" data-attributes="' . htmlspecialchars($dataAttributes, ENT_QUOTES, 'UTF-8') . '">
     164                        ' . esc_html__('Load More', 'cubewp-framework') . '
    115165                    </button>
    116166                </div>';
    117167            }
    118            
    119         }else{
    120             $post_markup = self::cwp_no_result_found();
    121         }
    122         wp_reset_query();
     168        } else {
     169            $post_markup = self::cwp_no_result_found();
     170        }
     171        wp_reset_query();
    123172
    124173        if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] === 'cubewp_posts_output') {
    125174            wp_send_json_success(array('content' => $post_markup, 'newAttributes' => $parameters, 'has_more_posts' => $has_more_posts));
    126175        } else {
    127             return $conatiner_open.$post_markup.$conatiner_close.$load_btn;
    128         }
    129     }
    130 
    131     public static function init() {
     176            return $container_open . $post_markup . $container_close . $load_btn;
     177        }
     178    }
     179
     180    public static function init()
     181    {
    132182        $CubeWPClass = __CLASS__;
    133183        new $CubeWPClass;
    134184    }
    135185
    136     public function cubewp_shortcode_posts_callback($parameters) {
    137         $title  = isset( $parameters['title'] ) ? $parameters['title'] : '';
     186    public function cubewp_shortcode_posts_callback($parameters)
     187    {
     188        $title  = isset($parameters['title']) ? $parameters['title'] : '';
    138189        $output = '<div class="cwp-widget-shortcode">';
    139         if ( ! empty($title)) {
     190        if (! empty($title)) {
    140191            $output .= '<h2 class="cwp-widget-shortcode-heading">' . $title . '</h2>';
    141192        }
     
    146197    }
    147198
    148     private static function cwp_no_result_found(){
    149         return '<div class="cwp-empty-search"><img class="cwp-empty-search-img" src="'.esc_url(CWP_PLUGIN_URI.'cube/assets/frontend/images/no-result.png').'" alt=""><h2>'.esc_html__('No Results Found','cubewp-framework').'</h2><p>'.esc_html__('There are no results matching your search.','cubewp-framework').'</p></div>';
    150     }
     199    private static function cwp_no_result_found()
     200    {
     201        return '<div class="cwp-empty-search"><img class="cwp-empty-search-img" src="' . esc_url(CWP_PLUGIN_URI . 'cube/assets/frontend/images/no-result.png') . '" alt=""><h2>' . esc_html__('No Results Found', 'cubewp-framework') . '</h2><p>' . esc_html__('There are no results matching your search.', 'cubewp-framework') . '</p></div>';
     202    }
    151203}
  • cubewp-framework/trunk/cube/functions/admin-functions.php

    r3155340 r3202079  
    604604
    605605/**
     606 * Method cubewp_initialize_modules
     607 *
     608 *
     609 * @return void
     610 * @since  1.0.0
     611 */
     612if ( ! function_exists('cubewp_initialize_modules')) {
     613    function cubewp_initialize_modules() {
     614        $modules = CWP()->cubewp_get_modules();
     615        foreach ($modules as $index  => $module) {
     616            $module_slug      = $module['slug'];
     617            $module_class    = $module['load'];
     618            $options = CWP()->cubewp_options($module_slug);
     619            $validation_property = CubeWp_Add_Ons::LIC.CubeWp_Add_Ons::ENSE;
     620            if (isset($options->$validation_property) && $options->$validation_property == 'valid') {
     621                if (class_exists($module_class)) {
     622                    $module_class::instance();
     623                }
     624            }
     625        }
     626    }
     627
     628    add_action('cubewp_loaded', 'cubewp_initialize_modules', 10);
     629}
     630
     631/**
    606632 * Get custom post types
    607633 *
     
    16481674        return $located;
    16491675    }
    1650 }
    1651 
    1652 /**
    1653  * Method cubewp_extra_features
    1654  *
    1655  *
    1656  * @return class
    1657  * @since  1.0.0
    1658  */
    1659 if ( ! function_exists('cubewp_extra_features')) {
    1660     function cubewp_extra_features() {
    1661         $add_ons = CubeWp_Add_Ons::cubewp_add_ons();
    1662         foreach ($add_ons as $key => $add_on) {
    1663             $slug     = $add_on['slug'];
    1664             $load   = $add_on['load'];
    1665             $cubewp = CWP()->cubewp_options($slug);
    1666             $lic = CubeWp_Add_Ons::LIC.CubeWp_Add_Ons::ENSE;
    1667             if (isset($cubewp->$lic) && $cubewp->$lic == 'valid') {
    1668                 if (class_exists($load)) {
    1669                     $load::instance();
    1670                 }
    1671             }
    1672         }
    1673     }
    1674 
    1675     add_action('cubewp_loaded', 'cubewp_extra_features', 10);
    16761676}
    16771677
     
    23512351    $custom_post_types = cwp_post_types();
    23522352    // Check if the current user is a subscriber
    2353     if (current_user_can('subscriber')) {
     2353    $user = wp_get_current_user();
     2354    if (!empty($user->roles) && in_array('subscriber', (array) $user->roles, true) && count($user->roles) === 1) {
    23542355        global $submenu;
    23552356        // Loop through each custom post type
     
    23822383    if($post_type == '') return [];
    23832384
    2384     $cubewp_styles = [];
     2385    $cubewp_styles = $cubewp_cards = [];
    23852386    if(class_exists('CubeWp_Loop_Builder')){
    2386         $cubewp_cards = CubeWp_Loop_Builder::$cubewp_style_options;
     2387        $post_types = CWP_all_post_types();
     2388        foreach ( $post_types as $_post_type => $label ) {
     2389            $cubewp_cards[ $_post_type ]['label']           = $label;
     2390            $cubewp_cards[ $_post_type ]['loop-styles'] = cwp_get_loop_styles_by_post_type($_post_type);
     2391        }
    23872392        if(isset($cubewp_cards[$post_type]['loop-styles'])){
    23882393            $cubewp_styles = apply_filters( 'cubewp/post/card/styles', $cubewp_cards[$post_type]['loop-styles'], $post_type);
     
    23902395    }
    23912396    return $cubewp_styles;
     2397}
     2398
     2399/**
     2400 * Method cwp_get_loop_styles_by_post_type
     2401 *
     2402 * @param $post_type
     2403 *
     2404 * @return array
     2405 */
     2406function cwp_get_loop_styles_by_post_type($post_type) {
     2407    global $cwpOptions;
     2408    $custom_styles = isset($cwpOptions['cwp_loop_style'][$post_type]) && !empty($cwpOptions['cwp_loop_style'][$post_type]) ? explode(',', $cwpOptions['cwp_loop_style'][$post_type]) : [];
     2409
     2410    $default_styles = [
     2411        'default_style' => esc_html__('Basic Style', 'cubewp-framework')
     2412    ];
     2413
     2414    $_custom_styles = [];
     2415    foreach ($custom_styles as $style) {
     2416        $key = str_replace(' ', '_', $style);
     2417        $_custom_styles[$key] = $style;
     2418    }
     2419
     2420    $filter_styles = apply_filters("cubewp/loop/builder/{$post_type}/styles", []);
     2421    $filter_styles = is_array($filter_styles) ? $filter_styles : [];
     2422
     2423    $loop_styles = array_merge($default_styles, $_custom_styles, $filter_styles);
     2424    return $loop_styles;
    23922425}
    23932426
  • cubewp-framework/trunk/cube/modules/builder/class-cubewp-loop-builder.php

    r3155346 r3202079  
    7575        $cwpOptions = ! empty( $cwpOptions ) ? $cwpOptions : get_option( 'cwpOptions' );
    7676
    77         $post_types       = CWP_all_post_types();
    78 
    79         // Styles coming from CUbeWp settings.
    80         $custom_styles = isset($cwpOptions['cwp_loop_style']) & !empty($cwpOptions['cwp_loop_style']) ? $cwpOptions['cwp_loop_style'] : [];
     77        $post_types = CWP_all_post_types();
    8178
    8279        $switcher_options = array();
    8380        if ( ! empty( $post_types ) ) {
    8481            foreach ( $post_types as $post_type => $label ) {
    85                 $switcher_options[ $post_type ]['label']        = $label;
    86                 $loop_styles                                    = apply_filters( "cubewp/loop/builder/{$post_type}/styles", array() );
    87                 $loop_styles                                    = ! empty( $loop_styles ) && is_array( $loop_styles ) ? $loop_styles : array();
    88                 $_loop_styles                                   = isset($custom_styles[$post_type]) && !empty($custom_styles[$post_type]) ? self::render_custom_styles($custom_styles[$post_type]) : self::render_custom_styles();
    89                 $loop_styles                                    = array_merge( $_loop_styles, $loop_styles );
    90                 $switcher_options[ $post_type ]['loop-styles']  = $loop_styles;
     82                $switcher_options[ $post_type ]['label'] = $label;
     83                $switcher_options[ $post_type ]['loop-styles'] = cwp_get_loop_styles_by_post_type($post_type);
    9184            }
    9285        }
    9386
    9487        self::$cubewp_style_options = $switcher_options;
    95     }
    96 
    97     private static function render_custom_styles($styles = '') {
    98         $styles_array = [];
    99         if(!empty($styles)){
    100             $styles_array = explode(",", $styles);
    101         }
    102        
    103         //Default STyle for all post types
    104         $new_array = array(
    105             'default_style' => esc_html__( 'Basic Style', 'cubewp-frontend' )
    106         );
    107 
    108         if(is_array($styles_array) && !empty($styles_array)){
    109             foreach($styles_array as $style){
    110                 $key = str_replace(' ', '_', $style);
    111                 $new_array[$key] = $style;
    112             }
    113         }
    114 
    115         return $new_array;
    11688    }
    11789
Note: See TracChangeset for help on using the changeset viewer.