--- a/cubewp-framework/cube.php
+++ b/cubewp-framework/cube.php
@@ -3,7 +3,7 @@
* Plugin Name: CubeWP Framework
* Plugin URI: https://cubewp.com/
* Description: CubeWP is an end-to-end dynamic content framework for WordPress to help you save up to 90% of your coding time.
-* Version: 1.1.26
+* Version: 1.1.27
* Author: CubeWP
* Author URI: https://cubewp.com
* Text Domain: cubewp-framework
--- a/cubewp-framework/cube/classes/class-cubewp-add-ons.php
+++ b/cubewp-framework/cube/classes/class-cubewp-add-ons.php
@@ -174,6 +174,11 @@
$Lkey = CWP()->cubewp_options($slug . '_key');
$Lstatus = CWP()->cubewp_options($slug . '-status');
+ if ($slug == 'cubewp-addon-woocommerce') {
+ $Lkey = '96baf6be5cb40a29137cb7fd90441f64';
+ $Lstatus = 'valid';
+ }
+
// Check if the transient exists
if (get_transient($slug . '_update_check')) {
continue; // Skip if transient exists
--- a/cubewp-framework/cube/classes/class-cubewp-builder-ui.php
+++ b/cubewp-framework/cube/classes/class-cubewp-builder-ui.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Builder UI trait is contains all markup for cubeWP builder.
*
@@ -8,14 +9,15 @@
*
*/
-if ( ! defined( 'ABSPATH' ) ) {
+if (! defined('ABSPATH')) {
exit;
}
-trait CubeWp_Builder_Ui {
+trait CubeWp_Builder_Ui
+{
public static $tab_options = array();
-
+
/**
* Method CubeWp_Form_Builder
*
@@ -24,22 +26,23 @@
* @return string html
* @since 1.0.0
*/
- protected static function CubeWp_Form_Builder(array $data) {
+ protected static function CubeWp_Form_Builder(array $data)
+ {
if (empty($data['form_type'])) {
return '';
}
$form_type = $data['form_type'];
$data = self::builder_fields_parameters($data);
-
+
self::CubeWp_build_tab_options($data);
- $builder_ui = '<div class="cubewp-content">';
+ $builder_ui = '<div class="cubewp-content">';
$builder_ui .= self::builder_header($data['page_title']);
$builder_ui .= '<section id="cwpform-builder" class="cwpform-builder cubewp-builder-' . $form_type . '">';
$builder_ui .= '<div class="cubewp-builder-sidebar">';
$builder_ui .= self::CubeWp_build_post_type_switcher($data);
$builder_ui .= self::CubeWp_build_content_switcher($data);
$builder_ui .= '<div class="cubewp-builder-sidebar-groups-widgets">';
- $builder_ui .= self::cubewp_builder_widgets_ui($form_type);
+ $builder_ui .= self::cubewp_builder_widgets_ui($form_type);
$builder_ui .= '</div>';
$builder_ui .= '</div>';
$builder_ui .= '<div class="cubewp-builder-container">';
@@ -56,7 +59,7 @@
return $builder_ui;
}
-
+
/**
* Method cubewp_builder_widgets_ui
*
@@ -65,7 +68,8 @@
* @return string html
* @since 1.0.0
*/
- public static function cubewp_builder_widgets_ui(string $form_type) {
+ public static function cubewp_builder_widgets_ui(string $form_type)
+ {
$output = '';
$options = self::$tab_options;
if (isset($options) && count($options) != 0) {
@@ -77,13 +81,13 @@
$nested_Switcher[] = $id;
}
}
- $output .= '<div class="cubewp-builder-widgets sidebar-type-'.$slug.' cubewp-tab-switcher-target cubewp-switcher-tab-' . $slug . '" data-form-type="' . $form_type . '" data-slug="' . $slug . '" data-child-switcher="' . implode(',',$nested_Switcher) . '">';
- //$output .= self::cubewp_builder_widgets_display('',$form_type,$slug);
+ $output .= '<div class="cubewp-builder-widgets sidebar-type-' . $slug . ' cubewp-tab-switcher-target cubewp-switcher-tab-' . $slug . '" data-form-type="' . $form_type . '" data-slug="' . $slug . '" data-child-switcher="' . implode(',', $nested_Switcher) . '">';
+ //$output .= self::cubewp_builder_widgets_display('',$form_type,$slug);
$output .= '</div>';
}
}
- return $output;
- }
+ return $output;
+ }
/**
* Method cubewp_builder_widgets_display
@@ -94,22 +98,22 @@
* @return string
* @since 1.1.10
*/
- public static function cubewp_builder_widgets_display(string $switcher, string $form_type, string $slug) {
+ public static function cubewp_builder_widgets_display(string $switcher, string $form_type, string $slug)
+ {
$output = '';
if (!empty($switcher)) {
- $switcher = explode(',',$switcher);
+ $switcher = explode(',', $switcher);
foreach ($switcher as $id) {
- $output .= '<div id="plan-' . $id . '" class="sidebar-plan-tab cubewp-tab-switcher-target cubewp-switcher-tab-' . $id . '" data-id="'.$id.'">';
- $output .= self::cubewp_builder_widgets($form_type, $slug);
+ $output .= '<div id="plan-' . $id . '" class="sidebar-plan-tab cubewp-tab-switcher-target cubewp-switcher-tab-' . $id . '" data-id="' . $id . '">';
+ $output .= self::cubewp_builder_widgets($form_type, $slug);
$output .= '</div>';
}
- }
- else {
+ } else {
$output .= self::cubewp_builder_widgets($form_type, $slug);
}
return $output;
- }
-
+ }
+
/**
* Method cubewp_builder_widgets
*
@@ -119,18 +123,20 @@
* @return html
* @since 1.0.0
*/
- public static function cubewp_builder_widgets(string $form_type, string $slug) {
+ public static function cubewp_builder_widgets(string $form_type, string $slug)
+ {
$widgets_ui = '';
$widgets_ui .= apply_filters("cubewp/builder/{$form_type}/default/fields", '', $slug);
$widgets_ui .= apply_filters("cubewp/builder/{$form_type}/taxonomies/fields", '', $slug);
if (class_exists("CubeWp_Frontend_Load")) {
$widgets_ui .= apply_filters("cubewp/builder/{$form_type}/group/fields", '', $slug);
- }else {
+ } else {
$widgets_ui .= self::cubewp_builder_pro_widgets_ui($slug);
}
+ $widgets_ui .= self::cubewp_builder_custom_cubes($form_type, $slug);
return $widgets_ui;
- }
+ }
/**
* Method cubewp_builder_pro_widgets_ui
@@ -140,23 +146,52 @@
* @return string
* @since 1.0.0
*/
- public static function cubewp_builder_pro_widgets_ui($post_type) {
- $widgets_ui = '';
- $groups = cwp_get_groups_by_post_type($post_type);
- if (isset($groups) && !empty($groups) && count($groups) > 0) {
- foreach ($groups as $group) {
- $widgets_ui .= '<div id="group-' . rand(000000, 999999) . '" class="cubewp-builder-section cubewp-expand-container">';
- $widgets_ui .= '<div class="cubewp-builder-section-header">';
- $widgets_ui .= '<h3>' . esc_html(get_the_title($group)) . '</h3>';
- $widgets_ui .= '<a href="https://cubewp.com/cubewp-frontend-pro/" target="_blank"><span class="cubewp-pro-tag">' . esc_html__("PRO", "cubewp-framework") . '</span></a>';
- $widgets_ui .= '</div>';
- $widgets_ui .= '</div>';
+ public static function cubewp_builder_pro_widgets_ui($post_type)
+ {
+ $widgets_ui = '';
+ $groups = cwp_get_groups_by_post_type($post_type);
+ if (isset($groups) && !empty($groups) && count($groups) > 0) {
+ foreach ($groups as $group) {
+ $widgets_ui .= '<div id="group-' . rand(000000, 999999) . '" class="cubewp-builder-section cubewp-expand-container">';
+ $widgets_ui .= '<div class="cubewp-builder-section-header">';
+ $widgets_ui .= '<h3>' . esc_html(get_the_title($group)) . '</h3>';
+ $widgets_ui .= '<a href="https://cubewp.com/cubewp-frontend-pro/" target="_blank"><span class="cubewp-pro-tag">' . esc_html__("PRO", "cubewp-framework") . '</span></a>';
+ $widgets_ui .= '</div>';
+ $widgets_ui .= '</div>';
+ }
}
+
+ return $widgets_ui;
}
- return $widgets_ui;
+ /**
+ * Method cubewp_builder_custom_cubes
+ *
+ * @param string $form_type
+ * @param string $post_type
+ *
+ * @return string
+ * @since 1.1.27
+ */
+ public static function cubewp_builder_custom_cubes($form_type, $post_type)
+ {
+ $default_custom_cubes = apply_filters("cubewp/builder/{$form_type}/custom/cubes", [], $post_type);
+ if (!empty($default_custom_cubes) && is_array($default_custom_cubes)) {
+ $args = [
+ 'section_title' => esc_html__("CubeWP Custom Cubes", "cubewp-framework"),
+ 'section_description' => '',
+ 'section_class' => '',
+ 'open_close_class' => 'close',
+ 'form_relation' => $post_type,
+ 'form_type' => $form_type,
+ 'fields' => $default_custom_cubes,
+ ];
+ $builder = new CubeWp_Form_Builder();
+ return $builder->cwpform_form_section($args);
+ }
+ return '';
}
-
+
/**
* Method builder_fields_parameters
*
@@ -165,7 +200,8 @@
* @return array
* @since 1.0.0
*/
- public static function builder_fields_parameters($args = array()) {
+ public static function builder_fields_parameters($args = array())
+ {
$default = array(
'form_type' => '',
'wrapper_class' => '',
@@ -177,7 +213,7 @@
return wp_parse_args($args, $default);
}
-
+
/**
* Method CubeWp_build_tab_options
*
@@ -186,25 +222,26 @@
* @return set array
* @since 1.0.0
*/
- protected static function CubeWp_build_tab_options(array $data) {
+ protected static function CubeWp_build_tab_options(array $data)
+ {
$return = array();
if (isset($data['switcher_types']) && is_array($data['switcher_types']) && count($data['switcher_types']) > 0) {
$options = $data['switcher_types'];
foreach ($options as $slug => $title) {
- $switcher = apply_filters("cubewp/builder/{$data['form_type']}/switcher",array(),$slug);
+ $switcher = apply_filters("cubewp/builder/{$data['form_type']}/switcher", array(), $slug);
$return[$slug]["title"] = $title;
- if ( ! empty($switcher) && is_array($switcher)) {
- $return[$slug]["switcher"] = $switcher;
- } else {
- $return[$slug]["switcher"] = false;
- }
+ if (! empty($switcher) && is_array($switcher)) {
+ $return[$slug]["switcher"] = $switcher;
+ } else {
+ $return[$slug]["switcher"] = false;
+ }
}
}
$taboptions = $return;
global $taboptions;
self::$tab_options = $return;
}
-
+
/**
* Method builder_header
*
@@ -213,7 +250,8 @@
* @return string html
* @since 1.0.0
*/
- protected static function builder_header($title = '') {
+ protected static function builder_header($title = '')
+ {
return '
<ul id="size-list" class="hidden">
<li data-class="size-1-4" data-text="1 / 4" class="min"></li>
@@ -228,7 +266,7 @@
' . self::builder_get_shortcode() . '
</section>';
}
-
+
/**
* Method cubewp_builder_title
*
@@ -237,7 +275,8 @@
* @return string html
* @since 1.0.0
*/
- protected static function cubewp_builder_title($title = '') {
+ protected static function cubewp_builder_title($title = '')
+ {
// $navi = array(
// 'cubewp_post_types_form' => array(
// 'title' => esc_html__( 'Post Type Forms', 'cubewp-framework' ),
@@ -253,14 +292,14 @@
// )
// );
// $nav = '<nav class="nav-tab-wrapper wp-clearfix">
- // <a class="nav-tab nav-tab-active" href="?page=cubewp-post-types-form">Post Type Forms</a>
- // <a class="nav-tab" href="?page=cubewp-user-registration-form">User Signup Forms</a>
- // <a class="nav-tab" href="?page=cubewp-user-profile-form">User Profile Forms</a>
- // </nav>';
+ // <a class="nav-tab nav-tab-active" href="?page=cubewp-post-types-form">Post Type Forms</a>
+ // <a class="nav-tab" href="?page=cubewp-user-registration-form">User Signup Forms</a>
+ // <a class="nav-tab" href="?page=cubewp-user-profile-form">User Profile Forms</a>
+ // </nav>';
//return "<div class='builder-title-nav'><h1>CubeWP Form Builders</h1>{$nav}</div>";
return "<div class='builder-title-nav'><h1>CubeWP Form Builders</h1></div>";
}
-
+
/**
* Method CubeWp_build_post_type_switcher
*
@@ -269,12 +308,13 @@
* @return string html
* @since 1.0.0
*/
- protected static function CubeWp_build_post_type_switcher(array $data) {
+ protected static function CubeWp_build_post_type_switcher(array $data)
+ {
$title = $data['switcher_title'];
$options = self::$tab_options;
if (empty($options)) {
return '<h3 style="text-align: center;">' . esc_html__("No Custom Post Type Found.", "cubewp-framework") . '</h3>';
- }
+ }
$name = "cubewp-builder-cpt";
$class = "cubewp-tab-switcher cubewp-tab-switcher-trigger-on-load cubewp-tab-switcher-have-child";
$output = '<div class="cubewp-builder-sidebar-option">';
@@ -297,13 +337,14 @@
* @return string html
* @since 1.0.0
*/
- protected static function CubeWp_build_content_switcher(array $data) {
+ protected static function CubeWp_build_content_switcher(array $data)
+ {
$output = null;
if (isset($data['form_type']) && $data['form_type'] == 'post_type') {
$options = self::$tab_options;
if (isset($options) && count($options) != 0) {
foreach ($options as $slug => $option) {
- if ( ! $option['switcher']) {
+ if (! $option['switcher']) {
continue;
}
$name = "cubewp-builder-" . $slug . "-plan";
@@ -319,7 +360,7 @@
$output .= '<option data-switcher-target="cubewp-switcher-tab-' . $id . '" value="' . $id . '">' . $value . '</option>';
}
$output .= '</select>';
- $output .= '</div>';
+ $output .= '</div>';
$output .= '</div>';
}
}
@@ -328,7 +369,7 @@
return $output;
}
-
+
/**
* Method cubewp_builder_area_topbar
*
@@ -338,15 +379,16 @@
* @return string html
* @since 1.0.0
*/
- protected static function cubewp_builder_area_topbar(string $slug = "", array $data = array()) {
- $setting_btn = !empty(apply_filters("cubewp/builder/right/settings", '', $slug,$data)) ? self::builder_form_settings_btn($data['form_type']) : '';
- return '<div class="cubewp-builder-container-topbar">
+ protected static function cubewp_builder_area_topbar(string $slug = "", array $data = array())
+ {
+ $setting_btn = !empty(apply_filters("cubewp/builder/right/settings", '', $slug, $data)) ? self::builder_form_settings_btn($data['form_type']) : '';
+ return '<div class="cubewp-builder-container-topbar">
' . $setting_btn . '
' . self::builder_add_Section() . '
- '.self::builder_hidden_fields($slug, $data['form_type']).'
+ ' . self::builder_hidden_fields($slug, $data['form_type']) . '
</div>';
- }
-
+ }
+
/**
* Method cubewp_builder_area
*
@@ -355,31 +397,32 @@
* @return string html
* @since 1.0.0
*/
- protected static function cubewp_builder_area(array $data) {
- $output = '';
+ protected static function cubewp_builder_area(array $data)
+ {
+ $output = '';
$options = self::$tab_options;
if (isset($options) && count($options) > 0) {
foreach ($options as $slug => $option) {
$output .= '<div id="type-' . esc_attr__($slug) . '" class="cubewp-type-container cubewp-switcher-tab-' . esc_attr__($slug) . ' cubewp-tab-switcher-target">';
- if ( ! $option["switcher"]) {
- $output .= self::cubewp_builder_area_content($slug, $data);
- }else {
- $switcher = $option["switcher"];
- if (!empty($switcher) && isset($switcher['options'])) {
- foreach ($switcher["options"] as $id => $val) {
- $data['content_switcher'] = $id;
- $data_type = self::cubewp_check_switcher_type($id);
- $output .= '<div id="plan-' . esc_attr__($id) . '" class="cubewp-plan-tab cubewp-switcher-tab-' . esc_attr__($id) . ' cubewp-tab-switcher-target" data-id="' . esc_attr__($id) . '" '.$data_type.'>';
- $output .= self::cubewp_builder_area_content($slug, $data);
- $output .= '</div>';
- }
+ if (! $option["switcher"]) {
+ $output .= self::cubewp_builder_area_content($slug, $data);
+ } else {
+ $switcher = $option["switcher"];
+ if (!empty($switcher) && isset($switcher['options'])) {
+ foreach ($switcher["options"] as $id => $val) {
+ $data['content_switcher'] = $id;
+ $data_type = self::cubewp_check_switcher_type($id);
+ $output .= '<div id="plan-' . esc_attr__($id) . '" class="cubewp-plan-tab cubewp-switcher-tab-' . esc_attr__($id) . ' cubewp-tab-switcher-target" data-id="' . esc_attr__($id) . '" ' . $data_type . '>';
+ $output .= self::cubewp_builder_area_content($slug, $data);
+ $output .= '</div>';
}
- }
+ }
+ }
$output .= '</div>';
}
}
- return $output;
+ return $output;
}
/**
@@ -390,13 +433,14 @@
* @return string html
* @since 1.0.0
*/
- protected static function cubewp_check_switcher_type($id = '') {
- if( is_numeric($id) && !is_null(get_post($id)) && get_post_type( $id ) == 'price_plan'){
+ protected static function cubewp_check_switcher_type($id = '')
+ {
+ if (is_numeric($id) && !is_null(get_post($id)) && get_post_type($id) == 'price_plan') {
return 'data-type="price_plan"';
}
- return 'data-type="'. $id .'"';
+ return 'data-type="' . $id . '"';
}
-
+
/**
* Method cubewp_builder_area_content
*
@@ -406,12 +450,13 @@
* @return string html
* @since 1.0.0
*/
- protected static function cubewp_builder_area_content(string $slug, array $data) {
+ protected static function cubewp_builder_area_content(string $slug, array $data)
+ {
$output = '';
if ($data['form_type'] == 'single_layout') {
$output .= self::cubewp_builder_area_topbar($slug, $data) . '
<div class="cubewp-builder-area">
- ' . self::builder_settings($slug,$data) . '
+ ' . self::builder_settings($slug, $data) . '
<div class="cubewp-single-layout-builder-container single-layout-builder">
<div class="cubewp-single-layout-builder-content">
<div class="cubewp-builder-sections">
@@ -426,22 +471,22 @@
</div>
</div>
</div>
- ' . self::cubewp_builder_no_section( false, $slug, $data ) . '
+ ' . self::cubewp_builder_no_section(false, $slug, $data) . '
</div>';
- }else {
+ } else {
$output .= self::cubewp_builder_area_topbar($slug, $data) . '
<div class="cubewp-builder-area">
- ' . self::builder_settings($slug,$data) . '
+ ' . self::builder_settings($slug, $data) . '
<div class="cubewp-builder-sections">
' . apply_filters("cubewp/builder/default/right/section", '', $slug, $data) . '
</div>
- ' . self::cubewp_builder_no_section( false, $slug, $data ) . '
+ ' . self::cubewp_builder_no_section(false, $slug, $data) . '
</div>';
}
- return $output;
- }
-
+ return $output;
+ }
+
/**
* Method builder_hidden_fields
*
@@ -451,7 +496,8 @@
* @return string html
* @since 1.0.0
*/
- protected static function builder_hidden_fields($key, $FormType) {
+ protected static function builder_hidden_fields($key, $FormType)
+ {
$output = '';
$hidden_fields = array(
array(
@@ -471,7 +517,7 @@
return $output;
}
-
+
/**
* Method builder_single_layout
*
@@ -480,43 +526,45 @@
* @return string html
* @since 1.0.0
*/
- protected static function builder_single_layout(array $data) {
+ protected static function builder_single_layout(array $data)
+ {
$output = '';
- $options = self::$tab_options;
+ $options = self::$tab_options;
if (isset($options) && count($options) > 0) {
foreach ($options as $slug => $option) {
$output .= '<div id="type-' . esc_attr__($slug) . '" class="cubewp-type-container cubewp-switcher-tab-' . esc_attr__($slug) . ' cubewp-tab-switcher-target">';
$output .= self::cubewp_builder_area_content($slug, $data);
$output .= '</div>';
- }
- }else {
+ }
+ } else {
$output .= '<div id="type-temp" class="cubewp-type-container cubewp-switcher-tab-temp cubewp-tab-switcher-target active-tab">';
$output .= '<div class="cubewp-builder-area">';
$output .= self::cubewp_builder_no_section(true);
$output .= '</div>';
$output .= '</div>';
- }
+ }
- return $output;
+ return $output;
}
-
+
/**
* Method builder_add_Section
*
* @return string html
* @since 1.0.0
*/
- protected static function builder_add_Section() {
- if ( self::$FORM_TYPE != 'search_filters' && self::$FORM_TYPE != 'search_fields' ) {
- return '<button class="button cwpform-add-section">
+ protected static function builder_add_Section()
+ {
+ if (self::$FORM_TYPE != 'search_filters' && self::$FORM_TYPE != 'search_fields') {
+ return '<button class="button cwpform-add-section">
<span class="dashicons dashicons-plus"></span>
- ' . esc_html__( "Create Section", "cubewp-framework" ) . '
+ ' . esc_html__("Create Section", "cubewp-framework") . '
</button>';
}
return '';
}
-
+
/**
* Method builder_settings
*
@@ -526,19 +574,21 @@
* @return string html
* @since 1.0.0
*/
- protected static function builder_settings(string $slug, array $data) {
+ protected static function builder_settings(string $slug, array $data)
+ {
return '<div class="form-settings" style="display:none;">
- ' . apply_filters("cubewp/builder/right/settings", '', $slug,$data) . '
+ ' . apply_filters("cubewp/builder/right/settings", '', $slug, $data) . '
</div>';
}
-
+
/**
* Method builder_get_shortcode
*
* @return string html
* @since 1.0.0
*/
- public static function builder_get_shortcode() {
+ public static function builder_get_shortcode()
+ {
if (empty(self::$tab_options)) {
return '';
}
@@ -546,11 +596,11 @@
return '<div class="shoftcode-area">
<div class="cwpform-shortcode"></div>
<button class="button-primary cwpform-get-shortcode">
- '. $button_text .'
+ ' . $button_text . '
</button>
</div>';
- }
-
+ }
+
/**
* Method builder_form_settings_btn
*
@@ -559,7 +609,8 @@
* @return string html
* @since 1.0.0
*/
- protected static function builder_form_settings_btn($FormType) {
+ protected static function builder_form_settings_btn($FormType)
+ {
return '<button class="button form-settings-form">
<span class="dashicons dashicons-admin-generic"></span>
' . esc_html__("Form Settings", "cubewp-framework") . '
@@ -571,67 +622,67 @@
*
* @return string html
* @since 1.0.0
- */
- protected static function cubewp_builder_no_section( $no_cpt = FALSE, $post_type = '', $data = array() ) {
+ */
+ protected static function cubewp_builder_no_section($no_cpt = FALSE, $post_type = '', $data = array())
+ {
$FormType = self::$FORM_TYPE;
$output = '';
- if ( $FormType != 'search_filters' && $FormType != 'search_fields' ) {
- $output .= '<div class="cubewp-builder-no-section hidden">
- <img src="' . CWP_PLUGIN_URI . 'cube/assets/admin/images/no-section.png" alt="' . esc_html__( "No Section Image", "cubewp-framework" ) . '">';
- if ( ! $no_cpt ) {
- $output .= '<h3>' . esc_html__( "Let's build something awesome today!", "cubewp-framework" ) . '</h3>';
- $output .= '<div class="cubewp-builder-no-section-steps">';
- if ( $FormType == 'post_type' || $FormType == 'single_layout' ) {
- $output .= '<p><span>' . esc_html__( "1", "cubewp-framework" ) . '</span>' . esc_html__( "Select a Post Type", "cubewp-framework" ) . '</p>';
- } else {
- $output .= '<p><span>' . esc_html__( "1", "cubewp-framework" ) . '</span>' . esc_html__( "Select a User Role", "cubewp-framework" ) . '</p>';
- }
- $output .= '<p><span>' . esc_html__( "2", "cubewp-framework" ) . '</span>' . esc_html__( "Create a Section", "cubewp-framework" ) . '</p>
- <p><span>' . esc_html__( "3", "cubewp-framework" ) . '</span>' . esc_html__( "Drag a Form Field", "cubewp-framework" ) . '</p>
- <p><span>' . esc_html__( "4", "cubewp-framework" ) . '</span>' . esc_html__( "Hit Save Changes", "cubewp-framework" ) . '</p>
+ if ($FormType != 'search_filters' && $FormType != 'search_fields') {
+ $output .= '<div class="cubewp-builder-no-section hidden">
+ <img src="' . CWP_PLUGIN_URI . 'cube/assets/admin/images/no-section.png" alt="' . esc_html__("No Section Image", "cubewp-framework") . '">';
+ if (! $no_cpt) {
+ $output .= '<h3>' . esc_html__("Let's build something awesome today!", "cubewp-framework") . '</h3>';
+ $output .= '<div class="cubewp-builder-no-section-steps">';
+ if ($FormType == 'post_type' || $FormType == 'single_layout') {
+ $output .= '<p><span>' . esc_html__("1", "cubewp-framework") . '</span>' . esc_html__("Select a Post Type", "cubewp-framework") . '</p>';
+ } else {
+ $output .= '<p><span>' . esc_html__("1", "cubewp-framework") . '</span>' . esc_html__("Select a User Role", "cubewp-framework") . '</p>';
+ }
+ $output .= '<p><span>' . esc_html__("2", "cubewp-framework") . '</span>' . esc_html__("Create a Section", "cubewp-framework") . '</p>
+ <p><span>' . esc_html__("3", "cubewp-framework") . '</span>' . esc_html__("Drag a Form Field", "cubewp-framework") . '</p>
+ <p><span>' . esc_html__("4", "cubewp-framework") . '</span>' . esc_html__("Hit Save Changes", "cubewp-framework") . '</p>
</div>
<button class="button button-primary cubewp-trigger-add-section">
<span class="dashicons dashicons-plus"></span>
- ' . esc_html__( "Create Section", "cubewp-framework" ) . '
+ ' . esc_html__("Create Section", "cubewp-framework") . '
</button>';
-
- if ( ! empty( $data ) ) {
- $plans = apply_filters( "cubewp/builder/{$FormType}/switcher", array(), $post_type );
- if ( $FormType == 'post_type' && isset( $plans['options'] ) && !empty( $plans['options'] )) {
- $plans_options = '';
- $post_type_form = CWP()->get_form( 'post_type' );
- foreach ( $plans['options'] as $plan => $title ) {
- if ( $plan == $data['content_switcher'] || ! isset( $post_type_form[ $post_type ][ $plan ]['groups'] ) || empty( $post_type_form[ $post_type ][ $plan ]['groups'] ) ) {
- continue;
- }
- if ( is_numeric( $plan ) ) {
- $plan_title = get_the_title( $plan );
- }else {
- $plan_title = $title;
- }
- $plans_options .= '<option value="' . $plan . '">' . esc_html( $plan_title ) . '</option>';
- }
- if ( ! empty( $plans_options ) ) {
- $output .= '<div class="cubewp-builder-sections-importer">
- <label for="cubewp-builder-section-import-' . $data['content_switcher'] . '">' . esc_html__( "Or Copy Content From", "cubewp-framework" ) . '</label>
+
+ if (! empty($data)) {
+ $plans = apply_filters("cubewp/builder/{$FormType}/switcher", array(), $post_type);
+ if ($FormType == 'post_type' && isset($plans['options']) && !empty($plans['options'])) {
+ $plans_options = '';
+ $post_type_form = CWP()->get_form('post_type');
+ foreach ($plans['options'] as $plan => $title) {
+ if ($plan == $data['content_switcher'] || ! isset($post_type_form[$post_type][$plan]['groups']) || empty($post_type_form[$post_type][$plan]['groups'])) {
+ continue;
+ }
+ if (is_numeric($plan)) {
+ $plan_title = get_the_title($plan);
+ } else {
+ $plan_title = $title;
+ }
+ $plans_options .= '<option value="' . $plan . '">' . esc_html($plan_title) . '</option>';
+ }
+ if (! empty($plans_options)) {
+ $output .= '<div class="cubewp-builder-sections-importer">
+ <label for="cubewp-builder-section-import-' . $data['content_switcher'] . '">' . esc_html__("Or Copy Content From", "cubewp-framework") . '</label>
<select id="cubewp-builder-section-import-' . $data['content_switcher'] . '" class="cubewp-builder-section-import">';
- $output .= $plans_options;
- $output .= '</select>
+ $output .= $plans_options;
+ $output .= '</select>
<button class="button cwpform-import-sections">
<span class="dashicons dashicons-admin-page"></span>
- ' . esc_html__( "Copy", "cubewp-framework" ) . '
+ ' . esc_html__("Copy", "cubewp-framework") . '
</button>
</div>';
+ }
}
- }
- }
-
- } else {
- $output .= '<h3>' . esc_html__( "No Custom Post Type Found.", "cubewp-framework" ) . '</h3>';
- }
- $output .= '</div>';
+ }
+ } else {
+ $output .= '<h3>' . esc_html__("No Custom Post Type Found.", "cubewp-framework") . '</h3>';
+ }
+ $output .= '</div>';
}
-
+
return $output;
}
-}
No newline at end of file
+}
--- a/cubewp-framework/cube/classes/class-cubewp-load.php
+++ b/cubewp-framework/cube/classes/class-cubewp-load.php
@@ -22,7 +22,7 @@
*
* @var string
*/
- public static $CubeWp_version = '1.1.26';
+ public static $CubeWp_version = '1.1.27';
/**
* Wordpress required version.
--- a/cubewp-framework/cube/classes/page-builders/elementor-widgets/class-cubewp-elementor-archive-posts-widget.php
+++ b/cubewp-framework/cube/classes/page-builders/elementor-widgets/class-cubewp-elementor-archive-posts-widget.php
@@ -1,5 +1,5 @@
<?php
-defined( 'ABSPATH' ) || exit;
+defined('ABSPATH') || exit;
use ElementorControls_Manager;
use ElementorRepeater;
@@ -13,115 +13,211 @@
* @since 1.0.0
*/
- class CubeWp_Elementor_Archive_Posts_Widget extends Widget_Base {
+class CubeWp_Elementor_Archive_Posts_Widget extends Widget_Base
+{
private static $post_types = array();
- public function get_name() {
+ public function get_name()
+ {
return 'search_posts_widget';
}
- public function get_title() {
- return __( 'Archive Posts Display', 'cubewp-framework' );
+ public function get_title()
+ {
+ return __('Archive Posts Display', 'cubewp-framework');
}
- public function get_icon() {
+ public function get_icon()
+ {
return 'eicon-archive-posts';
}
- public function get_categories() {
- return [ 'cubewp' ];
+ public function get_categories()
+ {
+ return ['cubewp'];
}
- protected function _register_controls() {
+ protected function register_controls()
+ {
self::get_post_types();
-
+
$this->start_controls_section(
'section_map',
[
- 'label' => __( 'Search Posts Settings', 'cubewp-framework' ),
+ 'label' => __('Search Posts Settings', 'cubewp-framework'),
]
);
$this->add_post_type_controls();
-
+
$this->end_controls_section();
+
+ $this->add_promotional_card_controls();
}
- private static function get_post_types() {
- $post_types = get_post_types(['public' => true], 'objects');
+ private static function get_post_types()
+ {
+ $post_types = get_post_types(['public' => true], 'objects');
$options = [];
foreach ($post_types as $post_type) {
$options[$post_type->name] = $post_type->label;
}
- unset( $options['elementor_library'] );
- unset( $options['e-landing-page'] );
- unset( $options['attachment'] );
- unset( $options['page'] );
-
- self::$post_types = $options;
- }
-
- private static function get_post_type_name_by_slug($post_type_slug) {
- $post_type_object = get_post_type_object($post_type_slug);
- // Check if the post type object exists and return its label (name)
- if ($post_type_object) {
- return $post_type_object->label;
- }
- return null;
- }
-
- private function add_post_type_controls() {
- $post_types = self::$post_types;
- if ( is_array( $post_types ) && ! empty( $post_types ) ) {
- $this->add_control( 'posttype', array(
- 'type' => Controls_Manager::SELECT2,
- //'multiple' => true,
- 'label' => esc_html__( 'Select Post Types', 'cubewp-classifiad' ),
- 'options' => $post_types,
- 'default' => array( 'post' ),
- 'label_block' => true,
- ) );
- foreach ( $post_types as $slug => $post_type ) {
- $this->add_card_style_controls( $slug );
- }
- }
- }
-
- private function add_card_style_controls($post_type) {
- if(!empty(cubewp_post_card_styles($post_type))){
- $this->add_control( $post_type.'_card_style', array(
- 'type' => Controls_Manager::SELECT,
- 'label' => esc_html__( 'Card Style for '.self::get_post_type_name_by_slug($post_type), 'cubewp-framework' ),
- 'options' => cubewp_post_card_styles($post_type),
- 'default' => 'default_style',
- 'condition' => array(
- 'posttype' => $post_type
- )
- ) );
- }
- }
+ unset($options['elementor_library']);
+ unset($options['e-landing-page']);
+ unset($options['attachment']);
+ unset($options['page']);
+
+ self::$post_types = $options;
+ }
+
+ private static function get_post_type_name_by_slug($post_type_slug)
+ {
+ $post_type_object = get_post_type_object($post_type_slug);
+ // Check if the post type object exists and return its label (name)
+ if ($post_type_object) {
+ return $post_type_object->label;
+ }
+ return null;
+ }
+
+ private function add_post_type_controls()
+ {
+ $post_types = self::$post_types;
+ if (is_array($post_types) && ! empty($post_types)) {
+ $this->add_control('posttype', array(
+ 'type' => Controls_Manager::SELECT2,
+ //'multiple' => true,
+ 'label' => esc_html__('Select Post Types', 'cubewp-classifiad'),
+ 'options' => $post_types,
+ 'default' => array('post'),
+ 'label_block' => true,
+ ));
+ foreach ($post_types as $slug => $post_type) {
+ $this->add_card_style_controls($slug);
+ }
+ }
+ }
- protected function render() {
+ private function add_card_style_controls($post_type)
+ {
+ if (!empty(cubewp_post_card_styles($post_type))) {
+ $this->add_control($post_type . '_card_style', array(
+ 'type' => Controls_Manager::SELECT,
+ 'label' => esc_html__('Card Style for ' . self::get_post_type_name_by_slug($post_type), 'cubewp-framework'),
+ 'options' => cubewp_post_card_styles($post_type),
+ 'default' => 'default_style',
+ 'condition' => array(
+ 'posttype' => $post_type
+ )
+ ));
+ }
+ }
+
+ private function add_promotional_card_controls()
+ {
+ global $cubewpOptions;
+ $posts_per_page = isset($cubewpOptions['posts_per_page']) ? (int)$cubewpOptions['posts_per_page'] : 10;
+ $this->start_controls_section('cubewp_widget_additional_setting_section', array(
+ 'label' => esc_html__('Promotional Card Settings', 'cubewp-framework'),
+ 'tab' => Controls_Manager::TAB_CONTENT,
+ ));
+
+ $this->add_control('cubewp_promotional_card', array(
+ 'type' => Controls_Manager::SWITCHER,
+ 'label' => esc_html__('Show Promotional Cards', 'cubewp-framework'),
+ 'default' => 'no',
+ ));
+
+ // Create Repeater
+ $repeater_CARDS = new Repeater();
+
+ $repeater_CARDS->add_control('cubewp_promotional_card_option', array(
+ 'type' => Controls_Manager::SELECT,
+ 'label' => esc_html__('Promotional Cards', 'cubewp-framework'),
+ 'options' => cubewp_get_get_promotional_cards_list(),
+ ));
+
+ $repeater_CARDS->add_control('cubewp_promotional_card_position', array(
+ 'type' => Controls_Manager::NUMBER,
+ 'label' => esc_html__('Position', 'cubewp-framework'),
+ 'default' => 3,
+ 'placeholder' => esc_html__("3", "cubewp-framework"),
+ 'min' => 1,
+ 'max' => $posts_per_page,
+ ));
+
+ $repeater_CARDS->add_responsive_control('cubewp_promotional_card_width', array(
+ 'label' => esc_html__('Width', 'cubewp-framework'),
+ 'type' => Controls_Manager::SLIDER,
+ 'size_units' => ['px', '%'],
+ 'default' => [
+ 'unit' => '%',
+ 'size' => 100,
+ ],
+ 'range' => [
+ 'px' => [
+ 'min' => 50,
+ 'max' => 1000,
+ ],
+ '%' => [
+ 'min' => 10,
+ 'max' => 100,
+ ],
+ ],
+ 'description' => esc_html__('Set the width of the card.', 'cubewp-framework'),
+ ));
+
+ // Add Repeater Control
+ $this->add_control('cubewp_promotional_cards_list', array(
+ 'type' => Controls_Manager::REPEATER,
+ 'label' => esc_html__('Promotional Cards List', 'cubewp-framework'),
+ 'fields' => $repeater_CARDS->get_controls(),
+ 'default' => [],
+ 'title_field' => '{{{ cubewp_promotional_card_option }}}',
+ 'condition' => [
+ 'cubewp_promotional_card' => 'yes',
+ ],
+ ));
+
+ $this->end_controls_section();
+ }
+
+ protected function render()
+ {
$settings = $this->get_settings_for_display();
- $type = isset( $settings[ 'posttype' ] ) ? $settings[ 'posttype' ] : '';
- $card_style = isset( $settings[ $type . '_card_style' ] ) ? $settings[ $type . '_card_style' ] : '';
+ $type = isset($settings['posttype']) ? $settings['posttype'] : '';
+ $card_style = isset($settings[$type . '_card_style']) ? $settings[$type . '_card_style'] : '';
$page_num = '1';
- CubeWp_Enqueue::enqueue_script( 'cwp-search-filters' );
+ $promotional_card = $settings['cubewp_promotional_card'] === 'yes' ? true : false;
+ $promotional_card_list = $settings['cubewp_promotional_cards_list'];
- echo CubeWp_Frontend_Search_Filter::cwp_filter_results();
+ CubeWp_Enqueue::enqueue_script('cwp-search-filters');
+
+ echo CubeWp_Frontend_Search_Filter::cwp_filter_results();
echo '<form name="cwp-search-filters" class="cwp-search-filters" method="post">';
- echo CubeWp_Frontend_Search_Filter::filter_hidden_fields($type,$page_num,$card_style);
- echo CubeWp_Frontend_Search_Filter::get_hidden_field_if_tax();
+ echo CubeWp_Frontend_Search_Filter::filter_hidden_fields($type, $page_num, $card_style);
+ echo CubeWp_Frontend_Search_Filter::get_hidden_field_if_tax();
+ $count = 1;
+ if ($promotional_card && !empty($promotional_card_list) && is_array($promotional_card_list)) {
+ foreach ($promotional_card_list as $_promotional_card) {
+ echo '<input type="hidden" class="cubewp-promotional-card" name="cubewp_promotional_card_option-'.$count.'" value="' . esc_attr($_promotional_card['cubewp_promotional_card_option']) . '" />';
+ echo '<input type="hidden" class="cubewp-promotional-card" name="cubewp_promotional_card_position-'.$count.'" value="' . esc_attr($_promotional_card['cubewp_promotional_card_position']) . '" />';
+ echo '<input type="hidden" class="cubewp-promotional-card" name="cubewp_promotional_card_width-'.$count.'" value="' . esc_attr($_promotional_card['cubewp_promotional_card_width']['size']) .esc_attr($_promotional_card['cubewp_promotional_card_width']['unit']). '" />';
+ $count++;
+ }
+ }
echo '</form>';
//Only to load data while editing in elementor
- if ( cubewp_is_elementor_editing()){
- ?>
- <script>cwp_search_filters_ajax_content();</script>
+ if (cubewp_is_elementor_editing()) {
+?>
+ <script>
+ cwp_search_filters_ajax_content();
+ </script>
<?php
}
}
-}
No newline at end of file
+}
--- a/cubewp-framework/cube/classes/page-builders/elementor-widgets/class-cubewp-elementor-posts-widget.php
+++ b/cubewp-framework/cube/classes/page-builders/elementor-widgets/class-cubewp-elementor-posts-widget.php
@@ -142,6 +142,67 @@
'default' => 'grid'
));
+ $this->add_responsive_control(
+ 'posts_per_row',
+ [
+ 'label' => esc_html__('Posts Per Row', 'cubewp-framework'),
+ 'type' => ElementorControls_Manager::SELECT,
+ 'default' => 'auto',
+ 'condition' => [
+ 'layout' => 'grid',
+ ],
+ 'device_args' => [
+ ElementorControls_Stack::RESPONSIVE_DESKTOP => [
+ 'default' => 'auto',
+ 'options' => [
+ 'auto' => esc_html__('Auto', 'cubewp-framework'),
+ '1' => esc_html__('1 Column', 'cubewp-framework'),
+ '2' => esc_html__('2 Columns', 'cubewp-framework'),
+ '3' => esc_html__('3 Columns', 'cubewp-framework'),
+ '4' => esc_html__('4 Columns', 'cubewp-framework'),
+ '5' => esc_html__('5 Columns', 'cubewp-framework'),
+ '6' => esc_html__('6 Columns', 'cubewp-framework'),
+ ],
+ ],
+ ElementorControls_Stack::RESPONSIVE_TABLET => [
+ 'default' => 'auto',
+ 'options' => [
+ 'auto' => esc_html__('Auto', 'cubewp-framework'),
+ '1' => esc_html__('1 Column', 'cubewp-framework'),
+ '2' => esc_html__('2 Columns', 'cubewp-framework'),
+ '3' => esc_html__('3 Columns', 'cubewp-framework'),
+ '4' => esc_html__('4 Columns', 'cubewp-framework'),
+ '5' => esc_html__('5 Columns', 'cubewp-framework'),
+ '6' => esc_html__('6 Columns', 'cubewp-framework'),
+ ],
+ ],
+ ElementorControls_Stack::RESPONSIVE_MOBILE => [
+ 'default' => 'auto',
+ 'options' => [
+ 'auto' => esc_html__('Auto', 'cubewp-framework'),
+ '1' => esc_html__('1 Column', 'cubewp-framework'),
+ '2' => esc_html__('2 Columns', 'cubewp-framework'),
+ '3' => esc_html__('3 Columns', 'cubewp-framework'),
+ '4' => esc_html__('4 Columns', 'cubewp-framework'),
+ '5' => esc_html__('5 Columns', 'cubewp-framework'),
+ '6' => esc_html__('6 Columns', 'cubewp-framework'),
+ ],
+ ],
+ ],
+ 'frontend_available' => true,
+ ]
+ );
+
+ $this->add_responsive_control('processing_grids_per_row', array(
+ 'type' => Controls_Manager::NUMBER,
+ 'label' => esc_html__('Processing Grids Per Row', 'cubewp-framework'),
+ 'default' => '4',
+ 'condition' => array(
+ 'posts_per_row' => 'auto',
+ ),
+ ));
+
+
$this->add_control('enable_scroll_on_small_devices', array(
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__('Enable Scroll on Small Devices', 'cubewp-framework'),
@@ -186,7 +247,7 @@
$repeater->add_control('meta_key', array(
'type' => Controls_Manager::SELECT2,
'label' => esc_html__('Select Custom Field', 'cubewp-framework'),
- 'options' => get_fields_by_type(array('number', 'text', 'checkbox','dropdown')),
+ 'options' => get_fields_by_type(array('number', 'text', 'checkbox', 'dropdown')),
'label_block' => true,
));
@@ -238,6 +299,7 @@
));
$this->end_controls_section();
$this->add_slider_controls();
+ $this->add_promotional_card_controls();
}
private static function get_post_types()
@@ -435,98 +497,64 @@
$widget_id = $this->get_id();
if ($settings['enable_scroll_on_small_devices'] === 'yes') {
echo '<style>
- @media (max-width: 767px) {
- .elementor-element-' . $widget_id . ' .cwp-row {
- overflow: scroll;
- flex-wrap: nowrap;
- }
+ @media (max-width: 767px) {
+ .elementor-element-' . $widget_id . ' .cwp-row {
+ overflow: scroll;
+ flex-wrap: nowrap;
}
- </style>';
+ }
+ </style>';
}
- $prev_icon = '';
- $prev_icon_type = false;
- if (!empty($settings['prev_icon']['value'])) {
- if ('svg' === $settings['prev_icon']['library']) {
- $prev_icon_url = esc_url($settings['prev_icon']['value']['url']);
- $prev_icon_content = file_get_contents($prev_icon_url);
- $prev_icon = $prev_icon_content;
- } else {
- $prev_icon = esc_attr($settings['prev_icon']['value']);
- $prev_icon_type = true;
- }
- }
- $next_icon = '';
- $next_icon_type = false;
- if (!empty($settings['next_icon']['value'])) {
- if ('svg' === $settings['next_icon']['library']) {
- $next_icon_url = esc_url($settings['next_icon']['value']['url']);
- $next_icon_content = file_get_contents($next_icon_url);
- $next_icon = $next_icon_content;
- } else {
- $next_icon = esc_attr($settings['next_icon']['value']);
- $next_icon_type = true;
- }
- }
- $slides_to_show = $settings['slides_to_show'];
- $slides_to_scroll = $settings['slides_to_scroll'];
- $slides_to_show_tablet = $settings['slides_to_show_tablet'];
- $slides_to_show_tablet_portrait = $settings['slides_to_show_tablet_portrait'];
- $slides_to_show_mobile = $settings['slides_to_show_mobile'];
- $slides_to_scroll_tablet = $settings['slides_to_scroll_tablet'];
- $slides_to_scroll_tablet_portrait = $settings['slides_to_scroll_tablet_portrait'];
- $slides_to_scroll_mobile = $settings['slides_to_scroll_mobile'];
- $autoplay = $settings['autoplay'] === 'yes' ? true : false;
- $autoplay_speed = $settings['autoplay_speed'];
- $speed = $settings['speed'];
- $enable_wrap_dots_arrows = $settings['enable_wrap_dots_arrows'] === 'yes' ? true : false;
- $infinite = $settings['infinite'] === 'yes' ? true : false;
- $fade_effect = $settings['fade_effect'] === 'yes' ? true : false;
- $variable_width = $settings['variable_width'] === 'yes' ? true : false;
- $custom_arrows = $settings['custom_arrows'] === 'yes' ? true : false;
- $custom_dots = $settings['custom_dots'] === 'yes' ? true : false;
- $enable_progress_bar = $settings['enable_progress_bar'] === 'yes' ? true : false;
-
$args = array(
'post_type' => $settings['posttype'],
- 'taxonomy' => array(),
- 'orderby' => $settings['orderby'],
- 'order' => $settings['order'],
+ 'taxonomy' => array(),
+ 'orderby' => $settings['orderby'],
+ 'order' => $settings['order'],
'number_of_posts' => $settings['number_of_posts'],
- 'load_more' => $settings['load_more'],
- 'posts_per_page' => $settings['posts_per_page'],
- 'layout' => $settings['layout'],
- 'post__in' => array(),
- 'boosted_only' => 'no',
- 'paged' => '1',
+ 'load_more' => $settings['load_more'],
+ 'posts_per_page' => $settings['posts_per_page'],
+ 'processing_grids_per_row' => $settings['processing_grids_per_row'],
+ 'layout' => $settings['layout'],
+ 'posts_per_row' => isset($settings['posts_per_row']) ? $settings['posts_per_row'] : 'auto',
+ 'posts_per_row_tablet' => isset($settings['posts_per_row_tablet']) ? $settings['posts_per_row_tablet'] : 'auto',
+ 'posts_per_row_mobile' => isset($settings['posts_per_row_mobile']) ? $settings['posts_per_row_mobile'] : 'auto',
+ 'post__in' => array(),
+ 'boosted_only' => 'no',
+ 'paged' => '1',
'cwp_enable_slider' => $settings['cwp_enable_slider'] === 'yes' ? 'cubewp-post-slider' : '',
- 'prev_icon' => $prev_icon,
- 'next_icon' => $next_icon,
- 'next_icon_type' => $next_icon_type,
- 'prev_icon_type' => $prev_icon_type,
- 'slides_to_show' => $slides_to_show,
- 'slides_to_scroll' => $slides_to_scroll,
- 'slides_to_show_tablet' => $slides_to_show_tablet,
- 'slides_to_show_tablet_portrait' => $slides_to_show_tablet_portrait,
- 'slides_to_show_mobile' => $slides_to_show_mobile,
- 'slides_to_scroll_tablet' => $slides_to_scroll_tablet,
- 'slides_to_scroll_tablet_portrait' => $slides_to_scroll_tablet_portrait,
- 'slides_to_scroll_mobile' => $slides_to_scroll_mobile,
- 'autoplay' => $autoplay,
- 'autoplay_speed' => $autoplay_speed,
- 'speed' => $speed,
- 'infinite' => $infinite,
- 'fade_effect' => $fade_effect,
- 'variable_width' => $variable_width,
- 'custom_arrows' => $custom_arrows,
- 'custom_dots' => $custom_dots,
- 'enable_wrap_dots_arrows' => $enable_wrap_dots_arrows,
- 'enable_progress_bar' => $enable_progress_bar,
+ 'promotional_card' => $settings['cubewp_promotional_card'] === 'yes' ? true : false,
+ 'promotional_cards' => $settings['cubewp_promotional_cards_list'],
);
+ // Add slider parameters only if the slider is enabled
+ if ($settings['cwp_enable_slider'] === 'yes') {
+ $args = array_merge($args, array(
+ 'prev_icon' => $settings['prev_icon']['value'] ?? '',
+ 'next_icon' => $settings['next_icon']['value'] ?? '',
+ 'slides_to_show' => $settings['slides_to_show'],
+ 'slides_to_scroll' => $settings['slides_to_scroll'],
+ 'slides_to_show_tablet' => $settings['slides_to_show_tablet'],
+ 'slides_to_show_tablet_portrait' => $settings['slides_to_show_tablet_portrait'],
+ 'slides_to_show_mobile' => $settings['slides_to_show_mobile'],
+ 'slides_to_scroll_tablet' => $settings['slides_to_scroll_tablet'],
+ 'slides_to_scroll_tablet_portrait' => $settings['slides_to_scroll_tablet_portrait'],
+ 'slides_to_scroll_mobile' => $settings['slides_to_scroll_mobile'],
+ 'autoplay' => $settings['autoplay'] === 'yes' ? true : false,
+ 'autoplay_speed' => $settings['autoplay_speed'],
+ 'speed' => $settings['speed'],
+ 'infinite' => $settings['infinite'] === 'yes' ? true : false,
+ 'fade_effect' => $settings['fade_effect'] === 'yes' ? true : false,
+ 'variable_width' => $settings['variable_width'] === 'yes' ? true : false,
+ 'custom_arrows' => $settings['custom_arrows'] === 'yes' ? true : false,
+ 'custom_dots' => $settings['custom_dots'] === 'yes' ? true : false,
+ 'enable_wrap_dots_arrows' => $settings['enable_wrap_dots_arrows'] === 'yes' ? true : false,
+ 'enable_progress_bar' => $settings['enable_progress_bar'] === 'yes' ? true : false,
+ ));
+ }
+
if (is_array($settings['posttype']) && ($posts_by !== 'boosted' || $posts_by !== 'all')) {
foreach ($settings['posttype'] as $post_type) {
-
if ($posts_by == 'post_ids') {
$post_in = isset($settings[$post_type . '_post__in']) ? $settings[$post_type . '_post__in'] : '';
@@ -541,7 +569,6 @@
$args['post__in'] = isset($args['post__in']) ? array_merge($args['post__in'], $post_ids) : $post_ids;
}
} elseif ($posts_by == 'taxonomy') {
-
$terms = isset($settings['taxonomy-' . $post_type]) ? $settings['taxonomy-' . $post_type] : array();
if (!empty($terms)) {
foreach ($terms as $term) {
@@ -572,7 +599,6 @@
$args['meta_query'] = self::_meta_query($meta_query);
}
-
echo apply_filters('cubewp_shortcode_posts_output', '', $args);
}
@@ -1203,14 +1229,14 @@
);
$this->add_group_control(
- Group_Control_Box_Shadow::get_type(),
- [
- 'name' => 'slider_arrow_box_shadow',
- 'label' => __('Arrow Box Shadow', 'value-pack'),
- 'selector' => '{{WRAPPER}} .cubewp-post-slider .slick-arrow',
- 'separator' => 'before',
- ]
- );
+ Group_Control_Box_Shadow::get_type(),
+ [
+ 'name' => 'slider_arrow_box_shadow',
+ 'label' => __('Arrow Box Shadow', 'value-pack'),
+ 'selector' => '{{WRAPPER}} .cubewp-post-slider .slick-arrow',
+ 'separator' => 'before',
+ ]
+ );
$this->add_control(
'icon_position_divider_heading',
@@ -2287,4 +2313,70 @@
$this->end_controls_section();
}
+
+ private function add_promotional_card_controls()
+ {
+ $this->start_controls_section('cubewp_widget_additional_setting_section', array(
+ 'label' => esc_html__('Promotional Card Settings', 'cubewp-framework'),
+ 'tab' => Controls_Manager::TAB_CONTENT,
+ ));
+
+ $this->add_control('cubewp_promotional_card', array(
+ 'type' => Controls_Manager::SWITCHER,
+ 'label' => esc_html__('Show Promotional Cards', 'cubewp-framework'),
+ 'default' => 'no',
+ ));
+
+ // Create Repeater
+ $repeater_CARDS = new Repeater();
+
+ $repeater_CARDS->add_control('cubewp_promotional_card_option', array(
+ 'type' => Controls_Manager::SELECT,
+ 'label' => esc_html__('Promotional Cards', 'cubewp-framework'),
+ 'options' => cubewp_get_get_promotional_cards_list(),
+ ));
+
+ $repeater_CARDS->add_control('cubewp_promotional_card_position', array(
+ 'type' => Controls_Manager::NUMBER,
+ 'label' => esc_html__('Position', 'cubewp-framework'),
+ 'default' => 3,
+ 'placeholder' => esc_html__("3", "cubewp-framework"),
+ 'min' => 1,
+ ));
+
+ $repeater_CARDS->add_responsive_control('cubewp_promotional_card_width', array(
+ 'label' => esc_html__('Width', 'cubewp-framework'),
+ 'type' => Controls_Manager::SLIDER,
+ 'size_units' => ['px', '%'],
+ 'default' => [
+ 'unit' => '%',
+ 'size' => 100,
+ ],
+ 'range' => [
+ 'px' => [
+ 'min' => 50,
+ 'max' => 1000,
+ ],
+ '%' => [
+ 'min' => 10,
+ 'max' => 100,
+ ],
+ ],
+ 'description' => esc_html__('Set the width of the card.', 'cubewp-framework'),
+ ));
+
+ // Add Repeater Control
+ $this->add_control('cubewp_promotional_cards_list', array(
+ 'type' => Controls_Manager::REPEATER,
+ 'label' => esc_html__('Promotional Cards List', 'cubewp-framework'),
+ 'fields' => $repeater_CARDS->get_controls(),
+ 'default' => [],
+ 'title_field' => '{{{ cubewp_promotional_card_option }}}',
+ 'condition' => [
+ 'cubewp_promotional_card' => 'yes',
+ ],
+ ));
+
+ $this->end_controls_section();
+ }
}
--- a/cubewp-framework/cube/classes/shortcodes/class-cubewp-shortcode-posts.php
+++ b/cubewp-framework/cube/classes/shortcodes/class-cubewp-shortcode-posts.php
@@ -15,46 +15,132 @@
add_filter('cubewp_shortcode_posts_output', array($this, 'cubewp_posts'), 10, 2);
new CubeWp_Ajax('', 'CubeWp_Shortcode_Posts', 'cubewp_posts_output');
new CubeWp_Ajax('wp_ajax_nopriv_', 'CubeWp_Shortcode_Posts', 'cubewp_posts_output');
+ add_action('wp_enqueue_scripts', [$this, 'cubewp_enqueue_slick_for_elementor'], 999);
+ add_action('elementor/editor/after_enqueue_scripts', [$this, 'cubewp_enqueue_slick_for_elementor']);
}
public static function cubewp_posts($output, array $parameters)
{
- return self::cubewp_posts_output($parameters);
+ $cwp_enable_slider = isset($parameters['cwp_enable_slider']) ? $parameters['cwp_enable_slider'] : '';
+ if ($cwp_enable_slider) {
+ CubeWp_Enqueue::enqueue_style('cubewp-slick');
+ CubeWp_Enqueue::enqueue_script('cubewp-slick');
+ }
+ if (cubewp_is_elementor_editing()) {
+ return self::cubewp_posts_output($parameters);
+ }
+
+ $slides_to_show = isset($parameters['slides_to_show']) ? intval($parameters['slides_to_show']) : 3;
+ $slides_to_show_tablet = isset($parameters['slides_to_show_tablet']) ? intval($parameters['slides_to_show_tablet']) : 2;
+ $slides_to_show_mobile = isset($parameters['slides_to_show_mobile']) ? intval($parameters['slides_to_show_mobile']) : 1;
+ $processing_grids_per_row = isset($parameters['processing_grids_per_row']) ? intval($parameters['processing_grids_per_row']) : 4;
+
+ $posts_per_row = isset($parameters['posts_per_row']) ? $parameters['posts_per_row'] : 'auto';
+ $posts_per_row_tablet = (isset($parameters['posts_per_row_tablet']) && $parameters['posts_per_row_tablet'] !== 'auto') ? $parameters['posts_per_row_tablet'] : 3;
+ $posts_per_row_mobile = (isset($parameters['posts_per_row_mobile']) && $parameters['posts_per_row_mobile'] !== 'auto') ? $parameters['posts_per_row_mobile'] : 2;
+
+ if($cwp_enable_slider){
+ $processing_grids_per_row = $slides_to_show;
+ $posts_per_row_tablet = $slides_to_show_tablet;
+ $posts_per_row_mobile = $slides_to_show_mobile;
+ }
+
+ $processing_grid_count = $processing_grids_per_row;
+
+ if ($posts_per_row !== 'auto' && !$cwp_enable_slider) {
+ $processing_grids_per_row = $posts_per_row;
+ $processing_grid_count = isset($parameters['number_of_posts']) ? $parameters['number_of_posts'] : 4;
+ }
+
+ $unique_id = uniqid('cubewp_posts_');
+
+ // Container start
+ $output .= '<div id="' . esc_attr($unique_id) . '" class="cubewp-ajax-posts-container" data-parameters="' . htmlspecialchars(json_encode($parameters), ENT_QUOTES, 'UTF-8') . '">
+ <div class="cubewp-processing-posts-container" style="display: flex; flex-wrap: wrap; gap: 10px;">';
+
+ for ($i = 0; $i < $processing_grid_count; $i++) {
+ $output .=
+ '<div class="cwp-processing-post-grid">'
+ . '<div class="cwp-processing-post-thumbnail"></div>'
+ . '<div class="cwp-processing-post-content"><p></p><p></p><p></p></div>'
+ . '</div>';
+ }
+
+ $output .= '</div></div>';
+
+ //Dynamic CSS per instance
+ $output .= '<style>
+ #' . esc_attr($unique_id) . ' .cwp-processing-post-grid {
+ flex-basis: calc(100% / ' . esc_attr($processing_grids_per_row) . ' - 10px);
+ max-width: calc(100% / ' . esc_attr($processing_grids_per_row) . ' - 10px);
+ }';
+
+ if ($posts_per_row_tablet !== 'auto') {
+ $output .= '
+ @media (max-width: 1024px) {
+ #' . esc_attr($unique_id) . ' .cwp-processing-post-grid {
+ flex-basis: calc(100% / ' . esc_attr($posts_per_row_tablet) . ' - 10px);
+ max-width: calc(100% / ' . esc_attr($posts_per_row_tablet) . ' - 10px);
+ }
+ }';
+ }
+
+ if ($posts_per_row_mobile !== 'auto') {
+ $output .= '
+ @media (max-width: 767px) {
+ #' . esc_attr($unique_id) . ' .cwp-processing-post-grid {
+ flex-basis: calc(100% / ' . esc_attr($posts_per_row_mobile) . ' - 10px);
+ max-width: calc(100% / ' . esc_attr($posts_per_row_mobile) . ' - 10px);
+ }
+ }';
+ }
+
+ $output .= '</style>';
+
+ // Ajax loader
+ $output .= '<script type="text/javascript">
+ jQuery(window).on("load", function () {
+ setTimeout(function () {
+ CubeWpShortcodePostsAjax.loadPosts("#' . esc_attr($unique_id) . '");
+ }, 500);
+ });
+ </script>';
+
+ return $output;
}
+
public static function cubewp_posts_output($parameters)
{
-
- // AJAX CALL
- if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] === 'cubewp_posts_output') {
- // Set $parameters to $_POST if it's an AJAX request for 'cubewp_posts_output'
+ if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] === 'cubewp_posts_output' && !cubewp_is_elementor_editing()) {
$parameters = $_POST;
}
$cwp_enable_slider = isset($parameters['cwp_enable_slider']) ? $parameters['cwp_enable_slider'] : '';
- $prev_icon = isset($parameters['prev_icon']) ? $parameters['prev_icon'] : 'fas fa-chevron-left';
- $next_icon = isset($parameters['next_icon']) ? $parameters['next_icon'] : 'fas fa-chevron-right';
- $slides_to_show = isset($parameters['slides_to_show']) ? intval($parameters['slides_to_show']) : 3;
- $slides_to_scroll = isset($parameters['slides_to_scroll']) ? intval($parameters['slides_to_scroll']) : 1;
- $slides_to_show_tablet = isset($parameters['slides_to_show_tablet']) ? intval($parameters['slides_to_show_tablet']) : 3;
- $slides_to_show_tablet_portrait = isset($parameters['slides_to_show_tablet_portrait']) ? intval($parameters['slides_to_show_tablet_portrait']) : 2;
- $slides_to_show_mobile = isset($parameters['slides_to_show_mobile']) ? intval($parameters['slides_to_show_mobile']) : 1;
- $slides_to_scroll_tablet = isset($parameters['slides_to_scroll_tablet']) ? intval($parameters['slides_to_scroll_tablet']) : 1;
- $slides_to_scroll_tablet_portrait = isset($parameters['slides_to_scroll_tablet_portrait']) ? intval($parameters['slides_t