Changeset 3097249
- Timestamp:
- 06/04/2024 09:37:59 AM (11 months ago)
- Location:
- unlimited-elements-for-elementor/trunk
- Files:
-
- 2 added
- 34 edited
-
assets_libraries/filters/ue_filters.js (modified) (1 diff)
-
assets_libraries/remote/ue-remote-controls.js (modified) (12 diffs)
-
inc_php/framework/include_framework.php (modified) (1 diff)
-
inc_php/framework/settings.class.php (modified) (3 diffs)
-
inc_php/layouts/unitecreator_layout.class.php (modified) (3 diffs)
-
inc_php/unitecreator_actions.class.php (modified) (1 diff)
-
inc_php/unitecreator_addon.class.php (modified) (1 diff)
-
inc_php/unitecreator_addons.class.php (modified) (2 diffs)
-
inc_php/unitecreator_categories.class.php (modified) (1 diff)
-
inc_php/unitecreator_filters_process.class.php (modified) (38 diffs)
-
inc_php/unitecreator_form.class.php (modified) (1 diff)
-
inc_php/unitecreator_globals.class.php (modified) (1 diff)
-
inc_php/unitecreator_helperhtml.class.php (modified) (1 diff)
-
inc_php/unitecreator_params_processor.class.php (modified) (3 diffs)
-
inc_php/unitecreator_web_api.class.php (modified) (1 diff)
-
js/admin.js (modified) (1 diff)
-
provider/assets/gutenberg_integrate.js (modified) (2 diffs)
-
provider/core/unlimited_elements/elementor/elementor_integrate.class.php (modified) (1 diff)
-
provider/core/unlimited_elements/elementor/elementor_widget.class.php (modified) (1 diff)
-
provider/core/unlimited_elements/globals.class.php (modified) (4 diffs)
-
provider/core/unlimited_elements/helper_provider_core.class.php (modified) (2 diffs)
-
provider/core/unlimited_elements/provider_core_admin.class.php (modified) (1 diff)
-
provider/core/unlimited_elements/settings/elementor.xml (added)
-
provider/core/unlimited_elements/settings/general_settings_el.xml (modified) (1 diff)
-
provider/core/unlimited_elements/settings/gutenberg.xml (added)
-
provider/functions_wordpress.class.php (modified) (2 diffs)
-
provider/gutenberg_integrate.class.php (modified) (8 diffs)
-
provider/include_provider_after.php (modified) (1 diff)
-
provider/provider_alt_loader.php (modified) (1 diff)
-
provider/provider_helper.class.php (modified) (4 diffs)
-
provider/provider_params_processor.class.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
release_log.txt (modified) (1 diff)
-
settings/layout_addon_container_settings.xml (modified) (1 diff)
-
unlimited_elements.php (modified) (1 diff)
-
views/layouts.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
unlimited-elements-for-elementor/trunk/assets_libraries/filters/ue_filters.js
r3094530 r3097249 3212 3212 3213 3213 var urlAddition = "ucfrontajaxaction=getfiltersdata&layoutid="+layoutID+"&elid="+widgetID; 3214 3214 3215 3215 urlAjax = addUrlParam(urlAjax, urlAddition); 3216 3216 -
unlimited-elements-for-elementor/trunk/assets_libraries/remote/ue-remote-controls.js
r3094530 r3097249 1809 1809 */ 1810 1810 this.setAction = function(action, objElement, allowMultiple){ 1811 1811 1812 1812 if(g_vars.trace_debug == true){ 1813 1813 trace("set action: "+action); … … 1834 1834 1835 1835 if(allowMultiple !== true) 1836 if(linkedAction) 1836 if(linkedAction){ 1837 1838 trace("not allow multiple action: "+action); 1839 1837 1840 return(false); 1841 } 1838 1842 1839 1843 objElement.data("uc-action", action); … … 1861 1865 1862 1866 var isEditorMode = isInsideEditor(); 1863 1867 1864 1868 //in editor mode check debug every second 1865 1869 … … 2356 2360 */ 2357 2361 function isInsideEditor(){ 2358 2362 2359 2363 if(g_vars.is_editor !== null) 2360 2364 return g_vars.is_editor; 2365 2366 //check for gutenberg 2367 2368 if(typeof g_ucAdmin !== "undefined"){ 2369 g_vars.is_editor = true; 2370 return(true); 2371 } 2372 2361 2373 2362 2374 if (window.parent === window.top) { … … 2373 2385 } 2374 2386 2375 // check for gutenberg2376 if (typeof window.parent.wp !== "undefined" && typeof window.parent.wp.blocks !== "undefined") {2377 g_vars.is_editor = true;2378 return true;2379 }2380 2381 2387 g_vars.is_editor = false; 2382 2388 … … 2400 2406 */ 2401 2407 function checkWidgetInsideEditor(){ 2402 2408 2403 2409 //check for disconnect 2404 2410 try{ … … 2455 2461 this.onWidgetInit = function(widgetID, func, options){ 2456 2462 2457 2458 2463 try{ 2459 2464 2465 if(g_vars.is_inited == true) 2466 return(false); 2467 2460 2468 if(g_vars.trace_debug == true){ 2461 2469 trace("on widget init"); … … 2479 2487 2480 2488 if(g_vars.is_inited == false){ 2481 2489 2482 2490 if(g_vars.trace_debug == true){ 2483 2491 trace(widgetID+" not inited yet, waiting for parent init"); … … 2509 2517 2510 2518 onWidgetReady(); 2511 2512 g_vars.funcOnInit(g_objWidget); 2513 2519 2520 if(g_vars.funcOnInit){ 2521 2522 g_vars.is_inited = true; 2523 g_vars.funcOnInit(g_objWidget); 2524 } 2525 2514 2526 }catch(message){ 2515 2527 … … 2538 2550 2539 2551 //if under template switcher - modify sync id 2540 2552 2541 2553 if(g_vars.trace_debug == true){ 2542 2554 trace("Start parent sync"); … … 2556 2568 2557 2569 var isEditorMode = isInsideEditor(); 2558 2570 2559 2571 objSync.setOptions(syncID, isEditorMode); 2560 2572 … … 2763 2775 2764 2776 jQuery(document).on("uc-remote-parent-init",function(event, objParent, optionsAPI){ 2765 2777 2766 2778 var objRemote = new UERemoteWidgets(); 2767 2779 objRemote.onParentInit(objParent, optionsAPI); 2768 2780 2769 2781 }); 2770 2782 -
unlimited-elements-for-elementor/trunk/inc_php/framework/include_framework.php
r3071404 r3097249 43 43 require_once $folderIncludes . 'table.class.php'; 44 44 require_once $folderIncludes . 'font_manager.class.php'; 45 require_once $folderIncludes . 'shapes.class.php';46 45 require_once $folderIncludes . 'services.class.php'; 47 46 -
unlimited-elements-for-elementor/trunk/inc_php/framework/settings.class.php
r3094530 r3097249 1324 1324 public function loadXMLFile($filepath, $loadedSettingsType = null){ 1325 1325 1326 1327 1326 $obj = UniteFunctionsUC::loadXMLFile($filepath); 1328 1327 1329 1328 if(empty($obj)) 1330 1329 UniteFunctionsUC::throwError("Wrong xml file format: $filepath"); … … 1364 1363 $sapParams["nodraw"] = UniteFunctionsUC::strToBool($nodraw); 1365 1364 } 1366 1367 UniteFunctionsUC::validateNotEmpty($sapName," sapName");1368 1365 1366 UniteFunctionsUC::validateNotEmpty($sapName,"name in fieldset attributes: $sapLabel"); 1367 1369 1368 if(!empty($loadFrom)){ 1370 1369 1371 1370 $this->addExternalSettings($loadFrom, $loadParam, $loadedSettingsType); 1372 1371 continue; … … 1687 1686 private function addExternalSettings($filename, $loadParam = null, $loadType = null){ 1688 1687 1689 $filepathSettings = GlobalsUC::$pathSettings."{$filename}.xml"; 1690 1688 $filepathSettings = GlobalsUnlimitedElements::$pathPluginSettings."{$filename}.xml"; 1689 1690 if(file_exists($filepathSettings) == false) 1691 $filepathSettings = GlobalsUC::$pathSettings."{$filename}.xml"; 1692 1691 1693 if(file_exists($filepathSettings) == false) 1692 1694 UniteFunctionsUC::throwError("The file: {$filename}.xml don't found in settings folder"); -
unlimited-elements-for-elementor/trunk/inc_php/layouts/unitecreator_layout.class.php
r3023498 r3097249 16 16 protected $addonType = null, $arrAllOptionsCache = null; 17 17 protected $extraParams = array(); //extra params for link generate etc 18 protected $ objShapes, $layoutType, $isTemplate = false, $objLayouts;18 protected $layoutType, $isTemplate = false, $objLayouts; 19 19 protected $objLayoutType; 20 20 … … 32 32 public function __construct(){ 33 33 34 $this->objShapes = new UniteShapeManagerUC();35 34 $this->objLayouts = new UniteCreatorLayouts(); 36 35 … … 1737 1736 */ 1738 1737 public function modifySettings_collectSpecialAddonNames($settings, $elementType){ 1739 1740 $nameTop = $this->objShapes->getShapeDividerNameFromSettings($settings, "top"); 1741 if(!empty($nameTop)) 1742 $this->arrAddonNames[$nameTop."_".GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER] = GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER; 1743 1744 $nameBottom = $this->objShapes->getShapeDividerNameFromSettings($settings, "bottom"); 1745 if(!empty($nameBottom)) 1746 $this->arrAddonNames[$nameBottom."_".GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER] = GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER; 1747 1738 1748 1739 1749 1740 $bgAddonName = $this->getBGAddonNameFromSettings($settings); -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_actions.class.php
r3076456 r3097249 584 584 585 585 break; 586 case "get_shapes_css":587 588 $objShapes = new UniteShapeManagerUC();589 $objShapes->outputCssShapes();590 exit;591 break;592 586 case "save_screenshot": 593 587 -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_addon.class.php
r3094530 r3097249 219 219 220 220 UniteFunctionsUC::validateNotEmpty($id, "widget id"); 221 221 222 UniteFunctionsUC::validateNumeric($id,"widget id"); 223 222 224 $id = (int)$id; 223 225 -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_addons.class.php
r3090199 r3097249 722 722 723 723 foreach($arrAddons as $key => $addonID){ 724 724 725 $addon = new UniteCreatorAddon(); 725 726 $addon->initByID($addonID); 726 727 727 728 $addons[] = $addon; 728 729 $arrAddons[$key] = $addon->getID(); … … 996 997 */ 997 998 public function deleteAddonFromData($data){ 998 999 999 1000 $addonID = UniteFunctionsUC::getVal($data, "addonID"); 1000 1001 UniteFunctionsUC::validateNotEmpty($addonID, "Widget ID"); 1001 1002 1003 UniteFunctionsUC::validateNumeric($addonID,"widget id"); 1004 1002 1005 $addon = new UniteCreatorAddon(); 1003 1006 $addon->initByID($addonID); 1004 1007 1008 $addonID = (int)$addonID; 1009 1005 1010 $this->db->delete(GlobalsUC::$table_addons, "id={$addonID}"); 1006 1011 1007 1012 $addon->triggerAfterDeleteAction(); 1008 1013 } -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_categories.class.php
r2541303 r3097249 853 853 private function remove($catID){ 854 854 855 $catID = UniteFunctionsUC::validateNumeric($catID,"category id"); 856 855 857 $catID = (int)$catID; 856 858 -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_filters_process.class.php
r3094530 r3097249 3 3 * @package Unlimited Elements 4 4 * @author unlimited-elements.com 5 * @copyright (C) 2021 Unlimited Elements, All Rights Reserved. 5 * @copyright (C) 2021 Unlimited Elements, All Rights Reserved. 6 6 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html 7 7 * */ … … 11 11 12 12 const DEBUG_MAIN_QUERY = false; 13 13 14 14 const DEBUG_FILTER = false; 15 15 16 16 const DEBUG_PARSED_TERMS = false; 17 17 18 18 private static $showDebug = false; 19 19 20 20 private static $filters = null; 21 21 private static $arrInputFiltersCache = null; 22 22 private static $arrFiltersAssocCache = null; 23 private static $currentTermCache = null; 23 private static $currentTermCache = null; 24 24 private static $isModeInit = false; 25 25 26 26 private static $isGutenberg = false; 27 27 private static $platform = false; 28 28 private static $objGutenberg = null; 29 29 30 30 private static $isScriptAdded = false; 31 31 private static $isFilesAdded = false; … … 34 34 private static $isModeReplace = false; 35 35 private static $numTotalPosts; 36 36 37 37 private static $originalQueryVars = null; 38 38 private $contentWidgetsDebug = array(); 39 private static $lastArgs = null; 39 private static $lastArgs = null; 40 40 private static $isUnderAjaxSearch = false; 41 41 public static $isUnderAjax = false; 42 42 private static $showEchoDebug = false; 43 43 44 44 private $hasSelectedByRequest = false; 45 45 private $hasSelectedTerm = false; 46 47 46 47 48 48 const TYPE_TABS = "tabs"; 49 49 const TYPE_SELECT = "select"; 50 50 const TYPE_CHECKBOX = "checkbox"; 51 51 52 52 const ROLE_CHILD = "child"; 53 53 const ROLE_TERM_CHILD = "term_child"; 54 54 55 55 private function _______SORT_FILTER_WIDGET_DATA__________(){} 56 56 57 57 /** 58 58 * get sort filter data … … 61 61 */ 62 62 public static function getSortFilterData($filterType, $params){ 63 63 64 64 //get fields 65 65 66 66 $arrFields = UniteFunctionsUC::getVal($params, "fields"); 67 67 68 68 $arrFields = UniteFunctionsUC::getVal($arrFields, "fields_fields"); 69 70 69 70 71 71 if(empty($arrFields)) 72 72 $arrFields = array( 73 73 array("title"=>"Default","type"=>"default"), 74 74 ); 75 75 76 76 $isForWooProducts = false; 77 77 if($filterType == "woo") 78 78 $isForWooProducts = true; 79 79 80 80 $arrWooTypes = array("sale_price","sales","rating"); 81 81 82 82 $output = array(); 83 83 84 84 $isEnableMeta = UniteFunctionsUC::getVal($params, "enable_meta"); 85 85 $isEnableMeta = UniteFunctionsUC::strToBool($isEnableMeta); 86 86 87 87 //find if the meta enabled - old way 88 88 89 89 if($isEnableMeta == true){ 90 90 $metaName = UniteFunctionsUC::getVal($params, "meta_name"); 91 91 92 92 $metaName = trim($metaName); 93 93 94 94 if(empty($metaName)) 95 95 $isEnableMeta = false; 96 96 } 97 97 98 98 foreach($arrFields as $field){ 99 99 100 100 $title = UniteFunctionsUC::getVal($field, "title"); 101 101 $type = UniteFunctionsUC::getVal($field, "type"); 102 102 103 103 //disable meta if not selected 104 104 105 105 $typeForOutput = null; 106 106 107 107 if($type == "meta"){ 108 108 109 109 $fieldMetaName = UniteFunctionsUC::getVal($field, "meta_name"); 110 110 $fieldMetaType = UniteFunctionsUC::getVal($field, "meta_type"); 111 111 112 112 if(empty($fieldMetaName) && $isEnableMeta == true){ 113 113 $fieldMetaName = $metaName; 114 114 } 115 115 116 116 if(empty($fieldMetaName)) 117 117 continue; 118 118 119 119 if(empty($fieldMetaType)) 120 120 continue; 121 121 122 122 $fieldMetaName = trim($fieldMetaName); 123 123 124 124 $typeForOutput = "meta__{$fieldMetaName}__{$fieldMetaType}"; 125 125 } 126 126 127 127 //filter woo types 128 128 if($isForWooProducts == false&& in_array($type, $arrWooTypes) == true) 129 129 continue; 130 130 131 131 if(!empty($typeForOutput)) 132 132 $type = $typeForOutput; 133 133 134 134 $output[$type] = $title; 135 135 } 136 137 136 137 138 138 return($output); 139 139 } 140 141 142 143 140 141 142 143 144 144 /** 145 145 * get fitler url from the given slugs 146 146 */ 147 147 private function getUrlFilter_term($term, $taxonomyName){ 148 148 149 149 $key = "filter-term"; 150 150 151 151 $taxPrefix = $taxonomyName."--"; 152 152 153 153 if($taxonomyName == "category"){ 154 154 $taxPrefix = ""; 155 155 $key="filter-category"; 156 156 } 157 157 158 158 $slug = $term->slug; 159 159 160 160 $value = $taxPrefix.$slug; 161 161 162 162 $urlAddition = "{$key}=".urlencode($value); 163 163 164 164 $urlCurrent = GlobalsUC::$current_page_url; 165 165 166 166 $url = UniteFunctionsUC::addUrlParams($urlCurrent, $urlAddition); 167 167 168 168 return($url); 169 169 } 170 170 171 171 /** 172 172 * check if the term is acrive 173 173 */ 174 174 private function isTermActive($term, $arrActiveFilters = null){ 175 175 176 176 if(empty($term)) 177 177 return(false); 178 178 179 179 if($arrActiveFilters === null) 180 180 $arrActiveFilters = $this->getRequestFilters(); 181 181 182 182 if(empty($arrActiveFilters)) 183 183 return(false); 184 184 185 185 $taxonomy = $term->taxonomy; 186 186 187 187 $selectedTermID = UniteFunctionsUC::getVal($arrActiveFilters, $taxonomy); 188 188 189 189 if(empty($selectedTermID)) 190 190 return(false); 191 191 192 192 if($selectedTermID === $term->term_id) 193 193 return(true); 194 194 195 195 return(false); 196 196 } 197 197 198 198 /** 199 199 * get current term by query vars 200 200 */ 201 201 private function getCurrentTermByQueryVars($queryVars){ 202 202 203 203 if(is_array($queryVars) == false) 204 204 return(null); 205 205 206 206 if(empty($queryVars)) 207 207 return(null); 208 208 209 209 if(count($queryVars) > 1) 210 210 return(null); 211 211 212 212 $postType = null; 213 213 if(isset($queryVars["post_type"])){ 214 214 215 215 $postType = $queryVars["post_type"]; 216 216 unset($queryVars["post_type"]); 217 217 } 218 218 219 219 $args = array(); 220 220 if(!empty($postType)) 221 221 $args["post_type"] = $postType; 222 222 223 223 if(!empty($queryVars)){ 224 224 $taxonomy = null; 225 225 $slug = null; 226 226 227 227 foreach($queryVars as $queryTax=>$querySlug){ 228 228 229 229 $taxonomy = $queryTax; 230 230 $slug = $querySlug; 231 231 } 232 232 233 233 $args = array(); 234 234 $args["taxonomy"] = $taxonomy; 235 $args["slug"] = $slug; 236 } 237 238 235 $args["slug"] = $slug; 236 } 237 238 239 239 $arrTerms = get_terms($args); 240 240 241 241 $isError = is_wp_error($arrTerms); 242 242 243 243 if($isError == true){ 244 244 if(self::$showDebug == true){ 245 245 246 246 dmp("error get terms"); 247 247 dmp($args); 248 248 dmp($arrTerms); 249 249 } 250 250 251 251 UniteFunctionsUC::throwError("cannot get the terms"); 252 252 } 253 253 254 254 if(empty($arrTerms)) 255 255 return(null); 256 256 257 257 $term = $arrTerms[0]; 258 258 259 259 return($term); 260 260 } 261 262 261 262 263 263 /** 264 264 * get current term 265 265 */ 266 266 private function getCurrentTerm(){ 267 267 268 268 if(!empty(self::$currentTermCache)) 269 269 return(self::$currentTermCache); 270 270 271 271 if(is_archive() == false) 272 272 return(null); 273 273 274 274 if(!empty(self::$originalQueryVars)){ 275 275 276 276 $currentTerm = $this->getCurrentTermByQueryVars(self::$originalQueryVars); 277 277 }else{ 278 278 $currentTerm = get_queried_object(); 279 280 281 279 280 281 282 282 if($currentTerm instanceof WP_Term == false) 283 283 $currentTerm = null; 284 284 } 285 285 286 286 self::$currentTermCache = $currentTerm; 287 287 288 288 return($currentTerm); 289 289 } 290 290 291 291 private function _______PARSE_INPUT_FILTERS__________(){} 292 292 293 293 /** 294 294 * get request array 295 295 */ 296 296 private function getArrRequest(){ 297 297 298 298 $request = $_GET; 299 299 if(!empty($_POST)) 300 300 $request = array_merge($request, $_POST); 301 301 302 302 return($request); 303 303 } 304 305 304 305 306 306 307 307 /** … … 309 309 */ 310 310 private function parseStrTerms_groups($strValues){ 311 311 312 312 preg_match_all('/\|(.*?)\|/', $strValues, $matches); 313 313 314 314 if(empty($matches)) 315 315 return(array()); 316 316 317 317 $arrGroups = $matches[0]; 318 318 $arrGroupValues = $matches[1]; 319 319 320 320 $arrReplace = array(); 321 321 322 322 //break into groups 323 323 324 324 foreach($arrGroups as $index => $group){ 325 325 326 326 $strReplace = "group".($index+1)."_".UniteFunctionsUC::getRandomString(); 327 327 328 328 $strGroupValues = $arrGroupValues[$index]; 329 329 330 330 $arrReplace[$strReplace] = $strGroupValues; 331 331 332 332 $strValues = str_replace($group, $strReplace, $strValues); 333 333 } 334 334 335 335 //get the array 336 336 337 337 $arrValues = $this->parseStrTerms_values($strValues); 338 338 339 339 foreach($arrValues as $key => $value){ 340 340 341 341 if(isset($arrReplace[$value])){ 342 342 343 343 $strGroupValue = $arrReplace[$value]; 344 344 345 345 $arrGroupValue = $this->parseStrTerms_values($strGroupValue); 346 346 347 347 $arrGroupValue["relation"] = "OR"; 348 348 349 349 if(count($arrGroupValue) == 1) 350 350 $arrGroupValue = $arrGroupValue[0]; 351 351 352 352 $arrValues[$key] = $arrGroupValue; 353 353 } 354 355 } 356 354 355 } 356 357 357 $arrValues["relation"] = "AND"; 358 358 359 359 return($arrValues); 360 360 } 361 362 363 361 362 363 364 364 /** 365 365 * parse the values 366 366 */ 367 367 private function parseStrTerms_values($strValues){ 368 368 369 369 //get the groups instead 370 370 371 371 if(strpos($strValues,"|") !== false){ 372 372 373 373 $arrValues = $this->parseStrTerms_groups($strValues); 374 374 375 375 return($arrValues); 376 376 } 377 377 378 378 $arrValues = explode(".", $strValues); 379 379 380 380 $isTermsAnd = false; 381 381 foreach($arrValues as $valueKey=>$value){ … … 385 385 } 386 386 } 387 387 388 388 if($isTermsAnd == true) 389 389 $arrValues["relation"] = "AND"; 390 390 391 391 return($arrValues); 392 392 } 393 394 393 394 395 395 /** 396 396 * parse filters string … … 399 399 400 400 $arrUrlKeys = $this->getUrlPartsKeys(); 401 401 402 402 $taxSapSign = UniteFunctionsUC::getVal($arrUrlKeys, "tax_sap","~"); 403 403 404 404 $strFilters = trim($strFilters); 405 405 406 406 $arrFilters = explode(";", $strFilters); 407 407 408 408 //fill the terms 409 409 $arrTerms = array(); 410 410 411 411 foreach($arrFilters as $strFilter){ 412 412 413 413 $arrFilter = explode($taxSapSign, $strFilter); 414 414 415 415 if(count($arrFilter) != 2) 416 416 continue; 417 417 418 418 $key = $arrFilter[0]; 419 419 $strValues = $arrFilter[1]; 420 420 421 421 $arrValues = $this->parseStrTerms_values($strValues); 422 422 423 423 $arrTerms[$key] = $arrValues; 424 425 } 426 427 424 425 } 426 427 428 428 //show debug terms 429 429 430 430 if(self::DEBUG_PARSED_TERMS == true){ 431 431 432 432 dmp("parsed terms"); 433 433 dmp($arrTerms); 434 434 exit(); 435 435 } 436 437 436 437 438 438 $arrOutput = array(); 439 439 440 440 if(!empty($arrTerms)) 441 441 $arrOutput[self::TYPE_TABS] = $arrTerms; 442 443 442 443 444 444 return($arrOutput); 445 445 } 446 446 447 447 /** 448 448 * get orderby input filter 449 449 */ 450 450 private function getArrInputFilters_getOrderby($arrOutput, $request){ 451 451 452 452 $orderby = UniteFunctionsUC::getVal($request, "ucorderby"); 453 453 $orderby = UniteProviderFunctionsUC::sanitizeVar($orderby, UniteFunctionsUC::SANITIZE_KEY); 454 454 455 455 if(empty($orderby)) 456 456 return($arrOutput); 457 457 458 458 //check if valid 459 459 $arrOrderby = UniteFunctionsWPUC::getArrSortBy(true); 460 460 461 461 if($orderby == "id") 462 462 $orderby = "ID"; 463 463 464 464 if(is_string($orderby) && isset($arrOrderby[$orderby])) 465 465 $arrOutput["orderby"] = $orderby; … … 467 467 //meta old name 468 468 if($orderby == "meta"){ 469 469 470 470 $orderbyMeta = UniteFunctionsUC::getVal($request, "ucorderby_meta"); 471 471 $orderbyMeta = UniteProviderFunctionsUC::sanitizeVar($orderbyMeta, UniteFunctionsUC::SANITIZE_KEY); 472 472 473 473 $orderbyMetaType = UniteFunctionsUC::getVal($request, "ucorderby_metatype"); 474 474 $orderbyMetaType = UniteProviderFunctionsUC::sanitizeVar($orderbyMetaType, UniteFunctionsUC::SANITIZE_KEY); 475 475 476 476 if(!empty($orderbyMeta)){ 477 477 $arrOutput["orderby"] = $orderby; 478 478 $arrOutput["orderby_metaname"] = $orderbyMeta; 479 479 } 480 480 481 481 if(!empty($orderbyMetaType)) 482 482 $arrOutput["orderby_metatype"] = $orderbyMetaType; 483 483 484 484 } 485 485 486 486 //meta new way 487 487 488 488 if(strpos($orderby, "meta__") === false) 489 489 return($arrOutput); 490 490 491 491 $arrMeta = explode("__", $orderby); 492 492 493 493 if(count($arrMeta) != 3) 494 494 return($arrOutput); 495 495 496 496 $orderby = $arrMeta[0]; 497 497 $metaName = $arrMeta[1]; 498 498 $metaType = $arrMeta[2]; 499 499 500 500 if($orderby != "meta") 501 501 return($arrOutput); 502 502 503 503 $arrOutput["orderby"] = $orderby; 504 504 $arrOutput["orderby_metaname"] = $metaName; 505 505 $arrOutput["orderby_metatype"] = $metaType; 506 507 506 507 508 508 return($arrOutput); 509 509 } 510 511 510 511 512 512 /** 513 513 * get filters array from input 514 514 */ 515 515 private function getArrInputFilters(){ 516 516 517 517 if(!empty(self::$arrInputFiltersCache)) 518 518 return(self::$arrInputFiltersCache); 519 519 520 520 $request = $this->getArrRequest(); 521 521 522 522 $strTerms = UniteFunctionsUC::getVal($request, "ucterms"); 523 523 524 524 $arrOutput = array(); 525 525 526 526 //parse filters 527 527 528 528 if(!empty($strTerms)){ 529 529 if(self::$showDebug == true) 530 530 dmp("input filters found: $strTerms"); 531 531 532 532 $arrOutput = $this->parseStrTerms($strTerms); 533 533 } 534 534 535 535 //page 536 536 537 537 $page = UniteFunctionsUC::getVal($request, "ucpage"); 538 538 $page = (int)$page; 539 539 540 540 if(!empty($page)) 541 541 $arrOutput["page"] = $page; 542 542 543 543 //offset 544 544 $offset = UniteFunctionsUC::getVal($request, "ucoffset"); 545 545 $offset = (int)$offset; 546 546 547 547 if(!empty($offset)) 548 548 $arrOutput["offset"] = $offset; 549 549 550 550 //num items 551 551 552 552 $numItems = UniteFunctionsUC::getVal($request, "uccount"); 553 553 $numItems = (int)$numItems; 554 554 555 555 if(!empty($numItems)) 556 556 $arrOutput["num_items"] = $numItems; 557 557 558 558 //search 559 559 $search = UniteFunctionsUC::getVal($request, "ucs"); 560 560 561 561 if(!empty($search)) 562 562 $arrOutput["search"] = $search; 563 563 564 564 //price 565 565 566 566 $priceFrom = UniteFunctionsUC::getVal($request, "ucpricefrom"); 567 567 $priceTo = UniteFunctionsUC::getVal($request, "ucpriceto"); 568 568 569 569 if(!empty($priceFrom)) 570 570 $arrOutput["price_from"] = $priceFrom; 571 571 572 572 if(!empty($priceTo)) 573 573 $arrOutput["price_to"] = $priceTo; 574 575 574 575 576 576 //exclude 577 577 $exclude = UniteFunctionsUC::getVal($request, "ucexclude"); 578 578 $exclude = UniteProviderFunctionsUC::sanitizeVar($exclude, UniteFunctionsUC::SANITIZE_TEXT_FIELD); 579 579 580 580 if(!empty($exclude)){ 581 581 582 582 $isValid = UniteFunctionsUC::isValidIDsList($exclude); 583 583 584 584 if($isValid == true) 585 585 $arrOutput["exclude"] = $exclude; 586 586 } 587 587 588 588 //orderby 589 589 590 590 $arrOutput = $this->getArrInputFilters_getOrderby($arrOutput, $request); 591 592 591 592 593 593 //orderdir 594 594 595 595 $orderDir = UniteFunctionsUC::getVal($request, "ucorderdir"); 596 596 597 597 if($orderDir == "asc" || $orderDir == "desc") 598 598 $arrOutput["orderdir"] = $orderDir; 599 600 599 600 601 601 self::$arrInputFiltersCache = $arrOutput; 602 603 602 603 604 604 return($arrOutput); 605 605 } 606 607 608 606 607 608 609 609 /** 610 610 * get filters arguments 611 611 */ 612 612 public function getRequestFilters(){ 613 613 614 614 if(self::$filters !== null) 615 615 return(self::$filters); 616 616 617 617 self::$filters = array(); 618 618 619 619 $arrInputFilters = $this->getArrInputFilters(); 620 620 621 621 if(empty($arrInputFilters)) 622 622 return(self::$filters); 623 623 624 624 $arrTerms = UniteFunctionsUC::getVal($arrInputFilters, self::TYPE_TABS); 625 625 626 626 if(!empty($arrTerms)) 627 627 self::$filters["terms"] = $arrTerms; 628 628 629 629 //get the page 630 630 631 631 $page = UniteFunctionsUC::getVal($arrInputFilters, "page"); 632 632 633 633 if(!empty($page) && is_numeric($page)) 634 634 self::$filters["page"] = $page; 635 635 636 636 //get the offset 637 637 638 638 $offset = UniteFunctionsUC::getVal($arrInputFilters, "offset"); 639 639 640 640 if(!empty($offset) && is_numeric($offset)) 641 641 self::$filters["offset"] = $offset; 642 643 642 643 644 644 //get num items 645 645 $numItems = UniteFunctionsUC::getVal($arrInputFilters, "num_items"); 646 646 647 647 if(!empty($numItems) && is_numeric($numItems)) 648 648 self::$filters["num_items"] = $numItems; 649 649 650 650 //get search 651 651 $search = UniteFunctionsUC::getVal($arrInputFilters, "search"); 652 652 653 653 if(!empty($search)) 654 654 self::$filters["search"] = $search; 655 655 656 656 //get exclude 657 657 $exclude = UniteFunctionsUC::getVal($arrInputFilters, "exclude"); 658 658 659 659 if(!empty($exclude)) 660 660 self::$filters["exclude"] = $exclude; 661 661 662 662 //get orderby 663 663 $orderby = UniteFunctionsUC::getVal($arrInputFilters, "orderby"); 664 664 665 665 if(!empty($orderby)){ 666 666 667 667 self::$filters["orderby"] = $orderby; 668 668 669 669 if($orderby == "meta"){ 670 670 self::$filters["orderby_metaname"] = UniteFunctionsUC::getVal($arrInputFilters, "orderby_metaname"); … … 672 672 } 673 673 } 674 674 675 675 //get orderdir 676 676 $orderdir = UniteFunctionsUC::getVal($arrInputFilters, "orderdir"); … … 678 678 if(!empty($orderdir)) 679 679 self::$filters["orderdir"] = $orderdir; 680 680 681 681 //price 682 682 683 683 $priceFrom = UniteFunctionsUC::getVal($arrInputFilters, "price_from"); 684 684 $priceTo = UniteFunctionsUC::getVal($arrInputFilters, "price_to"); 685 685 686 686 if(!empty($priceFrom) && is_numeric($priceFrom)) 687 687 self::$filters["price_from"] = $priceFrom; 688 688 689 689 if(!empty($priceTo) && is_numeric($priceTo)) 690 690 self::$filters["price_to"] = $priceTo; 691 692 691 692 693 693 return(self::$filters); 694 694 } 695 696 695 696 697 697 private function _______FILTER_ARGS__________(){} 698 699 698 699 700 700 /** 701 701 * get offset 702 702 */ 703 703 private function processRequestFilters_setPaging($args, $page, $numItems){ 704 705 if(empty($page)) 704 705 if(empty($page)) 706 706 return(null); 707 707 708 708 $perPage = UniteFunctionsUC::getVal($args, "posts_per_page"); 709 709 710 710 if(empty($perPage)) 711 711 return($args); 712 712 713 713 $offset = null; 714 714 $postsPerPage = null; 715 715 716 716 //set posts per page and offset 717 717 if(!empty($numItems) && $page > 1){ 718 718 719 719 if($page == 2) 720 720 $offset = $perPage; 721 721 else if($page > 2) 722 722 $offset = $perPage+($page-2)*$numItems; 723 723 724 724 $postsPerPage = $numItems; 725 725 726 726 }else{ //no num items 727 727 $offset = ($page-1)*$perPage; 728 728 } 729 729 730 730 if(!empty($offset)) 731 731 $args["offset"] = $offset; 732 732 733 733 if(!empty($postsPerPage)) 734 734 $args["posts_per_page"] = $postsPerPage; 735 735 736 736 return($args); 737 737 } 738 738 739 739 /** 740 740 * get tax query from terms array 741 741 */ 742 742 private function getTaxQuery($arrTax){ 743 743 744 744 $arrQuery = array(); 745 745 746 746 foreach($arrTax as $taxonomy=>$arrTerms){ 747 747 748 748 $relation = UniteFunctionsUC::getVal($arrTerms, "relation"); 749 749 750 750 if($relation == "AND"){ //multiple 751 751 752 752 unset($arrTerms["relation"]); 753 753 754 754 foreach($arrTerms as $term){ 755 755 756 756 $item = array(); 757 757 $item["taxonomy"] = $taxonomy; 758 758 $item["field"] = "slug"; 759 759 $item["terms"] = $term; 760 760 761 761 $arrQuery[] = $item; 762 762 } 763 763 764 764 }else{ //single (or) 765 765 766 766 $item = array(); 767 767 $item["taxonomy"] = $taxonomy; 768 768 $item["field"] = "slug"; 769 769 $item["terms"] = $arrTerms; 770 770 771 771 $arrQuery[] = $item; 772 772 } 773 774 } 775 773 774 } 775 776 776 $arrQuery["relation"] = "AND"; 777 777 778 778 return($arrQuery); 779 779 } 780 780 781 781 /** 782 782 * remove "not in" tax query 783 783 */ 784 784 private function keepNotInTaxQuery($arrTaxQuery){ 785 785 786 786 if(empty($arrTaxQuery)) 787 787 return(null); 788 788 789 789 $arrNew = array(); 790 790 791 791 foreach($arrTaxQuery as $tax){ 792 792 793 793 if(isset($tax["operator"])){ 794 794 $arrNew[] = $tax; 795 795 continue; 796 796 } 797 797 798 798 $operator = UniteFunctionsUC::getVal($tax, "operator"); 799 799 if($operator == "NOT IN") 800 800 $arrNew[] = $tax; 801 801 } 802 802 803 803 return($arrNew); 804 804 } 805 806 805 806 807 807 /** 808 808 * set arguments tax query, merge with existing if avaliable 809 809 */ 810 810 private function setArgsTaxQuery($args, $arrTaxQuery){ 811 811 812 812 if(empty($arrTaxQuery)) 813 813 return($args); 814 814 815 815 $existingTaxQuery = UniteFunctionsUC::getVal($args, "tax_query"); 816 816 817 817 //if replace terms mode - just delete the existing tax query 818 818 if(self::$isModeReplace == true){ 819 819 $existingTaxQuery = $this->keepNotInTaxQuery($existingTaxQuery); 820 820 } 821 821 822 822 if(empty($existingTaxQuery)){ 823 823 824 824 $args["tax_query"] = $arrTaxQuery; 825 825 826 826 return($args); 827 827 } 828 828 829 829 $newTaxQuery = array( 830 $existingTaxQuery, 830 $existingTaxQuery, 831 831 $arrTaxQuery 832 832 ); 833 833 834 834 $newTaxQuery["relation"] = "AND"; 835 836 835 836 837 837 $args["tax_query"] = $newTaxQuery; 838 838 839 839 return($args); 840 840 } 841 842 841 842 843 843 /** 844 844 * process request filters 845 845 */ 846 846 public function processRequestFilters($args, $isFilterable, $isMainQuery = false){ 847 847 848 848 //allow all ajax, forbid under request and not filterable. 849 849 850 850 if($isFilterable == false) 851 851 return($args); 852 852 853 853 $arrFilters = $this->getRequestFilters(); 854 854 855 855 $arrMetaQuery = array(); 856 856 857 857 //---- set offset and count ---- 858 858 859 859 $page = UniteFunctionsUC::getVal($arrFilters, "page"); 860 860 $numItems = UniteFunctionsUC::getVal($arrFilters, "num_items"); … … 866 866 $priceFrom = UniteFunctionsUC::getVal($arrFilters, "price_from"); 867 867 $priceTo = UniteFunctionsUC::getVal($arrFilters, "price_to"); 868 869 868 869 870 870 if(!empty($page)) 871 871 $args = $this->processRequestFilters_setPaging($args, $page, $numItems); 872 872 873 873 //set paging by offset 874 874 if(!empty($offset)) 875 875 $args["offset"] = $offset; 876 876 877 877 if(!empty($numItems)) 878 878 $args["posts_per_page"] = $numItems; 879 879 880 880 //search 881 881 if(!empty($search) && $search != "_all_"){ 882 882 $args["s"] = $search; 883 883 } 884 884 885 885 //orderby 886 886 if(!empty($orderby) && $orderby != "default"){ 887 887 888 888 $args["orderby"] = $orderby; 889 889 890 890 if($orderby == "meta"){ 891 891 892 892 $metaName = UniteFunctionsUC::getVal($arrFilters, "orderby_metaname"); 893 893 $metaType = UniteFunctionsUC::getVal($arrFilters, "orderby_metatype"); 894 894 895 895 if(!empty($metaName)){ 896 896 897 897 if($metaType == "number") 898 898 $args["orderby"] = "meta_value_num"; 899 899 else 900 900 $args["orderby"] = "meta_value"; 901 901 902 902 $args["meta_key"] = $metaName; 903 903 904 904 } 905 906 } 907 905 906 } 907 908 908 if($orderby == UniteFunctionsWPUC::SORTBY_PRICE){ 909 909 $args["orderby"] = "meta_value_num"; 910 910 $args["meta_key"] = "_price"; 911 911 } 912 912 913 913 if($orderby == UniteFunctionsWPUC::SORTBY_SALE_PRICE){ 914 914 $args["orderby"] = "meta_value_num"; 915 915 $args["meta_key"] = "_sale_price"; 916 916 } 917 918 } 919 917 918 } 919 920 920 //orderdir 921 921 if(!empty($orderdir) && $orderdir != "default"){ 922 922 $args["order"] = strtoupper($orderdir); 923 923 } 924 925 924 925 926 926 $arrTerms = UniteFunctionsUC::getVal($arrFilters, "terms"); 927 927 if(!empty($arrTerms)){ 928 928 929 929 //combine the tax queries 930 930 $arrTaxQuery = $this->getTaxQuery($arrTerms); 931 931 932 932 if(!empty($arrTaxQuery)) 933 933 $args = $this->setArgsTaxQuery($args, $arrTaxQuery); 934 934 } 935 935 936 936 //exclude 937 937 if(!empty($exclude)){ 938 938 939 939 $arrExclude = explode(",", $exclude); 940 940 941 941 $arrExclude = array_unique($arrExclude); 942 942 943 943 $arrNotIn = UniteFunctionsUC::getVal($args, "post__not_in"); 944 944 945 945 if(empty($arrNotIn)) 946 946 $arrNotIn = array(); 947 947 948 948 $arrNotIn = array_merge($arrNotIn, $arrExclude); 949 949 950 950 $args["post__not_in"] = $arrExclude; 951 952 } 953 951 952 } 953 954 954 //supress all filters 955 955 if(self::$isUnderAjaxSearch == true){ 956 956 957 957 $args["suppress_filters"] = true; 958 958 959 959 //delete all filters in case of ajax search 960 960 961 961 UniteCreatorAjaxSeach::supressThirdPartyFilters(); 962 963 } 964 962 963 } 964 965 965 //Woo Prices 966 966 967 967 if(!empty($priceFrom)){ 968 968 969 969 $arrMetaQuery[] = array( 970 970 'key' => '_price', … … 974 974 ); 975 975 } 976 976 977 977 if(!empty($priceTo)){ 978 978 979 979 $arrMetaQuery[] = array( 980 980 'key' => '_price', … … 985 985 } 986 986 987 987 988 988 //set the meta query 989 989 990 990 if(!empty($arrMetaQuery)){ 991 991 992 992 $arrExistingMeta = UniteFunctionsUC::getVal($args, "meta_query",array()); 993 993 994 994 $args["meta_query"] = array_merge($arrExistingMeta, $arrMetaQuery); 995 995 } 996 996 997 997 998 998 if(self::$showDebug == true){ 999 999 1000 1000 dmp("args:"); 1001 1001 dmp($args); 1002 1002 1003 1003 dmp("filters:"); 1004 1004 dmp($arrFilters); 1005 1005 } 1006 1006 1007 1007 return($args); 1008 1008 } 1009 1009 1010 1010 1011 1011 private function _______AJAX__________(){} 1012 1012 1013 1013 /** 1014 1014 * get addon post list name 1015 1015 */ 1016 1016 private function getAddonPostListName($addon){ 1017 1017 1018 1018 $paramPostList = $addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST); 1019 1019 1020 1020 $postListName = UniteFunctionsUC::getVal($paramPostList, "name"); 1021 1021 1022 1022 return($postListName); 1023 1023 } 1024 1025 1024 1025 1026 1026 /** 1027 1027 * validate if the addon ajax ready … … 1029 1029 */ 1030 1030 private function validateAddonAjaxReady($addon, $arrSettingsValues){ 1031 1031 1032 1032 $paramPostList = $addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST); 1033 1033 1034 1034 $paramListing = $addon->getListingParamForOutput(); 1035 1035 1036 1036 if(empty($paramPostList) && !empty($paramListing)) 1037 1037 $paramPostList = $paramListing; 1038 1038 1039 1039 if(empty($paramPostList)) 1040 1040 UniteFunctionsUC::throwError("Widget not ready for ajax"); 1041 1041 1042 1042 $postListName = UniteFunctionsUC::getVal($paramPostList, "name"); 1043 1043 1044 1044 //check for ajax search 1045 1045 $options = $addon->getOptions(); 1046 1046 $special = UniteFunctionsUC::getVal($options, "special"); 1047 1047 1048 1048 if($special === "ajax_search") 1049 1049 return($postListName); 1050 1051 1050 1051 1052 1052 $isAjaxReady = UniteFunctionsUC::getVal($arrSettingsValues, $postListName."_isajax"); 1053 1053 $isAjaxReady = UniteFunctionsUC::strToBool($isAjaxReady); 1054 1054 1055 1055 if($isAjaxReady == false) 1056 1056 UniteFunctionsUC::throwError("The ajax is not ready for this widget"); 1057 1057 1058 1058 return($postListName); 1059 1059 } 1060 1061 1060 1061 1062 1062 /** 1063 1063 * process the html output - convert all the links, remove the query part … … 1066 1066 1067 1067 $currentUrl = GlobalsUC::$current_page_url; 1068 1068 1069 1069 $arrUrl = parse_url($currentUrl); 1070 1070 1071 1071 $query = "?".UniteFunctionsUC::getVal($arrUrl, "query"); 1072 1072 1073 1073 $html = str_replace($query, "", $html); 1074 1074 1075 1075 $query = str_replace("&", "&", $query); 1076 1076 1077 1077 $html = str_replace($query, "", $html); 1078 1078 1079 1079 return($html); 1080 1080 } 1081 1081 1082 1082 /** 1083 1083 * modify settings values before set to addon … … 1085 1085 */ 1086 1086 private function modifySettingsValues($arrSettingsValues, $postListName){ 1087 1087 1088 1088 $paginationType = UniteFunctionsUC::getVal($arrSettingsValues, "pagination_type"); 1089 1089 1090 1090 if(!empty($paginationType)) 1091 1091 $arrSettingsValues[$postListName."_pagination_type"] = $paginationType; 1092 1092 1093 return($arrSettingsValues); 1094 } 1093 return($arrSettingsValues); 1094 } 1095 1096 1097 /** 1098 * get content element html 1099 */ 1100 private function getContentWidgetHtml($arrContent, $elementID, $isGrid = true){ 1095 1101 1096 1097 /**1098 * get content element html1099 */1100 private function getContentWidgetHtml($arrContent, $elementID, $isGrid = true){1101 1102 1102 if(self::$isGutenberg == false) 1103 1103 $arrElement = HelperProviderCoreUC_EL::getArrElementFromContent($arrContent, $elementID); 1104 1104 else 1105 $arrElement = self::$objGutenberg->getBlockByRootI D($arrContent, $elementID);1105 $arrElement = self::$objGutenberg->getBlockByRootId($arrContent, $elementID); 1106 1106 1107 1107 if(empty($arrElement)){ 1108 1108 1109 1109 UniteFunctionsUC::throwError(self::$platform." Widget with id: $elementID not found"); 1110 1110 } 1111 1112 1111 1112 1113 1113 //Elementor Validations 1114 1114 1115 1115 if(self::$isGutenberg == false){ 1116 1116 1117 1117 $type = UniteFunctionsUC::getVal($arrElement, "elType"); 1118 1118 1119 1119 if($type != "widget") 1120 1120 UniteFunctionsUC::throwError("The element is not a widget"); 1121 1121 1122 1122 $widgetType = UniteFunctionsUC::getVal($arrElement, "widgetType"); 1123 1123 1124 1124 if(strpos($widgetType, "ucaddon_") === false){ 1125 1125 1126 1126 if($widgetType == "global") 1127 1127 UniteFunctionsUC::throwError("Ajax filtering doesn't work with global widgets. Please change the grid to regular widget."); 1128 1128 1129 1129 UniteFunctionsUC::throwError("Cannot output widget content for widget: $widgetType"); 1130 1130 } 1131 1132 } 1133 1131 1132 } 1133 1134 1134 //get settings values 1135 1135 1136 1136 if(self::$isGutenberg == false) 1137 1137 $arrSettingsValues = UniteFunctionsUC::getVal($arrElement, "settings"); … … 1139 1139 $arrSettingsValues = self::$objGutenberg->getSettingsFromBlock($arrElement); 1140 1140 1141 1141 1142 1142 //init addon 1143 1143 1144 1144 $addon = new UniteCreatorAddon(); 1145 1145 1146 1146 if(self::$isGutenberg == false){ //init in elementor 1147 1147 1148 1148 $widgetName = str_replace("ucaddon_", "", $widgetType); 1149 1149 $addon->initByAlias($widgetName, GlobalsUC::ADDON_TYPE_ELEMENTOR); 1150 1150 1151 1151 }else{ //init in gutenberg 1152 1152 1153 1153 $blockName = UniteFunctionsUC::getVal($arrElement, "blockName"); 1154 1154 $addon->initByBlockName($blockName, GlobalsUC::ADDON_TYPE_ELEMENTOR); 1155 1155 } 1156 1157 1156 1157 1158 1158 //make a check that ajax option is on in this widget 1159 1159 1160 1160 if($isGrid == true){ 1161 1161 1162 1162 $postListName = $this->validateAddonAjaxReady($addon, $arrSettingsValues); 1163 1163 1164 1164 $arrSettingsValues = $this->modifySettingsValues($arrSettingsValues, $postListName); 1165 1165 } 1166 1166 1167 1167 $addon->setParamsValues($arrSettingsValues); 1168 1169 1168 1169 1170 1170 //init the ajax search object to modify the post search list, if available 1171 1171 if(GlobalsProviderUC::$isUnderAjaxSearch){ 1172 1172 1173 1173 $objAjaxSearch = new UniteCreatorAjaxSeach(); 1174 1174 $objAjaxSearch->initCustomAjaxSeach($addon); 1175 1175 } 1176 1176 1177 1177 //------ get the html output 1178 1178 1179 1179 //collect the debug html 1180 1180 if(self::$showDebug == false) 1181 1181 ob_start(); 1182 1182 1183 1183 $objOutput = new UniteCreatorOutput(); 1184 1184 1185 1185 $isDebugFromGet = HelperUC::hasPermissionsFromQuery("ucfieldsdebug"); 1186 1186 1187 1187 if($isDebugFromGet == true) 1188 1188 $objOutput->showDebugData(true); … … 1191 1191 1192 1192 if($isDebugFromGet == true){ 1193 1193 1194 1194 HelperProviderUC::showLastQueryPosts(); 1195 1195 1196 1196 dmp("End Here"); 1197 1197 exit(); 1198 1198 } 1199 1199 1200 1200 if(self::$showDebug == false){ 1201 1201 $htmlDebug = ob_get_contents(); 1202 1202 1203 1203 ob_end_clean(); 1204 1204 } 1205 1205 1206 1206 1207 1207 $output = array(); 1208 1208 1209 1209 //get only items 1210 1210 if($isGrid == true){ 1211 1211 1212 1212 $arrHtml = $objOutput->getHtmlItems(); 1213 1213 1214 1214 $output["html"] = UniteFunctionsUC::getVal($arrHtml, "html_items1"); 1215 1215 $output["html2"] = UniteFunctionsUC::getVal($arrHtml, "html_items2"); 1216 1216 1217 1217 $output["uc_id"] = $objOutput->getWidgetID(); 1218 1219 1218 1219 1220 1220 }else{ //not a grid - output of html template 1221 1221 1222 1222 $htmlBody = $objOutput->getHtmlOnly(); 1223 1223 1224 1224 $htmlBody = $this->processAjaxHtmlOutput($htmlBody); 1225 1225 1226 1226 $output["html"] = $htmlBody; 1227 1227 } 1228 1229 1228 1229 1230 1230 if(!empty($htmlDebug)) 1231 1231 $output["html_debug"] = $htmlDebug; 1232 1232 1233 1233 return($output); 1234 1234 } 1235 1236 1235 1236 1237 1237 /** 1238 1238 * get content widgets html 1239 1239 */ 1240 1240 private function getContentWidgetsHTML($arrContent, $strIDs, $isGrid = false){ 1241 1241 1242 1242 if(empty($strIDs)) 1243 1243 return(null); 1244 1244 1245 1245 $arrIDs = explode(",", $strIDs); 1246 1246 1247 1247 $arrHTML = array(); 1248 1248 1249 1249 $this->contentWidgetsDebug = array(); 1250 1250 1251 1251 foreach($arrIDs as $elementID){ 1252 1252 1253 1253 $output = $this->getContentWidgetHtml($arrContent, $elementID, $isGrid); 1254 1254 1255 1255 $htmlDebug = UniteFunctionsUC::getVal($output, "html_debug"); 1256 1256 1257 1257 $html = UniteFunctionsUC::getVal($output, "html"); 1258 1258 $html2 = UniteFunctionsUC::getVal($output, "html2"); 1259 1259 1260 1260 //collect the debug 1261 1261 if(!empty($htmlDebug)) 1262 1262 $this->contentWidgetsDebug[$elementID] = $htmlDebug; 1263 1263 1264 1264 if($isGrid == false){ 1265 1265 $arrHTML[$elementID] = $html; 1266 1266 continue; 1267 1267 } 1268 1268 1269 1269 //if case of grid 1270 1271 1270 1271 1272 1272 $arrOutput = array(); 1273 1273 $arrOutput["html_items"] = $html; 1274 1274 1275 1275 if(!empty($html2)) 1276 1276 $arrOutput["html_items2"] = $html2; 1277 1277 1278 1278 $arrHTML[$elementID] = $arrOutput; 1279 1280 } 1281 1279 1280 } 1281 1282 1282 return($arrHTML); 1283 1283 } 1284 1284 1285 1285 1286 1286 /** 1287 1287 * get init filtres taxonomy request 1288 1288 */ 1289 1289 private function getInitFiltersTaxRequest($request, $strTestIDs){ 1290 1290 1291 1291 if(strpos($request, "WHERE 1=2") !== false) 1292 1292 return(null); 1293 1293 1294 1294 $posLimit = strpos($request, "LIMIT"); 1295 1295 1296 1296 if($posLimit){ 1297 1297 $request = substr($request, 0, $posLimit-1); 1298 1298 $request = trim($request); 1299 1299 } 1300 1300 1301 1301 //remove the calc found rows 1302 1302 1303 1303 $request = str_replace("SQL_CALC_FOUND_ROWS", "", $request); 1304 1304 1305 1305 $prefix = UniteProviderFunctionsUC::$tablePrefix; 1306 1306 1307 1307 $request = str_replace($prefix."posts.*", $prefix."posts.id", $request); 1308 1309 //wrap it in get term id's request 1310 1308 1309 //wrap it in get term id's request 1310 1311 1311 $arrTermIDs = explode(",", $strTestIDs); 1312 1312 1313 1313 if(empty($arrTermIDs)) 1314 1314 return(null); 1315 1315 1316 1316 $selectTerms = ""; 1317 1317 $selectTop = ""; 1318 1318 1319 1319 $query = "SELECT \n"; 1320 1320 1321 1321 foreach($arrTermIDs as $termID){ 1322 1322 1323 1323 if(!empty($selectTerms)){ 1324 1324 $selectTerms .= ",\n"; 1325 1325 $selectTop .= ",\n"; 1326 1326 } 1327 1327 1328 1328 $name = "term_$termID"; 1329 1329 1330 1330 $selectTerms .= "SUM(if(tt.`parent` = $termID OR tt.`term_id` = $termID, 1, 0)) AS $name"; 1331 1331 1332 1332 $selectTop .= "SUM(if($name > 0, 1, 0)) as $name"; 1333 1334 } 1335 1333 1334 } 1335 1336 1336 $query .= $selectTerms; 1337 1337 1338 1338 $sql = " 1339 1339 FROM `{$prefix}posts` p … … 1343 1343 ({$request}) \n 1344 1344 GROUP BY p.`id`"; 1345 1345 1346 1346 $query .= $sql; 1347 1347 1348 1348 $fullQuery = "SELECT $selectTop from($query) as summary"; 1349 1349 1350 1350 1351 1351 return($fullQuery); 1352 1352 } 1353 1354 1353 1354 1355 1355 1356 1356 /** … … 1358 1358 */ 1359 1359 private function modifyFoundTermsIDs($arrFoundTermIDs){ 1360 1360 1361 1361 if(isset($arrFoundTermIDs[0])) 1362 1362 $arrFoundTermIDs = $arrFoundTermIDs[0]; 1363 1363 1364 1364 $arrTermsAssoc = array(); 1365 1365 1366 1366 foreach($arrFoundTermIDs as $strID=>$count){ 1367 1367 1368 1368 $termID = str_replace("term_", "", $strID); 1369 1369 1370 1370 $arrTermsAssoc[$termID] = $count; 1371 1371 } 1372 1372 1373 1373 return($arrTermsAssoc); 1374 1374 } 1375 1376 1375 1376 1377 1377 /** 1378 1378 * get widget ajax data 1379 1379 */ 1380 1380 private function putWidgetGridFrontAjaxData(){ 1381 1381 1382 1382 //validate by response code 1383 1383 1384 1384 $responseCode = http_response_code(); 1385 1385 1386 1386 if($responseCode != 200){ 1387 1387 http_response_code(200); 1388 1388 UniteFunctionsUC::throwError("Request not allowed, please make sure the ajax is allowed for the ajax grid"); 1389 1389 } 1390 1390 1391 1391 //init widget by post id and element id 1392 1392 1393 1393 self::$platform = UniteFunctionsUC::getPostGetVariable("platform","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1394 1394 1395 1395 self::$isGutenberg = (self::$platform == "gutenberg"); 1396 1397 1396 1397 1398 1398 $layoutID = UniteFunctionsUC::getPostGetVariable("layoutid","",UniteFunctionsUC::SANITIZE_KEY); 1399 1399 $elementID = UniteFunctionsUC::getPostGetVariable("elid","",UniteFunctionsUC::SANITIZE_KEY); 1400 1400 1401 1401 $addElIDs = UniteFunctionsUC::getPostGetVariable("addelids","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1402 1402 $syncIDs = UniteFunctionsUC::getPostGetVariable("syncelids","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); //additional grids 1403 1403 1404 1404 $isModeFiltersInit = UniteFunctionsUC::getPostGetVariable("modeinit","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1405 1405 $isModeFiltersInit = UniteFunctionsUC::strToBool($isModeFiltersInit); 1406 1406 1407 1407 self::$isModeInit = $isModeFiltersInit; 1408 1408 1409 1409 $testTermIDs = UniteFunctionsUC::getPostGetVariable("testtermids","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1410 1410 UniteFunctionsUC::validateIDsList($testTermIDs); … … 1413 1413 $isModeReplace = UniteFunctionsUC::getPostGetVariable("ucreplace","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1414 1414 $isModeReplace = UniteFunctionsUC::strToBool($isModeReplace); 1415 1415 1416 1416 GlobalsProviderUC::$isUnderAjax = true; 1417 1417 1418 1418 self::$isModeReplace = $isModeReplace; 1419 1419 1420 1420 //if($isModeFiltersInit == true) 1421 1421 //GlobalsProviderUC::$skipRunPostQueryOnce = true; 1422 1422 1423 1423 if(self::$isGutenberg == false) 1424 1424 $arrContent = HelperProviderCoreUC_EL::getElementorContentByPostID($layoutID); 1425 1425 else{ //gutenberg 1426 1426 1427 1427 self::$objGutenberg = new UniteCreatorGutenbergIntegrate(); 1428 1428 1429 1429 $arrContent = self::$objGutenberg->getPostBlocks($layoutID); 1430 1430 } 1431 1431 1432 1432 if(empty($arrContent)) 1433 1433 UniteFunctionsUC::throwError(self::$platform." content not found"); 1434 1434 1435 1435 //run the post query 1436 1436 $arrHtmlWidget = $this->getContentWidgetHtml($arrContent, $elementID); 1437 1437 1438 1438 if(empty(GlobalsProviderUC::$lastPostQuery)) 1439 1439 self::$numTotalPosts = 0; 1440 1440 else 1441 1441 self::$numTotalPosts = GlobalsProviderUC::$lastPostQuery->found_posts; 1442 1442 1443 1443 //find the term id's for test (find or not in the current posts query) 1444 1444 if(!empty($testTermIDs)){ 1445 1445 1446 1446 if(self::$showDebug == true) 1447 1447 dmp("---- Test Not Empty Terms----"); 1448 1448 1449 1449 $args = GlobalsProviderUC::$lastQueryArgs; 1450 1450 1451 1451 if(self::$showDebug == true){ 1452 1452 dmp("--- Last Query Args:"); 1453 1453 dmp($args); 1454 1454 } 1455 1455 1456 1456 $query = new WP_Query($args); 1457 1457 1458 1458 $request = $query->request; 1459 1459 1460 1460 $taxRequest = $this->getInitFiltersTaxRequest($request, $testTermIDs); 1461 1461 1462 1462 if(self::$showDebug == true){ 1463 1463 1464 1464 dmp("---- Terms request: "); 1465 1465 dmp($taxRequest); 1466 1466 } 1467 1467 1468 1468 $arrFoundTermIDs = array(); 1469 1469 1470 1470 if(!empty($taxRequest)){ 1471 1471 1472 1472 $db = HelperUC::getDB(); 1473 1473 try{ 1474 1474 1475 1475 $arrFoundTermIDs = $db->fetchSql($taxRequest); 1476 1476 $arrFoundTermIDs = $this->modifyFoundTermsIDs($arrFoundTermIDs); 1477 1477 1478 1478 }catch(Exception $e){ 1479 1479 //just leave it empty 1480 1480 } 1481 1481 } 1482 1483 1482 1483 1484 1484 if(self::$showDebug == true){ 1485 1485 1486 1486 dmp("--- result - terms with num posts"); 1487 1487 dmp($arrFoundTermIDs); 1488 1488 } 1489 1489 1490 1490 //set the test term id's for the output 1491 GlobalsProviderUC::$arrTestTermIDs = $arrFoundTermIDs; 1492 } 1493 1491 GlobalsProviderUC::$arrTestTermIDs = $arrFoundTermIDs; 1492 } 1493 1494 1494 $htmlGridItems = UniteFunctionsUC::getVal($arrHtmlWidget, "html"); 1495 1495 $htmlGridItems2 = UniteFunctionsUC::getVal($arrHtmlWidget, "html2"); 1496 1496 1497 1497 //replace widget id 1498 $widgetHTMLID = UniteFunctionsUC::getVal($arrHtmlWidget, "uc_id"); 1499 1498 $widgetHTMLID = UniteFunctionsUC::getVal($arrHtmlWidget, "uc_id"); 1499 1500 1500 if(!empty($widgetHTMLID)){ 1501 1501 1502 1502 $htmlGridItems = str_replace($widgetHTMLID, "%uc_widget_id%", $htmlGridItems); 1503 1503 $htmlGridItems2 = str_replace($widgetHTMLID, "%uc_widget_id%", $htmlGridItems2); 1504 1504 } 1505 1505 1506 1506 $htmlDebug = UniteFunctionsUC::getVal($arrHtmlWidget, "html_debug"); 1507 1507 1508 1508 $addWidgetsHTML = $this->getContentWidgetsHTML($arrContent, $addElIDs); 1509 1509 1510 1510 $syncWidgetsHTML = $this->getContentWidgetsHTML($arrContent, $syncIDs, true); 1511 1511 1512 1512 1513 1513 //output the html 1514 $outputData = array(); 1515 1514 $outputData = array(); 1515 1516 1516 if(!empty($htmlDebug)) 1517 1517 $outputData["html_debug"] = $htmlDebug; 1518 1518 1519 1519 if($isModeFiltersInit == false){ 1520 1520 $outputData["html_items"] = $htmlGridItems; 1521 1521 1522 1522 $htmlGridItems2 = trim($htmlGridItems2); 1523 1523 1524 1524 if(!empty($htmlGridItems2)) 1525 1525 $outputData["html_items2"] = $htmlGridItems2; 1526 1527 } 1528 1526 1527 } 1528 1529 1529 if(!empty($addWidgetsHTML)) 1530 1530 $outputData["html_widgets"] = $addWidgetsHTML; 1531 1531 1532 1532 if(!empty($syncWidgetsHTML)) 1533 1533 $outputData["html_sync_widgets"] = $syncWidgetsHTML; 1534 1534 1535 1535 if(!empty($this->contentWidgetsDebug)) 1536 1536 $outputData["html_widgets_debug"] = $this->contentWidgetsDebug; 1537 1537 1538 1538 //add query data 1539 1539 1540 1540 $arrQueryData = HelperUC::$operations->getLastQueryData(); 1541 1541 1542 1542 $strQueryPostIDs = HelperUC::$operations->getLastQueryPostIDs(); 1543 1543 1544 1544 $outputData["query_data"] = $arrQueryData; 1545 1545 $outputData["query_ids"] = $strQueryPostIDs; 1546 1547 1546 1547 1548 1548 if(self::$showEchoDebug == true){ 1549 1549 1550 1550 dmp("The posts: "); 1551 1551 1552 1552 HelperUC::$operations->putPostsCustomFieldsDebug(GlobalsProviderUC::$lastPostQuery->posts); 1553 1553 1554 1554 dmp("showing the debug"); 1555 1555 1556 1556 exit(); 1557 1557 } 1558 1558 1559 1559 HelperUC::ajaxResponseData($outputData); 1560 1560 1561 1561 } 1562 1562 1563 1563 private function _______DYNAMIC_POPUP__________(){} 1564 1564 1565 1565 /** 1566 1566 * put dynamic popup cache 1567 1567 */ 1568 1568 private function putDynamicPopupCache(){ 1569 1569 1570 1570 $postID = 10767; 1571 1571 1572 1572 $templateID = 9532; 1573 1573 1574 1574 $widgetID = "max111"; 1575 1575 1576 1576 $post = get_post($postID); 1577 1577 1578 1578 $template = get_post($templateID); 1579 1579 1580 1580 //dmp($template);exit(); 1581 1581 1582 1582 HelperProviderCoreUC_EL::putListingItemTemplate_post($post, $templateID, $widgetID); 1583 1584 1585 1583 1584 1585 1586 1586 dmp("dynamic popup cache"); 1587 1587 exit(); 1588 1589 } 1590 1588 1589 } 1590 1591 1591 private function _______AJAX_SEARCH__________(){} 1592 1592 1593 1593 /** 1594 1594 * before custom posts query … … 1596 1596 */ 1597 1597 public function onBeforeCustomPostsQuery($query){ 1598 1598 1599 1599 if(GlobalsProviderUC::$isUnderAjaxSearch == false) 1600 1600 return(false); 1601 1601 1602 1602 global $wp_the_query; 1603 1603 $wp_the_query = $query; 1604 1604 } 1605 1606 1605 1606 1607 1607 /** 1608 1608 * ajax search … … 1611 1611 1612 1612 self::$isUnderAjaxSearch = true; 1613 1613 1614 1614 $responseCode = http_response_code(); 1615 1615 1616 1616 if($responseCode != 200) 1617 1617 http_response_code(200); 1618 1618 1619 1619 define("UE_AJAX_SEARCH_ACTIVE", true); 1620 1620 1621 1621 $layoutID = UniteFunctionsUC::getPostGetVariable("layoutid","",UniteFunctionsUC::SANITIZE_KEY); 1622 1622 $elementID = UniteFunctionsUC::getPostGetVariable("elid","",UniteFunctionsUC::SANITIZE_KEY); 1623 1623 1624 1624 $arrContent = HelperProviderCoreUC_EL::getElementorContentByPostID($layoutID); 1625 1625 1626 1626 if(empty($arrContent)) 1627 1627 UniteFunctionsUC::throwError("Elementor content not found"); 1628 1628 1629 1629 //run the post query 1630 1630 GlobalsProviderUC::$isUnderAjaxSearch = true; 1631 1631 1632 1632 //for outside filters - check that under ajax 1633 1633 1634 1634 $arrHtmlWidget = $this->getContentWidgetHtml($arrContent, $elementID); 1635 1635 1636 1636 GlobalsProviderUC::$isUnderAjaxSearch = false; 1637 1637 1638 1638 $htmlGridItems = UniteFunctionsUC::getVal($arrHtmlWidget, "html"); 1639 1639 $htmlGridItems2 = UniteFunctionsUC::getVal($arrHtmlWidget, "html2"); 1640 1640 1641 1641 $htmlDebug = UniteFunctionsUC::getVal($arrHtmlWidget, "html_debug"); 1642 1642 1643 1643 //output the html 1644 $outputData = array(); 1645 1644 $outputData = array(); 1645 1646 1646 if(!empty($htmlDebug)) 1647 1647 $outputData["html_debug"] = $htmlDebug; 1648 1648 1649 1649 $outputData["html_items"] = $htmlGridItems; 1650 1650 1651 1651 $htmlGridItems2 = trim($htmlGridItems2); 1652 1652 1653 1653 if(!empty($htmlGridItems2)) 1654 1654 $outputData["html_items2"] = $htmlGridItems2; 1655 1656 1655 1656 1657 1657 HelperUC::ajaxResponseData($outputData); 1658 1658 } 1659 1659 1660 1660 private function _______WIDGET__________(){} 1661 1662 1661 1662 1663 1663 /** 1664 1664 * include the filters js files 1665 1665 */ 1666 1666 private function includeJSFiles(){ 1667 1667 1668 1668 if(self::$isFilesAdded == true) 1669 1669 return(false); 1670 1670 1671 1671 UniteProviderFunctionsUC::addAdminJQueryInclude(); 1672 1672 1673 1673 $urlFiltersJS = GlobalsUC::$url_assets_libraries."filters/ue_filters.js"; 1674 HelperUC::addScriptAbsoluteUrl_widget($urlFiltersJS, "ue_filters"); 1675 1674 HelperUC::addScriptAbsoluteUrl_widget($urlFiltersJS, "ue_filters"); 1675 1676 1676 self::$isFilesAdded = true; 1677 1677 } 1678 1678 1679 1679 /** 1680 1680 * put custom scripts 1681 1681 */ 1682 1682 private function putCustomJsScripts(){ 1683 1683 1684 1684 if(self::$isScriptAdded == true) 1685 1685 return(false); 1686 1686 1687 1687 self::$isScriptAdded = true; 1688 1688 1689 1689 $arrData = $this->getFiltersJSData(); 1690 1690 1691 1691 $strData = UniteFunctionsUC::jsonEncodeForClientSide($arrData); 1692 1692 1693 1693 $script = "/* Unlimited Elements Filters */ \n"; 1694 1694 $script .= "window.g_strFiltersData = {$strData};"; 1695 1695 1696 1696 UniteProviderFunctionsUC::printCustomScript($script); 1697 1697 } 1698 1698 1699 1699 /** 1700 1700 * put custom style 1701 1701 */ 1702 1702 private function putCustomStyle(){ 1703 1703 1704 1704 if(self::$isStyleAdded == true) 1705 1705 return(false); 1706 1706 1707 1707 self::$isStyleAdded = true; 1708 1708 1709 1709 $style = " 1710 1710 .uc-ajax-loading{ … … 1712 1712 } 1713 1713 "; 1714 1714 1715 1715 UniteProviderFunctionsUC::printCustomStyle($style); 1716 1716 } 1717 1718 1717 1718 1719 1719 /** 1720 1720 * include the client side scripts 1721 1721 */ 1722 1722 private function includeClientSideScripts(){ 1723 1723 1724 1724 $isInsideEditor = GlobalsProviderUC::$isInsideEditor; 1725 1725 1726 1726 if($isInsideEditor == true) 1727 1727 return(false); 1728 1728 1729 1729 $this->includeJSFiles(); 1730 1730 1731 1731 $this->putCustomJsScripts(); 1732 1732 1733 1733 $this->putCustomStyle(); 1734 1735 } 1736 1737 1738 1734 1735 } 1736 1737 1738 1739 1739 /** 1740 1740 * get active archive terms 1741 1741 */ 1742 1742 private function getActiveArchiveTerms($taxonomy){ 1743 1743 1744 1744 if(is_archive() == false) 1745 1745 return(null); … … 1749 1749 if(empty($currentTerm)) 1750 1750 return(null); 1751 1751 1752 1752 if($currentTerm instanceof WP_Term == false) 1753 1753 return(null); 1754 1754 1755 1755 $termID = $currentTerm->term_id; 1756 1756 1757 1757 $args = array(); 1758 1758 $args["taxonomy"] = $taxonomy; 1759 1759 $args["parent"] = $termID; 1760 1760 1761 1761 $arrTerms = get_terms($args); 1762 1762 1763 1763 return($arrTerms); 1764 1764 } 1765 1766 1767 1765 1766 1767 1768 1768 /** 1769 1769 * add values to settings from data … … 1771 1771 */ 1772 1772 public function addWidgetFilterableVarsFromData($data, $dataPosts, $postListName, $arrPostIDs = null){ 1773 1773 1774 1774 //check if ajax related 1775 1775 $isAjax = UniteFunctionsUC::getVal($dataPosts, $postListName."_isajax"); 1776 1776 $isAjax = UniteFunctionsUC::strToBool($isAjax); 1777 1777 1778 1778 $addClass = ""; 1779 1779 $strAttributes = ""; 1780 1780 1781 1781 //avoid duplicates handle 1782 1782 1783 1783 if(!empty($arrPostIDs)){ 1784 1784 1785 1785 $addClass = " uc-avoid-duplicates"; 1786 1786 1787 1787 $strPostIDs = implode(",", $arrPostIDs); 1788 1788 $strAttributes = " data-postids='$strPostIDs'"; 1789 1790 } 1791 1789 1790 } 1791 1792 1792 if($isAjax == false){ 1793 1793 1794 1794 $data["uc_filtering_attributes"] = $strAttributes; 1795 1795 $data["uc_filtering_addclass"] = $addClass; 1796 1796 1797 1797 return($data); 1798 1798 } 1799 1800 1799 1800 1801 1801 //all ajax related 1802 1802 1803 1803 $addClass .= " uc-filterable-grid"; 1804 1804 1805 1805 $filterBehavoiur = UniteFunctionsUC::getVal($dataPosts, $postListName."_ajax_seturl"); 1806 1806 1807 1807 $strAttributes .= " data-ajax='true' "; 1808 1808 1809 1809 if(!empty($filterBehavoiur)) 1810 1810 $strAttributes .= " data-filterbehave='$filterBehavoiur' "; 1811 1811 1812 1812 //add ajax group 1813 1813 1814 1814 $filterGroup = UniteFunctionsUC::getVal($dataPosts, $postListName."_filtering_group"); 1815 1815 1816 1816 if(!empty($filterGroup)){ 1817 1817 $filterGroup = esc_attr($filterGroup); 1818 1818 $strAttributes .= " data-filtergroup='$filterGroup' "; 1819 1819 } 1820 1821 1820 1821 1822 1822 //add last query 1823 1823 $arrQueryData = HelperUC::$operations->getLastQueryData(); 1824 1824 1825 1825 $jsonQueryData = UniteFunctionsUC::jsonEncodeForHtmlData($arrQueryData); 1826 1826 1827 1827 $strAttributes .= " querydata='$jsonQueryData'"; 1828 1828 1829 1829 $this->includeClientSideScripts(); 1830 1830 1831 1831 $data["uc_filtering_attributes"] = $strAttributes; 1832 1832 $data["uc_filtering_addclass"] = $addClass; 1833 1833 1834 1834 return($data); 1835 1835 } 1836 1836 1837 1837 /** 1838 1838 * add widget variables … … 1840 1840 */ 1841 1841 public function addWidgetFilterableVariables($data, $addon, $arrPostIDs = array()){ 1842 1842 1843 1843 $param = $addon->getParamByType(UniteCreatorDialogParam::PARAM_POSTS_LIST); 1844 1844 1845 1845 if(empty($param)) 1846 1846 return($data); 1847 1847 1848 1848 $postListName = UniteFunctionsUC::getVal($param, "name"); 1849 1849 1850 1850 $dataPosts = UniteFunctionsUC::getVal($data, $postListName); 1851 1851 1852 1852 $data = $this->addWidgetFilterableVarsFromData($data, $dataPosts, $postListName, $arrPostIDs); 1853 1853 1854 1854 return($data); 1855 1855 } … … 1857 1857 /** 1858 1858 * default sign is "~" 1859 * 1859 * 1860 1860 */ 1861 1861 private function getUrlPartsKeys(){ 1862 1862 1863 1863 $arrParts = array(); 1864 1864 $arrParts["tax_sap"] = apply_filters("ue_filters_url_key__taxonomy_sap","~"); 1865 1865 1866 1866 return($arrParts); 1867 1867 } 1868 1868 1869 1869 /** 1870 1870 * get filters attributes … … 1872 1872 */ 1873 1873 private function getFiltersJSData(){ 1874 1874 1875 1875 $urlBase = UniteFunctionsUC::getBaseUrl(GlobalsUC::$current_page_url, true); //strip pagination 1876 1876 1877 1877 //include some common url filters 1878 1878 $orderby = UniteFunctionsUC::getGetVar("orderby","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1879 1879 1880 1880 if(!empty($orderby)){ 1881 1881 $orderby = urlencode($orderby); 1882 1882 $urlBase = UniteFunctionsUC::addUrlParams($urlBase, "orderby=$orderby"); 1883 1883 } 1884 1884 1885 1885 //include the search if exists 1886 1886 1887 1887 $search = UniteFunctionsUC::getGetVar("s","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1888 1888 1889 1889 if(empty($search)){ 1890 1890 $search = null; 1891 1891 1892 1892 if(isset($_GET["s"]) && $_GET["s"] == "") 1893 1893 $search = ""; 1894 1894 } 1895 1896 1895 1897 1896 if($search !== null){ 1898 1897 $search = urlencode($search); … … 1911 1910 1912 1911 //debug client url 1913 1912 1914 1913 $isDebug = UniteFunctionsUC::getGetVar("ucfiltersdebug","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1915 1914 $isDebug = UniteFunctionsUC::strToBool($isDebug); 1916 1915 1917 1916 //get url parts 1918 1917 $arrUrlKeys = $this->getUrlPartsKeys(); 1919 1918 1920 1919 //get current filters 1921 1920 1922 1921 $arrData = array(); 1923 1922 $arrData["platform"] = GlobalsProviderUC::$renderPlatform; … … 1926 1925 $arrData["urlkeys"] = $arrUrlKeys; 1927 1926 $arrData["postid"] = get_the_id(); 1928 1929 1927 1928 1930 1929 if($isDebug == true) 1931 1930 $arrData["debug"] = true; 1932 1931 1933 1932 return($arrData); 1934 1933 } 1935 1936 1934 1935 1937 1936 private function _____MODIFY_PARAMS_PROCESS_TERMS_______(){} 1938 1939 1937 1938 1940 1939 /** 1941 1940 * check if term selected by request 1942 1941 */ 1943 1942 private function isTermSelectedByRequest($term, $selectedTerms){ 1944 1943 1945 1944 $taxonomy = UniteFunctionsUC::getVal($term, "taxonomy"); 1946 1945 1947 1946 if(empty($taxonomy)) 1948 1947 return(false); 1949 1948 1950 1949 $arrSlugs = UniteFunctionsUC::getVal($selectedTerms, $taxonomy); 1951 1950 1952 1951 if(empty($arrSlugs)) 1953 1952 return(false); 1954 1953 1955 1954 $slug = UniteFunctionsUC::getVal($term, "slug"); 1956 1955 1957 1956 $found = in_array($slug, $arrSlugs); 1958 1957 1959 1958 return($found); 1960 1959 } 1961 1962 1960 1961 1963 1962 /** 1964 1963 * modify selected by request … … 1967 1966 1968 1967 $this->hasSelectedByRequest = false; 1969 1968 1970 1969 $selectedTerms = null; 1971 1970 $selectedTermIDs = null; 1972 1971 1973 1972 //if mode init - get selected id's from request 1974 1973 if(self::$isModeInit == true){ 1975 1974 1976 1975 $strSelectedTermIDs = UniteFunctionsUC::getPostGetVariable("ucinitselectedterms","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 1977 1976 1978 1977 if(empty($strSelectedTermIDs)) 1979 1978 return($arrTerms); 1980 1979 1981 1980 UniteFunctionsUC::validateIDsList($strSelectedTermIDs,"selected terms"); 1982 1981 1983 1982 $selectedTermIDs = explode(",", $strSelectedTermIDs); 1984 1983 1985 1984 if(empty($selectedTermIDs)) 1986 1985 return($arrTerms); 1987 1986 1988 1987 }else{ 1989 1988 1990 1989 $arrRequest = $this->getRequestFilters(); 1991 1990 1992 1991 if(empty($arrRequest)) 1993 1992 return($arrTerms); 1994 1993 1995 1994 $selectedTerms = UniteFunctionsUC::getVal($arrRequest, "terms"); 1996 1995 1997 1996 if(empty($selectedTerms)) 1998 1997 return($arrTerms); 1999 2000 } 2001 2002 1998 1999 } 2000 2001 2003 2002 $arrSelected = array(); 2004 2003 2005 2004 foreach($arrTerms as $index => $term){ 2006 2005 2007 2006 if(!empty($selectedTerms)) 2008 2007 $isSelected = $this->isTermSelectedByRequest($term, $selectedTerms); 2009 2008 else{ 2010 2009 2011 2010 $termID = UniteFunctionsUC::getVal($term, "id"); 2012 2011 if(empty($termID)) 2013 2012 continue; 2014 2013 2015 2014 $isSelected = in_array($termID, $selectedTermIDs); 2016 2015 } 2017 2016 2018 2017 if($isSelected == false) 2019 2018 continue; 2020 2019 2021 2020 2022 2021 $arrSelected["term_".$index] = true; 2023 2022 } 2024 2023 2025 2024 if(empty($arrSelected)) 2026 2025 return($arrTerms); 2027 2026 2028 2027 $this->hasSelectedByRequest = true; 2029 2028 2030 2029 //modify the selected 2031 2030 2032 2031 foreach($arrTerms as $index => $term){ 2033 2032 2034 2033 $isSelected = UniteFunctionsUC::getVal($arrSelected, "term_".$index); 2035 2034 2036 2035 if($isSelected == true){ 2037 2036 $term["iscurrent"] = true; 2038 2037 $term["isselected"] = true; 2039 2038 2040 2039 }else{ 2041 2040 2042 2041 $term["iscurrent"] = false; 2043 2042 $term["isselected"] = false; 2044 2043 $term["class_selected"] = ""; 2045 2044 } 2046 2045 2047 2046 $arrTerms[$index] = $term; 2048 2047 } 2049 2048 2050 2049 return($arrTerms); 2051 2050 } 2052 2053 2051 2052 2054 2053 /** 2055 2054 * modify filters - add first item 2056 2055 */ 2057 2056 private function modifyOutputTerms_addFirstItem($arrTerms, $data, $filterType){ 2058 2057 2059 2058 //don't add first item if no terms, if no terms, no "all" as well 2060 2059 2061 2060 if(empty($arrTerms)) 2062 2061 return(array()); 2063 2062 2064 2063 $addFirst = UniteFunctionsUC::getVal($data, "add_first"); 2065 2064 $addFirst = UniteFunctionsUC::strToBool($addFirst); 2066 2065 2067 2066 if($addFirst == false) 2068 2067 return($arrTerms); 2069 2070 2068 2069 2071 2070 $text = UniteFunctionsUC::getVal($data, "first_item_text", __("All","unlimited-elements-for-elementor")); 2072 2071 2073 2072 $firstTerm = array(); 2074 2073 $firstTerm["index"] = 0; … … 2078 2077 $firstTerm["parent_id"] = ""; 2079 2078 $firstTerm["taxonomy"] = ""; 2080 2079 2081 2080 $firstTerm["addclass"] = " uc-item-all"; 2082 2081 2083 2082 if(!empty(self::$numTotalPosts)) 2084 2083 $firstTerm["num_posts"] = self::$numTotalPosts; 2085 2084 2086 2085 array_unshift($arrTerms, $firstTerm); 2087 2086 2088 2087 return($arrTerms); 2089 2088 } 2090 2091 2089 2090 2092 2091 /** 2093 2092 * modify the selected - first selected from options 2094 2093 */ 2095 2094 private function modifyOutputTerms_modifySelected($arrTerms, $data, $filterType){ 2096 2095 2097 2096 if(empty($arrTerms)) 2098 2097 return($arrTerms); 2099 2098 2100 2099 $isSelectFirst = UniteFunctionsUC::getVal($data, "select_first"); 2101 2100 $isSelectFirst = UniteFunctionsUC::strToBool($isSelectFirst); 2102 2101 2103 2102 if($filterType == self::TYPE_SELECT) 2104 2103 $isSelectFirst = true; 2105 2104 2106 2105 if($filterType == self::TYPE_TABS){ 2107 2106 2108 2107 $role = UniteFunctionsUC::getVal($data, "filter_role"); 2109 2108 2110 2109 if(strpos($role,"child") !== false) 2111 2110 $isSelectFirst = false; 2112 2111 } 2113 2112 2114 2113 if($isSelectFirst == false) 2115 return($arrTerms); 2116 2114 return($arrTerms); 2115 2117 2116 $numSelectedTab = UniteFunctionsUC::getVal($data, "selected_tab_number"); 2118 2117 if(empty($numSelectedTab)) 2119 2118 $numSelectedTab = 1; 2120 2119 2121 2120 //correct selected tab 2122 2121 2123 2122 $numTerms = count($arrTerms); 2124 2123 2125 2124 if($isSelectFirst == true && $numSelectedTab > $numTerms) 2126 2125 $numSelectedTab = 1; 2127 2126 2128 2127 $firstNotHiddenIndex = null; 2129 2128 2130 2129 $hasSelectedTerm = false; 2131 2130 2132 2131 foreach($arrTerms as $index => $term){ 2133 2132 2134 2133 //set the index 2135 2134 $numTab = ($index + 1); 2136 2135 2137 2136 $term["index"] = $index; 2138 2137 2139 2138 //check if hidden 2140 2139 2141 2140 $isHidden = UniteFunctionsUC::getVal($term, "hidden"); 2142 2141 $isHidden = UniteFunctionsUC::strToBool($isHidden); 2143 2142 2144 2143 if($isHidden == true) 2145 2144 continue; 2146 2145 2147 2146 if($firstNotHiddenIndex === null) 2148 2147 $firstNotHiddenIndex = $index; 2149 2148 2150 2149 if($numTab == $numSelectedTab){ 2151 2150 $term["isselected"] = true; 2152 2151 $hasSelected = true; 2153 2152 } 2154 2153 2155 2154 $arrTerms[$index] = $term; 2156 2155 } 2157 2156 2158 2157 if($hasSelected == true) 2159 2158 return($arrTerms); 2160 2159 2161 2160 if($firstNotHiddenIndex === null) 2162 2161 return($arrTerms); 2163 2162 2164 2163 if($filterType != self::TYPE_SELECT) 2165 2164 return($arrTerms); 2166 2165 2167 2166 //make sure the first item selected in select filter 2168 2167 if($isSelectFirst == true) 2169 2168 $arrTerms[$firstNotHiddenIndex]["isselected"] = true; 2170 2171 2169 2170 2172 2171 return($arrTerms); 2173 2172 } 2174 2175 2176 /** 2177 * modify the terms for init after 2173 2174 2175 /** 2176 * modify the terms for init after 2178 2177 */ 2179 2178 private function modifyOutputTerms_setNumPosts($arrTerms){ 2180 2179 2181 2180 if(GlobalsProviderUC::$arrTestTermIDs === null) 2182 2181 return($arrTerms); 2183 2182 2184 2183 $arrParentNumPosts = array(); 2185 2184 2186 2185 $arrPostNums = GlobalsProviderUC::$arrTestTermIDs; 2187 2186 2188 2187 foreach($arrTerms as $key => $term){ 2189 2188 2190 2189 $termID = UniteFunctionsUC::getVal($term, "id"); 2191 2190 2192 2191 $termFound = array_key_exists($termID, $arrPostNums); 2193 2192 2194 2193 $numPosts = 0; 2195 2194 2196 2195 if($termFound){ 2197 2196 $numPosts = $arrPostNums[$termID]; 2198 2197 } 2199 2198 2200 2199 //add parent id if exists 2201 2200 $parentID = UniteFunctionsUC::getVal($term, "parent_id"); 2202 2201 2203 2202 //set the number of posts 2204 2203 $term["num_posts"] = $numPosts; 2205 2204 2206 2205 if(!empty($term["num_products"])) 2207 2206 $term["num_products"] = $numPosts; 2208 2207 2209 2208 $isHidden = !$termFound; 2210 2209 2211 2210 if($numPosts == 0) 2212 2211 $isHidden = true; 2213 2212 2214 2213 $htmlAttributes = ""; 2215 2214 $htmlAttributesNew = ""; 2216 2215 2217 2216 if($isHidden == true){ 2218 2217 $htmlAttributes = "hidden='hidden' style='display:none'"; 2219 2218 $htmlAttributesNew = "hidden='hidden' "; //no style 2220 2219 2221 2220 $addClass = UniteFunctionsUC::getVal($term, "addclass"); 2222 2221 $addClass .= " uc-item-hidden"; 2223 2222 2224 2223 $term["addclass"] = $addClass; 2225 2224 } 2226 2225 2227 2226 $term["hidden"] = $isHidden; 2228 2227 $term["html_attributes"] = $htmlAttributes; 2229 2228 $term["html_attributes2"] = $htmlAttributesNew; 2230 2231 $arrTerms[$key] = $term; 2232 } 2233 2234 2229 2230 $arrTerms[$key] = $term; 2231 } 2232 2233 2235 2234 return($arrTerms); 2236 2235 } 2237 2238 2236 2237 2239 2238 /** 2240 2239 * modify limit loaded items 2241 2240 */ 2242 2241 private function modifyOutputTerms_tabs_modifyLimitGrayed($arrTerms, $limitGrayedItems){ 2243 2242 2244 2243 if(empty($limitGrayedItems)) 2245 2244 return($arrTerms); 2246 2245 2247 2246 $numTerms = count($arrTerms); 2248 2247 2249 2248 if($numTerms < $limitGrayedItems) 2250 2249 return($arrTerms); 2251 2250 2252 2251 foreach($arrTerms as $index => $term){ 2253 2252 2254 2253 if($index < $limitGrayedItems) 2255 2254 continue; 2256 2255 2257 2256 $addClass = UniteFunctionsUC::getVal($term, "addclass"); 2258 2257 $addClass .= " uc-hide-loading-item"; 2259 2258 2260 2259 $term["addclass"] = $addClass; 2261 2260 2262 2261 $arrTerms[$index] = $term; 2263 2262 } 2264 2265 2266 return($arrTerms); 2267 } 2268 2263 2264 2265 return($arrTerms); 2266 } 2267 2269 2268 /** 2270 2269 * set selected class by options 2271 2270 */ 2272 2271 private function modifyOutputTerms_setSelectedClass($arrTerms, $filterType){ 2273 2272 2274 2273 if(empty($arrTerms)) 2275 2274 return($arrTerms); 2276 2275 2277 2276 foreach($arrTerms as $index => $term){ 2278 2277 2279 2278 $isSelected = UniteFunctionsUC::getVal($term, "isselected"); 2280 2279 $isSelected = UniteFunctionsUC::strToBool($isSelected); 2281 2280 2282 2281 if($isSelected == false) 2283 2282 continue; 2284 2283 2285 2284 //hidden can't be selected 2286 2285 2287 2286 $isHidden = UniteFunctionsUC::getVal($term, "hidden"); 2288 2287 $isHidden = UniteFunctionsUC::strToBool($isHidden); 2289 2288 2290 2289 if($isHidden == true) 2291 2290 continue; 2292 2291 2293 2292 $class = UniteFunctionsUC::getVal($term, "addclass",""); 2294 2293 $class .= " uc-selected"; 2295 2294 2296 2295 $term["addclass"] = $class; 2297 2296 2298 2297 //set select attribute 2299 2298 switch($filterType){ 2300 2299 case self::TYPE_SELECT: 2301 2300 2302 2301 $htmlAttributes = UniteFunctionsUC::getVal($term, "html_attributes"); 2303 2302 2304 2303 if(empty($htmlAttributes)) 2305 2304 $htmlAttributes = ""; 2306 2305 2307 2306 $htmlAttributes .= " selected"; 2308 2307 2309 2308 $term["html_attributes"] = $htmlAttributes; 2310 2309 2311 2310 break; 2312 2311 case self::TYPE_CHECKBOX: 2313 2312 2314 2313 $term["html_attributes_input"] = " checked"; 2315 2314 2316 2315 break; 2317 2316 } 2318 2317 2319 2318 //set hasSelected - true, only if there are some selected slug 2320 2319 2321 2320 $selectedSlug = UniteFunctionsUC::getVal($term, "slug"); 2322 2321 2323 2322 if(!empty($selectedSlug)) 2324 2323 $this->hasSelectedTerm = true; 2325 2324 2326 2325 $arrTerms[$index] = $term; 2327 2328 } 2329 2330 2326 2327 } 2328 2329 2331 2330 return($arrTerms); 2332 2331 } 2333 2334 2332 2333 2335 2334 /** 2336 2335 * check if filter should be hidden, if selected items avaliable … … 2338 2337 */ 2339 2338 private function modifyOutputTerms_isFilterHidden($data, $arrTerms, $isUnderAjax){ 2340 2339 2341 2340 if($isUnderAjax == false) 2342 2341 return(false); 2343 2342 2344 2343 $role = UniteFunctionsUC::getVal($data, "filter_role"); 2345 2344 2346 2345 if($role != "child") 2347 2346 return(false); 2348 2347 2349 2348 if(empty($arrTerms)) 2350 2349 return(true); 2351 2350 2352 2351 //get number of not hidden items 2353 2352 2354 2353 $numItems = 0; 2355 2354 2356 2355 foreach($arrTerms as $term){ 2357 2356 2358 2357 $isHidden = UniteFunctionsUC::getVal($term, "hidden"); 2359 2358 $isHidden = UniteFunctionsUC::strToBool($isHidden); 2360 2359 2361 2360 if($isHidden == true) 2362 2361 continue; 2363 2362 2364 2363 $numItems++; 2365 2364 } 2366 2365 2367 2366 if($numItems > 1) 2368 2367 return(false); 2369 2368 2370 2369 $firstItem = $arrTerms[0]; 2371 2370 2372 2371 $slug = UniteFunctionsUC::getVal($firstItem, "slug"); 2373 2372 2374 2373 $isAllItem = empty($slug); 2375 2374 2376 2375 //if there is only "all" item, it should be hidden as well 2377 2376 2378 2377 if($isAllItem == true) 2379 return(true); 2380 2381 return(false); 2382 } 2383 2378 return(true); 2379 2380 return(false); 2381 } 2382 2384 2383 /** 2385 2384 * get data attributes 2386 2385 */ 2387 2386 private function modifyOutputTerms_getDataAttributes($arrTerms, $filterType){ 2388 2387 2389 2388 foreach($arrTerms as $index => $term){ 2390 2389 2391 2390 $termID = UniteFunctionsUC::getVal($term, "id"); 2392 2391 2393 2392 if(empty($termID)) 2394 2393 continue; 2395 2394 2396 2395 $title = UniteFunctionsUC::getVal($term, "name"); 2397 2396 $slug = UniteFunctionsUC::getVal($term, "slug"); 2398 2397 $taxonomy = UniteFunctionsUC::getVal($term, "taxonomy"); 2399 2398 2400 2399 $type = "term"; 2401 2400 2402 2401 $title = esc_attr($title); 2403 2402 $slug = esc_attr($slug); 2404 2403 $taxonomy = esc_attr($taxonomy); 2405 2404 2406 2405 $key = "{$type}|{$taxonomy}|{$slug}"; 2407 2406 2408 2407 $htmlData = " data-id=\"$termID\" data-type=\"$type\" data-slug=\"$slug\" data-taxonomy=\"$taxonomy\" data-title=\"{$title}\" data-key=\"{$key}\" "; 2409 2408 2410 2409 $term["html_data"] = $htmlData; 2411 2410 2412 2411 $arrTerms[$index] = $term; 2413 2412 } 2414 2413 2415 2414 return($arrTerms); 2416 2415 } 2417 2418 2419 2416 2417 2418 2420 2419 /** 2421 2420 * get editor filter arguments 2422 2421 */ 2423 2422 public function addEditorFilterArguments($data, $typeArg){ 2424 2423 2425 2424 $filterType = self::TYPE_TABS; 2426 2425 2427 2426 switch($typeArg){ 2428 2427 case "type_select": … … 2433 2432 break; 2434 2433 } 2435 2436 2434 2435 2437 2436 //add the filter related js and css includes 2438 2437 $this->includeClientSideScripts(); 2439 2438 2440 2439 $isInitAfter = UniteFunctionsUC::getVal($data, "init_after"); 2441 2440 $isInitAfter = UniteFunctionsUC::strToBool($isInitAfter); 2442 2441 2443 2442 $isReplaceTerms = UniteFunctionsUC::getVal($data, "replace_terms"); 2444 2443 $isReplaceTerms = UniteFunctionsUC::strToBool($isReplaceTerms); 2445 2444 2446 2445 $limitGrayedItems = UniteFunctionsUC::getVal($data, "load_limit_grayed"); 2447 2446 $limitGrayedItems = (int)$limitGrayedItems; 2448 2447 2449 2448 $filterRole = UniteFunctionsUC::getVal($data, "filter_role"); 2450 if($filterRole == "single") 2449 if($filterRole == "single") 2451 2450 $filterRole = ""; 2452 2451 2453 2452 $attributes = ""; 2454 2453 $style = ""; … … 2456 2455 $addClassItem = ""; 2457 2456 $isFirstLoad = true; //not in ajax, or with init after (also first load) 2458 2457 2459 2458 $connectGroup = UniteFunctionsUC::getVal($data, "connect_group"); 2460 2459 2461 2460 if($connectGroup == "auto") 2462 2461 $connectGroup = null; 2463 2462 2464 2463 $isInsideEditor = GlobalsProviderUC::$isInsideEditor; 2465 2464 2466 2465 $isUnderAjax = self::$isUnderAjax; 2467 2466 2468 2467 if($isUnderAjax == true) 2469 2468 $isFirstLoad = false; 2470 2469 2471 2470 if($isInitAfter == true){ 2472 2471 2473 2472 $attributes = " data-initafter=\"true\""; 2474 2473 2475 2474 if($isUnderAjax == false && $isInsideEditor == false){ 2476 2475 $addClassItem = " uc-filter-item-hidden"; 2477 2476 $addClass .= " uc-filter-initing"; 2478 2477 } 2479 2478 2480 2479 $isFirstLoad = true; 2481 2480 } 2482 2481 2483 2482 if($filterRole == self::ROLE_TERM_CHILD){ 2484 2483 2485 2484 $termID = UniteFunctionsUC::getVal($data, "child_termid"); 2486 2485 2487 2486 if(!empty($termID)) 2488 2487 $attributes .= " data-childterm=\"$termID\""; 2489 2490 } 2491 2488 2489 } 2490 2492 2491 if(!empty($connectGroup)) 2493 2492 $attributes .= " data-connectgroup=\"$connectGroup\""; 2494 2495 2493 2494 2496 2495 if($isInsideEditor == true) 2497 2496 $isFirstLoad = true; 2498 2497 2499 2498 //main filter 2500 2499 2501 2500 if(!empty($filterRole)) 2502 2501 $attributes .= " data-role=\"{$filterRole}\""; 2503 2502 2504 2503 if($isReplaceTerms == true) 2505 2504 $attributes .= " data-replace-mode=\"true\""; 2506 2507 2505 2506 2508 2507 //modify terms 2509 2508 2510 2509 $arrTerms = UniteFunctionsUC::getVal($data, "taxonomy"); 2511 2510 2512 2511 //modify the hidden as well 2513 2512 2514 2513 $arrTerms = $this->modifyOutputTerms_setNumPosts($arrTerms, $isInitAfter, $isFirstLoad); 2515 2514 2516 2515 //modify the selected class - add first 2517 2516 $arrTerms = $this->modifyOutputTerms_addFirstItem($arrTerms, $data, $filterType); 2518 2517 2519 2518 //modify the selected class 2520 2519 $arrTerms = $this->modifyOutputTerms_modifySelected($arrTerms, $data,$filterType); 2521 2520 2522 2521 $arrTerms = $this->modifyOutputTerms_modifySelectedByRequest($arrTerms); 2523 2522 2524 2523 $isFilterHidden = false; 2525 2524 2526 2525 switch($filterType){ 2527 2526 case self::TYPE_TABS: 2528 2527 case self::TYPE_CHECKBOX: 2529 2528 2530 2529 if($isInitAfter == true && !empty($limitGrayedItems) && $isUnderAjax == false) 2531 2530 $arrTerms = $this->modifyOutputTerms_tabs_modifyLimitGrayed($arrTerms, $limitGrayedItems); 2532 2531 2533 2532 $isFilterHidden = $this->modifyOutputTerms_isFilterHidden($data, $arrTerms, $isUnderAjax); 2534 2533 2535 2534 break; 2536 2535 case self::TYPE_SELECT: 2537 2536 2538 2537 //modify if hidden 2539 2538 2540 2539 $isFilterHidden = $this->modifyOutputTerms_isFilterHidden($data, $arrTerms, $isUnderAjax); 2541 2540 break; 2542 2541 } 2543 2544 2542 2543 2545 2544 $arrTerms = $this->modifyOutputTerms_setSelectedClass($arrTerms, $filterType); 2546 2545 2547 2546 $arrTerms = $this->modifyOutputTerms_getDataAttributes($arrTerms, $filterType); 2548 2549 2550 //hide child filter at start 2551 2552 if(strpos($filterRole,"child") !== false && 2553 $isUnderAjax == false && 2547 2548 2549 //hide child filter at start 2550 2551 if(strpos($filterRole,"child") !== false && 2552 $isUnderAjax == false && 2554 2553 $isInsideEditor == false){ 2555 2554 2556 2555 $addClass .= " uc-filter-initing uc-initing-filter-hidden"; 2557 2556 } 2558 2557 2559 2558 if($this->hasSelectedTerm == true) 2560 2559 $addClass .= " uc-has-selected"; 2561 2560 2562 2561 if($isFilterHidden) 2563 2562 $addClass .= " uc-filter-hidden"; 2564 2563 2565 2564 $data["filter_isajax"] = $isUnderAjax?"yes":"no"; 2566 2565 $data["filter_attributes"] = $attributes; … … 2569 2568 $data["filter_addclass_item"] = $addClassItem; 2570 2569 $data["filter_first_load"] = $isFirstLoad?"yes":"no"; 2571 2570 2572 2571 $data["taxonomy"] = $arrTerms; 2573 2574 2572 2573 2575 2574 return($data); 2576 2575 } 2577 2578 2576 2577 2579 2578 private function _______MAIN__________(){} 2580 2581 2579 2580 2582 2581 /** 2583 2582 * show the main query debug 2584 2583 */ 2585 2584 private function showMainQueryDebug(){ 2586 2585 2587 2586 global $wp_query; 2588 2587 2589 2588 $args = $wp_query->query_vars; 2590 2589 2591 2590 $argsForDebug = UniteFunctionsWPUC::cleanQueryArgsForDebug($args); 2592 2591 2593 2592 dmp("MAIN QUERY DEBUG"); 2594 2593 2595 2594 dmp($argsForDebug); 2596 2597 } 2598 2595 2596 } 2597 2599 2598 /** 2600 2599 * is ajax request 2601 2600 */ 2602 2601 public function isFrontAjaxRequest(){ 2603 2602 2604 2603 if(self::$isAjaxCache !== null) 2605 2604 return(self::$isAjaxCache); 2606 2605 2607 2606 $frontAjaxAction = UniteFunctionsUC::getPostGetVariable("ucfrontajaxaction","",UniteFunctionsUC::SANITIZE_KEY); 2608 2607 2609 2608 if($frontAjaxAction == "getfiltersdata"){ 2610 2609 self::$isAjaxCache = true; 2611 2610 return(true); 2612 2611 } 2613 2612 2614 2613 self::$isAjaxCache = false; 2615 2614 2616 2615 return(false); 2617 2616 } 2618 2617 2619 2618 /** 2620 2619 * just return true 2621 2620 */ 2622 2621 public function pluginProtection_ezCacheHideComment(){ 2623 2622 2624 2623 return(true); 2625 2624 } 2626 2627 2625 2626 2628 2627 /** 2629 2628 * run some cross plugin protections 2630 2629 */ 2631 2630 private function runSomeCrossPluginProtections(){ 2632 2631 2633 2632 add_filter("wp_bost_hide_cache_time_comment",array($this, "pluginProtection_ezCacheHideComment")); 2634 2635 } 2636 2633 2634 } 2635 2637 2636 /** 2638 2637 * set if show debug or not 2639 2638 */ 2640 2639 private function setShowDebug(){ 2641 2640 2642 2641 if(self::DEBUG_FILTER == true){ 2643 2642 self::$showDebug = true; 2644 2643 return(false); 2645 2644 } 2646 2645 2647 2646 //set debug only for logged in users 2648 2647 2649 2648 $isDebug = UniteFunctionsUC::getGetVar("ucfiltersdebug","",UniteFunctionsUC::SANITIZE_TEXT_FIELD); 2650 2649 $isDebug = UniteFunctionsUC::strToBool($isDebug); 2651 2650 2652 2651 if($isDebug == true){ 2653 2652 2654 2653 $hasPermissions = UniteFunctionsWPUC::isCurrentUserHasPermissions(); 2655 2654 2656 2655 if($hasPermissions == true){ 2657 2656 self::$showEchoDebug = true; 2658 2657 self::$showDebug = true; 2659 2658 2660 2659 dmp("SHOW DEBUG, logged in user"); 2661 2660 } 2662 2663 } 2664 2665 } 2666 2667 /** 2668 * check and set display errors by general option 2661 2662 } 2663 2664 } 2665 2666 /** 2667 * check and set display errors by general option 2669 2668 s */ 2670 2669 private function checkSetErrorsReporting(){ 2671 2670 2672 2671 $setDisplayErrors = HelperProviderCoreUC_EL::getGeneralSetting("enable_display_errors_ajax"); 2673 2672 $setDisplayErrors = UniteFunctionsUC::strToBool($setDisplayErrors); 2674 2673 2675 2674 if($setDisplayErrors == true){ 2676 2675 2677 2676 ini_set("display_errors", "on"); 2678 2677 error_reporting(E_ALL); 2679 2678 } 2680 2681 } 2682 2683 2679 2680 } 2681 2682 2684 2683 /** 2685 2684 * test the request filter 2686 2685 */ 2687 2686 public function operateAjaxResponse(){ 2688 2687 2689 2688 if(self::DEBUG_MAIN_QUERY == true){ 2690 2689 $this->showMainQueryDebug(); 2691 2690 exit(); 2692 2691 } 2693 2692 2694 2693 $frontAjaxAction = UniteFunctionsUC::getPostGetVariable("ucfrontajaxaction","",UniteFunctionsUC::SANITIZE_KEY); 2695 2694 2696 2695 if(empty($frontAjaxAction)) 2697 2696 return(false); 2698 2697 2699 2698 $this->runSomeCrossPluginProtections(); 2700 2699 2701 2700 $this->setShowDebug(); 2702 2701 2703 2702 $this->checkSetErrorsReporting(); 2704 2703 2705 2704 self::$isUnderAjax = true; 2706 2705 2707 2706 try{ 2708 2707 2709 2708 switch($frontAjaxAction){ 2710 2709 case "getfiltersdata": … … 2715 2714 break; 2716 2715 case "submitform": 2717 2716 2718 2717 $form = new UniteCreatorForm(); 2719 2718 $form->submitFormFront(); 2720 2719 2721 2720 break; 2722 2721 case "removefromcart": 2723 2722 2724 2723 $objWoo = UniteCreatorWooIntegrate::getInstance(); 2725 2724 2726 2725 $objWoo->removeFromCartFromData(); 2727 2726 2728 2727 break; 2729 2728 case "updatecartquantity": 2730 2729 2731 2730 $objWoo = UniteCreatorWooIntegrate::getInstance(); 2732 2731 2733 2732 $objWoo->updateCartQuantityFromData(); 2734 2733 break; 2735 2734 case "getcartdata": 2736 2735 2737 2736 $objWoo = UniteCreatorWooIntegrate::getInstance(); 2738 2737 $objWoo->outputCartFragments(); 2739 2738 2740 2739 break; 2741 2740 case "dynamicpopupcache": 2742 2741 2743 2742 $this->putDynamicPopupCache(); 2744 2743 2745 2744 break; 2746 2745 case "custom": 2747 2746 2748 2747 do_action("uc_custom_front_ajax_action"); 2749 2748 2750 2749 //if not catch - will throw error 2751 2750 2752 2751 default: 2753 2752 UniteFunctionsUC::throwError("wrong front ajax action: $frontAjaxAction"); 2754 2753 break; 2755 2754 } 2756 2755 2757 2756 }catch(Exception $e){ 2758 2757 2759 2758 $message = $e->getMessage(); 2760 2759 2761 2760 HelperUC::ajaxResponseError($message); 2762 2763 } 2764 2765 } 2766 2767 2761 2762 } 2763 2764 } 2765 2766 2768 2767 /** 2769 2768 * init wordpress front filters 2770 2769 */ 2771 2770 public function initWPFrontFilters(){ 2772 2771 2773 2772 if(is_admin() == true) 2774 2773 return(false); 2775 2774 2776 2775 add_action("wp", array($this, "operateAjaxResponse")); 2777 2776 2778 2777 add_action("ue_before_custom_posts_query", array($this, "onBeforeCustomPostsQuery")); 2779 2778 //add_action("ue_after_custom_posts_query", array($this, "onAfterCustomPostsQuery")); 2780 2781 2782 } 2783 2784 2779 2780 2781 } 2782 2783 2785 2784 } -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_form.class.php
r3094530 r3097249 212 212 213 213 $postContent = HelperProviderCoreUC_EL::getElementorContentByPostID($postId); 214 214 215 215 if(empty($postContent)) 216 216 UniteFunctionsUC::throwError("Form elementor content not found."); -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_globals.class.php
r3094530 r3097249 259 259 260 260 //dmp("init globals"); 261 261 262 262 UniteProviderFunctionsUC::doAction(UniteCreatorFilters::ACTION_AFTER_INIT_GLOBALS); 263 263 264 264 if(self::$is_admin){ 265 265 -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_helperhtml.class.php
r3094530 r3097249 201 201 $js .= self::TAB2.'var g_ucElIcons = '.$jsonElementorIcons.';'.self::BR; 202 202 203 204 //output shapes205 /*206 $objShapes = new UniteShapeManagerUC();207 $jsonShapes = $objShapes->getJsonShapes();208 $js .= self::TAB2.'var g_ucArrSvgShapes = '.$jsonShapes.';'.self::BR;209 */210 203 211 204 //get nonce -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_params_processor.class.php
r3076447 r3097249 1107 1107 1108 1108 1109 private function z________SHAPE________(){}1110 1111 1112 /**1113 * get the shape addon1114 */1115 private function getProcessedParamsValue_shapeOutput($data, $value, $param){1116 1117 $paramName = UniteFunctionsUC::getVal($param, "name");1118 1119 $shapeData = "";1120 1121 if(empty($value)){1122 $data[$paramName] = "";1123 return($data);1124 }1125 1126 if(empty($this->objShapes))1127 $this->objShapes = new UniteShapeManagerUC();1128 1129 $svgContent = $this->objShapes->getShapeSVGContent($value);1130 $data[$paramName] = $svgContent;1131 1132 return($data);1133 }1134 1135 1136 /**1137 * addon picker output1138 */1139 private function getProcessedParamsValue_addonPickerOutput($data, $value, $param){1140 1141 $addonType = UniteFunctionsUC::getVal($param, "addon_type");1142 1143 switch($addonType){1144 case GlobalsUC::ADDON_TYPE_SHAPES:1145 $data = $this->getProcessedParamsValue_shapeOutput($data, $value, $param);1146 break;1147 }1148 1149 return($data);1150 }1151 1152 1109 1153 1110 private function z_________INSTAGRAM_________(){} … … 1927 1884 $data[$name] = $this->getGoogleMapOutput($value, $name, $param); 1928 1885 break; 1929 case UniteCreatorDialogParam::PARAM_SHAPE:1930 $data = $this->getProcessedParamsValue_shapeOutput($data, $value, $param);1931 break;1932 case UniteCreatorDialogParam::PARAM_ADDONPICKER:1933 $data = $this->getProcessedParamsValue_addonPickerOutput($data, $value, $param);1934 break;1935 1886 } 1936 1887 … … 2160 2111 */ 2161 2112 public function getProcessedItemsData($arrItems, $processType, $forTemplate = true, $filterType = null){ 2162 2113 2163 2114 $this->validateInited(); 2164 2115 self::validateProcessType($processType); -
unlimited-elements-for-elementor/trunk/inc_php/unitecreator_web_api.class.php
r3034661 r3097249 1418 1418 protected function getImportedAddonData($addonType, $addonID){ 1419 1419 1420 if($addonType != GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER) 1421 return(array()); 1422 1423 $objShapes = new UniteShapeManagerUC(); 1424 $shapeBGContent = $objShapes->getShapeBGContentBYAddonID($addonID); 1425 1426 $data = array(); 1427 $data["shape_content"] = $shapeBGContent; 1428 1429 return($data); 1420 1421 return(array()); 1430 1422 } 1431 1423 -
unlimited-elements-for-elementor/trunk/js/admin.js
r3071404 r3097249 2682 2682 if(!g_ucAdmin) 2683 2683 g_ucAdmin = new UniteAdminUC(); 2684 2684 2685 2685 g_ucAdmin.globalInit(); 2686 2686 -
unlimited-elements-for-elementor/trunk/provider/assets/gutenberg_integrate.js
r3094530 r3097249 182 182 } 183 183 184 if (!settingsContent) 184 var settings = getSettings(); 185 186 if (!settings) 185 187 return; // wait for the settings 186 188 … … 195 197 id: props.attributes._id, 196 198 root_id: props.attributes._rootId, 197 settings: getSettings(),199 settings: settings, 198 200 selectors: true, 199 201 }, function (response) { -
unlimited-elements-for-elementor/trunk/provider/core/unlimited_elements/elementor/elementor_integrate.class.php
r3094530 r3097249 1704 1704 if($isEnabled == false) 1705 1705 return(false); 1706 1706 1707 1707 $isPreviewOption = UniteFunctionsUC::getGetVar("elementor-preview", "", UniteFunctionsUC::SANITIZE_KEY); 1708 1708 -
unlimited-elements-for-elementor/trunk/provider/core/unlimited_elements/elementor/elementor_widget.class.php
r3094530 r3097249 2092 2092 if(empty($arrItems)) 2093 2093 $arrItems = array(); 2094 2094 2095 2095 $arrDefaults = array(); 2096 2096 -
unlimited-elements-for-elementor/trunk/provider/core/unlimited_elements/globals.class.php
r3094530 r3097249 94 94 public static $pluginTitleCurrent; 95 95 96 public static $pathPlugin; 97 public static $pathPluginSettings; 98 96 99 97 100 /** … … 99 102 */ 100 103 public static function initGlobals(){ 104 105 self::$pluginTitleCurrent = self::PLUGIN_TITLE; 106 107 self::$urlTemplatesList = admin_url("edit.php?post_type=elementor_library&tabs_group=library"); 108 109 self::$urlAccount = admin_url("admin.php?page=unlimitedelements-account"); 110 111 UniteProviderFunctionsUC::addAction('admin_init', array("GlobalsUnlimitedElements", 'initAdminNotices')); 112 113 if(GlobalsUC::$is_admin == true && HelperUC::hasPermissionsFromQuery("showadminnotices")) 114 self::$debugAdminNotices = true; 115 116 //set paths 117 118 self::$pathPlugin = dirname(__FILE__)."/"; 119 120 self::$pathPlugin = UniteFunctionsUC::pathToUnix(self::$pathPlugin); 121 122 self::$pathPluginSettings = self::$pathPlugin."settings/"; 123 124 } 125 126 127 /** 128 * init after loaded 129 */ 130 public static function initAfterPluginsLoaded(){ 101 131 102 132 if(defined("UE_ENABLE_GUTENBERG_SUPPORT")){ … … 106 136 if(GlobalsUC::$inDev == true && defined("UE_DISABLE_ELEMENTOR_SUPPORT")){ 107 137 self::$enableElementorSupport = false; 108 138 109 139 if(self::$enableElementorSupport == false && self::$enableGutenbergSupport == true) 110 140 self::$isGutenbergOnly = true; 111 112 141 } 113 114 self::$pluginTitleCurrent = self::PLUGIN_TITLE;115 142 116 143 if(self::$isGutenbergOnly == true){ … … 119 146 } 120 147 121 self::$urlTemplatesList = admin_url("edit.php?post_type=elementor_library&tabs_group=library");122 123 self::$urlAccount = admin_url("admin.php?page=unlimitedelements-account");124 125 UniteProviderFunctionsUC::addAction('admin_init', array("GlobalsUnlimitedElements", 'initAdminNotices'));126 127 148 if(self::$enableGutenbergSupport == true) 128 149 self::initGutenbergIntegration(); 129 130 if(GlobalsUC::$is_admin == true && HelperUC::hasPermissionsFromQuery("showadminnotices")) 131 self::$debugAdminNotices = true; 132 150 133 151 } 134 152 153 135 154 /** 136 155 * init the admin notices -
unlimited-elements-for-elementor/trunk/provider/core/unlimited_elements/helper_provider_core.class.php
r3094530 r3097249 606 606 */ 607 607 public static function getPostContent($postID, $content=""){ 608 608 609 609 if(empty($postID)) 610 610 return(false); … … 1250 1250 1251 1251 self::$urlCore = GlobalsUC::$urlPlugin.$pathRelative; 1252 1252 1253 1253 self::$filepathGeneralSettings = self::$pathCore."settings/general_settings_el.xml"; 1254 1254 -
unlimited-elements-for-elementor/trunk/provider/core/unlimited_elements/provider_core_admin.class.php
r3094530 r3097249 21 21 ? GlobalsUnlimitedElements::VIEW_DASHBOARD 22 22 : GlobalsUnlimitedElements::VIEW_ADDONS_ELEMENTOR; 23 23 24 24 $this->arrAllowedViews = array( 25 25 "addons_elementor", -
unlimited-elements-for-elementor/trunk/provider/core/unlimited_elements/settings/general_settings_el.xml
r3094530 r3097249 3 3 <fields> 4 4 5 <fieldset name="elementor" label="Widgets for Elementor"> 6 7 <field name="el_enable" 8 type="boolean" 9 default="true" 10 label="<b>Enable Unlimited Elements</b>" 11 description="If disabled, the Unlimited Elements will not appear in the Elementor Page Builder"> 12 </field> 13 14 <field type="bulk_control_start" 15 parent="el_enable" 16 ctype="show" 17 value="true" 18 /> 19 20 21 <field name="css_includes_to" 22 type="list" 23 default="body" 24 label=" Include Css Files To" 25 description="Choose where to include css files"> 26 <option value="body" text="Body Before Widget HTML" /> 27 <option value="footer" text="Footer" /> 28 </field> 29 30 31 <field name="enable_import_export" 32 type="boolean" 33 default="true" 34 label=" Show Import and Export Buttons In Templates" 35 description="Show special import and export buttons (import and export with images) in elementor saved templates screen"> 36 </field> 37 38 39 <field name="enable_backgrounds" 40 type="boolean" 41 default="true" 42 label=" Enable Background Widgets" 43 description="Enable background widgets for elementor sections"> 44 </field> 45 46 <field name="enable_panel_previews" 47 type="boolean" 48 default="true" 49 label=" Show Elementor Panel Widgets Previews" 50 description="Show preview images of widget boxes in elementor editor side panel"> 51 </field> 52 53 <field type="bulk_control_end" /> 54 55 </fieldset> 56 5 <fieldset name="elementor" label="Widgets for Elementor" loadfrom="elementor" load_condition="elementor_enabled"></fieldset> 6 7 <!-- 8 <fieldset name="gutenberg" label="Blocks for Gutenberg" loadfrom="gutenberg" load_condition="gutenberg_enabled"></fieldset> 9 --> 10 57 11 <fieldset name="widgets" label="Widgets"> 58 12 -
unlimited-elements-for-elementor/trunk/provider/functions_wordpress.class.php
r3094530 r3097249 2780 2780 if(empty($post)) 2781 2781 return (""); 2782 2783 //UniteFunctionsUC::showTrace(); 2784 //dmp($post); 2785 2782 2786 2783 $postID = $post->ID; 2787 2784 … … 2790 2787 if(isset(self::$cachePostContent[$postID])) 2791 2788 return (self::$cachePostContent[$postID]); 2792 2793 self::$cachePostContent[$postID] = $post->post_content; 2794 2789 2795 2790 $isEditMode = GlobalsProviderUC::$isInsideEditor; 2796 2791 2797 2792 if($isEditMode == false) 2798 2793 $content = get_the_content(null, false, $post); -
unlimited-elements-for-elementor/trunk/provider/gutenberg_integrate.class.php
r3085242 r3097249 20 20 */ 21 21 public function __construct(){ 22 23 22 } 24 23 … … 95 94 $categories[] = array( 96 95 'slug' => GlobalsUnlimitedElements::PLUGIN_NAME, 97 'title' => __('Elementor Widgets', 'unlimited-elements-for-elementor'),96 'title' => GlobalsUnlimitedElements::PLUGIN_TITLE_GUTENBERG, 98 97 ); 99 98 100 99 return $categories; 101 100 } … … 123 122 */ 124 123 public function renderBlock($attributes){ 125 124 126 125 GlobalsProviderUC::$renderPlatform = GlobalsProviderUC::RENDER_PLATFORM_GUTENBERG; 127 126 128 127 $data = array( 129 128 'id' => $attributes['_id'], … … 132 131 'selectors' => true, 133 132 ); 134 133 135 134 $addonsManager = new UniteCreatorAddons(); 136 135 $addonData = $addonsManager->getAddonOutputData($data); … … 183 182 } 184 183 185 186 184 /** 187 185 * Get the Gutenberg blocks. … … 190 188 */ 191 189 private function getBlocks(){ 192 190 193 191 if(empty(self::$blocks) === true){ 194 192 $addonsOrder = ''; … … 197 195 $addonsManager = new UniteCreatorAddons(); 198 196 $addons = $addonsManager->getArrAddons($addonsOrder, $addonsParams, $addonsType); 199 197 200 198 foreach($addons as $addon){ 201 202 199 $name = $addon->getBlockName(); 203 200 204 201 self::$blocks[$name] = array( 205 202 'name' => $name, … … 249 246 * Get the parsed Gutenberg blocks. 250 247 * 251 * @return array 252 */ 253 public function getParsedBlocks($postID = null){ 254 255 $post = get_post($postID); 256 248 * @param int|null $postId 249 * 250 * @return array 251 */ 252 public function getPostBlocks($postId = null){ 253 254 $post = get_post($postId); 255 $blocks = parse_blocks($post->post_content); 256 257 return $blocks; 258 } 259 260 /** 261 * Get the existing parsed Gutenberg blocks. 262 * 263 * @return array 264 */ 265 public function getParsedBlocks(){ 266 267 $parsedBlocks = $this->getPostBlocks(); 257 268 $existingBlocks = $this->getBlocks(); 258 $parsedBlocks = parse_blocks($post->post_content); 269 $blocks = $this->extractParsedBlocks($parsedBlocks, $existingBlocks); 270 271 return $blocks; 272 } 273 274 /** 275 * Get block by root identifier. 276 * 277 * @param array $content 278 * @param int $rootId 279 * 280 * @return array|null 281 */ 282 public function getBlockByRootId($content, $rootId){ 283 284 if(empty($content) === true) 285 return null; 286 287 if(is_array($content) === false) 288 return null; 289 290 if(empty($rootId) === true) 291 return null; 292 293 foreach($content as $block){ 294 if(isset($block['blockName']) === false) 295 continue; 296 297 $blockAttributes = UniteFunctionsUC::getVal($block, 'attrs'); 298 $blockRootId = UniteFunctionsUC::getVal($blockAttributes, '_rootId'); 299 300 if($rootId === $blockRootId) 301 return $block; 302 303 $innerBlocks = UniteFunctionsUC::getVal($block, 'innerBlocks'); 304 305 if(empty($innerBlocks) === false && is_array($innerBlocks) === true){ 306 $innerBlock = $this->getBlockByRootId($innerBlocks, $rootId); 307 308 if(empty($innerBlock) === false) 309 return $innerBlock; 310 } 311 } 312 313 return null; 314 } 315 316 /** 317 * Get settings from the given block. 318 * 319 * @param array $block 320 * 321 * @return array 322 */ 323 public function getSettingsFromBlock($block){ 324 325 $attributes = UniteFunctionsUC::getVal($block, 'attrs', array()); 326 $data = UniteFunctionsUC::getVal($attributes, 'data', null); 327 328 if(empty($data) === true) 329 return array(); 330 331 $settings = UniteFunctionsUC::jsonDecode($data); 332 333 return $settings; 334 } 335 336 /** 337 * Extract the existing parsed Gutenberg blocks. 338 * 339 * @param array $parsedBlocks 340 * @param array $existingBlocks 341 * 342 * @return array 343 */ 344 private function extractParsedBlocks($parsedBlocks, $existingBlocks){ 345 259 346 $blocks = array(); 260 347 261 348 foreach($parsedBlocks as $block){ 262 349 $name = $block['blockName']; 263 350 264 if(empty($existingBlocks[$name]) === false) 351 if(empty($existingBlocks[$name]) === false){ 265 352 $blocks[] = array( 266 353 'name' => $name, 267 354 'html' => render_block($block), 268 355 ); 356 } 357 358 $innerBlocks = UniteFunctionsUC::getVal($block, 'innerBlocks'); 359 360 if(empty($innerBlocks) === false && is_array($innerBlocks) === true){ 361 $blocks = array_merge($blocks, $this->extractParsedBlocks($innerBlocks, $existingBlocks)); 362 } 269 363 } 270 364 271 365 return $blocks; 272 366 } 273 274 /**275 * get post blocks276 */277 public function getPostBlocks($postID){278 279 $post = get_post($postID);280 281 $arrBlocks = parse_blocks($post->post_content);282 283 return($arrBlocks);284 }285 286 287 /**288 * get block by root id289 */290 public function getBlockByRootID($arrContent, $rootID){291 292 if(empty($arrContent))293 return(null);294 295 if(is_array($arrContent) == false)296 return(null);297 298 if(empty($rootID))299 return(null);300 301 foreach($arrContent as $block){302 303 if(isset($block["blockName"]) == false)304 continue;305 306 $attributes = UniteFunctionsUC::getVal($block, "attrs");307 308 $blockRootID = UniteFunctionsUC::getVal($attributes, "_rootId");309 310 if($rootID === $blockRootID)311 return($block);312 313 $innerBlocks = UniteFunctionsUC::getVal($block, "innerBlocks");314 315 if(!empty($innerBlocks) && is_array($innerBlocks)){316 317 $innerBlock = $this->getBlockByRootID($innerBlocks, $rootID);318 319 if(!empty($innerBlock))320 return($innerBlock);321 }322 323 }324 325 return(null);326 }327 328 /**329 * get settings from block330 */331 public function getSettingsFromBlock($arrBlock){332 333 $attributes = UniteFunctionsUC::getVal($arrBlock, "attrs");334 335 if(empty($attributes))336 return(array());337 338 $data = UniteFunctionsUC::getVal($attributes, "data");339 340 $arrSettings = UniteFunctionsUC::jsonDecode($data);341 342 return($arrSettings);343 }344 345 367 346 368 } -
unlimited-elements-for-elementor/trunk/provider/include_provider_after.php
r2093023 r3097249 4 4 5 5 HelperProviderUC::registerPlugins(); 6 -
unlimited-elements-for-elementor/trunk/provider/provider_alt_loader.php
r2948512 r3097249 43 43 44 44 HelperUC::validatePluginStartup(); 45 45 46 46 require_once GlobalsUC::$pathProvider."core/provider_main_file.php"; 47 47 -
unlimited-elements-for-elementor/trunk/provider/provider_helper.class.php
r3094530 r3097249 478 478 */ 479 479 public static function onPluginsLoaded(){ 480 481 GlobalsUC::initAfterPluginsLoaded(); 482 483 GlobalsUnlimitedElements::initAfterPluginsLoaded(); 480 484 481 485 load_plugin_textdomain("unlimited-elements-for-elementor", false, GlobalsUC::$pathWPLanguages); 482 483 GlobalsUC::initAfterPluginsLoaded();484 486 485 487 UniteCreatorWooIntegrate::initActions(); … … 558 560 */ 559 561 public static function onPluginsLoadedCallPlugins(){ 560 562 561 563 do_action("addon_library_register_plugins"); 562 564 … … 582 584 583 585 add_action("plugins_loaded", array("HelperProviderUC","onPluginsLoadedCallPlugins")); 584 586 585 587 } 586 588 … … 930 932 */ 931 933 public static function isBackgroundsEnabled(){ 932 934 933 935 if(GlobalsUnlimitedElements::$enableElementorSupport == false) 934 936 return(false); -
unlimited-elements-for-elementor/trunk/provider/provider_params_processor.class.php
r3090199 r3097249 777 777 $arrData["post_type"] = UniteFunctionsUC::getVal($arrPost, "post_type"); 778 778 779 $content = UniteFunctionsWPUC::getPostContent($post); 780 779 $password = $post->post_password; 780 if(!empty($password)) 781 $content = ""; 782 else 783 $content = UniteFunctionsWPUC::getPostContent($post); 784 785 781 786 $arrData["content"] = $content; 782 787 783 788 $link = UniteFunctionsWPUC::getPermalink($post); 784 789 … … 863 868 864 869 $exceprt = UniteFunctionsUC::getVal($arrPost, "post_excerpt"); 865 870 866 871 $intro = $exceprt; 867 872 $introFull = ""; … … 883 888 $arrData["intro"] = $intro; 884 889 $arrData["intro_full"] = $introFull; 885 890 886 891 //put data 887 892 $strDate = UniteFunctionsUC::getVal($arrPost, "post_date"); -
unlimited-elements-for-elementor/trunk/readme.txt
r3094530 r3097249 4 4 Tags: elementor, elements, addons, elementor addons, elementor widget, page builder, builder, visual editor, wordpress page builder, elementor 5 5 Requires at least: 3.5 6 Tested up to: 6.5 6 Tested up to: 6.5.3 7 7 Stable tag: 1.0 8 8 License: GPLv2 or later … … 867 867 868 868 == Changelog == 869 870 version 1.5.110: 2024-06-04 871 872 Plugin Changes: 873 874 * Fix: remote arrows was sendin next/prev commands twice 875 * Fix: fix some password protected content related security issue 876 * Fix: fix some sql security small issue 877 878 879 Widgets Changes: 880 881 * Feature: Email Field (Pro) - Added Asterisk Size option, allowing customization of asterisk size for better design flexibility and emphasis. 882 * Feature: Phone Field (Pro) - Added Asterisk Size option, allowing customization of asterisk size for better design flexibility and emphasis. 883 * Feature: Event List (Pro) - Added Timezone option, ensuring that expired and upcoming events are counted according to the specified timezone for accurate event scheduling and display. 884 * Feature: Number Field (Pro) - Added "Limit Number of Digits" option, allowing users to restrict the number of digits displayed for better control and readability of numerical data. 885 * Feature: Phone Field (Pro) - Added "Limit Number of Digits" option, allowing users to restrict the number of digits displayed for better control and readability of numerical data. 886 * Feature: Transparent Split Hero (Free) - Added options to enable or disable widget contents like title, subtitle, etc., and introduced an option to add an image or logo for greater customization and flexibility. 887 * Feature: Unlimited Charts (Pro) - Added Line Chart Background Color option, allowing customization of the background color for line charts to enhance visual appeal. 888 * Fix: Submit Button (Free) - Added validation function for the phone field to ensure correct email format and improve data accuracy. 889 * Fix: Mega Menu (Pro) - Added fix for layout issue that sometimes occurs after page load, ensuring consistent and stable page rendering. 890 * Fix: Post Carousel (Pro) - Set padding to 0 in Nav Dots to avoid default CSS overrides, ensuring consistent and desired styling. 891 * Fix: Semi Circle Progress Bar (Pro) - Added support for Mega Slider widget, enabling the creation and display of Semi Circle Progress Bar widget in interactive sliders for enhanced content presentation. 892 * Fix: Floating Chat Buttons (Pro) - Fixed Pulse Animation Grabber Type issue, ensuring correct animation behavior and improved visual effects. 893 * Fix: Content Tabs (Free) - Added a small delay before widget initialization to ensure the Content Tabs widget works properly within other widgets, improving overall functionality and integration. 894 * Fix: Remote Tabs (Pro) - Changed selector for padding option to resolve issue where link was not clicked when tab was clicked, improving click response accuracy. 895 869 896 870 897 -
unlimited-elements-for-elementor/trunk/release_log.txt
r3094530 r3097249 1 2 3 version 1.5.110: 4 5 * Fix: remote arrows was sendin next/prev commands twice 6 * Fix: fix some password protected content related security issue 7 * Fix: fix some sql security small issue 1 8 2 9 -
unlimited-elements-for-elementor/trunk/settings/layout_addon_container_settings.xml
r2063047 r3097249 79 79 </fieldset> 80 80 81 <fieldset name="background" label="Background" loadfrom="background"></fieldset> 82 81 <fieldset name="background" label="Background" loadfrom="background"></fieldset> 82 83 83 <fieldset name="common_hidden" loadfrom="common_hidden"></fieldset> 84 84 -
unlimited-elements-for-elementor/trunk/unlimited_elements.php
r3090199 r3097249 5 5 * Description: Unlimited Elements - Huge Widgets Pack for Elementor Website Builder, with html/css/js widget creator and editor 6 6 * Author: Unlimited Elements 7 * Version: 1.5.1 087 * Version: 1.5.110 8 8 * Author URI: http://unlimited-elements.com 9 9 * Text Domain: unlimited-elements-for-elementor 10 10 * Domain Path: /languages 11 11 * 12 * Tested up to: 6.5 13 * Elementor tested up to: 3.21. 214 * Elementor Pro tested up to: 3.21. 012 * Tested up to: 6.5.3 13 * Elementor tested up to: 3.21.8 14 * Elementor Pro tested up to: 3.21.3 15 15 */ 16 16 -
unlimited-elements-for-elementor/trunk/views/layouts.php
r3094530 r3097249 7 7 * */ 8 8 defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access'); 9 9 10 10 11 require HelperUC::getPathViewObject("layouts_view.class");
Note: See TracChangeset
for help on using the changeset viewer.