PATH:
home
/
lab2454c
/
equitablegold.com
/
wp-content
/
plugins
/
unlimited-elements-for-elementor
/
provider
<?php /** * @package Unlimited Elements * @author unlimited-elements.com * @copyright (C) 2012 Unite CMS, All Rights Reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html * */ defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access'); class ProviderOperationsUC extends UCOperations{ /** * get search text from data */ private function getSearchFromData($data){ $type = UniteFunctionsUC::getVal($data, "_type"); if($type != "query") return(null); $searchTerm = UniteFunctionsUC::getVal($data, "q"); return($searchTerm); } /** * get select 2 terms titles from array of id's or slugs */ public function getSelect2TermsTitles($data){ $arrIDs = UniteFunctionsUC::getVal($data, "post_ids"); if(empty($arrIDs)) return(null); if(is_string($arrIDs)){ $arrIDs = explode(",", $arrIDs); } $firstID = $arrIDs[0]; //search by slugs if(is_numeric($firstID) == false){ $args = array("slug"=>$arrIDs); }else{ $args = array("include"=>$arrIDs); } $response = get_terms($args); if(empty($response)) return(null); $output = array(); foreach($response as $term){ $termID = $term->term_id; $title = $term->name; $taxonomy = $term->taxonomy; $title .= " ($taxonomy)"; $item = array(); $item["id"] = $termID; $item["text"] = $title; $output[] = $item; } return($output); } /** * get select 2 terms titles from array of id's or slugs */ public function getSelect2UsersTitles($data){ $arrIDs = UniteFunctionsUC::getVal($data, "post_ids"); if(empty($arrIDs)) return(null); if(is_string($arrIDs)){ $arrIDs = explode(",", $arrIDs); } $args = array("include"=>$arrIDs); $response = get_users($args); if(empty($response)) return(null); $output = array(); foreach($response as $user){ $item = $this->getUserResult($user); $output[] = $item; } return($output); } /** * get select 2 post titles from array of id's */ public function getSelect2PostTitles($data){ $arrIDs = UniteFunctionsUC::getVal($data, "post_ids"); $arrTypesAssoc = UniteFunctionsWPUC::getPostTypesAssoc(array(), true); if(empty($arrIDs)) return(null); $response = UniteFunctionsWPUC::getPostTitlesByIDs($arrIDs); if(empty($response)) return(null); $output = array(); foreach($response as $record){ $id = UniteFunctionsUC::getVal($record, "id"); $title = UniteFunctionsUC::getVal($record, "title"); $postType = UniteFunctionsUC::getVal($record, "type"); $typeTitle = UniteFunctionsUC::getVal($arrTypesAssoc, $postType); if(empty($typeTitle)) $typeTitle = $postType; $title .= " ($typeTitle)"; $item = array(); $item["id"] = $id; $item["text"] = $title; $output[] = $item; } return($output); } /** * get terms list for select */ public function getTermsListForSelectFromData($data){ $limit = 10; $search = $this->getSearchFromData($data); $taxonomy = UniteFunctionsUC::getVal($data, "taxonomy"); $query = array(); $query["number"] = $limit; $query["search"] = $search; $query["hide_empty"] = false; $arrTaxNames = array(); $isSingleTax = true; if(!empty($taxonomy)){ $query["taxonomy"] = $taxonomy; } if(is_array($taxonomy) && count($taxonomy) > 1) $isSingleTax = false; $response = get_terms($query); //try to get some taxonomies if(empty($response) && count($search) == 1){ unset($query["search"]); $response = get_terms($query); } if(empty($response)) return(null); $arrResult = array(); foreach($response as $term){ $termID = $term->term_id; $name = $term->name; $taxonomy = $term->taxonomy; $count = $term->count; if($taxonomy == "post_tag") $taxonomy = "tag"; if($isSingleTax == false) $title = $name.", ($taxonomy, {$count} items)"; else $title = $name.", ({$count} items)"; $arr = array(); $arr["id"] = $termID; $arr["text"] = $title; $arrResult[] = $arr; } $arrOutput = array(); $arrOutput["results"] = $arrResult; $arrOutput["pagination"] = array("more"=>false); return($arrOutput); } /** * get user result object */ private function getUserResult($user){ $data = (array)$user->data; $caps = (array)$user->caps; $cap = UniteFunctionsUC::getFirstNotEmptyKey($caps); $name = UniteFunctionsUC::getVal($data, "display_name"); if(empty($name)) $name = UniteFunctionsUC::getVal($data, "user_nicename"); if(empty($name)) $name = UniteFunctionsUC::getVal($data, "user_login"); if(empty($name)) $name = UniteFunctionsUC::getVal($data, "user_email"); $userID = UniteFunctionsUC::getVal($data, "ID"); $text = "$name ($cap)"; $arr = array(); $arr["id"] = $userID; $arr["text"] = $text; return($arr); } /** * get terms list for select */ public function getUsersListForSelectFromData($data){ $limit = 10; $search = $this->getSearchFromData($data); $query = array(); $query["search"] = "*$search*"; $query["number"] = 10; $users = get_users($query); if(empty($users)) return(null); $arrResult = array(); foreach($users as $user){ $arr = $this->getUserResult($user); $arrResult[] = $arr; } $arrOutput = array(); $arrOutput["results"] = $arrResult; $arrOutput["pagination"] = array("more"=>false); return($arrOutput); } /** * get post list for select2 */ public function getPostListForSelectFromData($data, $addNotSelected = false, $limit = 10){ $search = $this->getSearchFromData($data); $filterPostType = UniteFunctionsUC::getVal($data, "post_type"); switch($filterPostType){ case "product": $arrTypesAssoc = array("product" => __("Product","unlimited-elements-for-elementor")); break; case "elementor_template": $arrTypesAssoc = array("elementor_library" => __("Template","unlimited-elements-for-elementor")); break; default: $arrTypesAssoc = UniteFunctionsWPUC::getPostTypesAssoc(array(), true); break; } $arrPostTypes = array_keys($arrTypesAssoc); $strPostTypes = implode("','", $arrPostTypes); $strPostTypes = "'$strPostTypes'"; //prepare query $db = HelperUC::getDB(); $tablePosts = UniteProviderFunctionsUC::$tablePosts; $search = $db->escape($search); $where = "post_type in ($strPostTypes)"; $where .= " and post_status in ('publish','draft','private')"; $isStartWord = (strlen($search) == 1); $whereStartWord = $where." and post_title like '$search%'"; $whereRegular = $where." and post_title like '%$search%'"; $sqlStartWord = "select * from $tablePosts where $whereStartWord order by post_date desc limit $limit"; $sql = "select * from $tablePosts where $whereRegular order by post_date desc limit $limit "; if($isStartWord == true){ //start word, then regular $response = $db->fetchSql($sqlStartWord); if(empty($response)) $response = $db->fetchSql($sql); }else{ //regular only $response = $db->fetchSql($sql); } if(empty($response)) return(array()); $arrResult = array(); //add empty value if($addNotSelected == true){ $arr = array(); $arr["id"] = 0; $arr["text"] = __("[please select post]", "unlimited-elements-for-elementor"); $arrResult[] = $arr; } foreach($response as $post){ $postID = $post["ID"]; $postTitle = $post["post_title"]; $postType = $post["post_type"]; $postTypeTitle = UniteFunctionsUC::getVal($arrTypesAssoc, $postType); if(empty($postTypeTitle)) $postTypeTitle = $postType; $title = $postTitle." - ($postTypeTitle)"; $arr = array(); $arr["id"] = $postID; $arr["text"] = $title; $arrResult[] = $arr; } $arrOutput = array(); $arrOutput["results"] = $arrResult; $arrOutput["pagination"] = array("more"=>false); return($arrOutput); } }
[-] custom_post_types.class.php
[edit]
[-] provider_layouts_exporter.class.php
[edit]
[+]
..
[-] include_provider_after.php
[edit]
[-] provider_template_engine.class.php
[edit]
[-] provider_web_api.class.php
[edit]
[-] wpml_integrate.class.php
[edit]
[+]
core
[-] provider_admin.class.php
[edit]
[-] provider_admin_plugin_base.class.php
[edit]
[-] integrations.class.php
[edit]
[-] provider_globals.class.php
[edit]
[-] provider_front.class.php
[edit]
[-] provider_addon.class.php
[edit]
[-] provider_browser.class.php
[edit]
[-] provider_manager_addons.class.php
[edit]
[-] provider_dialog_param.class.php
[edit]
[-] include_provider.php
[edit]
[-] woocommerce_integrate.class.php
[edit]
[-] provider_settings_output.class.php
[edit]
[-] provider_categories.class.php
[edit]
[-] provider_operations.class.php
[edit]
[-] provider_helper.class.php
[edit]
[-] toolset_integrate.class.php
[edit]
[+]
settings
[-] provider_functions.class.php
[edit]
[+]
assets
[-] gutenberg_integrate.class.php
[edit]
[-] provider_alt_loader.php
[edit]
[-] provider_layouts.class.php
[edit]
[-] provider_layout_output.class.php
[edit]
[-] provider_settings.class.php
[edit]
[+]
admin_notices
[+]
views
[-] provider_library.class.php
[edit]
[-] wpml_translation_module.class.php
[edit]
[-] provider_settings_multisource.class.php
[edit]
[-] provider_client_text.php
[edit]
[+]
freemius
[-] provider_actions.class.php
[edit]
[-] pods_integrate.class.php
[edit]
[-] functions_wordpress.class.php
[edit]
[-] provider_db.class.php
[edit]
[-] provider_params_processor.class.php
[edit]
[-] acf_integrate.class.php
[edit]
[-] provider_params_processor_multisource.class.php
[edit]
[-] provider_layout.class.php
[edit]
[-] provider_output.class.php
[edit]