Changeset 3202079
- Timestamp:
- 12/04/2024 06:11:53 AM (12 months ago)
- Location:
- cubewp-framework/trunk/cube
- Files:
-
- 13 edited
-
assets/admin/js/cubewp-admin.js (modified) (3 diffs)
-
assets/frontend/css/cubewp-styles.css (modified) (1 diff)
-
assets/frontend/js/cubewp-alerts.js (modified) (6 diffs)
-
classes/class-cubewp-add-ons.php (modified) (10 diffs)
-
classes/class-cubewp-enqueue.php (modified) (2 diffs)
-
classes/class-cubewp-export.php (modified) (2 diffs)
-
classes/class-cubewp-import.php (modified) (50 diffs)
-
classes/class-cubewp-load.php (modified) (2 diffs)
-
classes/class-cubewp-single-cpt.php (modified) (18 diffs)
-
classes/page-builders/elementor-widgets/class-cubewp-elementor-posts-widget.php (modified) (15 diffs)
-
classes/shortcodes/class-cubewp-shortcode-posts.php (modified) (6 diffs)
-
functions/admin-functions.php (modified) (5 diffs)
-
modules/builder/class-cubewp-loop-builder.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cubewp-framework/trunk/cube/assets/admin/js/cubewp-admin.js
r3155340 r3202079 179 179 alert(response.msg); 180 180 }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 } 181 187 var export_custom_forms = false; 182 188 if ( jQuery('.export-form').find('#custom-forms-fields').length > 0 ) { … … 186 192 } 187 193 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 } 188 197 if (export_custom_forms) { 189 198 _ajax_data += '&download_now=false'; … … 199 208 }else{ 200 209 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 } 201 214 jQuery.ajax({ 202 215 type: 'POST', 203 216 url: cwp_vars_params.ajax_url, 204 data: 'action=cwp_custom_forms&export=success&nonce='+cwp_vars_params.nonce,217 data: custom_form_data, 205 218 dataType: 'json', 206 219 success: function (response) { -
cubewp-framework/trunk/cube/assets/frontend/css/cubewp-styles.css
r2824477 r3202079 712 712 margin: 0 0 0 0; 713 713 } 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 6 6 if ($parent.hasClass("cwp-js-alert")) { 7 7 $parent.hide(); 8 } else {8 } else { 9 9 $parent.remove(); 10 10 } … … 46 46 }); 47 47 } 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 } 48 131 }); 49 132 … … 52 135 $alert_class = '', 53 136 $cwp_alert_content = $cwp_alert.find('.cwp-alert-content'); 54 137 55 138 if ($cwp_alert.is(":visible") && $cwp_alert_content.html() === notification_content) { 56 139 return false; … … 59 142 $cwp_alert.find('.cwp-alert-close').trigger("click"); 60 143 } 61 if ( notification_type === 'success') {144 if (notification_type === 'success') { 62 145 $alert_class = 'cwp-alert-success'; 63 } else if ( notification_type === 'warning') {146 } else if (notification_type === 'warning') { 64 147 $alert_class = 'cwp-alert-warning'; 65 } else if ( notification_type === 'info') {148 } else if (notification_type === 'info') { 66 149 $alert_class = 'cwp-alert-info'; 67 } else if ( notification_type === 'error') {150 } else if (notification_type === 'error') { 68 151 $alert_class = 'cwp-alert-danger'; 69 152 } … … 90 173 url: cwp_alert_ui_params.ajax_url, 91 174 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, 93 176 dataType: "json", 94 177 success: function (response) { 95 178 cwp_notification_ui(response.type, response.msg); 96 if ( typeof response.text != 'undefined' && response.text != '' ){179 if (typeof response.text != 'undefined' && response.text != '') { 97 180 thisObj.addClass('cwp-saved-post'); 98 181 thisObj.removeClass('cwp-save-post'); … … 111 194 url: cwp_alert_ui_params.ajax_url, 112 195 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, 114 197 dataType: "json", 115 198 success: function (response) { 116 199 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') { 119 202 thisObj.closest('tr').remove(); 120 203 } -
cubewp-framework/trunk/cube/classes/class-cubewp-add-ons.php
r3167922 r3202079 1 1 <?php 2 2 3 if ( ! defined( 'ABSPATH' )) {4 exit; // Exit if accessed directly.3 if (! defined('ABSPATH')) { 4 exit; // Exit if accessed directly. 5 5 } 6 class CubeWp_Add_Ons { 6 class CubeWp_Add_Ons 7 { 7 8 8 9 // API route 9 10 public $route = 'https://cubewp.com'; 10 11 11 // store URL12 // store URL 12 13 public $purchase_url = 'https://cubewp.com/store'; 13 14 … … 30 31 public static $action = 'edd_action'; 31 32 32 public function __construct() { 33 public function __construct() 34 { 33 35 //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); 126 40 } 127 41 … … 131 45 * @version 1.0 132 46 */ 133 public function _plugins($plugin) { 134 47 public function _plugins($plugin) 48 { 49 135 50 global $wpdb; 136 51 … … 140 55 $wp_version = $GLOBALS['wp_version']; 141 56 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; 144 59 145 60 // PHP check 146 61 $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; 149 64 150 65 // SQL check 151 66 $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; 154 69 155 70 // 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); 161 75 } 162 76 163 77 return $this->add_on_management($plugin); 164 165 78 } 166 79 … … 171 84 */ 172 85 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')) { 177 91 178 92 $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'); 179 93 180 if (isset($add_ons[$plugin])){94 if (isset($add_ons[$plugin])) { 181 95 182 96 $path = $add_ons[$plugin]['path']; 183 97 $item_name = $add_ons[$plugin]['item_name']; 184 98 $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'] : ''; 186 100 $file = $path . "config.txt"; 187 101 188 if (empty(CWP()->cubewp_options($slug))){189 102 if (empty(CWP()->cubewp_options($slug))) { 103 190 104 $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'); 191 105 $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'); … … 193 107 194 108 195 if ( file_exists ( $file )) {196 197 $key = file_get_contents ( $file);109 if (file_exists($file)) { 110 111 $key = file_get_contents($file); 198 112 199 113 // 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); 203 117 return; 204 118 } 205 119 206 // data to send in our API request207 $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)); 216 130 // make sure the response came back okay 217 if ( is_wp_error( $response )) {218 die($file_is_not_valid);219 }220 // decode the license data221 $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) { 225 139 die($lic_is_not_valid); 226 } else{140 } else { 227 141 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); 230 144 } 231 }else{145 } else { 232 146 die($lic_is_not_valid); 233 147 } 234 unlink ( $file);235 } else{148 unlink($file); 149 } else { 236 150 //file not good 237 die($need_fresh_file);151 die($need_fresh_file); 238 152 } 239 153 } 240 241 }else{ 154 } else { 242 155 //Plugin not good 243 die($not_our_plugin); 244 } 245 } 246 156 die($not_our_plugin); 157 } 158 } 247 159 } 248 160 … … 252 164 * @version 1.1 253 165 */ 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 { 285 211 $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')) { 293 219 $transient = true; 294 220 } 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) { 298 224 $api_params = array( 299 225 'edd_action' => 'check_license', 300 226 'license' => $Lkey, 301 'item_name' => urlencode( $item_name),302 'url' => get_bloginfo( 'url'),227 'item_name' => urlencode($item_name), 228 'url' => get_bloginfo('url'), 303 229 ); 304 230 … … 312 238 ) 313 239 ); 314 315 if ( is_wp_error( $response ))240 241 if (is_wp_error($response)) 316 242 return false; 317 243 318 244 $license_data = json_decode( 319 wp_remote_retrieve_body( $response)245 wp_remote_retrieve_body($response) 320 246 ); 321 247 322 if ( isset($license_data->license)){323 if ( $license_data->license != 'valid') {248 if (isset($license_data->license)) { 249 if ($license_data->license != 'valid') { 324 250 $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); 327 253 CWP()->update_cubewp_options($slug, $license_data); 328 254 } 329 255 } 330 256 331 257 // Set to check again in 12 hours 332 258 set_transient( 333 259 $slug . '_checking', 334 260 $license_data, 335 ( 60 * 60 * 12)261 (60 * 60 * 24) 336 262 ); 337 338 263 } 339 264 } 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)) 349 272 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); 358 284 CWP()->update_cubewp_options($slug, ''); 359 285 return false; … … 361 287 } 362 288 363 public function updates_enable_for_free_addon() { 289 public function updates_enable_for_free_addon() 290 { 364 291 //cwp_pre(get_option('cubewp-addon-social-logins_key')); 365 292 //delete_option('cubewp-addon-social-logins_key'); 366 293 367 $add_ons = self::cubewp_add_ons();294 $add_ons = CWP()->cubewp_get_modules(); 368 295 $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])) { 371 298 $path = $add_ons[$plugin]['path']; 372 299 $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'] : ''; 374 301 $file = $path . "config.txt"; 375 $existing_key = get_option($slug .'_key');302 $existing_key = get_option($slug . '_key'); 376 303 if (empty($existing_key) && $license_type == 'free') { 377 304 // 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); 382 309 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); 386 313 return; 387 314 } 388 389 315 } 390 316 } … … 392 318 } 393 319 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 } 398 325 } -
cubewp-framework/trunk/cube/classes/class-cubewp-enqueue.php
r3155340 r3202079 182 182 'version' => CUBEWP_VERSION, 183 183 ), 184 'cubewp-slick' => array( 185 'src' => CWP_PLUGIN_URI . 'cube/assets/lib/slick/slick.js', 186 'deps' => array( 'jquery' ), 187 'version' => CUBEWP_VERSION, 188 ), 184 189 ); 185 190 $register_scripts = apply_filters( 'frontend/script/register', $register_scripts ); … … 263 268 'cubewp-pretty-photo' => array( 264 269 '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', 265 277 'deps' => array(), 266 278 'version' => CUBEWP_VERSION, -
cubewp-framework/trunk/cube/classes/class-cubewp-export.php
r3155340 r3202079 183 183 value="cwp_settings" checked="checked"> 184 184 <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> 185 190 </div> 186 191 </div> … … 381 386 } 382 387 383 private function cwp_create_zip_file($final = false) {384 388 private function cwp_create_zip_file($final = false) 389 { 385 390 $files = self::cwp_file_names(); 386 391 $zip = new ZipArchive(); 387 392 388 $DelFilePath = $files['file_name'] .".zip";393 $DelFilePath = $files['file_name'] . ".zip"; 389 394 $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 404 423 $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 411 461 /** 412 462 * Method cwp_file_force_contents -
cubewp-framework/trunk/cube/classes/class-cubewp-import.php
r3155340 r3202079 1 1 <?php 2 2 3 /** 3 4 * CubeWp Import to import only cubewp related data. … … 7 8 */ 8 9 9 if ( ! defined( 'ABSPATH' )) {10 exit;10 if (! defined('ABSPATH')) { 11 exit; 11 12 } 12 13 … … 15 16 * CubeWp_Import 16 17 */ 17 class CubeWp_Import { 18 class CubeWp_Import 19 { 18 20 public static $terms = array(); 19 public function __construct(){ 21 public function __construct() 22 { 20 23 add_action('cubewp_import', array($this, 'manage_import')); 21 24 add_action('wp_ajax_cwp_import_data', array($this, 'cwp_import_data_callback')); 22 25 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') { 24 27 new CubeWp_Admin_Notice("cubewp-import-success", esc_html__('Data Imported Successfully', 'cubewp-framework'), 'success', false); 25 28 } 26 29 } 27 30 28 31 /** 29 32 * Method init … … 31 34 * @return void 32 35 */ 33 public static function init() { 36 public static function init() 37 { 34 38 $CubeClass = __CLASS__; 35 39 new $CubeClass; 36 40 } 37 41 38 42 /** 39 43 * Method manage_import … … 41 45 * @since 1.0.0 42 46 */ 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'])); 46 51 session_destroy(); 47 52 } 48 ?>53 ?> 49 54 <div id="cubewp-import" class="imp-exp"> 50 55 <div class="cubewp-page-header"> … … 57 62 <form id="import_form" method="post" action="" enctype="multipart/form-data"> 58 63 <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'); ?>"> 60 65 <div class="cubewp-import-box-container"> 61 66 <div class="cubewp-import-box"> … … 94 99 </form> 95 100 </div> 96 <?php97 } 101 <?php 102 } 98 103 /** 99 104 * Method rmdir_recursive … … 104 109 * @since 1.0.0 105 110 */ 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 } 115 132 /** 116 133 * Method cwp_import_data_callback … … 119 136 * @since 1.0.0 120 137 */ 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')) { 127 145 $import_file = $_FILES; 128 146 $filename = sanitize_file_name($import_file["file"]["name"]); … … 132 150 $name = explode(".", $filename); 133 151 $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) { 136 154 $okay = true; 137 155 break; 138 } 156 } 139 157 } 140 158 141 159 $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'))); 144 162 } 145 163 … … 147 165 $upload_dir = wp_upload_dir(); 148 166 $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)) { 150 168 mkdir($path, 0777, true); 151 169 } 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) 154 172 155 173 $targetdir = $path . $filenoext; // target directory … … 159 177 /* target directory is same as filename without extension */ 160 178 161 if (is_dir($targetdir)) $this->rmdir_recursive ($targetdir);179 if (is_dir($targetdir)) $this->rmdir_recursive($targetdir); 162 180 163 181 mkdir($targetdir, 0777); … … 165 183 /* here it is really happening */ 166 184 167 if (move_uploaded_file($source, $targetzip)) {185 if (move_uploaded_file($source, $targetzip)) { 168 186 $zip = new ZipArchive(); 169 187 $x = $zip->open($targetzip); // open the zip file to extract … … 171 189 $zip->extractTo($targetdir); // place in the directory with same name 172 190 $zip->close(); 173 174 191 unlink($targetzip); 175 192 } 176 193 $moved = true; 177 } else { 194 } else { 178 195 $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 != '') { 183 199 $setup_file = $this->cwp_import_files(true); 184 if (file_exists($targetdir.$setup_file)){200 if (file_exists($targetdir . $setup_file)) { 185 201 self::cwp_import_cubewp_data($targetdir, $setup_file); 186 202 } 187 203 188 204 $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)) { 192 208 $message = self::cwp_import_wordpress_content($targetdir, $content_file); 193 209 } 194 210 } 195 211 } 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 } 196 220 $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 201 225 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'))); 204 228 } 205 229 } … … 211 235 * @since 1.0.0 212 236 */ 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'))); 216 241 wp_die(); 217 242 } 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'))); 220 245 wp_die(); 221 246 } 222 if (isset($_POST['data_type']) && $_POST['data_type'] == 'dummy'){247 if (isset($_POST['data_type']) && $_POST['data_type'] == 'dummy') { 223 248 $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); 225 250 $content = 'false'; 226 if (!isset($_POST['content'])){251 if (!isset($_POST['content'])) { 227 252 $setup_file = $this->cwp_import_files(true); 228 if (file_exists($targetdir.$setup_file)){253 if (file_exists($targetdir . $setup_file)) { 229 254 self::cwp_import_cubewp_data($targetdir, $setup_file); 230 255 } 231 256 232 257 $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)) { 236 261 $message = self::cwp_import_wordpress_content($targetdir, $content_file); 237 262 } 238 263 } 239 264 } 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)) { 242 275 $content = 'true'; 243 276 } 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)) { 247 280 $message = self::cwp_import_wordpress_content($targetdir, $contents); 248 281 } … … 250 283 do_action('cwp_actions_after_demo_imported'); 251 284 $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', ''); 254 287 $successMessage = ''; 255 if (is_array($success) && isset($success['selecter']) && isset($success['message'])){288 if (is_array($success) && isset($success['selecter']) && isset($success['message'])) { 256 289 $successMessage = $success; 257 290 } 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 260 293 wp_die(); 261 294 } 262 295 } 263 296 297 264 298 /** 265 299 * Method cwp_import_dummy_content … … 268 302 * @since 1.0.0 269 303 */ 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) { 272 307 return '/cwp-setup.json'; 273 } else if($content == true){308 } else if ($content == true) { 274 309 return '/content.xml'; 275 310 } … … 280 315 ); 281 316 } 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 283 382 /** 284 383 * Method cwp_import_cubewp_data … … 288 387 * @return void 289 388 */ 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 != '') { 293 393 294 394 $file = $targetdir . $file; 295 $file_content = file_get_contents( $file);395 $file_content = file_get_contents($file); 296 396 $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) { 300 400 case 'post_types': 301 $this->cwp_import_post_types( $import_data);302 break;401 $this->cwp_import_post_types($import_data); 402 break; 303 403 case 'taxonomies': 304 $this->cwp_import_taxonomies( $import_data);305 break;404 $this->cwp_import_taxonomies($import_data); 405 break; 306 406 case 'custom_fields': 307 $this->cwp_import_custom_fields( $import_data);308 break;407 $this->cwp_import_custom_fields($import_data); 408 break; 309 409 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; 312 412 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; 315 415 case 'terms': 316 416 $_SESSION['terms'] = $import_data; 317 break;417 break; 318 418 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; 321 421 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; 324 424 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; 327 427 case 'search_forms': 328 $this->cwp_import_search_forms( $import_data);329 break;428 $this->cwp_import_search_forms($import_data); 429 break; 330 430 case 'filter_forms': 331 $this->cwp_import_filter_forms( $import_data);332 break;431 $this->cwp_import_filter_forms($import_data); 432 break; 333 433 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; 336 436 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; 339 439 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; 342 442 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; 345 445 case 'cwp_settings': 346 $this->cwp_import_settings( $import_data);347 break;446 $this->cwp_import_settings($import_data); 447 break; 348 448 } 349 449 } … … 353 453 } 354 454 355 455 356 456 /** 357 457 * Method cwp_import_wordpress_content … … 361 461 * @return void 362 462 */ 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 != '') { 365 466 $file = $targetdir . $file; 366 467 if (!defined('WP_LOAD_IMPORTERS')) { … … 389 490 } else { 390 491 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 tocommunity 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."; 392 493 } else { 494 // Step 1: Import content without fetching attachments 393 495 ob_start(); 394 496 $wp_import = new WP_Import(); 395 497 $wp_import->fetch_attachments = true; 396 $wp_import->import( $file);498 $wp_import->import($file); 397 499 ob_end_clean(); 398 500 } … … 400 502 } 401 503 } 402 403 504 505 404 506 /** 405 507 * Method cwp_import_post_types … … 410 512 * @since 1.0.0 411 513 */ 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)) { 415 518 $cwp_custom_types = CWP_types(); 416 519 $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])) { 419 522 $cwp_custom_types[$post_type] = $post_type_data; 420 523 } … … 422 525 update_option('cwp_custom_types', $cwp_custom_types); 423 526 } 424 425 } 426 527 } 528 427 529 /** 428 530 * Method cwp_import_taxonomies … … 433 535 * @since 1.0.0 434 536 */ 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)) { 438 541 $cwp_custom_taxonomies = get_option('cwp_custom_taxonomies'); 439 542 $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])) { 442 545 $cwp_custom_taxonomies[$taxonomy_name] = $taxonomy_data; 443 546 } … … 445 548 update_option('cwp_custom_taxonomies', $cwp_custom_taxonomies); 446 549 } 447 448 } 449 550 } 551 450 552 /** 451 553 * Method cwp_import_terms … … 456 558 * @since 1.0.0 457 559 */ 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) { 465 568 $id = wp_insert_term( 466 569 $terms['name'], 467 $terms['taxonomy'], 570 $terms['taxonomy'], 468 571 array( 469 572 'slug' => $terms['slug'], … … 477 580 return $id; 478 581 } 479 480 } 481 582 } 583 482 584 /** 483 585 * Method cwp_import_custom_fields … … 488 590 * @since 1.0.0 489 591 */ 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)) { 493 596 $cwp_custom_fields = CWP()->get_custom_fields('post_types'); 494 597 $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])) { 498 601 $cwp_custom_fields[$field_slug] = $field_options; 499 602 } … … 502 605 } 503 606 } 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)) { 510 613 $cwp_tax_custom_fields = CWP()->get_custom_fields('taxonomy'); 511 614 $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])) { 515 618 $cwp_tax_custom_fields[$taxonomy_name] = $taxonomy_custom_fields; 516 619 } … … 519 622 } 520 623 } 521 522 } 523 624 } 625 524 626 /** 525 627 * Method cwp_import_user_custom_fields … … 530 632 * @since 1.0.0 531 633 */ 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)) { 535 638 $cwp_user_custom_fields = CWP()->get_custom_fields('user'); 536 639 $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])) { 540 643 $cwp_user_custom_fields[$user_role] = $user_custom_fields; 541 644 } … … 544 647 } 545 648 } 546 547 } 548 649 } 650 549 651 /** 550 652 * Method cwp_import_post_type_forms … … 555 657 * @since 1.0.0 556 658 */ 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)) { 559 662 $cwp_post_type_forms = CWP()->get_form('post_type'); 560 663 $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])) { 564 667 $cwp_post_type_forms[$post_type] = $form_data; 565 668 } … … 578 681 * @since 1.0.0 579 682 */ 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)) { 582 686 $cwp_loop_builder_forms = CWP()->get_form('loop_builder'); 583 687 $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])) { 587 691 $cwp_loop_builder_forms[$post_type] = $form_data; 588 692 } … … 601 705 * @since 1.1.4 602 706 */ 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)) { 605 710 $cwp_custom_fields = CWP()->get_custom_fields('custom_forms'); 606 711 $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])) { 610 715 $cwp_custom_fields[$field_slug] = $field_options; 611 716 } … … 615 720 } 616 721 } 617 722 618 723 /** 619 724 * Method cwp_import_search_forms … … 624 729 * @since 1.0.0 625 730 */ 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)) { 628 734 $cwp_search_forms = CWP()->get_form('search_fields'); 629 735 $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])) { 633 739 $cwp_search_forms[$post_type] = $form_data; 634 740 } … … 638 744 } 639 745 } 640 746 641 747 /** 642 748 * Method cwp_import_filter_forms … … 647 753 * @since 1.0.0 648 754 */ 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)) { 651 758 $cwp_filter_forms = CWP()->get_form('search_filters'); 652 759 $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])) { 656 763 $cwp_filter_forms[$post_type] = $form_data; 657 764 } … … 661 768 } 662 769 } 663 770 664 771 /** 665 772 * Method cwp_import_user_reg_forms … … 670 777 * @since 1.0.0 671 778 */ 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)) { 674 782 $cwp_user_forms = CWP()->get_form('user_register'); 675 783 $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])) { 679 787 $cwp_user_forms[$user_role] = $form_data; 680 788 } … … 684 792 } 685 793 } 686 794 687 795 /** 688 796 * Method cwp_import_user_profile_forms … … 693 801 * @since 1.0.0 694 802 */ 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)) { 697 806 $cwp_user_forms = CWP()->get_form('user_profile'); 698 807 $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])) { 702 811 $cwp_user_forms[$user_role] = $form_data; 703 812 } … … 707 816 } 708 817 } 709 818 710 819 /** 711 820 * Method cwp_import_single_layout_forms … … 716 825 * @since 1.0.0 717 826 */ 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)) { 720 830 $cwp_single_layout_forms = CWP()->get_form('single_layout'); 721 831 $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])) { 725 835 $cwp_single_layout_forms[$user_role] = $form_data; 726 836 } … … 739 849 * @since 1.0.0 740 850 */ 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)) { 743 854 $cwp_userdash = CWP()->cubewp_options('cwp_userdash'); 744 855 $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])) { 748 859 $cwp_userdash[$key] = $form_data; 749 860 } … … 762 873 * @since 1.0.0 763 874 */ 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)) { 766 878 $cwp_settings = CWP()->cubewp_options('cwp_settings'); 767 879 $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])) { 771 883 $cwp_settings[$key] = $form_data; 772 884 } … … 776 888 } 777 889 } 778 779 890 } 780 891 session_write_close(); -
cubewp-framework/trunk/cube/classes/class-cubewp-load.php
r3187693 r3202079 21 21 * @var string 22 22 */ 23 public static $CubeWp_version = '1.1.2 2';23 public static $CubeWp_version = '1.1.23'; 24 24 25 25 /** … … 152 152 // Set Cubewp settings. 153 153 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; 154 192 } 155 193 -
cubewp-framework/trunk/cube/classes/class-cubewp-single-cpt.php
r2984614 r3202079 1 1 <?php 2 2 3 /** 3 4 * CubeWp single cpt contains all function to show single post page content … … 7 8 */ 8 9 9 if ( ! defined( 'ABSPATH' )) {10 exit;10 if (! defined('ABSPATH')) { 11 exit; 11 12 } 12 13 … … 14 15 * CubeWp_Single_Cpt 15 16 */ 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 17 class 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 27 29 /** 28 30 * Method instance … … 31 33 * @since 1.0.0 32 34 */ 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 58 63 /** 59 64 * Method cubewp_post_metas … … 64 69 * @since 1.0.0 65 70 */ 66 public static function cubewp_post_metas($postid='', $rest_data = false) { 71 public static function cubewp_post_metas($postid = '', $rest_data = false) 72 { 67 73 if (!empty($postid)) self::$post_id = $postid; 68 $args = array();74 $args = array(); 69 75 $groups = !isset(self::$groups) || empty(self::$groups) ? cwp_get_groups_by_post_id(self::$post_id) : self::$groups; 70 76 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 } 83 91 } 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 ); 84 101 } 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 );94 102 } 95 103 } … … 98 106 return $args; 99 107 } 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) . '"> 138 148 <p>' . $term->name . '</p> 139 149 </a> 140 150 </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 167 178 /** 168 179 * Method get_post_save_button … … 171 182 * @since 1.0.0 172 183 */ 173 public static function get_post_save_button() { 184 public static function get_post_save_button() 185 { 174 186 $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"); 180 192 $SavedClass = 'cwp-save-post'; 181 193 } 182 194 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) . '"> 184 196 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"> 185 197 <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"/> … … 188 200 <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"/> 189 201 </svg> 190 <span class="cwp-saved-text">' .esc_html($SavedText).'</span>202 <span class="cwp-saved-text">' . esc_html($SavedText) . '</span> 191 203 </span> 192 204 </div>'; 193 205 } 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 { 202 215 $user_id = self::$author_id; 203 216 return get_user_details($user_id); 204 217 } 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 { 213 227 $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> 218 232 ' . self::get_post_breadcrumb_tags('tags') . ' 219 233 </div>'; 220 } else{234 } else { 221 235 return ''; 222 236 } 223 237 } 224 238 225 239 /** 226 240 * Method get_post_sidebar … … 229 243 * @since 1.0.0 230 244 */ 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"> 233 248 ' . self::field_author() . ' 234 249 </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"> 237 252 ' . self::get_post_sidebar_tags() . ' 238 253 </div>'; 239 254 } 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 { 252 268 $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'] : ''; 256 272 $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'])) { 260 276 $field_type = 'terms'; 261 277 } 262 278 } 263 $value = self::get_single_meta_value($meta_key, $field_type);279 $value = self::get_single_meta_value($meta_key, $field_type); 264 280 $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)) { 267 283 $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 } 274 290 return $output; 275 291 } 276 292 277 293 /** 278 294 * Method get_single_meta_value … … 284 300 * @since 1.0.0 285 301 */ 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') { 289 306 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); 294 311 $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); 297 314 if (is_array($values)) { 298 315 $value = self::get_repeating_Fields_value($values); 299 316 } 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); 302 319 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); 305 322 $value = array( 306 323 'address' => $value, … … 310 327 } 311 328 } 312 if (empty($value)){329 if (empty($value)) { 313 330 return ''; 314 331 } 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 { 327 345 $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) { 332 350 $options = get_field_options($k); 333 if (count($options)>0){351 if (count($options) > 0) { 334 352 $field_type = $options['type']; 335 353 $field_label = $options['label']; 336 354 $field_class = $options['class']; 337 355 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 341 359 $subValue = array( 342 360 'address' => $subValue, … … 344 362 'lng' => $lng 345 363 ); 346 } elseif($field_type == 'dropdown' || $field_type == 'radio' || $field_type == 'checkbox'){364 } elseif ($field_type == 'dropdown' || $field_type == 'radio' || $field_type == 'checkbox') { 347 365 $subValue = render_multi_value($k, $subValue); 348 366 } … … 360 378 } 361 379 } 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; 371 390 if (is_array(self::$groups)) self::$groups = array_reverse(self::$groups); 372 391 foreach (self::$groups as $group) { 373 $fields = cwp_get_fields_by_group_id( $group);392 $fields = cwp_get_fields_by_group_id($group); 374 393 if (!empty($fields) && is_array($fields)) { 375 394 $fields_ui = self::get_post_group_fields_callback($fields); 376 if (!empty($fields_ui)){395 if (!empty($fields_ui)) { 377 396 $output .= '<div class="cwp-single-group">'; 378 397 $output .= $fields_ui; 379 $output .= '</div>';398 $output .= '</div>'; 380 399 } 381 400 } … … 384 403 } 385 404 386 405 387 406 /** 388 407 * Method get_single_sidebar_area … … 391 410 * @since 1.0.0 392 411 */ 393 public static function get_single_sidebar_area() { 412 public static function get_single_sidebar_area() 413 { 394 414 echo self::get_post_sidebar(); 395 396 } 415 } 397 416 /** 398 417 * Method get_single_content_area … … 400 419 * @since 1.0.0 401 420 */ 402 public static function get_single_content_area() { 421 public static function get_single_content_area() 422 { 403 423 echo self::get_post_content(); 404 424 } 405 425 406 426 /** 407 427 * Method get_sections_data_of … … 412 432 * @since 1.0.0 413 433 */ 414 public static function get_sections_data_of($of='') { 434 public static function get_sections_data_of($of = '') 435 { 415 436 $section = array(); 416 if (is_array(self::$groups)) {437 if (is_array(self::$groups)) { 417 438 foreach (self::$groups as $group) { 418 439 $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; 421 442 } 422 443 } 423 444 return $section; 424 445 } 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 { 433 455 return '<div class="cwp-single-right-side"> 434 456 <div class="cwp-single-groups"> … … 437 459 </div>'; 438 460 } 439 440 461 } -
cubewp-framework/trunk/cube/classes/page-builders/elementor-widgets/class-cubewp-elementor-posts-widget.php
r3161906 r3202079 1 1 <?php 2 defined( 'ABSPATH') || exit;2 defined('ABSPATH') || exit; 3 3 4 4 use Elementor\Controls_Manager; … … 13 13 * @since 1.0.0 14 14 */ 15 class CubeWp_Elementor_Posts_Widget extends Widget_Base { 15 class CubeWp_Elementor_Posts_Widget extends Widget_Base 16 { 16 17 17 18 private static $post_types = array(); 18 19 private static $settings = array(); 19 20 20 public function get_name() { 21 public function get_name() 22 { 21 23 return 'cubewp_posts'; 22 24 } 23 25 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'); 26 29 } 27 30 28 public function get_icon() { 31 public function get_icon() 32 { 29 33 return 'eicon-post-list'; 30 34 } 31 35 32 public function get_categories() { 33 return array( 'cubewp' ); 36 public function get_categories() 37 { 38 return array('cubewp'); 34 39 } 35 40 36 public function get_keywords() { 41 public function get_keywords() 42 { 37 43 return array( 38 44 'cubewp', … … 53 59 } 54 60 55 protected function register_controls() { 61 protected function register_controls() 62 { 56 63 self::get_post_types(); 57 64 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'), 60 67 'tab' => Controls_Manager::TAB_CONTENT, 61 ) );62 68 )); 69 63 70 $this->add_post_type_controls(); 64 71 $this->add_additional_controls(); 65 66 67 $this->add_control( 'orderby', array(72 73 74 $this->add_control('orderby', array( 68 75 'type' => Controls_Manager::SELECT, 69 'label' => esc_html__( 'Order By', 'cubewp-framework'),76 'label' => esc_html__('Order By', 'cubewp-framework'), 70 77 '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'), 74 81 ), 75 82 'default' => 'date', 76 ) );77 $this->add_control( 'order', array(83 )); 84 $this->add_control('order', array( 78 85 'type' => Controls_Manager::SELECT, 79 'label' => esc_html__( 'Order', 'cubewp-framework'),86 'label' => esc_html__('Order', 'cubewp-framework'), 80 87 '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'), 83 90 ), 84 91 'default' => 'DESC', … … 86 93 'orderby!' => 'rand', 87 94 ), 88 ) );89 $this->add_control( 'number_of_posts', array(95 )); 96 $this->add_control('number_of_posts', array( 90 97 'type' => Controls_Manager::SELECT, 91 'label' => esc_html__( 'Number Of Posts', 'cubewp-framework'),98 'label' => esc_html__('Number Of Posts', 'cubewp-framework'), 92 99 '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') 104 113 ), 105 114 'default' => '3' 106 ) );107 $this->add_control( 'load_more', array(115 )); 116 $this->add_control('load_more', array( 108 117 'type' => Controls_Manager::SWITCHER, 109 'label' => esc_html__( 'Load More Button', 'cubewp-framework'),118 'label' => esc_html__('Load More Button', 'cubewp-framework'), 110 119 'default' => 'yes', 111 120 'condition' => array( 112 121 'number_of_posts' => '-1', 113 122 ) 114 ) );115 $this->add_control( 'posts_per_page', array(123 )); 124 $this->add_control('posts_per_page', array( 116 125 'type' => Controls_Manager::NUMBER, 117 'label' => esc_html__( 'Posts Per Page', 'cubewp-framework'),126 'label' => esc_html__('Posts Per Page', 'cubewp-framework'), 118 127 'default' => '6', 119 128 'condition' => array( … … 121 130 'load_more' => 'yes', 122 131 ) 123 ) );124 125 $this->add_control( 'layout', array(132 )); 133 134 $this->add_control('layout', array( 126 135 'type' => Controls_Manager::SELECT, 127 'label' => esc_html__( 'Layout', 'cubewp-framework'),136 'label' => esc_html__('Layout', 'cubewp-framework'), 128 137 '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') 131 140 ), 132 141 '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 )); 134 153 135 154 $this->end_controls_section(); 136 155 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'), 139 158 'tab' => Controls_Manager::TAB_CONTENT, 140 159 'condition' => array( 141 'posts_by' => array('all', 'taxonomy'),160 'posts_by' => array('all', 'taxonomy'), 142 161 ), 143 ) );144 $this->add_control( 'filter_by_meta', array(162 )); 163 $this->add_control('filter_by_meta', array( 145 164 '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'), 147 166 'default' => 'no', 148 ) );149 150 $this->add_control( 'meta_relation', array(167 )); 168 169 $this->add_control('meta_relation', array( 151 170 '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"), 154 173 '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'), 157 176 ), 158 177 'default' => 'or', … … 160 179 'filter_by_meta' => 'yes', 161 180 ), 162 ) );181 )); 163 182 164 183 $repeater = new Repeater(); 165 184 166 $repeater->add_control( 'meta_key', array(185 $repeater->add_control('meta_key', array( 167 186 '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')), 170 189 'label_block' => true, 171 ) );172 173 $repeater->add_control( 'meta_value', array(190 )); 191 192 $repeater->add_control('meta_value', array( 174 193 '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"), 178 197 'label_block' => true, 179 ) );180 181 $repeater->add_control( 'meta_compare', array(198 )); 199 200 $repeater->add_control('meta_compare', array( 182 201 '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"), 185 204 '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'), 200 219 ), 201 220 'default' => 'LIKE', … … 204 223 'meta_value!' => '', 205 224 ), 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'), 210 229 'type' => Controls_Manager::REPEATER, 211 230 'fields' => $repeater->get_controls(), … … 215 234 'posttype!' => '', 216 235 ), 217 218 ) );236 237 )); 219 238 $this->end_controls_section(); 239 $this->add_slider_controls(); 220 240 } 221 241 222 private static function get_post_types() { 242 private static function get_post_types() 243 { 223 244 $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']); 232 253 233 254 self::$post_types = $options; 234 255 } 235 236 private function add_post_type_controls() { 256 257 private function add_post_type_controls() 258 { 237 259 $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( 240 262 'type' => Controls_Manager::SELECT2, 241 263 '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'), 244 266 'options' => $post_types, 245 'default' => array( 'post'),267 'default' => array('post'), 246 268 '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); 250 272 } 251 273 } 252 274 } 253 275 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 )); 267 288 } 268 289 } 269 290 270 private function add_additional_controls() { 271 291 private function add_additional_controls() 292 { 293 272 294 $post_types = self::$post_types; 273 if ( is_array( $post_types ) && ! empty( $post_types )) {295 if (is_array($post_types) && ! empty($post_types)) { 274 296 $options = array( 275 "all" => esc_html__( "All"),276 "taxonomy" => esc_html__( "By Taxonomy"),297 "all" => esc_html__("All"), 298 "taxonomy" => esc_html__("By Taxonomy"), 277 299 //"post_ids" => esc_html__( "By IDs" ), 278 300 ); 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"); 281 303 } 282 $this->add_control( 'posts_by', array(304 $this->add_control('posts_by', array( 283 305 'type' => Controls_Manager::SELECT, 284 'label' => esc_html__( 'Show Posts', 'cubewp-framework'),306 'label' => esc_html__('Show Posts', 'cubewp-framework'), 285 307 'options' => $options, 286 308 'condition' => array( … … 288 310 ), 289 311 '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); 294 316 } 295 317 } 296 318 } 297 319 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( 303 326 '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'), 305 328 'description' => esc_html__('Leave empty if you want to display all posts.', 'cubewp-framework'), 306 329 'options' => self::get_terms_by_post_type($post_type), … … 311 334 ), 312 335 'label_block' => true, 313 ) );336 )); 314 337 } 315 338 } 316 339 317 private function add_posttype_controls( $post_type ) { 340 private function add_posttype_controls($post_type) 341 { 318 342 //$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( 322 346 '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'), 324 348 'description' => esc_html__('Leave empty if you want to display all posts.', 'cubewp-framework'), 325 349 'options' => $posts, 326 350 'multiple' => true, 327 'placeholder' => esc_html__( 'Please Select Posts', 'cubewp-framework'),351 'placeholder' => esc_html__('Please Select Posts', 'cubewp-framework'), 328 352 'condition' => array( 329 353 'posts_by' => "post_ids", … … 331 355 ), 332 356 'label_block' => true, 333 ) );357 )); 334 358 } 335 359 } 336 360 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 )); 342 367 $posts = $query->cubewp_post_query(); 343 368 $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 350 375 return $return; 351 376 } 352 377 353 private static function get_terms_by_post_type( $post_type ) { 378 private static function get_terms_by_post_type($post_type) 379 { 354 380 $object = cubewp_terms_by_post_types($post_type); 355 381 $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']; 359 385 } 360 386 } 361 387 362 388 return $termArray; 363 389 } 364 390 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 { 366 393 $post_type_object = get_post_type_object($post_type_slug); 367 394 // Check if the post type object exists and return its label (name) … … 372 399 } 373 400 374 protected static function split_taxonomy_and_term($input) { 401 protected static function split_taxonomy_and_term($input) 402 { 375 403 if (preg_match('/\[(.*?)\](.*)/', $input, $matches)) { 376 404 return [ … … 379 407 ]; 380 408 } 381 409 382 410 // Return null if the format is not matched 383 411 return null; 384 412 } 385 413 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'])) { 388 417 $meta_query = array(); 389 418 $meta_query['relation'] = $args['relation']; 390 419 $numeric_comparisons = ['=', '!=', '>', '>=', '<', '<=', 'BETWEEN', 'NOT BETWEEN']; 391 foreach ($args['query'] as $index => $query){420 foreach ($args['query'] as $index => $query) { 392 421 $meta_query[$index] = array( 393 422 'key' => $query['meta_key'], … … 401 430 return $meta_query; 402 431 } 403 } 404 405 protected function render() { 432 } 433 434 protected function render() 435 { 406 436 $settings = $this->get_settings_for_display(); 407 437 $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 411 494 $args = array( 412 495 'post_type' => $settings['posttype'], … … 421 504 'boosted_only' => 'no', 422 505 '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); 433 537 } 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) { 440 543 $result = self::split_taxonomy_and_term($term); 441 544 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']; 444 547 } 445 548 } 446 549 } 447 448 550 } 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)) { 451 553 $args['card_style'][$post_type] = $card_style; 452 554 } 453 555 } 454 556 } 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'; 459 561 } 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'; 465 567 $args['meta_query'] = self::_meta_query($meta_query); 466 568 } 467 468 469 echo apply_filters( 'cubewp_shortcode_posts_output','', $args);569 570 571 echo apply_filters('cubewp_shortcode_posts_output', '', $args); 470 572 } 471 573 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 } 472 1961 } -
cubewp-framework/trunk/cube/classes/shortcodes/class-cubewp-shortcode-posts.php
r3161906 r3202079 7 7 * @class CubeWp_Frontend_Posts_Shortcode 8 8 */ 9 class CubeWp_Shortcode_Posts { 10 11 public function __construct() { 9 class CubeWp_Shortcode_Posts 10 { 11 12 public function __construct() 13 { 12 14 add_shortcode('cubewp_shortcode_posts', array($this, 'cubewp_shortcode_posts_callback')); 13 15 add_filter('cubewp_shortcode_posts_output', array($this, 'cubewp_posts'), 10, 2); … … 16 18 } 17 19 18 public static function cubewp_posts($output, array $parameters) { 20 public static function cubewp_posts($output, array $parameters) 21 { 19 22 return self::cubewp_posts_output($parameters); 20 23 } 21 24 22 public static function cubewp_posts_output($parameters) { 25 public static function cubewp_posts_output($parameters) 26 { 23 27 24 28 // AJAX CALL … … 28 32 } 29 33 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'; 30 57 31 58 $args = array( … … 37 64 ); 38 65 39 if (isset($parameters['number_of_posts'])){66 if (isset($parameters['number_of_posts'])) { 40 67 $args['posts_per_page'] = $parameters['number_of_posts']; 41 68 } 42 69 43 if (isset($parameters['posts_per_page'])){70 if (isset($parameters['posts_per_page'])) { 44 71 $args['posts_per_page'] = $parameters['posts_per_page']; 45 72 } 46 73 47 if (isset($parameters['page_num'])){74 if (isset($parameters['page_num'])) { 48 75 $args['page_num'] = $parameters['page_num']; 49 76 } 50 77 51 78 $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 } 55 82 if (isset($parameters['post__in']) && ! empty($parameters['post__in']) && is_array($parameters['post__in'])) { 56 83 $args['post__in'] = $parameters['post__in']; 57 }84 } 58 85 if (isset($parameters['taxonomy']) && ! empty($parameters['taxonomy']) && is_array($parameters['taxonomy'])) { 59 86 foreach ($parameters['taxonomy'] as $taxonomy) { … … 70 97 if ($layout == 'list') { 71 98 $col_class = 'cwp-col-12'; 72 $row_class = 'list-view';99 $row_class = 'list-view'; 73 100 } 74 101 $query = new CubeWp_Query($args); 75 102 $posts = $query->cubewp_post_query(); 76 103 $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 80 129 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 } 90 141 } 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); 99 149 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'])) { 103 153 $parameters['page_num'] = $parameters['page_num'] + 1; 104 } else{154 } else { 105 155 $parameters['page_num'] = 2; 106 156 } 107 157 $has_more_posts = $args['page_num'] < $posts->max_num_pages; 108 158 $dataAttributes = json_encode($parameters); 109 CubeWp_Enqueue::enqueue_script( 'cwp-load-more');110 159 CubeWp_Enqueue::enqueue_script('cwp-load-more'); 160 111 161 112 162 $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') . ' 115 165 </button> 116 166 </div>'; 117 167 } 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(); 123 172 124 173 if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] === 'cubewp_posts_output') { 125 174 wp_send_json_success(array('content' => $post_markup, 'newAttributes' => $parameters, 'has_more_posts' => $has_more_posts)); 126 175 } 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 { 132 182 $CubeWPClass = __CLASS__; 133 183 new $CubeWPClass; 134 184 } 135 185 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'] : ''; 138 189 $output = '<div class="cwp-widget-shortcode">'; 139 if ( ! empty($title)) {190 if (! empty($title)) { 140 191 $output .= '<h2 class="cwp-widget-shortcode-heading">' . $title . '</h2>'; 141 192 } … … 146 197 } 147 198 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 } 151 203 } -
cubewp-framework/trunk/cube/functions/admin-functions.php
r3155340 r3202079 604 604 605 605 /** 606 * Method cubewp_initialize_modules 607 * 608 * 609 * @return void 610 * @since 1.0.0 611 */ 612 if ( ! 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 /** 606 632 * Get custom post types 607 633 * … … 1648 1674 return $located; 1649 1675 } 1650 }1651 1652 /**1653 * Method cubewp_extra_features1654 *1655 *1656 * @return class1657 * @since 1.0.01658 */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);1676 1676 } 1677 1677 … … 2351 2351 $custom_post_types = cwp_post_types(); 2352 2352 // 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) { 2354 2355 global $submenu; 2355 2356 // Loop through each custom post type … … 2382 2383 if($post_type == '') return []; 2383 2384 2384 $cubewp_styles = [];2385 $cubewp_styles = $cubewp_cards = []; 2385 2386 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 } 2387 2392 if(isset($cubewp_cards[$post_type]['loop-styles'])){ 2388 2393 $cubewp_styles = apply_filters( 'cubewp/post/card/styles', $cubewp_cards[$post_type]['loop-styles'], $post_type); … … 2390 2395 } 2391 2396 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 */ 2406 function 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; 2392 2425 } 2393 2426 -
cubewp-framework/trunk/cube/modules/builder/class-cubewp-loop-builder.php
r3155346 r3202079 75 75 $cwpOptions = ! empty( $cwpOptions ) ? $cwpOptions : get_option( 'cwpOptions' ); 76 76 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(); 81 78 82 79 $switcher_options = array(); 83 80 if ( ! empty( $post_types ) ) { 84 81 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); 91 84 } 92 85 } 93 86 94 87 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 types104 $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;116 88 } 117 89
Note: See TracChangeset
for help on using the changeset viewer.