Changeset 3161075
- Timestamp:
- 10/01/2024 06:43:00 PM (18 months ago)
- Location:
- guidant
- Files:
-
- 135 added
- 1 deleted
- 10 edited
-
tags/1.2.1 (added)
-
tags/1.2.1/appsero (added)
-
tags/1.2.1/appsero/.php-cs-fixer.dist.php (added)
-
tags/1.2.1/appsero/readme.md (added)
-
tags/1.2.1/appsero/src (added)
-
tags/1.2.1/appsero/src/Client.php (added)
-
tags/1.2.1/appsero/src/Insights.php (added)
-
tags/1.2.1/appsero/src/License.php (added)
-
tags/1.2.1/appsero/src/Updater.php (added)
-
tags/1.2.1/assets (added)
-
tags/1.2.1/assets/css (added)
-
tags/1.2.1/assets/css/admin-global.css (added)
-
tags/1.2.1/assets/css/admin.css (added)
-
tags/1.2.1/assets/css/css-tooltip.css (added)
-
tags/1.2.1/assets/css/frontend.css (added)
-
tags/1.2.1/assets/css/rSlider.css (added)
-
tags/1.2.1/assets/css/select2.min.css (added)
-
tags/1.2.1/assets/img (added)
-
tags/1.2.1/assets/img/edit.svg (added)
-
tags/1.2.1/assets/img/empty_img.png (added)
-
tags/1.2.1/assets/img/guidant-back-icon.svg (added)
-
tags/1.2.1/assets/img/guidant-by-pro-banner-halloween.jpg (added)
-
tags/1.2.1/assets/img/guidant-by-pro-banner.jpg (added)
-
tags/1.2.1/assets/img/guidant-icon.svg (added)
-
tags/1.2.1/assets/img/guidant-logo.svg (added)
-
tags/1.2.1/assets/img/haloween-guidant-mobile.jpg (added)
-
tags/1.2.1/assets/img/haloween-guidant.jpg (added)
-
tags/1.2.1/assets/img/info.svg (added)
-
tags/1.2.1/assets/img/settings.svg (added)
-
tags/1.2.1/assets/img/trash.svg (added)
-
tags/1.2.1/assets/js (added)
-
tags/1.2.1/assets/js/admin_cards.js (added)
-
tags/1.2.1/assets/js/admin_conditions.js (added)
-
tags/1.2.1/assets/js/admin_custom_fields.js (added)
-
tags/1.2.1/assets/js/admin_elements.js (added)
-
tags/1.2.1/assets/js/admin_filters.js (added)
-
tags/1.2.1/assets/js/admin_forms.js (added)
-
tags/1.2.1/assets/js/admin_guide_update.js (added)
-
tags/1.2.1/assets/js/admin_guides.js (added)
-
tags/1.2.1/assets/js/admin_main.js (added)
-
tags/1.2.1/assets/js/admin_reports.js (added)
-
tags/1.2.1/assets/js/admin_sliders.js (added)
-
tags/1.2.1/assets/js/frontend.js (added)
-
tags/1.2.1/assets/js/rSlider.js (added)
-
tags/1.2.1/assets/js/select2.min.js (added)
-
tags/1.2.1/backend (added)
-
tags/1.2.1/backend/api (added)
-
tags/1.2.1/backend/api/attributes_suggestion.php (added)
-
tags/1.2.1/backend/api/attributes_value_suggestion.php (added)
-
tags/1.2.1/backend/api/card_tab_page_get.php (added)
-
tags/1.2.1/backend/api/card_tab_page_save.php (added)
-
tags/1.2.1/backend/api/conditions_create.php (added)
-
tags/1.2.1/backend/api/conditions_delete.php (added)
-
tags/1.2.1/backend/api/conditions_list.php (added)
-
tags/1.2.1/backend/api/elements_create.php (added)
-
tags/1.2.1/backend/api/elements_delete.php (added)
-
tags/1.2.1/backend/api/elements_list.php (added)
-
tags/1.2.1/backend/api/elements_sort.php (added)
-
tags/1.2.1/backend/api/fields_create.php (added)
-
tags/1.2.1/backend/api/fields_delete.php (added)
-
tags/1.2.1/backend/api/fields_list.php (added)
-
tags/1.2.1/backend/api/filters_create.php (added)
-
tags/1.2.1/backend/api/filters_delete.php (added)
-
tags/1.2.1/backend/api/filters_list.php (added)
-
tags/1.2.1/backend/api/filters_sort.php (added)
-
tags/1.2.1/backend/api/form_tab_page_get.php (added)
-
tags/1.2.1/backend/api/form_tab_page_save.php (added)
-
tags/1.2.1/backend/api/guidant_fetch_filter_id.php (added)
-
tags/1.2.1/backend/api/guide_tab_page_get.php (added)
-
tags/1.2.1/backend/api/guides_create.php (added)
-
tags/1.2.1/backend/api/guides_delete.php (added)
-
tags/1.2.1/backend/api/guides_list.php (added)
-
tags/1.2.1/backend/api/logic_create.php (added)
-
tags/1.2.1/backend/api/logic_delete.php (added)
-
tags/1.2.1/backend/api/logic_elements_suggestions.php (added)
-
tags/1.2.1/backend/api/logic_filter_suggestions.php (added)
-
tags/1.2.1/backend/api/logic_list.php (added)
-
tags/1.2.1/backend/api/reports_list.php (added)
-
tags/1.2.1/backend/api/result_attributes_suggestion.php (added)
-
tags/1.2.1/backend/api/results_create.php (added)
-
tags/1.2.1/backend/api/results_delete.php (added)
-
tags/1.2.1/backend/api/results_list.php (added)
-
tags/1.2.1/backend/api/results_sort.php (added)
-
tags/1.2.1/backend/api/slider_tab_page_get.php (added)
-
tags/1.2.1/backend/api/slider_tab_page_save.php (added)
-
tags/1.2.1/backend/api/submission_delete.php (added)
-
tags/1.2.1/backend/class-guidant-admin.php (added)
-
tags/1.2.1/backend/class-guidant-ajax.php (added)
-
tags/1.2.1/backend/class-guidant-meta.php (added)
-
tags/1.2.1/backend/templates (added)
-
tags/1.2.1/backend/templates/dashboard.php (added)
-
tags/1.2.1/backend/templates/modals (added)
-
tags/1.2.1/backend/templates/modals/create_condition.php (added)
-
tags/1.2.1/backend/templates/modals/create_field.php (added)
-
tags/1.2.1/backend/templates/modals/create_logic.php (added)
-
tags/1.2.1/backend/templates/modals/create_result.php (added)
-
tags/1.2.1/backend/templates/modals/popup_pro.php (added)
-
tags/1.2.1/backend/templates/modals/popup_pro_x.php (added)
-
tags/1.2.1/backend/templates/modals/single_submission.php (added)
-
tags/1.2.1/backend/templates/modals/update_condition.php (added)
-
tags/1.2.1/backend/templates/modals/update_field.php (added)
-
tags/1.2.1/backend/templates/modals/update_logic.php (added)
-
tags/1.2.1/backend/templates/modals/update_result.php (added)
-
tags/1.2.1/backend/templates/views (added)
-
tags/1.2.1/backend/templates/views/card.php (added)
-
tags/1.2.1/backend/templates/views/custom_fields.php (added)
-
tags/1.2.1/backend/templates/views/element.php (added)
-
tags/1.2.1/backend/templates/views/filter.php (added)
-
tags/1.2.1/backend/templates/views/form.php (added)
-
tags/1.2.1/backend/templates/views/guide.php (added)
-
tags/1.2.1/backend/templates/views/guide_update.php (added)
-
tags/1.2.1/backend/templates/views/header.php (added)
-
tags/1.2.1/backend/templates/views/reports.php (added)
-
tags/1.2.1/backend/templates/views/slider.php (added)
-
tags/1.2.1/backend/useful-plugins.php (added)
-
tags/1.2.1/frontend (added)
-
tags/1.2.1/frontend/api (added)
-
tags/1.2.1/frontend/api/guidant_guide_submission.php (added)
-
tags/1.2.1/frontend/class-guidant-ajax.php (added)
-
tags/1.2.1/frontend/class-guidant-frontend.php (added)
-
tags/1.2.1/frontend/class-guidant-shortcode.php (added)
-
tags/1.2.1/frontend/templates (added)
-
tags/1.2.1/frontend/templates/dashboard.php (added)
-
tags/1.2.1/frontend/templates/views (added)
-
tags/1.2.1/frontend/templates/views/single_card.php (added)
-
tags/1.2.1/frontend/templates/views/single_filter.php (added)
-
tags/1.2.1/frontend/templates/views/single_form_element.php (added)
-
tags/1.2.1/frontend/templates/views/single_slider.php (added)
-
tags/1.2.1/guidant.php (added)
-
tags/1.2.1/includes (added)
-
tags/1.2.1/includes/GuidantRenderer.php (added)
-
tags/1.2.1/includes/GuidantSettings.php (added)
-
tags/1.2.1/includes/GuidantUtils.php (added)
-
tags/1.2.1/index.php (added)
-
tags/1.2.1/readme.txt (added)
-
trunk/assets/css/admin.css (modified) (1 diff)
-
trunk/assets/js/frontend.js (modified) (1 diff)
-
trunk/frontend/api/guidant_guide_submission.php (modified) (1 diff)
-
trunk/frontend/api/guidant_guide_submission_handler.php (deleted)
-
trunk/frontend/class-guidant-ajax.php (modified) (1 diff)
-
trunk/frontend/templates/views/single_card.php (modified) (4 diffs)
-
trunk/guidant.php (modified) (3 diffs)
-
trunk/includes/GuidantRenderer.php (modified) (7 diffs)
-
trunk/includes/GuidantSettings.php (modified) (1 diff)
-
trunk/includes/GuidantUtils.php (modified) (10 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
guidant/trunk/assets/css/admin.css
r3116503 r3161075 1498 1498 1499 1499 .guidant-main .guidant_form_group ul.select2-selection__rendered { 1500 text-wrap: wrap !important;1501 } 1500 text-wrap: wrap; 1501 } -
guidant/trunk/assets/js/frontend.js
r3132133 r3161075 171 171 172 172 jQuery(document).on("click", "[data-filter_to_show]", function () { 173 if (typeof jQuery(this).data("filter_to_show") !== "undefined" && jQuery(this).data("filter_to_show") != null) { 174 if (jQuery(this).data("filter_to_show") < 2) { 175 jQuery(this) 176 .closest(".guidantguide_filter") 177 .find(".guidantguide_btn_next") 178 .hide(); 179 jQuery(this) 180 .closest(".guidantguide_filter") 181 .find(".guidantguide_btn_submit") 182 .show(); 183 } else { 184 jQuery(this) 185 .closest(".guidantguide_filter") 186 .find(".guidantguide_btn_next") 187 .show(); 188 jQuery(this) 189 .closest(".guidantguide_filter") 190 .find(".guidantguide_btn_submit") 191 .hide(); 192 } 193 } 173 174 if (jQuery(this).data("filter_to_show") == 1) { 175 jQuery(this) 176 .closest(".guidantguide_filter") 177 .find(".guidantguide_btn_next") 178 .hide(); 179 jQuery(this) 180 .closest(".guidantguide_filter") 181 .find(".guidantguide_btn_submit") 182 .show(); 183 } else { 184 jQuery(this) 185 .closest(".guidantguide_filter") 186 .find(".guidantguide_btn_next") 187 .show(); 188 jQuery(this) 189 .closest(".guidantguide_filter") 190 .find(".guidantguide_btn_submit") 191 .hide(); 192 } 194 193 }); 195 194 -
guidant/trunk/frontend/api/guidant_guide_submission.php
r3128007 r3161075 1 1 <?php 2 2 3 if (!class_exists('GuidantSubmissionHandler')) { 4 require_once GUIDANT_PATH . 'frontend/api/guidant_guide_submission_handler.php'; 3 /* Receive post data */ 4 $resultant_post_id_element_wise = array(); 5 if(isset($_REQUEST['security']) && isset($_REQUEST['guide_id']) && isset($_REQUEST['submissions'])) { 6 7 check_ajax_referer( 'guidant_hashkey', 'security' ); 8 9 $guide_id = sanitize_text_field($_REQUEST['guide_id']); 10 $submissions = $_REQUEST['submissions']; 11 $submissions = urldecode($submissions); 12 $submissions = stripcslashes($submissions); 13 $submissions_obj = json_decode($submissions, TRUE); 14 15 16 17 $display_result = $this->settings->updateGuideSettings($guide_id, "display_result"); 18 $display_result = ($display_result == Null) ? "true" : $display_result; 19 20 $result_maximum = $this->settings->updateGuideSettings($guide_id, "result_maximum"); 21 $result_maximum = ($result_maximum == Null) ? "-1" : $result_maximum; 22 23 $submission_tracking = $this->settings->updateGuideSettings($guide_id, "submission_tracking"); 24 $submission_tracking = ($submission_tracking == Null) ? "enable" : $submission_tracking; 25 26 /* ========== Record Submission ========== */ 27 if($submission_tracking == "enable"){ 28 $submission_id = 0; 29 if(is_array($submissions_obj)){ 30 if(sizeof($submissions_obj)>0){ 31 $user = wp_get_current_user(); 32 $user_id = ( isset( $user->ID ) ? (int) $user->ID : 0 ); 33 $submission_id = $this->settings->recordNewSubmission($guide_id, $user_id, current_time( 'timestamp' )); 34 foreach ($submissions_obj as $filter_id=>$elements) { 35 foreach ($elements as $element) { 36 if($element['element_type'] == "card"){ 37 $this->settings->insertSubmissionData($submission_id, $element['element_id'], ($element['element_value'] != 0) ? "checked" : ""); 38 }else if($element['element_type'] == "slider"){ 39 $this->settings->insertSubmissionData($submission_id, $element['element_id'], $element['element_value']); 40 }else if($element['element_type'] == "form"){ 41 $this->settings->insertSubmissionData($submission_id, $element['element_id'], $element['element_value']); 42 } 43 } 44 } 45 } 46 } 47 } 48 49 /* ========== Record Submission ========== */ 50 51 52 53 54 55 56 57 foreach ($submissions_obj as $filter_id => $elements) { 58 $filter_wise_resultant_ids = array(); 59 foreach ($elements as $element) { 60 $element_wise_resultant_ids = array(); 61 62 if ($element['element_type'] == "card") { 63 if ($element['element_value'] != 0) { 64 $condition_wise_resultant_ids = array(); 65 $behavior = $this->settings->updateElementSettings($element['element_id'], "behavior"); 66 $behavior = ($behavior == Null) ? "or" : $behavior; 67 68 $conditions = $this->settings->listAllConditions($element['element_id']); 69 foreach ($conditions as $single_condition) { 70 $attribute_type = $this->settings->updateConditionSettings($single_condition['condition_id'], "attribute_type"); 71 $matching_type = $this->settings->updateConditionSettings($single_condition['condition_id'], "matching_type"); 72 $value = $this->settings->updateConditionSettings($single_condition['condition_id'], "value"); 73 74 // Decode the stored JSON value to get multiple values 75 $values = json_decode($value, true); 76 77 if (is_array($values)) { 78 foreach ($values as $single_value) { 79 if ($display_result == "true") { 80 $condition_wise_resultant_ids[] = $this->renderer->queryBuilder($attribute_type, $matching_type, $single_value); 81 } 82 } 83 } else { 84 if ($display_result == "true") { 85 $condition_wise_resultant_ids[] = $this->renderer->queryBuilder($attribute_type, $matching_type, $value); 86 } 87 } 88 } 89 90 if ($behavior == "and") { 91 $condition_wise_resultant_ids = array_filter($condition_wise_resultant_ids); // filter out empty array 92 $element_wise_resultant_ids = array_merge($element_wise_resultant_ids, array_intersect(...$condition_wise_resultant_ids)); 93 } else if ($behavior == "or") { 94 $element_wise_resultant_ids = array_merge($element_wise_resultant_ids, ...$condition_wise_resultant_ids); 95 } 96 } 97 } else if ($element['element_type'] == "slider") { 98 $condition_wise_resultant_ids = array(); 99 $behavior = $this->settings->updateElementSettings($element['element_id'], "behavior"); 100 $behavior = ($behavior == Null) ? "or" : $behavior; 101 102 $conditions = $this->settings->listAllConditions($element['element_id']); 103 foreach ($conditions as $single_condition) { 104 $attribute_type = $this->settings->updateConditionSettings($single_condition['condition_id'], "attribute_type"); 105 $matching_type = $this->settings->updateConditionSettings($single_condition['condition_id'], "matching_type"); 106 $value = $element['element_value']; 107 108 if ($display_result == "true") { 109 $condition_wise_resultant_ids[] = $this->renderer->queryBuilder($attribute_type, $matching_type, $value); 110 } 111 } 112 113 if ($behavior == "and") { 114 $condition_wise_resultant_ids = array_filter($condition_wise_resultant_ids); // filter out empty array 115 $element_wise_resultant_ids = array_merge($element_wise_resultant_ids, array_intersect(...$condition_wise_resultant_ids)); 116 } else if ($behavior == "or") { 117 $element_wise_resultant_ids = array_merge($element_wise_resultant_ids, ...$condition_wise_resultant_ids); 118 } 119 } else if ($element['element_type'] == "form") { 120 $this->settings->insertSubmissionData($submission_id, $element['element_id'], $element['element_value']); 121 } 122 123 $filter_wise_resultant_ids = array_merge($filter_wise_resultant_ids, $element_wise_resultant_ids); 124 } 125 126 if (sizeof($filter_wise_resultant_ids) > 0) { 127 $resultant_post_id_element_wise[] = $filter_wise_resultant_ids; 128 } 129 } 130 131 132 if($display_result == "true") { 133 134 if (sizeof($resultant_post_id_element_wise) > 1) { 135 $filtered_post_ids = array_intersect(...$resultant_post_id_element_wise); 136 } else { 137 $filtered_post_ids = $resultant_post_id_element_wise[0]; 138 } 139 140 $filtered_post_ids = array_values($filtered_post_ids); 141 142 143 144 145 /* Clear IDs not public/published post, pop the max ID into best result */ 146 $filtered_post_ids = $this->renderer->clearUnNecessaryIds($filtered_post_ids, $result_maximum); 147 sort($filtered_post_ids); 148 $best_result_id = array(); 149 $best_result_id[] = array_pop($filtered_post_ids); 150 /* Clear IDs not public/published post, pop the max ID into best result */ 151 152 153 154 $list_result_attributes = array(); 155 $list_results = $this->settings->listAllResults($guide_id); 156 foreach ($list_results as $single_result) { 157 $list_result_attributes[] = array( 158 "attribute_type" => $this->settings->updateResultSettings($single_result['result_id'], "attribute_type"), 159 "prefix" => $this->settings->updateResultSettings($single_result['result_id'], "prefix"), 160 "button_text" => $this->settings->updateResultSettings($single_result['result_id'], "button_text"), 161 "image_height" => $this->settings->updateResultSettings($single_result['result_id'], "image_height"), 162 ); 163 } 164 165 $result = array("status" => 'true', 166 "best_result" => $this->renderer->resultRender($best_result_id, $list_result_attributes), 167 "other_results" => $this->renderer->resultRender($filtered_post_ids, $list_result_attributes) 168 ); 169 }else{ 170 $result = array("status" => 'true'); 171 } 172 173 174 175 }else{ 176 $result = array("status" => 'false'); 5 177 } 6 178 7 $settings = new GuidantSettings();8 $utils = new GuidantUtils();9 $renderer = new GuidantRenderer();10 179 11 $processor = new GuidantSubmissionHandler($settings, $renderer, $utils); 12 $processor->processRequest(); 13 180 echo json_encode($result, JSON_UNESCAPED_UNICODE); -
guidant/trunk/frontend/class-guidant-ajax.php
r3128007 r3161075 28 28 } 29 29 30 31 30 32 } 31 33 } -
guidant/trunk/frontend/templates/views/single_card.php
r3132133 r3161075 1 1 <?php 2 2 3 3 4 $card_image = $this->settings->updateElementSettings($single_element['element_id'], "card_image"); 4 if (!empty($card_image)) { 5 $card_image = "<img src=\"" . esc_url($card_image) . "\" width=\"100px\" height=\"100px\">"; 5 if (isset($card_image)) { 6 if (strlen(trim($card_image)) > 0) { 7 $card_image = "<img src=\"" . $card_image . "\" width=\"100px\" height=\"100px\">"; 8 } 6 9 } 7 10 … … 10 13 $total_filter_number = count($this->settings->listAllFilters($guide_id)); 11 14 12 $filter_to_show = array();15 $filter_to_show = []; 13 16 foreach ($list_logics as $single_logic) { 14 17 $selected_element = $this->settings->updateLogicSettings($single_logic['logic_id'], "selected_element"); … … 16 19 17 20 if ($selected_element == $single_element['element_id']) { 21 // Decode the JSON array and merge it with $filter_to_hide 18 22 $selected_filter_to_hide_array = json_decode($selected_filter_to_hide, true); 23 24 $number_of_filter_to_hide = count($selected_filter_to_hide_array); 25 $filter_to_show[$single_element['element_id']] = $total_filter_number - $number_of_filter_to_hide; 26 19 27 if (is_array($selected_filter_to_hide_array)) { 20 $number_of_filter_to_hide = count($selected_filter_to_hide_array);21 $filter_to_show[$single_element['element_id']] = $total_filter_number - $number_of_filter_to_hide;22 28 $filter_to_hide = array_merge($filter_to_hide, $selected_filter_to_hide_array); 23 29 } … … 29 35 ?> 30 36 31 <div class="guidantguide_single_card guidantguide_element" 32 data-element_id="<?php echo esc_attr($element_id) ?>" 33 data-filter_to_hide="<?php echo esc_attr($filter_to_hide_arr_str) ?>" 34 <?php if(isset($filter_to_show[$element_id])) { ?> 35 data-filter_to_show="<?php echo esc_attr($filter_to_show[$element_id]) ?>"> 36 <?php } ?> 37 38 <div class="guidantguide_single_card guidantguide_element" data-element_id="<?php echo esc_attr($single_element['element_id']) ?>" data-filter_to_hide="<?php echo esc_attr($filter_to_hide_arr_str) ?>" data-filter_to_show="<?php echo esc_attr($filter_to_show[$element_id] ?? '') ?>"> 37 39 <?php echo isset($card_image) ? $card_image : ""; ?> 38 <h4><?php echo esc_html($this->settings->updateElementSettings($element_id, "card_label")) ?></h4> 39 <span 40 class="<?php echo esc_attr($this->settings->updateFilterSettings($single_filter['filter_id'], "card_type")) ?>"></span> 40 <h4><?php echo esc_attr($this->settings->updateElementSettings($single_element['element_id'], "card_label")) ?></h4> 41 <span class="<?php echo esc_attr($this->settings->updateFilterSettings($single_filter['filter_id'], "card_type")) ?>"></span> 41 42 </div> -
guidant/trunk/guidant.php
r3132133 r3161075 4 4 * Plugin URI: https://wpcommerz.com/guidant/ 5 5 * Description: Build Multi-step Guided Selling Process & Smart Forms to Convert 10X More Traffic Into Leads & New Customers. 6 * Version: 1.2. 06 * Version: 1.2.1 7 7 * Author: WPCommerz 8 8 * Author URI: https://wpcommerz.com/ … … 15 15 16 16 // If this file is called directly, abort. 17 if ( ! defined( 'WPINC' )) {17 if (!defined('WPINC')) { 18 18 die; 19 19 } 20 20 21 define( 'GUIDANT_VERSION', '1.2.0');22 defined( 'GUIDANT_PATH' ) or define( 'GUIDANT_PATH', plugin_dir_path( __FILE__ ));23 defined( 'GUIDANT_URL' ) or define( 'GUIDANT_URL', plugin_dir_url( __FILE__ ));24 defined( 'GUIDANT_BASE_PATH' ) or define( 'GUIDANT_BASE_PATH', plugin_basename(__FILE__));25 defined( 'GUIDANT_IMG_DIR' ) or define( 'GUIDANT_IMG_DIR', plugin_dir_url( __FILE__ ) . 'assets/img/');26 defined( 'GUIDANT_CSS_DIR' ) or define( 'GUIDANT_CSS_DIR', plugin_dir_url( __FILE__ ) . 'assets/css/');27 defined( 'GUIDANT_JS_DIR' ) or define( 'GUIDANT_JS_DIR', plugin_dir_url( __FILE__ ) . 'assets/js/');21 define('GUIDANT_VERSION', '1.2.1'); 22 defined('GUIDANT_PATH') or define('GUIDANT_PATH', plugin_dir_path(__FILE__)); 23 defined('GUIDANT_URL') or define('GUIDANT_URL', plugin_dir_url(__FILE__)); 24 defined('GUIDANT_BASE_PATH') or define('GUIDANT_BASE_PATH', plugin_basename(__FILE__)); 25 defined('GUIDANT_IMG_DIR') or define('GUIDANT_IMG_DIR', plugin_dir_url(__FILE__) . 'assets/img/'); 26 defined('GUIDANT_CSS_DIR') or define('GUIDANT_CSS_DIR', plugin_dir_url(__FILE__) . 'assets/css/'); 27 defined('GUIDANT_JS_DIR') or define('GUIDANT_JS_DIR', plugin_dir_url(__FILE__) . 'assets/js/'); 28 28 29 29 /** … … 32 32 * @return void 33 33 */ 34 function appsero_init_tracker_guidant() { 34 function appsero_init_tracker_guidant() 35 { 35 36 36 if ( ! class_exists( 'Appsero\Client' )) {37 if (!class_exists('Appsero\Client')) { 37 38 require_once __DIR__ . '/appsero/src/Client.php'; 38 39 } 39 40 40 $client = new Appsero\Client( '5862c38b-086b-417e-b2bd-6aeed31716a1', 'WP Guidant', __FILE__);41 $client = new Appsero\Client('5862c38b-086b-417e-b2bd-6aeed31716a1', 'WP Guidant', __FILE__); 41 42 42 43 // Active insights -
guidant/trunk/includes/GuidantRenderer.php
r3128007 r3161075 63 63 $sql .= "INNER JOIN {$wpdb->terms} AS t ON (tt.term_id = t.term_id) "; 64 64 break; 65 case "post_author":66 $sql .= "INNER JOIN {$wpdb->users} AS u ON (p.post_author = u.ID) ";67 break;68 65 } 69 66 … … 73 70 case "post_category": 74 71 $sql .= "AND tt.taxonomy = 'category' "; 75 $sql .= "AND t. term_id{$matching_type_and_value} ";72 $sql .= "AND t.name {$matching_type_and_value} "; 76 73 break; 77 74 case "post_tags": … … 80 77 break; 81 78 case "post_title": 82 $sql .= "AND p. ID{$matching_type_and_value} ";79 $sql .= "AND p.post_title {$matching_type_and_value} "; 83 80 break; 84 81 case "post_type": … … 92 89 break; 93 90 case "post_author": 94 $sql .= "AND u.ID {$matching_type_and_value} "; 91 $sql .= "INNER JOIN {$wpdb->users} AS u ON (p.post_author = u.ID) "; 92 $sql .= "AND u.display_name {$matching_type_and_value} "; 95 93 break; 96 94 case "woocommerce_category": 97 95 if (class_exists('WooCommerce')) { 98 96 $sql .= "AND tt.taxonomy = 'product_cat' "; 99 $sql .= "AND t. term_id{$matching_type_and_value} ";97 $sql .= "AND t.name {$matching_type_and_value} "; 100 98 } 101 99 break; … … 109 107 if (class_exists('WooCommerce')) { 110 108 $sql .= "AND p.post_type = 'product' "; 111 $sql .= "AND p. ID{$matching_type_and_value} ";109 $sql .= "AND p.post_title {$matching_type_and_value} "; 112 110 } 113 111 break; … … 157 155 $sql .= "GROUP BY p.ID "; 158 156 157 // Prepare values for wpdb::prepare 159 158 if ($matching_type === 'between' || $matching_type === 'not_between') { 160 159 $valueParts = explode(",", $value); … … 168 167 } 169 168 170 171 172 169 public function clearUnnecessaryIds($post_id_arr, $limit = -1) 173 170 { 174 171 global $wpdb; 175 176 // Check if the post_id_arr is empty 177 if (empty($post_id_arr)) { 178 return []; 179 } 180 181 // Safely escape the post IDs for inclusion in the query 182 $post_id_str = implode("','", array_map('esc_sql', $post_id_arr)); 183 $limit_sql = $limit != -1 ? $wpdb->prepare("LIMIT %d", $limit) : ""; 184 185 // Construct the query 172 $post_id_str = implode("','", $post_id_arr); 173 $limit_sql = $limit != -1 ? $wpdb->prepare(" LIMIT %d", $limit) : ""; 186 174 $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND ID IN ('{$post_id_str}') ORDER BY ID DESC {$limit_sql}"; 187 188 // Execute the query and get the results189 175 $listPosts = $wpdb->get_results($sql, ARRAY_A); 190 191 // Return the list of IDs192 176 return wp_list_pluck($listPosts, 'ID'); 193 177 } 194 178 195 196 179 public function resultRender($post_id_arr, $list_result_attributes) 197 180 { 181 global $wpdb; 182 $post_id_str = implode("','", $post_id_arr); 183 198 184 $output = ''; 199 185 200 foreach ($post_id_arr as $post_id) { 201 $post = get_post($post_id); 202 if (!$post) { 203 continue; 186 $sql = "SELECT * FROM {$wpdb->prefix}posts WHERE post_status = 'publish' 187 AND ID IN ('{$post_id_str}') ORDER BY ID DESC"; 188 $listPosts = $wpdb->get_results($sql); 189 if (!empty($listPosts)) { 190 foreach ($listPosts as $post) { 191 $output .= "<div class=\"single_post\">"; 192 193 foreach ($list_result_attributes as $single_result_attribute) { 194 $attribute_name = $single_result_attribute['attribute_type']; 195 $prefix = isset($single_result_attribute['prefix']) ? trim($single_result_attribute['prefix']) . " " : " "; 196 197 // Default values for optional attributes 198 $button_text = isset($single_result_attribute['button_text']) ? $single_result_attribute['button_text'] : 'View'; 199 $image_height = isset($single_result_attribute['image_height']) ? $single_result_attribute['image_height'] : '200'; 200 $add_to_cart_btn_default_text = isset($single_result_attribute['add_to_cart_btn_default_text']) ? $single_result_attribute['add_to_cart_btn_default_text'] : 'Add to Cart'; 201 $add_to_cart_btn_loading_text = isset($single_result_attribute['add_to_cart_btn_loading_text']) ? $single_result_attribute['add_to_cart_btn_loading_text'] : 'Adding...'; 202 $add_to_cart_btn_added_text = isset($single_result_attribute['add_to_cart_btn_added_text']) ? $single_result_attribute['add_to_cart_btn_added_text'] : 'Added to Cart'; 203 204 switch ($attribute_name) { 205 case 'post_category': 206 $post_categories = get_the_terms($post->ID, 'category'); 207 if ($post_categories && !is_wp_error($post_categories)) { 208 $post_categories_str = join(', ', wp_list_pluck($post_categories, 'name')); 209 $output .= "<div class=\"post_category\">{$prefix}{$post_categories_str}</div>"; 210 } 211 break; 212 case 'post_title': 213 $output .= "<div class=\"post_title\">{$prefix}{$post->post_title}</div>"; 214 break; 215 case 'post_date': 216 $output .= "<div class=\"post_date\">{$prefix}{$post->post_date}</div>"; 217 break; 218 case 'post_modified': 219 $output .= "<div class=\"post_modified\">{$prefix}{$post->post_modified}</div>"; 220 break; 221 case 'post_author': 222 $author_name = get_the_author_meta('display_name', $post->post_author); 223 $output .= "<div class=\"post_author\">{$prefix}" . esc_html($author_name) . "</div>"; 224 break; 225 case 'post_thumbnail': 226 if (has_post_thumbnail($post->ID)) { 227 $image_url = get_the_post_thumbnail_url($post->ID, 'post-thumbnail'); 228 $output .= "<div class=\"post_thumbnail\"><img style='height: {$image_height}px !important;' src=\"{$image_url}\"></div>"; 229 } 230 break; 231 case 'post_excerpt': 232 $excerpt = get_the_excerpt($post); 233 $output .= "<div class=\"post_excerpt\">{$prefix}" . esc_html($excerpt) . "</div>"; 234 break; 235 case 'post_permalink': 236 $permalink = get_permalink($post); 237 $output .= "<div class=\"post_permalink\"><a target='_blank' href=\"{$permalink}\">{$button_text}</a></div>"; 238 break; 239 case 'woocommerce_category': 240 if (class_exists('WooCommerce')) { 241 $terms = wp_get_post_terms($post->ID, 'product_cat'); 242 if (!empty($terms)) { 243 $category_names = wp_list_pluck($terms, 'name'); 244 $output .= "<div class=\"woocommerce_category\">{$prefix}" . implode(', ', $category_names) . "</div>"; 245 } 246 } 247 break; 248 case 'woocommerce_price': 249 if (class_exists('WooCommerce')) { 250 $price = get_post_meta($post->ID, '_price', true); 251 if (!empty($price)) { 252 $output .= "<div class=\"woocommerce_price\">{$prefix}" . wc_price($price) . "</div>"; 253 } 254 } 255 break; 256 case 'woocommerce_add_to_cart': 257 if (class_exists('WooCommerce')) { 258 $product = wc_get_product($post->ID); 259 if ($product && $product->is_type('simple')) { 260 $product_id = $product->get_id(); 261 $product_sku = $product->get_sku(); 262 $add_to_cart_url = $product->add_to_cart_url(); 263 $output .= "<div class=\"woocommerce_add_to_cart\" data-add_to_cart_btn_default_text=\"{$add_to_cart_btn_default_text}\" data-add_to_cart_btn_loading_text=\"{$add_to_cart_btn_loading_text}\" data-add_to_cart_btn_added_text=\"{$add_to_cart_btn_added_text}\"><a href=\"{$add_to_cart_url}\" data-product_id=\"{$product_id}\" data-product_sku=\"{$product_sku}\" class=\"ajax_add_to_cart add_to_cart_button\">{$add_to_cart_btn_default_text}</a></div>"; 264 } 265 } 266 break; 267 case 'custom_meta': 268 if (strpos($attribute_name, 'post_meta_') !== false) { 269 $meta_key = str_replace("post_meta_", "", $attribute_name); 270 $post_meta = get_post_meta($post->ID, $meta_key, true); 271 $output .= "<div class=\"custom_meta\">{$prefix}" . esc_html($post_meta) . "</div>"; 272 } 273 break; 274 default: 275 // Handle other attributes similarly 276 break; 277 } 278 } 279 280 $output .= "</div>"; 204 281 } 205 206 $output .= "<div class=\"single_post\">"; 207 208 foreach ($list_result_attributes as $single_result_attribute) { 209 $attribute_name = $single_result_attribute['attribute_type']; 210 $prefix = isset($single_result_attribute['prefix']) ? trim($single_result_attribute['prefix']) . " " : " "; 211 212 // Default values for optional attributes 213 $button_text = isset($single_result_attribute['button_text']) ? $single_result_attribute['button_text'] : 'View'; 214 $image_height = isset($single_result_attribute['image_height']) ? $single_result_attribute['image_height'] : '200'; 215 $add_to_cart_btn_default_text = isset($single_result_attribute['add_to_cart_btn_default_text']) ? $single_result_attribute['add_to_cart_btn_default_text'] : 'Add to Cart'; 216 $add_to_cart_btn_loading_text = isset($single_result_attribute['add_to_cart_btn_loading_text']) ? $single_result_attribute['add_to_cart_btn_loading_text'] : 'Adding...'; 217 $add_to_cart_btn_added_text = isset($single_result_attribute['add_to_cart_btn_added_text']) ? $single_result_attribute['add_to_cart_btn_added_text'] : 'Added to Cart'; 218 219 switch ($attribute_name) { 220 case 'post_category': 221 $post_categories = get_the_terms($post->ID, 'category'); 222 if ($post_categories && !is_wp_error($post_categories)) { 223 $post_categories_str = join(', ', wp_list_pluck($post_categories, 'name')); 224 $output .= "<div class=\"post_category\">{$prefix}{$post_categories_str}</div>"; 225 } 226 break; 227 case 'post_title': 228 $output .= "<div class=\"post_title\">{$prefix}{$post->post_title}</div>"; 229 break; 230 case 'post_date': 231 $output .= "<div class=\"post_date\">{$prefix}{$post->post_date}</div>"; 232 break; 233 case 'post_modified': 234 $output .= "<div class=\"post_modified\">{$prefix}{$post->post_modified}</div>"; 235 break; 236 case 'post_author': 237 $author_name = get_the_author_meta('display_name', $post->post_author); 238 $output .= "<div class=\"post_author\">{$prefix}" . esc_html($author_name) . "</div>"; 239 break; 240 case 'post_thumbnail': 241 if (has_post_thumbnail($post->ID)) { 242 $image_url = get_the_post_thumbnail_url($post->ID, 'post-thumbnail'); 243 $output .= "<div class=\"post_thumbnail\"><img style='height: {$image_height}px !important;' src=\"{$image_url}\"></div>"; 244 } 245 break; 246 case 'post_excerpt': 247 $excerpt = get_the_excerpt($post); 248 $output .= "<div class=\"post_excerpt\">{$prefix}" . esc_html($excerpt) . "</div>"; 249 break; 250 case 'post_permalink': 251 $permalink = get_permalink($post); 252 $output .= "<div class=\"post_permalink\"><a target='_blank' href=\"{$permalink}\">{$button_text}</a></div>"; 253 break; 254 case 'woocommerce_category': 255 if (class_exists('WooCommerce')) { 256 $terms = wp_get_post_terms($post->ID, 'product_cat'); 257 if (!empty($terms)) { 258 $category_names = wp_list_pluck($terms, 'name'); 259 $output .= "<div class=\"woocommerce_category\">{$prefix}" . implode(', ', $category_names) . "</div>"; 260 } 261 } 262 break; 263 case 'woocommerce_price': 264 if (class_exists('WooCommerce')) { 265 $price = get_post_meta($post->ID, '_price', true); 266 if (!empty($price)) { 267 $output .= "<div class=\"woocommerce_price\">{$prefix}" . wc_price($price) . "</div>"; 268 } 269 } 270 break; 271 case 'woocommerce_add_to_cart': 272 if (class_exists('WooCommerce')) { 273 $product = wc_get_product($post->ID); 274 if ($product && $product->is_type('simple')) { 275 $product_id = $product->get_id(); 276 $product_sku = $product->get_sku(); 277 $add_to_cart_url = $product->add_to_cart_url(); 278 $output .= "<div class=\"woocommerce_add_to_cart\" data-add_to_cart_btn_default_text=\"{$add_to_cart_btn_default_text}\" data-add_to_cart_btn_loading_text=\"{$add_to_cart_btn_loading_text}\" data-add_to_cart_btn_added_text=\"{$add_to_cart_btn_added_text}\"><a href=\"{$add_to_cart_url}\" data-product_id=\"{$product_id}\" data-product_sku=\"{$product_sku}\" class=\"ajax_add_to_cart add_to_cart_button\">{$add_to_cart_btn_default_text}</a></div>"; 279 } 280 } 281 break; 282 case 'custom_meta': 283 if (strpos($attribute_name, 'post_meta_') !== false) { 284 $meta_key = str_replace("post_meta_", "", $attribute_name); 285 $post_meta = get_post_meta($post->ID, $meta_key, true); 286 $output .= "<div class=\"custom_meta\">{$prefix}" . esc_html($post_meta) . "</div>"; 287 } 288 break; 289 default: 290 // Handle other attributes similarly 291 break; 292 } 293 } 294 295 $output .= "</div>"; 296 } 297 282 } 298 283 return $output; 299 284 } -
guidant/trunk/includes/GuidantSettings.php
r3117743 r3161075 387 387 $key = substr(str_shuffle(str_repeat($x = '123456789', ceil($length / strlen($x)))), 1, $length); 388 388 foreach ($dataSubmissions as $singleSubmission){ 389 if(isset($single Submission['submission_id'])){390 if($single Submission['submission_id'] == $key){389 if(isset($singleField['submission_id'])){ 390 if($singleField['submission_id'] == $key){ 391 391 $exits = true; 392 392 } -
guidant/trunk/includes/GuidantUtils.php
r3128007 r3161075 119 119 public function getGuidantCustomFields($list_fields, $search) 120 120 { 121 $ wpguidantCustomFields = array();121 $guidantCustomFields = array(); 122 122 foreach ($list_fields as $single_field) { 123 $ wpguidantCustomFields[] = array("id" => "post_meta_" . $single_field['field_id'], "text" => "[Custom Field] " . $single_field['field_label']);124 } 125 return $this->filterBySearch($ wpguidantCustomFields, $search);123 $guidantCustomFields[] = array("id" => "post_meta_" . $single_field['field_id'], "text" => "[Custom Field] " . $single_field['field_label']); 124 } 125 return $this->filterBySearch($guidantCustomFields, $search); 126 126 } 127 127 … … 184 184 $terms = get_terms('category', $args); 185 185 foreach ($terms as $term) { 186 $attributeValues[] = array("id" => $term-> term_id, "text" => $term->name);186 $attributeValues[] = array("id" => $term->name, "text" => $term->name); 187 187 } 188 188 break; … … 198 198 $posts = get_posts($args); 199 199 foreach ($posts as $post) { 200 $attributeValues[] = array("id" => $post-> ID, "text" => $post->post_title);200 $attributeValues[] = array("id" => $post->post_title, "text" => $post->post_title); 201 201 } 202 202 break; … … 265 265 $users = get_users(array('search' => $search)); 266 266 foreach ($users as $user) { 267 $attributeValues[] = array("id" => $user-> ID, "text" => $user->display_name);267 $attributeValues[] = array("id" => $user->display_name, "text" => $user->display_name); 268 268 } 269 269 break; … … 289 289 $terms = get_terms($args); 290 290 foreach ($terms as $term) { 291 $attributeValues[] = array("id" => $term-> term_id, "text" => $term->name);291 $attributeValues[] = array("id" => $term->name, "text" => $term->name); 292 292 } 293 293 } … … 313 313 $query = new WP_Query($args); 314 314 if ($query->posts) { 315 $unique_tags = array();316 315 foreach ($query->posts as $post_id) { 317 316 $tags = wp_get_post_terms($post_id, 'product_tag'); 318 317 foreach ($tags as $tag) { 319 if (!in_array($tag->name, $unique_tags)) { 320 $unique_tags[] = $tag->name; 321 $attributeValues[] = array("id" => $tag->name, "text" => $tag->name); 322 } 318 $attributeValues[] = array("id" => $tag->name, "text" => $tag->name); 323 319 } 324 320 } … … 340 336 $products = get_posts($args); 341 337 foreach ($products as $product) { 342 $attributeValues[] = array("id" => $product-> ID, "text" => $product->post_title);338 $attributeValues[] = array("id" => $product->post_title, "text" => $product->post_title); 343 339 } 344 340 } … … 519 515 foreach ($terms as $term) { 520 516 $attributeValues[] = array("id" => $term->slug, "text" => $term->name); 517 file_put_contents('log.txt', print_r($attributeValues, true), FILE_APPEND); 521 518 } 522 519 } … … 573 570 return $attributeValues; 574 571 } 572 573 574 575 575 576 576 577 public function getIPAddress() … … 586 587 return $ip; 587 588 } 588 589 590 591 589 } 592 590 } -
guidant/trunk/readme.txt
r3132133 r3161075 5 5 Requires PHP: 7.4 6 6 Requires at least: 6.5 7 Tested up to: 6.6. 18 Stable tag: 1.2. 07 Tested up to: 6.6.2 8 Stable tag: 1.2.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 345 345 == Changelog == 346 346 347 = 1.2.1 = 348 1. Improved: overall performance with faster result filtration. 349 2. Improved: functions for conditional logic to hide multiple filters for a single card. 350 3. Improved: functions for adding various conditions values for a single card attribute. 351 4. Fixed: minor bugs. 352 347 353 = 1.2.0 = 348 354 1. Fixed: minor bugs. 349 355 350 1.1.9 356 = 1.1.9 = 351 357 1.Fixed JavaScript bugs. 352 358 2.Fixed Issue with different language WooCommerce product not found.
Note: See TracChangeset
for help on using the changeset viewer.