File "unitecreator_helper.class.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/unlimited-elements-for-elementor/inc_php/unitecreator_helper.class.php
File size: 37.45 B
MIME-type: text/x-php
Charset: 8 bit

Download   Open   Edit   Advanced Editor   Back

<?php

defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
class HelperUC extends UniteHelperBaseUC
{
    private static $db;
    public static $operations;
    private static $arrFontPanelData;
    private static $arrAdminNotices = array();
    private static $arrStickyAdminNotice = array();
    private static $isPutAnimations = false;
    private static $arrLogMemory = array();
    private static $arrHashCache = array();
    private static $arrRunOnceCache = array();
    private static $arrLocalText = array();
    private static $arrDebug;
    private static $hasOutput = false;
    public static function a____GENERAL____()
    {
    }
    public static function validatePluginStartup()
    {
        if (function_exists("simplexml_load_file") == false) {
            UniteFunctionsUC::throwError("Your php missing SimpleXML Extension. The plugin can't work without this extension because it has many xml files to load. Please enable this extension in php.ini");
        }
    }
    public static function getDB()
    {
        if (empty(self::$db)) {
            self::$db = new UniteCreatorDB();
        }
        return self::$db;
    }
    public static function setLocalText($arrText)
    {
        self::$arrLocalText = array_merge(self::$arrLocalText, $arrText);
    }
    public static function includeAllPlugins()
    {
        $objUCPlugins = new UniteCreatorPlugins();
        $objUCPlugins->initPlugins();
    }
    public static function runProviderFunc($func)
    {
        $args = func_get_args();
        array_shift($args);
        $exists = method_exists("UniteProviderFunctionsUC", $func);
        if (!$exists) {
            return false;
        }
        call_user_func_array(array("UniteProviderFunctionsUC", $func), $args);
    }
    public static function getFontPanelData()
    {
        if (!empty(self::$arrFontPanelData)) {
            return self::$arrFontPanelData;
        }
        require GlobalsUC::$pathSettings . "font_panel_data.php";
        self::$arrFontPanelData = $arrData;
        return self::$arrFontPanelData;
    }
    public static function getText($textKey)
    {
        $searchKey = strtolower($textKey);
        if (array_key_exists($searchKey, self::$arrLocalText)) {
            return self::$arrLocalText[$textKey];
        }
        if (array_key_exists($searchKey, GlobalsUC::$arrServerSideText)) {
            return GlobalsUC::$arrServerSideText[$textKey];
        }
        if (array_key_exists($searchKey, GlobalsUC::$arrClientSideText)) {
            return GlobalsUC::$arrClientSideText[$textKey];
        }
        return $textKey;
    }
    public static function putText($textKey)
    {
        echo self::getText($textKey);
    }
    public static function getSettingsObject($settingsName, $path = null)
    {
        $pathSettings = self::getPathSettings($settingsName, $path);
        $objSettings = new UniteCreatorSettings();
        $objSettings->loadXMLFile($pathSettings);
        return $objSettings;
    }
    public static function getAdminView()
    {
        if (UniteProviderFunctionsUC::isAdmin() == false) {
            return null;
        }
        $view = UniteCreatorAdmin::getView();
        return $view;
    }
    public static function getCssMobileSize($arrSizeCss, $cssPrefix = "")
    {
        $css = "";
        foreach ($arrSizeCss as $size => $cssSize) {
            if (empty($cssSize)) {
                continue;
            }
            $cssSize = UniteFunctionsUC::addTabsToText($cssSize, "    ");
            $cssSize = HelperHtmlUC::wrapCssMobile($cssSize, $size);
            if (!empty($css)) {
                $css .= "\n\n";
            }
            $css .= $cssSize;
        }
        if (!empty($cssPrefix) && !empty($css)) {
            $css = $cssPrefix . "\n\n" . $css;
        }
        return $css;
    }
    public static function isSpecialAddonType($type)
    {
        switch ($type) {
            case GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER:
            case GlobalsUC::ADDON_TYPE_SHAPES:
            case GlobalsUC::ADDON_TYPE_BGADDON:
                return true;
                break;
        }
        return false;
    }
    public static function isLayoutAddonType($addonType)
    {
        $objAddonType = UniteCreatorAddonType::getAddonTypeObject($addonType);
        $isLayout = $objAddonType->isLayout;
        return $isLayout;
    }
    public static function getProductFromRequest()
    {
        $action = UniteFunctionsUC::getPostGetVariable("client_action", "", UniteFunctionsUC::SANITIZE_TEXT_FIELD);
        if (empty($action)) {
            return null;
        }
        $data = UniteFunctionsUC::getPostGetVariable("data", "", UniteFunctionsUC::SANITIZE_NOTHING);
        $passData = UniteFunctionsUC::getVal($data, "manager_passdata");
        if (empty($passData)) {
            return null;
        }
        $product = UniteFunctionsUC::getVal($passData, "product");
        return $product;
    }
    public static function getPHPInfo()
    {
        if (function_exists("ini_get_all") == false) {
            return array();
        }
        $arrInfo = ini_get_all();
        if (empty($arrInfo)) {
            return array();
        }
        $arrKeys = array("memory_limit", "max_execution_time", "post_max_size", "upload_max_filesize");
        $arrInfoComputed = array();
        foreach ($arrKeys as $key) {
            $arrValues = UniteFunctionsUC::getVal($arrInfo, $key);
            $localValue = UniteFunctionsUC::getVal($arrValues, "local_value");
            $arrInfoComputed[$key] = $localValue;
        }
        return $arrInfoComputed;
    }
    public static function isRunCodeOnce($key)
    {
        $isAlreadyRun = UniteFunctionsUC::getVal(self::$arrRunOnceCache, $key);
        if ($isAlreadyRun === true) {
            return false;
        }
        self::$arrRunOnceCache[$key] = true;
        return true;
    }
    public static function a_______DEBUG________()
    {
    }
    public static function addDebug($title, $content = null)
    {
        if (empty(self::$arrDebug)) {
            self::$arrDebug = array();
        }
        $name = HelperUC::convertTitleToHandle($title);
        $item = array();
        $item["name"] = $name;
        $item["title"] = $title;
        $item["content"] = $content;
        self::$arrDebug[] = $item;
    }
    public static function clearDebug()
    {
        self::$arrDebug = array();
    }
    public static function getDebug()
    {
        return self::$arrDebug;
    }
    public static function a_______NOTICES________()
    {
    }
    public static function addAdminNotice($strNotice)
    {
        self::$arrAdminNotices[] = $strNotice;
    }
    public static function getAdminNotices()
    {
        $arrNotices = self::$arrAdminNotices;
        self::$arrAdminNotices = array();
        return $arrNotices;
    }
    public static function a__________MEMORY__________()
    {
    }
    public static function logMemoryUsage($operation, $isUpdateOption = false)
    {
        $usage = memory_get_usage();
        $diff = 0;
        if (!empty(self::$arrLogMemory)) {
            $lastArrUsage = self::$arrLogMemory[count(self::$arrLogMemory) - 1];
            $lastUsage = $lastArrUsage["usage"];
            $diff = $usage - $lastUsage;
        }
        $arrLogItem = array("oper" => $operation, "usage" => $usage, "diff" => $diff, "time" => time());
        if (empty(self::$arrLogMemory)) {
            $arrLogItem["current_page"] = GlobalsUC::$current_page_url;
        }
        self::$arrLogMemory[] = $arrLogItem;
        if ($isUpdateOption == true) {
            UniteProviderFunctionsUC::updateOption("unite_creator_memory_usage_log", self::$arrLogMemory);
        }
    }
    public static function getLastMemoryUsage()
    {
        $arrLog = UniteProviderFunctionsUC::getOption("unite_creator_memory_usage_log");
        return $arrLog;
    }
    public static function a_________STATE________()
    {
    }
    public static function setState($name, $value)
    {
        $optionName = "untecreator_state";
        $arrState = UniteProviderFunctionsUC::getOption($optionName);
        if (empty($arrState) || is_array($arrState) == false) {
            $arrState = array();
        }
        $arrState[$name] = $value;
        UniteProviderFunctionsUC::updateOption($optionName, $arrState);
    }
    public static function getState($name)
    {
        $optionName = "untecreator_state";
        $arrState = UniteProviderFunctionsUC::getOption($optionName);
        $value = UniteFunctionsUC::getVal($arrState, $name, null);
        return $value;
    }
    public static function printGeneralSettings()
    {
        $arrSettings = self::$operations->getGeneralSettings();
        dmp($arrSettings);
        exit;
    }
    public static function getGeneralSetting($name)
    {
        $arrSettings = self::$operations->getGeneralSettings();
        if (array_key_exists($name, $arrSettings) == false) {
            UniteFunctionsUC::throwError("General setting: {$name} don't exists");
        }
        $value = $arrSettings[$name];
        return $value;
    }
    public static function a________URL_AND_PATH_________()
    {
    }
    public static function URLtoFull($url, $urlBase = null)
    {
        if (is_numeric($url)) {
            return $url;
        }
        if (getType($urlBase) == "boolean") {
            UniteFunctionsUC::throwError("the url base should be null or string");
        }
        if (is_array($url)) {
            UniteFunctionsUC::throwError("url can't be array");
        }
        $url = trim($url);
        if (empty($url)) {
            return "";
        }
        $urlLower = strtolower($url);
        if (strpos($urlLower, "http://") !== false || strpos($urlLower, "https://") !== false) {
            return $url;
        }
        if (empty($urlBase)) {
            $url = GlobalsUC::$url_base . $url;
        } else {
            $convertUrl = GlobalsUC::$url_base;
            $filepath = self::pathToAbsolute($url);
            if (file_exists($filepath) == false) {
                $convertUrl = $urlBase;
            }
            $url = $convertUrl . $url;
        }
        $url = UniteFunctionsUC::cleanUrl($url);
        return $url;
    }
    public static function URLtoRelative($url, $isAssets = false)
    {
        $replaceString = GlobalsUC::$url_base;
        if ($isAssets == true) {
            $replaceString = GlobalsUC::$url_assets;
        }
        if (is_array($url)) {
            $strUrl = UniteFunctionsUC::getVal($url, "url");
            if (empty($strUrl)) {
                return $url;
            }
            $url["url"] = str_replace($replaceString, "", $strUrl);
            return $url;
        }
        $url = str_replace($replaceString, "", $url);
        return $url;
    }
    public static function URLtoAssetsRelative($url)
    {
        $url = str_replace(GlobalsUC::$url_assets, "", $url);
        return $url;
    }
    public static function urlToPath($url)
    {
        $urlRelative = self::URLtoRelative($url);
        $path = GlobalsUC::$path_base . $urlRelative;
        if (file_exists($path) == false) {
            return null;
        }
        return $path;
    }
    public static function arrUrlsToRelative($arrUrls, $isAssets = false)
    {
        if (!is_array($arrUrls)) {
            return $arrUrls;
        }
        foreach ($arrUrls as $key => $url) {
            $arrUrls[$key] = self::URLtoRelative($url, $isAssets);
        }
        return $arrUrls;
    }
    public static function arrUrlsToFull($arrUrls)
    {
        if (!is_array($arrUrls)) {
            return $arrUrls;
        }
        foreach ($arrUrls as $key => $url) {
            $arrUrls[$key] = self::URLtoFull($url);
        }
        return $arrUrls;
    }
    public static function pathToRelative($path, $addDots = true)
    {
        $realpath = realpath($path);
        if (!$realpath) {
            return $path;
        }
        $isDir = is_dir($realpath);
        $len = strlen($realpath);
        $realBase = realpath(GlobalsUC::$path_base);
        $relativePath = str_replace($realBase, "", $realpath);
        if ($addDots == true && strlen($relativePath) != strlen($realpath)) {
            $relativePath = ".." . $relativePath;
        }
        $relativePath = UniteFunctionsUC::pathToUnix($relativePath);
        if ($addDots == false) {
            $relativePath = ltrim($relativePath, "/");
        }
        if ($isDir == true) {
            $relativePath = UniteFunctionsUC::addPathEndingSlash($relativePath);
        }
        return $relativePath;
    }
    public static function pathToAbsolute($path)
    {
        $basePath = GlobalsUC::$path_base;
        $basePath = UniteFunctionsUC::pathToUnix($basePath);
        $path = UniteFunctionsUC::pathToUnix($path);
        $realPath = UniteFunctionsUC::realpath($path, false);
        if (!empty($realPath)) {
            return $path;
        }
        if (UniteFunctionsUC::isPathUnderBase($path, $basePath)) {
            $path = UniteFunctionsUC::pathToUnix($path);
            return $path;
        }
        $path = $basePath . "/" . $path;
        $path = UniteFunctionsUC::pathToUnix($path);
        return $path;
    }
    public static function pathToRelativeUrl($path)
    {
        $path = self::pathToRelative($path, false);
        $url = str_replace('\\', '/', $path);
        $url = ltrim($url, '/');
        return $url;
    }
    public static function pathToFullUrl($path)
    {
        if (empty($path)) {
            return "";
        }
        $url = self::pathToRelativeUrl($path);
        $url = self::URLtoFull($url);
        return $url;
    }
    public static function getImageDetails($urlImage)
    {
        $info = UniteFunctionsUC::getPathInfo($urlImage);
        $urlDir = UniteFunctionsUC::getVal($info, "dirname");
        if (!empty($urlDir)) {
            $urlDir = $urlDir . "/";
        }
        $arrInfo = array();
        $arrInfo["url_full"] = GlobalsUC::$url_base . $urlImage;
        $arrInfo["url_dir_image"] = $urlDir;
        $arrInfo["url_dir_thumbs"] = $urlDir . GlobalsUC::DIR_THUMBS . "/";
        $filepath = GlobalsUC::$path_base . urldecode($urlImage);
        $filepath = realpath($filepath);
        $path = dirname($filepath) . "/";
        $pathThumbs = $path . GlobalsUC::DIR_THUMBS . "/";
        $arrInfo["filepath"] = $filepath;
        $arrInfo["path"] = $path;
        $arrInfo["path_thumbs"] = $pathThumbs;
        return $arrInfo;
    }
    public static function convertTitleToHandle($title, $removeNonAscii = true)
    {
        $handle = strtolower($title);
        $handle = str_replace(array("", ""), "a", $handle);
        $handle = str_replace(array("", ""), "a", $handle);
        $handle = str_replace(array("", ""), "o", $handle);
        if ($removeNonAscii == true) {
            $handle = preg_replace("/[^a-z0-9\\s\\_]/i", " ", $handle);
        }
        $handle = preg_replace("/\\s\\s+/", " ", $handle);
        $handle = preg_replace("/\\s/", "_", $handle);
        $handle = preg_replace("/\\_\\_+/", "_", $handle);
        $handle = trim($handle, "_");
        return $handle;
    }
    public static function convertTitleToAlias($title)
    {
        $handle = self::convertTitleToHandle($title, false);
        $alias = str_replace("_", "-", $handle);
        return $alias;
    }
    public static function getUrlHandle($url, $addonName = null)
    {
        $urlNew = HelperUC::URLtoAssetsRelative($url);
        if ($urlNew != $url) {
            $urlNew = "uc_assets_" . $urlNew;
            $path = self::urlToPath($url);
            if (!empty($path)) {
                $arrInfo = pathinfo($path);
                $filename = UniteFunctionsUC::getVal($arrInfo, "basename");
                $filesize = filesize($path);
                $urlNew = "ac_assets_file_" . $filename . "_" . $filesize;
            }
        } else {
            $urlNew = HelperUC::URLtoRelative($url);
            if ($urlNew != $url) {
                $urlNew = "uc_" . $urlNew;
            } else {
                $urlNew = $url;
            }
        }
        $url = strtolower($urlNew);
        $url = str_replace("https://", "", $url);
        $url = str_replace("http://", "", $url);
        if (strpos($url, "uc_") !== 0) {
            $url = "uc_" . $url;
        }
        $handle = self::convertTitleToHandle($url);
        return $handle;
    }
    public static function convertFromUrlAssets($value, $urlAssets)
    {
        if (empty($urlAssets)) {
            return $value;
        }
        if (is_string($value) == false) {
            return $value;
        }
        $value = str_replace("[url_assets]/", $urlAssets, $value);
        $value = str_replace("{{url_assets}}/", $urlAssets, $value);
        return $value;
    }
    public static function urlToSSLCheck($url)
    {
        if (GlobalsUC::$is_ssl == true) {
            $url = UniteFunctionsUC::urlToSsl($url);
        }
        return $url;
    }
    public static function downloadFileToCacheFolder($urlFile)
    {
        $info = pathinfo($urlFile);
        $filename = UniteFunctionsUC::getVal($info, "basename");
        if (empty($filename)) {
            UniteFunctionsUC::throwError("no file given");
        }
        $ext = $info["extension"];
        if ($ext != "zip") {
            UniteFunctionsUC::throwError("wrong file given");
        }
        $pathCache = GlobalsUC::$path_cache;
        UniteFunctionsUC::mkdirValidate($pathCache, "cache folder");
        $pathCacheImport = $pathCache . "import/";
        UniteFunctionsUC::mkdirValidate($pathCacheImport, "cache import folder");
        $filepath = $pathCacheImport . $filename;
        $content = @file_get_contents($urlFile);
        if (empty($content)) {
            UniteFunctionsUC::throwError("Can't dowonload file from url: {$urlFile}");
        }
        UniteFunctionsUC::writeFile($content, $filepath);
        return $filepath;
    }
    public static function getFileContentByUrl($url, $filterExtention = null)
    {
        if (!empty($filterExtention)) {
            $info = pathinfo($url);
            $ext = UniteFunctionsUC::getVal($info, "extension");
            $ext = strtolower($ext);
            if ($ext != $filterExtention) {
                return null;
            }
        }
        $pathFile = self::urlToPath($url);
        if (empty($pathFile)) {
            return null;
        }
        if (file_exists($pathFile) == false) {
            return null;
        }
        $content = @file_get_contents($pathFile);
        return $content;
    }
    public static function a________VIEW_TEMPLATE_____()
    {
    }
    public static function getUrlAjax($action, $params = "")
    {
        $urlAjax = GlobalsUC::$url_ajax_full;
        $urlAjax = UniteFunctionsUC::addUrlParams($urlAjax, "action=" . GlobalsUC::PLUGIN_NAME . "_ajax_action&client_action={$action}");
        $nonce = UniteProviderFunctionsUC::getNonce();
        $urlAjax .= "&nonce={$nonce}";
        if (!empty($params)) {
            $urlAjax .= "&" . $params;
        }
        return $urlAjax;
    }
    public static function getViewUrl($viewName, $urlParams = "", $isBlankWindow = false, $isFront = false)
    {
        $params = "view=" . $viewName;
        if (!empty($urlParams)) {
            $params .= "&" . $urlParams;
        }
        if ($isFront == false) {
            $link = UniteFunctionsUC::addUrlParams(GlobalsUC::$url_component_admin, $params);
        } else {
            $link = UniteFunctionsUC::addUrlParams(GlobalsUC::$url_component_client, $params);
        }
        if ($isBlankWindow == true) {
            $link = UniteProviderFunctionsUC::convertUrlToBlankWindow($link);
        }
        $link = UniteProviderFunctionsUC::applyFilters(UniteCreatorFilters::FILTER_MODIFY_URL_VIEW, $link, $viewName, $params, $isBlankWindow, $isFront);
        return $link;
    }
    public static function getViewUrl_Addons($type = "")
    {
        if (empty($type)) {
            return self::getViewUrl(GlobalsUC::VIEW_ADDONS_LIST);
        }
        $params = array();
        $type = urldecode($type);
        $params = "addontype={$type}";
        $urlView = self::getViewUrl(GlobalsUC::VIEW_ADDONS_LIST, $params);
        return $urlView;
    }
    public static function getViewUrl_Default($params = "")
    {
        return self::getViewUrl(GlobalsUC::$view_default, $params);
    }
    public static function getViewUrl_TemplatesList($params = array(), $layoutType = null)
    {
        $urlParams = "";
        if (!empty($layoutType)) {
            $params["layout_type"] = $layoutType;
            $urlParams = "layout_type=" . $layoutType;
        }
        $url = self::getViewUrl(GlobalsUC::VIEW_TEMPLATES_LIST, $urlParams);
        $url = UniteProviderFunctionsUC::applyFilters(UniteCreatorFilters::FILTER_URL_TEMPLATES_LIST, $url, $params, $layoutType);
        return $url;
    }
    public static function getViewUrl_LayoutsList($params = array(), $layoutType = "")
    {
        $urlParams = "";
        if (!empty($layoutType)) {
            $params["layout_type"] = $layoutType;
            $urlParams = "layout_type=" . $layoutType;
        }
        $url = self::getViewUrl(GlobalsUC::VIEW_LAYOUTS_LIST, $urlParams);
        $url = UniteProviderFunctionsUC::applyFilters(UniteCreatorFilters::FILTER_URL_LAYOUTS_LIST, $url, $params);
        return $url;
    }
    private static function getUrlViewObject($view, $objectID, $optParams, $isBlankWindow = false)
    {
        $params = "";
        if (!empty($objectID)) {
            $params = "id={$objectID}";
        }
        if (!empty($optParams)) {
            if (!empty($params)) {
                $params .= "&";
            }
            $params .= $optParams;
        }
        return self::getViewUrl($view, $params, $isBlankWindow);
    }
    public static function getViewUrl_Layout($layoutID = null, $optParams = "", $layoutType = "")
    {
        if (!empty($layoutType)) {
            if (!empty($optParams)) {
                $optParams .= "&";
            }
            $optParams .= "layout_type=" . $layoutType;
        }
        $url = self::getUrlViewObject(GlobalsUC::VIEW_LAYOUT, $layoutID, $optParams, true);
        return $url;
    }
    public static function getViewUrl_Template($templateID = null, $templateType = "", $optParams = "")
    {
        UniteFunctionsUC::validateNotEmpty($templateType);
        if (!empty($optParams)) {
            $optParams .= "&";
        }
        $optParams .= "layout_type=" . $templateType;
        return self::getViewUrl_Layout($templateID, $optParams);
    }
    public static function getViewUrl_LayoutPreviewTemplate()
    {
        $urlTemplate = self::getViewUrl_LayoutPreview("[page]", true);
        return $urlTemplate;
    }
    public static function getViewUrl_LayoutPreview($layoutID, $isBlankWindow = false, $addParams = "", $isFront = true)
    {
        if ($layoutID == "[page]") {
            $urlPreviewTemplate = UniteProviderFunctionsUC::applyFilters("get_layout_preview_byid", null, $layoutID);
            if (!empty($urlPreviewTemplate)) {
                return $urlPreviewTemplate;
            }
        }
        $layoutID = (int) $layoutID;
        UniteFunctionsUC::validateNotEmpty($layoutID, "layout id");
        $urlPreview = null;
        $urlPreview = UniteProviderFunctionsUC::applyFilters("get_layout_preview_byid", $urlPreview, $layoutID);
        if (!empty($urlPreview)) {
            return $urlPreview;
        }
        $params = "id={$layoutID}";
        if (!empty($addParams)) {
            $params .= "&" . $addParams;
        }
        $url = self::getViewUrl(GlobalsUC::VIEW_LAYOUT_PREVIEW, $params, $isBlankWindow, $isFront);
        return $url;
    }
    public static function getUrlLayoutPreviewFront($layoutID, $addParams = null, $outputMode = null)
    {
        if (!empty($outputMode)) {
            if (empty($addParams)) {
                $addParams = "";
            }
            if (!empty($addParams)) {
                $addParams .= "&";
            }
            $addParams .= "outputmode=" . $outputMode;
        }
        $url = HelperUC::getViewUrl_LayoutPreview($layoutID, true, $addParams, true);
        $url = UniteProviderFunctionsUC::applyFilters(UniteCreatorFilters::FILTER_MODIFY_URL_LAYOUT_PREVIEW_FRONT, $url, $layoutID, $addParams);
        return $url;
    }
    public static function getViewUrl_EditAddon($addonID, $params = "", $hash = "")
    {
        $addonID = (int) $addonID;
        $strParams = "id={$addonID}";
        if (!empty($params)) {
            $strParams .= "&" . $params;
        }
        if (!empty($hash)) {
            $strParams .= "#" . $hash;
        }
        return self::getViewUrl(GlobalsUC::VIEW_EDIT_ADDON, $strParams);
    }
    public static function getViewUrl_TestAddon($addonID, $optParams = "")
    {
        $params = "id={$addonID}";
        if (!empty($optParams)) {
            $params .= "&" . $optParams;
        }
        return self::getViewUrl(GlobalsUC::VIEW_TEST_ADDON, $params);
    }
    public static function getViewUrl_AddonDefaults($addonID, $optParams = "")
    {
        $params = "id={$addonID}";
        if (!empty($optParams)) {
            $params .= "&" . $optParams;
        }
        return self::getViewUrl(GlobalsUC::VIEW_ADDON_DEFAULTS, $params);
    }
    public static function getTitleFromUrl($url, $defaultTitle = "item")
    {
        $info = pathinfo($url);
        $filename = UniteFunctionsUC::getVal($info, "filename");
        $filename = urldecode($filename);
        $title = $defaultTitle;
        if (!empty($filename)) {
            $title = $filename;
        }
        return $title;
    }
    private static function getPathFile($filename, $path, $defaultPath, $validateName, $ext = "php")
    {
        if (empty($path)) {
            $path = $defaultPath;
        }
        $filepath = $path . $filename . "." . $ext;
        UniteFunctionsUC::validateFilepath($filepath, $validateName);
        return $filepath;
    }
    public static function getPathTemplate($templateName, $path = null)
    {
        return self::getPathFile($templateName, $path, GlobalsUC::$pathTemplates, "Template");
    }
    public static function getPathView($viewName, $path = null)
    {
        return self::getPathFile($viewName, $path, GlobalsUC::$pathViews, "View");
    }
    public static function getPathViewObject($viewObjectName, $path = null)
    {
        return self::getPathFile($viewObjectName, $path, GlobalsUC::$pathViewsObjects, "View Object");
    }
    public static function getPathSettings($settingsName, $path = null)
    {
        return self::getPathFile($settingsName, $path, GlobalsUC::$pathSettings, "Settings", "xml");
    }
    public static function getPathTemplateProvider($templateName)
    {
        return self::getPathFile($templateName, GlobalsUC::$pathProviderTemplates, "", "Provider Template");
    }
    public static function getPathViewProvider($viewName)
    {
        return self::getPathFile($viewName, GlobalsUC::$pathProviderViews, "", "Provider View");
    }
    public static function getUrlFontAwesome($version = null)
    {
        if (empty($version)) {
            $version = "fa5";
        }
        if ($version == "fa4") {
            $url = GlobalsUC::$url_assets_libraries . "font-awsome/css/font-awesome.min.css";
        } else {
            $url = GlobalsUC::$url_assets_libraries . "font-awesome5/css/fontawesome-all.min.css";
        }
        return $url;
    }
    public static function a______SCRIPTS______()
    {
    }
    public static function putSmoothScrollIncludes($putJSInit = false)
    {
        $urlSmoothScroll = GlobalsUC::$url_assets_libraries . "smooth-scroll/smooth-scroll.min.js";
        HelperUC::addScriptAbsoluteUrl($urlSmoothScroll, "smooth-scroll");
        if ($putJSInit == false) {
            return false;
        }
        $script = "\r\n\t\t\t\twindow.addEventListener('load', function(){\r\n\t\t\t\t\tvar g_ucSmoothScroll = new SmoothScroll('a[href*=\"#\"]',{speed:1000});\r\n\t\t\t\t});\r\n\t\t\t";
        HelperUC::putCustomScript($script);
    }
    public static function putAnimationIncludes($animateOnly = false)
    {
        if (self::$isPutAnimations == true) {
            return false;
        }
        $urlAnimateCss = GlobalsUC::$url_assets_libraries . "animate/animate.css";
        self::addStyleAbsoluteUrl($urlAnimateCss, "animate");
        if ($animateOnly == true) {
            return false;
        }
        UniteProviderFunctionsUC::addAdminJQueryInclude();
        $urlWowJs = GlobalsUC::$url_assets_libraries . "animate/wow.min.js";
        self::addScriptAbsoluteUrl($urlWowJs, "wowjs");
        $script = "jQuery(document).ready(function(){new WOW().init()});";
        UniteProviderFunctionsUC::printCustomScript($script);
        self::$isPutAnimations = true;
    }
    public static function addScript($scriptName, $handle = null, $folder = "js", $inFooter = false)
    {
        if ($handle == null) {
            $handle = GlobalsUC::PLUGIN_NAME . "-" . $scriptName;
        }
        $url = GlobalsUC::$urlPlugin . $folder . "/" . $scriptName . ".js";
        UniteProviderFunctionsUC::addScript($handle, $url, $inFooter);
    }
    public static function addScriptAbsoluteUrl($urlScript, $handle, $inFooter = false)
    {
        UniteProviderFunctionsUC::addScript($handle, $urlScript, $inFooter);
    }
    public static function addStyle($styleName, $handle = null, $folder = "css")
    {
        if ($handle == null) {
            $handle = GlobalsUC::PLUGIN_NAME . "-" . $styleName;
        }
        UniteProviderFunctionsUC::addStyle($handle, GlobalsUC::$urlPlugin . $folder . "/" . $styleName . ".css");
    }
    public static function putCustomScript($script, $hardCoded = false)
    {
        UniteProviderFunctionsUC::printCustomScript($script, $hardCoded);
    }
    public static function putInlineStyle($css)
    {
        if (empty($css)) {
            return false;
        }
        $hash = md5($css);
        if (isset(self::$arrHashCache[$hash])) {
            return false;
        }
        self::$arrHashCache[$hash] = true;
        UniteProviderFunctionsUC::printCustomStyle($css);
    }
    public static function addStyleAbsoluteUrl($styleUrl, $handle)
    {
        UniteProviderFunctionsUC::addStyle($handle, $styleUrl);
    }
    public static function outputNote($message)
    {
        $message = esc_html($message);
        $message = "system note: <b>&nbsp;&nbsp;&nbsp;&nbsp;" . $message . "</b>";
        ?>
			<div class='unite-note'><?php 
        echo esc_html($message);
        ?></div>;
			<?php 
    }
    public static function outputAddonFromData($data)
    {
        $addons = new UniteCreatorAddons();
        $objAddon = $addons->initAddonByData($data);
        $objOutput = new UniteCreatorOutput();
        $objOutput->initByAddon($objAddon);
        $html = $objOutput->getHtmlBody();
        $objOutput->processIncludes();
        echo UniteProviderFunctionsUC::escCombinedHtml($html);
    }
    public static function getHtmlErrorMessage($message, $trace = "", $prefix = null)
    {
        if (empty($prefix)) {
            $prefix = HelperUC::getText("addon_library") . " Error: ";
        }
        $message = $prefix . $message;
        $html = self::$operations->getErrorMessageHtml($message, $trace);
        return $html;
    }
    public static function a______ASSETS_PATH______()
    {
    }
    public static function getAssetsPath($objAddonType = null)
    {
        if (empty($objAddonType)) {
            return GlobalsUC::$pathAssets;
        }
        if (!empty($objAddonType->pathAssets)) {
            return $objAddonType->pathAssets;
        }
        return GlobalsUC::$pathAssets;
    }
    public static function getAssetsUrl($objAddonType = null)
    {
        if (empty($objAddonType)) {
            return GlobalsUC::$url_assets;
        }
        if (!empty($objAddonType->urlAssets)) {
            return $objAddonType->urlAssets;
        }
        return GlobalsUC::$url_assets;
    }
    public static function validatePathUnderAssets($path, $objAddonType = null)
    {
        $isUnderAssets = self::isPathUnderAssetsPath($path, $objAddonType);
        if (!$isUnderAssets) {
            UniteFunctionsUC::throwError("The path should be under assets folder");
        }
    }
    public static function validateDBTablesExists()
    {
        $db = self::getDB();
        if ($db->isTableExists(GlobalsUC::$table_categories . "," . GlobalsUC::$table_addons) == false) {
            UniteFunctionsUC::throwError("Some DB table not exists");
        }
    }
    public static function isPathUnderAssetsPath($path, $objAddonType = null)
    {
        $assetsPath = self::getAssetsPath($objAddonType);
        $path = self::pathToAbsolute($path);
        $assetsPath = self::pathToAbsolute($assetsPath);
        $isUnderAssets = UniteFunctionsUC::isPathUnderBase($path, $assetsPath);
        return $isUnderAssets;
    }
    public static function isUrlUnderAssets($url, $objAddonType = null)
    {
        $urlAssets = self::getAssetsUrl($objAddonType);
        $url = self::URLtoFull($url);
        $url = strtolower($url);
        if (strpos($url, $urlAssets) !== false) {
            return true;
        }
        return false;
    }
    public static function isPathAssets($path, $objAddonType = null)
    {
        $assetsPath = self::getAssetsPath($objAddonType);
        $assetsPath = self::pathToAbsolute($assetsPath);
        $path = self::pathToAbsolute($path);
        if (!empty($path) && $path === $assetsPath) {
            return true;
        }
        return false;
    }
    public static function pathToAssetsRelative($path, $objAddonType = null)
    {
        $assetsPath = self::getAssetsPath($objAddonType);
        $assetsPath = self::pathToAbsolute($assetsPath);
        $path = self::pathToAbsolute($path);
        $relativePath = UniteFunctionsUC::pathToRelative($path, $assetsPath);
        return $relativePath;
    }
    public static function pathToAssetsAbsolute($path, $objAddonType = null)
    {
        if (self::isPathUnderAssetsPath($path, $objAddonType) == true) {
            return $path;
        }
        $assetsPath = self::getAssetsPath($objAddonType);
        $path = UniteFunctionsUC::joinPaths($assetsPath, $path);
        return $path;
    }
    public static function a______OUTPUT_LAYOUT______()
    {
    }
    public static function getDefaultPreviewImage($typeName)
    {
        $filenameDefaultPreview = "preview_{$typeName}.jpg";
        $urlPreview = GlobalsUC::$urlPlugin . "images/" . $filenameDefaultPreview;
        return $urlPreview;
    }
    public static function isElementorEditMode()
    {
        if (isset($_GET["elementor-preview"])) {
            return true;
        }
        $argPost = UniteFunctionsUC::getPostGetVariable("post", "", UniteFunctionsUC::SANITIZE_KEY);
        $argAction = UniteFunctionsUC::getPostGetVariable("action", "", UniteFunctionsUC::SANITIZE_KEY);
        if ($argAction == "elementor_render_widget" || $argAction == "elementor_ajax") {
            return true;
        }
        if (!empty($argPost) && !empty($argAction)) {
            return true;
        }
        return false;
    }
    public static function startBufferingWidgetsOutput()
    {
        UniteCreatorOutput::$isBufferingCssActive = true;
    }
    public static function outputWidgetsCssBuffer()
    {
        $htmlCssIncludes = UniteCreatorOutput::$bufferCssIncludes;
        echo "\n";
        echo $htmlCssIncludes;
        $css = UniteCreatorOutput::$bufferBodyCss;
        if (!empty($css)) {
            echo "\n<style type='text/css'> \n";
            echo "\n/* Unlimited Elements Css */ \n\n";
            echo $css . "\n";
            echo "</style>\n";
        }
        UniteCreatorOutput::$bufferCssIncludes = "";
        UniteCreatorOutput::$bufferBodyCss = "";
    }
    public static function outputTemplatePart($layoutType)
    {
        try {
            $objLayouts = new UniteCreatorLayouts();
            $objLayout = $objLayouts->getActiveTempaltePart($layoutType);
        } catch (Exception $e) {
            HelperHtmlUC::outputException($e);
            return false;
        }
        if (empty($objLayout)) {
            $typeTitle = $objLayouts->getLayoutTypeTitle($layoutType);
            $message = esc_html__("Template part", "unlimited-elements-for-elementor") . ": " . $typeTitle . esc_html__(" not found. Please create one in template parts page", "unlimited-elements-for-elementor");
            $html = HelperHtmlUC::getErrorMessageHtml($message);
            echo UniteProviderFunctionsUC::escCombinedHtml($html);
            return false;
        }
        self::outputLayout($objLayout);
    }
    public static function outputLayout($layoutID, $getHtml = false, $outputFullPage = false, $mode = null)
    {
        try {
            if (is_numeric($layoutID)) {
                $layoutID = UniteProviderFunctionsUC::sanitizeVar($layoutID, UniteFunctionsUC::SANITIZE_ID);
                $layout = new UniteCreatorLayout();
                $layout->initByID($layoutID);
            } else {
                $layout = $layoutID;
            }
            $outputLayout = new UniteCreatorLayoutOutput();
            $outputLayout->initByLayout($layout);
            if (!empty($mode)) {
                $outputLayout->setOutputMode($mode);
            }
            if ($getHtml == true) {
                if ($outputFullPage == false) {
                    $html = $outputLayout->getHtml();
                } else {
                    $html = $outputLayout->getFullPreviewHtml();
                }
                return $html;
            }
            if ($outputFullPage == false) {
                $outputLayout->putHtml();
            } else {
                $outputLayout->putFullPreviewHtml();
            }
            return $outputLayout;
        } catch (Exception $e) {
            if ($getHtml == true) {
                throw $e;
            } else {
                HelperHtmlUC::outputExceptionBox($e, HelperUC::getText("addon_library") . " Error");
            }
        }
    }
}
HelperUC::$operations = new UCOperations();