/** * * get revolution slider captions css */ function putRevCssCaptions() { $tableCss = "#__" . GlobalsRevSlider::TABLE_CSS_NAME; $db = new UniteDBRev(); $arrStyles = $db->fetch($tableCss); $cssStyles = UniteCssParserRev::parseDbArrayToCss($arrStyles, "\n"); header('Content-type: text/css'); echo $cssStyles; exit; }
/** * * a must function. you can not use it, but the function must stay there!. * */ public static function onAddScripts() { $operations = new RevOperations(); $arrValues = $operations->getGeneralSettingsValues(); $includesGlobally = UniteFunctionsRev::getVal($arrValues, "includes_globally", "on"); $includesFooter = UniteFunctionsRev::getVal($arrValues, "js_to_footer", "off"); $strPutIn = UniteFunctionsRev::getVal($arrValues, "pages_for_includes"); $isPutIn = RevSliderOutput::isPutIn($strPutIn, true); //put the includes only on pages with active widget or shortcode // if the put in match, then include them always (ignore this if) if ($isPutIn == false && $includesGlobally == "off") { $isWidgetActive = is_active_widget(false, false, "rev-slider-widget", true); $hasShortcode = UniteFunctionsWPRev::hasShortcode("rev_slider"); if ($isWidgetActive == false && $hasShortcode == false) { return false; } } self::addStyle("settings", "rs-plugin-settings", "rs-plugin/css"); //check if dynamic-captions.css exists. If not, include captions.php if (file_exists(self::$path_plugin . "rs-plugin/css/dynamic-captions.css") == false) { self::addDynamicStyle("captions", "rs-plugin-captions", "rs-plugin/css"); } else { $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); $styles = UniteCssParserRev::parseDbArrayToCss($styles, "\n"); wp_add_inline_style('rs-plugin-settings', $styles); //self::addStyle("dynamic-captions","rs-captions","rs-plugin/css"); } $custom_css = RevOperations::getStaticCss(); wp_add_inline_style('rs-plugin-settings', $custom_css); //self::addStyle("static-captions","rs-plugin-static","rs-plugin/css"); $setBase = is_ssl() ? "https://" : "http://"; $url_jquery = $setBase . "ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js?app=revolution"; self::addScriptAbsoluteUrl($url_jquery, "jquery"); if ($includesFooter == "off") { self::addScriptWaitFor("jquery.themepunch.plugins.min", "rs-plugin/js", 'themepunchtools', 'jquery'); self::addScriptWaitFor("jquery.themepunch.revolution.min", "rs-plugin/js", 'revmin', 'jquery'); } else { //put javascript to footer UniteBaseClassRev::addAction('wp_footer', 'putJavascript'); } }
/** * * @throws Exception */ public function initProcess() { // $loadTemplate = true; $revAction = Tools::getValue('revControllerAction'); // if(!empty($revAction)) $loadTemplate = false; $productAdmin = new RevSliderAdmin(_PS_MODULE_DIR_ . 'revsliderprestashop', $loadTemplate); switch ($revAction) { case 'uploadimage': $this->rev_uploader(); break; case 'captions': $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); header("Content-Type: text/css; charset=utf-8"); echo UniteCssParserRev::parseDbArrayToCss($styles, "\n"); break; default: break; } die; }
function cmo_import_sliders_ajax() { global $wpdb; if (!class_exists('UniteFunctionsRev')) { ajax_finish(false, __('Revolution Slider plugin is not installed or activated.', 'cumulo')); } else { $rev_directory = CMO_FRAMEWORK_PATH . '/demo/sliders/'; if (!empty($_POST['demo'])) { if ($_POST['demo'] != 'default') { $rev_directory .= $_POST['demo'] . '/'; } } foreach (glob($rev_directory . '*.zip') as $filename) { $filename = basename($filename); $rev_files[] = $rev_directory . $filename; } foreach ($rev_files as $rev_file) { $filepath = $rev_file; $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if ($importZip === true) { $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { if ($updateAnim == "true") { $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } } else { } //overwrite/append static-captions.css if (!empty($static)) { if (isset($updateStatic) && $updateStatic == "true") { RevOperations::updateStaticCss($static); } else { //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } else { } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = $wpdb->insert_id; $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; if (isset($params["image"])) { if (trim($params["image"]) !== '') { if ($importZip === true) { $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo esc_html($params["image"]) . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo esc_html($layer["image_url"]) . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } // create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $wpdb->insert(GlobalsRevSlider::$table_slides, $arrCreate); } } ajax_finish(true, "done"); } }
/** * Output Dynamic Inline Styles */ public function add_inline_styles() { echo '<div class="revsliderstyles">'; echo '<style type="text/css">'; $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); foreach ($styles as $key => $style) { $handle = str_replace('.tp-caption', '', $style['handle']); if (!isset($this->class_include[$handle])) { unset($styles[$key]); } } $styles = UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $styles = UniteCssParserRev::compress_css($styles); echo $styles; // KRISZTIAN MODIFICATION FOR INNERLAYERS $stylesinnerlayers = str_replace('.tp-caption', '', $styles); echo $stylesinnerlayers; // END MODIFICATION echo '</style>' . "\n"; echo '</div>'; }
public function importSliderFromPost($updateAnim = true, $updateStatic = true) { try { $sliderID = UniteFunctionsRev::getPostVariable("sliderid"); $sliderExists = !empty($sliderID); if ($sliderExists) { $this->initByID($sliderID); } $filepath = $_FILES["import_file"]["tmp_name"]; if (file_exists($filepath) == false) { UniteFunctionsRev::throwError("Import file not found!!!"); } if (!class_exists("ZipArchive")) { $importZip = false; } else { $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); } if ($importZip === true) { $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); if (!$slider_export) { UniteFunctionsRev::throwError("slider_export.txt does not exist!"); } $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } } else { $content = @file_get_contents($filepath); } if ($importZip === true) { $db = new UniteDBRev(); $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { if ($updateAnim == "true") { $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } dmp(__("animations imported!", REVSLIDER_TEXTDOMAIN)); } else { dmp(__("no custom animations found, if slider uses custom animations, the provided export may be broken...", REVSLIDER_TEXTDOMAIN)); } if (!empty($static)) { if ($updateStatic == "true") { RevOperations::updateStaticCss($static); } else { $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { continue; } if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } dmp(__("dynamic styles imported!", REVSLIDER_TEXTDOMAIN)); } else { dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...", REVSLIDER_TEXTDOMAIN)); } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); $arrSlider = @unserialize($content); if (empty($arrSlider)) { UniteFunctionsRev::throwError("Wrong export slider file format! This could be caused because the ZipArchive extension is not enabled."); } $sliderParams = $arrSlider["params"]; if ($sliderExists) { $sliderParams["title"] = $this->arrParams["title"]; $sliderParams["alias"] = $this->arrParams["alias"]; } if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); if ($sliderExists) { $arrUpdate = array("params" => $json_params); $this->db->update(GlobalsRevSlider::$table_sliders, $arrUpdate, array("id" => $sliderID)); } else { $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $this->db->insert(GlobalsRevSlider::$table_sliders, $arrInsert); } if ($sliderExists) { $this->deleteAllSlides(); } $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; if (isset($params["image"])) { if (strpos($params["image"], 'http') !== false) { } else { if (trim($params["image"]) !== '') { if ($importZip === true) { $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . __(' not found!<br>'); } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } } foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { if (trim($layer["image_url"]) !== '') { if (strpos($layer["image_url"], 'http') !== false) { } else { if ($importZip === true) { $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . __(' not found!<br>'); } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $my_layers = json_encode($layers); if (empty($my_layers)) { $my_layers = stripslashes(json_encode($layers)); } $my_params = json_encode($params); if (empty($my_params)) { $my_params = stripslashes(json_encode($params)); } $arrCreate["layers"] = $my_layers; $arrCreate["params"] = $my_params; $this->db->insert(GlobalsRevSlider::$table_slides, $arrCreate); } if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides'])) { $static_slide = $arrSlider['static_slides']; foreach ($static_slide as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; if (isset($params["image"])) { if (strpos($params["image"], 'http') !== false) { } else { if (trim($params["image"]) !== '') { if ($importZip === true) { $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . __(' not found!<br>'); } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } } foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { if (trim($layer["image_url"]) !== '') { if (strpos($layer["image_url"], 'http') !== false) { } else { if ($importZip === true) { $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . __(' not found!<br>'); } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $my_layers = json_encode($layers); if (empty($my_layers)) { $my_layers = stripslashes(json_encode($layers)); } $my_params = json_encode($params); if (empty($my_params)) { $my_params = stripslashes(json_encode($params)); } $arrCreate["layers"] = $my_layers; $arrCreate["params"] = $my_params; if ($sliderExists) { unset($arrCreate["slider_id"]); $this->db->update(GlobalsRevSlider::$table_static_slides, $arrCreate, array("slider_id" => $sliderID)); } else { $this->db->insert(GlobalsRevSlider::$table_static_slides, $arrCreate); } } } } catch (Exception $e) { $errorMessage = $e->getMessage(); return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID); } return array("success" => true, "sliderID" => $sliderID); }
/** * * import slider from multipart form */ public function importSliderFromPost($updateAnim = true, $updateStatic = true) { try { $sliderID = UniteFunctionsRev::getPostVariable("sliderid"); $sliderExists = !empty($sliderID); if ($sliderExists) { $this->initByID($sliderID); } $filepath = $_FILES["import_file"]["tmp_name"]; if (file_exists($filepath) == false) { UniteFunctionsRev::throwError("Import file not found!!!"); } //check if zip file or fallback to old, if zip, check if all files exist $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if ($importZip === true) { //true or integer. If integer, its not a correct zip file //check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); if (!$slider_export) { UniteFunctionsRev::throwError("slider_export.txt does not exist!"); } //if(!$custom_animations) UniteFunctionsRev::throwError("custom_animations.txt does not exist!"); //if(!$dynamic_captions) UniteFunctionsRev::throwError("dynamic-captions.css does not exist!"); //if(!$static_captions) UniteFunctionsRev::throwError("static-captions.css does not exist!"); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID if ($updateAnim == "true") { //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert with new handle $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } dmp(__("animations imported!", REVSLIDER_TEXTDOMAIN)); } else { dmp(__("no custom animations found, if slider uses custom animations, the provided export may be broken...", REVSLIDER_TEXTDOMAIN)); } //overwrite/append static-captions.css if (!empty($static)) { if ($updateStatic == "true") { //overwrite file RevOperations::updateStaticCss($static); } else { //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } dmp(__("dynamic styles imported!", REVSLIDER_TEXTDOMAIN)); } else { dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...", REVSLIDER_TEXTDOMAIN)); } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); if (empty($arrSlider)) { UniteFunctionsRev::throwError("Wrong export slider file format!"); } //update slider params $sliderParams = $arrSlider["params"]; if ($sliderExists) { $sliderParams["title"] = $this->arrParams["title"]; $sliderParams["alias"] = $this->arrParams["alias"]; $sliderParams["shortcode"] = $this->arrParams["shortcode"]; } if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); //update slider or craete new if ($sliderExists) { $arrUpdate = array("params" => $json_params); $this->db->update(GlobalsRevSlider::$table_sliders, $arrUpdate, array("id" => $sliderID)); } else { //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $this->db->insert(GlobalsRevSlider::$table_sliders, $arrInsert); } //-------- Slides Handle ----------- //delete current slides if ($sliderExists) { $this->deleteAllSlides(); } //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { //import if exists in zip folder if (trim($params["image"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $this->db->insert(GlobalsRevSlider::$table_slides, $arrCreate); } } catch (Exception $e) { $errorMessage = $e->getMessage(); return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID); } //update dynamic-captions.css RevOperations::updateDynamicCaptions(); return array("success" => true, "sliderID" => $sliderID); }
/** * * a must function. adds scripts on the page * add all page scripts and styles here. * pelase don't remove this function * common scripts even if the plugin not load, use this function only if no choise. */ public static function onAddScripts() { self::addStyle("edit_layers", "edit_layers"); //add google font //$urlGoogleFont = "http://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700"; //self::addStyleAbsoluteUrl($urlGoogleFont,"google-font-pt-sans-narrow"); self::addScriptCommon("edit_layers", "unite_layers"); self::addScriptCommon("css_editor", "unite_css_editor"); self::addScript("rev_admin"); self::addScript("jquery.themepunch.plugins.min", "rs-plugin/js", 'themepunchtools'); //include all media upload scripts self::addMediaUploadIncludes(); //add rs css: self::addStyle("settings", "rs-plugin-settings", "rs-plugin/css"); $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); $styles = UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $styles = UniteCssParserRev::compress_css($styles); wp_add_inline_style('rs-plugin-settings', $styles); $custom_css = RevOperations::getStaticCss(); $custom_css = UniteCssParserRev::compress_css($custom_css); wp_add_inline_style('rs-plugin-settings', $custom_css); //self::addStyle("static-captions","rs-plugin-static","rs-plugin/css"); }
/** * onAjax action handler */ public static function onFrontAjaxAction() { $db = new UniteDBRev(); $slider = new RevSlider(); $slide = new RevSlide(); $operations = new RevOperations(); $token = self::getPostVar("token", false); //verify the token $isVerified = wp_verify_nonce($token, 'RevSlider_Front'); $error = false; if ($isVerified) { $data = self::getPostVar('data', false); switch (self::getPostVar('client_action', false)) { case 'get_slider_html': $id = intval(self::getPostVar('id', 0)); if ($id > 0) { $html = ''; add_filter('revslider_add_js_delay', array('RevSliderAdmin', 'rev_set_js_delay')); ob_start(); $slider_class = RevSliderOutput::putSlider($id); $html = ob_get_contents(); //add styling $custom_css = RevOperations::getStaticCss(); $custom_css = UniteCssParserRev::compress_css($custom_css); $styles = $db->fetch(GlobalsRevSlider::$table_css); $styles = UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $styles = UniteCssParserRev::compress_css($styles); $html .= '<style type="text/css">' . $custom_css . '</style>'; $html .= '<style type="text/css">' . $styles . '</style>'; ob_clean(); ob_end_clean(); $result = !empty($slider_class) && $html !== '' ? true : false; if (!$result) { $error = __('Slider not found', REVSLIDER_TEXTDOMAIN); } else { if ($html !== false) { self::ajaxResponseData($html); } else { $error = __('Slider not found', REVSLIDER_TEXTDOMAIN); } } } else { $error = __('No Data Received', REVSLIDER_TEXTDOMAIN); } break; } } else { $error = true; } if ($error !== false) { $showError = __('Loading Error', REVSLIDER_TEXTDOMAIN); if ($error !== true) { $showError = __('Loading Error: ', REVSLIDER_TEXTDOMAIN) . $error; } self::ajaxResponseError($showError, false); } exit; }
/** * * a must function. adds scripts on the page * add all page scripts and styles here. * pelase don't remove this function * common scripts even if the plugin not load, use this function only if no choise. */ public static function onAddScripts() { global $wp_version; $style_pre = ''; $style_post = ''; if ($wp_version < 3.7) { $style_pre = '<style type="text/css">'; $style_post = '</style>'; } self::addStyle("edit_layers", "edit_layers"); //add google font //$urlGoogleFont = "http://fonts.useso.com/css?family=PT+Sans+Narrow:400,700"; //self::addStyleAbsoluteUrl($urlGoogleFont,"google-font-pt-sans-narrow"); self::addScriptCommon("edit_layers", "unite_layers"); self::addScriptCommon("css_editor", "unite_css_editor"); self::addScript("rev_admin"); self::addScript("jquery.themepunch.tools.min", "rs-plugin/js", 'tp-tools'); //include all media upload scripts self::addMediaUploadIncludes(); //add rs css: self::addStyle("settings", "rs-plugin-settings", "rs-plugin/css"); $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); $styles = UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $styles = UniteCssParserRev::compress_css($styles); wp_add_inline_style('rs-plugin-settings', $style_pre . $styles . $style_post); // KRISZTIAN MODIFICATION FOR INNERLAYERS $stylesinnerlayers = str_replace('.tp-caption', '', $styles); wp_add_inline_style('rs-plugin-settings', $style_pre . $stylesinnerlayers . $style_post); // END MODIFICATION $custom_css = RevOperations::getStaticCss(); $custom_css = UniteCssParserRev::compress_css($custom_css); wp_add_inline_style('rs-plugin-settings', $style_pre . $custom_css . $style_post); //self::addStyle("static-captions","rs-plugin-static","rs-plugin/css"); }
<?php header("Content-Type: text/css; charset=utf-8"); $absolute_path = str_replace('\\', '/', __FILE__); $path_to_file = explode('/revslider/rs-plugin/', $absolute_path); $path_to_wp = $path_to_file[0] . '/../..'; require_once $path_to_wp . '/wp-load.php'; $currentFolder = dirname($absolute_path); //include framework files require_once $currentFolder . '/../../inc_php/framework/include_framework.php'; $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); echo UniteCssParserRev::parseDbArrayToCss($styles, "\n");
function tt_revo_importer() { if (class_exists('UniteFunctionsRev')) { global $wpdb; $revo_directory = get_stylesheet_directory() . '/framework/addons/wordpress-importer/files/revsliders/'; $revo_files = array(); $db = new UniteDBRev(); $revo_obj = new RevSlider(); $aliases = $revo_obj->getAllSliderAliases(); foreach (glob($revo_directory . '*.txt') as $filename) { $filename = basename($filename); $revo_files[] = get_stylesheet_directory_uri() . '/framework/addons/wordpress-importer/files/revsliders/' . $filename; } foreach ($revo_files as $rev_file) { $get_revo_file = wp_remote_get($rev_file); $ncd = $get_revo_file['body']; if (base64_decode($ncd, true)) { $slider_data = @unserialize(base64_decode($ncd)); } else { ob_start(); $ncd = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", trim($ncd)); //clear errors in string ob_end_clean(); $slider_data = @unserialize($ncd); } if (empty($slider_data)) { continue; } $slider_params = $slider_data["params"]; if (in_array($slider_params['alias'], $aliases)) { continue; } $serialized_content = serialize($slider_data); /* Detecting Animations and Styles */ $animations = isset($slider_data["custom_animations"]) ? $slider_data["custom_animations"] : array(); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } $serialized_content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $serialized_content); } } // Static Captions $static = isset($slider_data["static_captions"]) ? $slider_data["static_captions"] : ""; if (!empty($static)) { RevOperations::updateStaticCss($static); } //overwrite/create dynamic-captions.css //parse css to classes if (isset($slider_data["dynamic_captions"]) && !empty($slider_data["dynamic_captions"])) { $dynamicCss = UniteCssParserRev::parseCssToArray($slider_data["dynamic_captions"]); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } } $slider_data = unserialize($serialized_content); $slider_params = $slider_data["params"]; /* if(isset($slider_params["background_image"])) { $slider_params["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($slider_params["background_image"]); } */ $json_params = json_encode($slider_params); $revoSliderInstance = array(); $revoSliderInstance["params"] = $json_params; $revoSliderInstance["title"] = UniteFunctionsRev::getVal($slider_params, "title", $slider_params['title']); $revoSliderInstance["alias"] = UniteFunctionsRev::getVal($slider_params, "alias", $slider_params['alias']); $sliderID = $db->insert(GlobalsRevSlider::$table_sliders, $revoSliderInstance); //create all slides $revoSlides = $slider_data["slides"]; foreach ($revoSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { // $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); $params["image"] = tt_revo_fix_img_url($slider_params["background_image"], $params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { // $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layer["image_url"] = tt_revo_fix_img_url($slider_params["background_image"], $layer["image_url"]); $layers[$key] = $layer; } } //create new slide $SlideInstance = array(); $SlideInstance["slider_id"] = $sliderID; $SlideInstance["slide_order"] = $slide["slide_order"]; $my_layers = json_encode($layers); if (empty($my_layers)) { $my_layers = stripslashes(json_encode($layers)); } $my_params = json_encode($params); if (empty($my_params)) { $my_params = stripslashes(json_encode($params)); } $SlideInstance["layers"] = $my_layers; $SlideInstance["params"] = $my_params; $db->insert(GlobalsRevSlider::$table_slides, $SlideInstance); } //check if static slide exists and import if (isset($slider_data['static_slides']) && !empty($slider_data['static_slides'])) { $static_slide = $slider_data['static_slides']; foreach ($static_slide as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { $params["image"] = tt_revo_fix_img_url($slider_params["background_image"], $params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { $layer["image_url"] = tt_revo_fix_img_url($slider_params["background_image"], $layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $my_layers = json_encode($layers); if (empty($my_layers)) { $my_layers = stripslashes(json_encode($layers)); } $my_params = json_encode($params); if (empty($my_params)) { $my_params = stripslashes(json_encode($params)); } $arrCreate["layers"] = $my_layers; $arrCreate["params"] = $my_params; $this->db->insert(GlobalsRevSlider::$table_static_slides, $arrCreate); } } } } }
} if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID if ($updateAnim == "true") { //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else {
public function previewOutputMarkup($sliderID, $output = null) { if ($sliderID == "empty_output") { $this->loadingMessageOutput(); exit; } if ($output == null) { $output = new RevSliderOutput(); } $slider = new RevSlider(); $slider->initByID($sliderID); $output->setPreviewMode(); //put the output html $urlPlugin = "http://yourpluginpath/"; $urlPreviewPattern = UniteBaseClassRev::$url_ajax_actions . "&client_action=preview_slider&only_markup=true&sliderid=" . $sliderID . "&lang=[lang]&nonce=[nonce]"; $setBase = Mage::helper('nwdrevslider')->isSsl() ? "https://" : "http://"; ?> <html> <head> <script type='text/javascript' src='<?php echo $setBase; ?> ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script> </head> <body style="padding:0px;margin:0px;"> <?php //UniteBaseClassRev::$url_plugin ob_start(); ?> <link rel='stylesheet' href='<?php echo $urlPlugin; ?> css/settings.css?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?> ' type='text/css' media='all' /> <?php $_usedStyles = array(); $_slides = $slider->getSlides(); foreach ($_slides as $_slide) { $_layers = $_slide->getLayers(); foreach ($_layers as $_layer) { $_style = isset($_layer['style']) ? $_layer['style'] : ''; if ($_style && !in_array($_style, $_usedStyles)) { $_usedStyles[] = $_style; } } } echo Mage::helper('nwdrevslider')->inlcudeStyleFonts($_usedStyles); $http = Mage::helper('nwdrevslider')->isSsl() ? 'https' : 'http'; ?> <script type='text/javascript' src='<?php echo $urlPlugin; ?> js/jquery.themepunch.tools.min.js?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?> '></script> <script type='text/javascript' src='<?php echo $urlPlugin; ?> js/jquery.themepunch.revolution.min.js?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?> '></script> <?php $head_content = ob_get_contents(); ob_clean(); ob_end_clean(); ob_start(); $custom_css = RevOperations::getStaticCss(); echo $custom_css . "\n\n"; echo '/*****************' . "\n"; echo ' ** ' . __('CAPTIONS CSS') . "\n"; echo ' ****************/' . "\n\n"; $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); echo UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $style_content = ob_get_contents(); ob_clean(); ob_end_clean(); ob_start(); $output->putSliderBase($sliderID); $content = ob_get_contents(); ob_clean(); ob_end_clean(); $script_content = substr($content, strpos($content, '<script type="text/javascript">'), strpos($content, '</script>') + 9 - strpos($content, '<script type="text/javascript">')); $content = htmlentities(str_replace($script_content, '', $content)); $script_content = str_replace(' ', '', $script_content); $script_content = str_replace(array('<script type="text/javascript">', '</script>'), '', $script_content); ?> <style> body { font-family:sans-serif; font-size:12px;} textarea { background:#f1f1f1; border:#ddd; font-size:10px; line-height:16px; margin-bottom:40px; padding:10px;} .rev_cont_title { color:#000; text-decoration:none;font-size:14px; line-height:24px; font-weight:800;background: #D5D5D5;padding: 10px;} .rev_cont_title a, .rev_cont_title a:visited { margin-left:25px;font-size:12px;line-height:12px;float:right;background-color:#8e44ad; color:#fff; padding:8px 10px;text-decoration:none;} .rev_cont_title a:hover { background-color:#9b59b6} </style> <p><?php $dir = Mage::getBaseUrl('media'); ?> <?php echo Mage::helper('nwdrevslider')->__('Replace image path:'); ?> <?php echo Mage::helper('nwdrevslider')->__('From:'); ?> <input type="text" name="orig_image_path" value="<?php echo $dir; ?> " /> <?php echo Mage::helper('nwdrevslider')->__('To:'); ?> <input type="text" name="replace_image_path" value="" /> <input id="rev_replace_images" type="button" name="replace_images" value="<?php echo Mage::helper('nwdrevslider')->__('Replace'); ?> " /> </p> <div class="rev_cont_title"><?php echo Mage::helper('nwdrevslider')->__('Header'); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_head_content" href="javascript:void(0);" original-title=""><?php echo Mage::helper('nwdrevslider')->__('Mark to Copy'); ?> </a><div style="clear:both"></div></div> <textarea id="rev_head_content" readonly="true" style="width: 100%; height: 100px; color:#3498db"><?php echo $head_content; ?> </textarea> <div class="rev_cont_title"><?php echo Mage::helper('nwdrevslider')->__('CSS'); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_style_content" href="javascript:void(0);" original-title=""><?php echo Mage::helper('nwdrevslider')->__('Mark to Copy'); ?> </a></div> <textarea id="rev_style_content" readonly="true" style="width: 100%; height: 100px;"><?php echo $style_content; ?> </textarea> <div class="rev_cont_title"><?php echo Mage::helper('nwdrevslider')->__('Body'); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_the_content" href="javascript:void(0);" original-title=""><?php echo Mage::helper('nwdrevslider')->__('Mark to Copy'); ?> </a></div> <textarea id="rev_the_content" readonly="true" style="width: 100%; height: 100px;"><?php echo $content; ?> </textarea> <div class="rev_cont_title"><?php echo Mage::helper('nwdrevslider')->__('Script'); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_script_content" href="javascript:void(0);" original-title=""><?php echo Mage::helper('nwdrevslider')->__('Mark to Copy'); ?> </a></div> <textarea id="rev_script_content" readonly="true" style="width: 100%; height: 100px;"><?php echo $script_content; ?> </textarea> <script> jQuery('body').on('click','.copytoclip',function() { jQuery("#"+jQuery(this).data('idt')).select(); }); jQuery('#rev_replace_images').on('click', function() { var originalPath = jQuery('input[name=orig_image_path]').val(); var replacePath = jQuery('input[name=replace_image_path]').val(); var revContent = $('#rev_the_content').val(); $('#rev_the_content').val(revContent.replace(originalPath, replacePath)); jQuery('input[name=orig_image_path]').val(replacePath); jQuery('input[name=replace_image_path]').val(originalPath); }); </script> </body> </html> <?php exit; }
/** * Output Dynamic Inline Styles */ public function add_inline_styles() { //echo '<div class="revsliderstyles">'; echo '<style scoped>'; $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); foreach ($styles as $key => $style) { $handle = str_replace('.tp-caption', '', $style['handle']); if (!isset($this->class_include[$handle])) { unset($styles[$key]); } } $styles = UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $styles = UniteCssParserRev::compress_css($styles); echo $styles; echo '</style>' . "\n"; //echo '</div>'; }
/** * * import contents of the css file */ public static function importCaptionsCssContentArray() { $db = new UniteDBRev(); $css = self::getCaptionsCssContentArray(); $static = array(); if (is_array($css) && $css !== false && count($css) > 0) { foreach ($css as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img $static[$class] = $styles; continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } if (!empty($static)) { //save static into static-captions.css $css = UniteCssParserRev::parseStaticArrayToCss($static); $static_cur = RevOperations::getStaticCss(); //get the open sans line! $css = $static_cur . "\n" . $css; self::updateStaticCss($css); } }
function royal_revslider_import($revslider_path) { if (!file_exists($revslider_path)) { return; } global $wpdb; if (class_exists('UniteFunctionsRev')) { // get zip files foreach (glob($revslider_path . '*.zip') as $filename) { $filename = basename($filename); $revslider_archives[] = $revslider_path . $filename; } foreach ($revslider_archives as $revslider_archive) { // finally import rev slider data files $filepath = $revslider_archive; // check if zip file or fallback to old, if zip, check if all files exist if (!class_exists("ZipArchive")) { $importZip = false; } else { $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); } if ($importZip === true) { // true or integer. If integer, its not a correct zip file // check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } } //overwrite/append static-captions.css if (!empty($static)) { $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = $wpdb->insert_id; //-------- Slides Handle ----------- //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { //import if exists in zip folder if (trim($params["image"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image = $zip->getStream('images/' . $params["image"]); if (!$image) { // echo 'Not Found'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { // echo 'Not Found'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $wpdb->insert(GlobalsRevSlider::$table_slides, $arrCreate); } } } }
function fusion_importer() { global $wpdb; if (current_user_can('manage_options')) { if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } // we are loading importers if (!class_exists('WP_Importer')) { // if main importer class doesn't exist $wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; include $wp_importer; } if (!class_exists('WP_Import')) { // if WP importer doesn't exist $wp_import = get_template_directory() . '/framework/plugins/importer/wordpress-importer.php'; include $wp_import; } if (class_exists('WP_Importer') && class_exists('WP_Import')) { // check for main import class and wp import class if (!isset($_POST['demo_type']) || trim($_POST['demo_type']) == '') { $demo_type = 'classic'; } else { $demo_type = $_POST['demo_type']; } switch ($demo_type) { case 'agency': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/agency_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/agency_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/agency_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/agency_demo/fusion_slider.zip'; break; case 'app': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/app_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/app_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/app_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/app_demo/fusion_slider.zip'; break; case 'travel': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/travel_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/travel_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/travel_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/travel_demo/fusion_slider.zip'; break; case 'cafe': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/cafe_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/cafe_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/cafe_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/cafe_demo/fusion_slider.zip'; break; case 'fashion': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/fashion_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/fashion_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/fashion_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/fashion_demo/fusion_slider.zip'; break; case 'architecture': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/architecture_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/architecture_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/architecture_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/architecture_demo/fusion_slider.zip'; break; case 'hosting': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/hosting_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/hosting_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/hosting_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/hosting_demo/fusion_slider.zip'; break; case 'hotel': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/hotel_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/hotel_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/hotel_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/hotel_demo/fusion_slider.zip'; break; case 'law': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/law_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/law_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/law_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/law_demo/fusion_slider.zip'; break; case 'lifestyle': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/fusion_slider.zip'; break; default: $shop_demo = true; $woo_xml = get_template_directory() . '/framework/plugins/importer/classic_demo/avada.xml'; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/classic_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/classic_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('ContactSidebar' => 'Contact Sidebar', 'FAQ' => 'FAQ', 'HomepageSidebar' => 'Home Page Sidebar', 'Portfolio' => 'Portfolio', 'Megamenu1' => 'Megamenu1', 'Megamenu2' => 'Megamenu2'); // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/classic_demo/widget_data.json'; $layerslider_exists = true; $layer_directory = get_template_directory() . '/framework/plugins/importer/classic_demo/layersliders/'; $revslider_exists = true; $rev_directory = get_template_directory() . '/framework/plugins/importer/classic_demo/revsliders/'; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/classic_demo/fusion_slider.zip'; } add_filter('intermediate_image_sizes_advanced', 'avada_filter_image_sizes'); /* Import Woocommerce if WooCommerce Exists */ if (class_exists('WooCommerce') && $shop_demo == true) { $importer = new WP_Import(); $theme_xml = $woo_xml; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); // Set pages $woopages = array('woocommerce_shop_page_id' => 'Shop', 'woocommerce_cart_page_id' => 'Cart', 'woocommerce_checkout_page_id' => 'Checkout', 'woocommerce_pay_page_id' => 'Checkout → Pay', 'woocommerce_thanks_page_id' => 'Order Received', 'woocommerce_myaccount_page_id' => 'My Account', 'woocommerce_edit_address_page_id' => 'Edit My Address', 'woocommerce_view_order_page_id' => 'View Order', 'woocommerce_change_password_page_id' => 'Change Password', 'woocommerce_logout_page_id' => 'Logout', 'woocommerce_lost_password_page_id' => 'Lost Password'); foreach ($woopages as $woo_page_name => $woo_page_title) { $woopage = get_page_by_title($woo_page_title); if (isset($woopage) && $woopage->ID) { update_option($woo_page_name, $woopage->ID); // Front Page } } // We no longer need to install pages delete_option('_wc_needs_pages'); delete_transient('_wc_activation_redirect'); // Flush rules after install flush_rewrite_rules(); } else { $importer = new WP_Import(); /* Import Posts, Pages, Portfolio Content, FAQ, Images, Menus */ $theme_xml = $theme_xml_file; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); flush_rewrite_rules(); } // Set imported menus to registered theme locations $locations = get_theme_mod('nav_menu_locations'); // registered menu locations in theme $menus = wp_get_nav_menus(); // registered menus if ($menus) { if ($demo_type == 'classic') { $opmenu = get_page_by_title('One Page'); } foreach ($menus as $menu) { // assign menus to theme locations if ($demo_type == 'classic') { if ($menu->name == 'Main') { $locations['main_navigation'] = $menu->term_id; } else { if ($menu->name == '404') { $locations['404_pages'] = $menu->term_id; } else { if ($menu->name == 'Top') { $locations['top_navigation'] = $menu->term_id; } } } // Assign One Page Menu if (isset($opmenu) && $opmenu->ID && $menu->name == 'One Page') { update_post_meta($opmenu->ID, 'pyre_displayed_menu', $menu->term_id); } } elseif ($demo_type == 'agency') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'app') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'travel') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'cafe') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'fashion') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'architecture') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'hosting') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'hotel') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'law') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'lifestyle') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } } } set_theme_mod('nav_menu_locations', $locations); // set menus to locations // Import Theme Options $theme_options_txt = $theme_options_file; // theme options data file $theme_options_txt = file_get_contents($theme_options_txt); $smof_data = unserialize(base64_decode($theme_options_txt)); update_option(OPTIONS, $smof_data); // update theme options // Add sidebar widget areas if ($sidebar_exists == true) { update_option('sbg_sidebars', $sidebars); foreach ($sidebars as $sidebar) { $sidebar_class = avada_name_to_class($sidebar); register_sidebar(array('name' => $sidebar, 'id' => 'avada-custom-sidebar-' . strtolower($sidebar_class), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="heading"><h4 class="widget-title">', 'after_title' => '</h4></div>')); } } // Add data to widgets if (isset($widgets_file) && $widgets_file) { $widgets_json = $widgets_file; // widgets data file $widgets_json = file_get_contents($widgets_json); $widget_data = $widgets_json; $import_widgets = fusion_import_widget_data($widget_data); } // Import Layerslider if (function_exists('layerslider_import_sample_slider') && $layerslider_exists == true) { // if layerslider is activated // Get importUtil include WP_PLUGIN_DIR . '/LayerSlider/classes/class.ls.importutil.php'; foreach (glob($layer_directory . '*.zip') as $filename) { // get all files from revsliders data dir $filename = basename($filename); $layer_files[] = $layer_directory . $filename; } foreach ($layer_files as $layer_file) { // finally import layer slider $import = new LS_ImportUtil($layer_file); } // Get all sliders // Table name $table_name = $wpdb->prefix . "layerslider"; // Get sliders $sliders = $wpdb->get_results("SELECT * FROM {$table_name}\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE flag_hidden = '0' AND flag_deleted = '0'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY date_c ASC"); if (!empty($sliders)) { foreach ($sliders as $key => $item) { $slides[$item->id] = $item->name; } } if ($slides) { foreach ($slides as $key => $val) { $slides_array[$val] = $key; } } // Assign LayerSlider if ($demo_type == 'classic') { $lspage = get_page_by_title('Layer Slider'); if (isset($lspage) && $lspage->ID && $slides_array['Avada Full Width']) { update_post_meta($lspage->ID, 'pyre_slider', $slides_array['Avada Full Width']); } } } // Import Revslider if (class_exists('UniteFunctionsRev') && $revslider_exists == true) { // if revslider is activated foreach (glob($rev_directory . '*.zip') as $filename) { // get all files from revsliders data dir $filename = basename($filename); $rev_files[] = $rev_directory . $filename; } foreach ($rev_files as $rev_file) { // finally import rev slider data files $filepath = $rev_file; //check if zip file or fallback to old, if zip, check if all files exist $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if ($importZip === true) { //true or integer. If integer, its not a correct zip file //check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID if ($updateAnim == "true") { //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert with new handle $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } } else { } //overwrite/append static-captions.css if (!empty($static)) { if (isset($updateStatic) && $updateStatic == "true") { //overwrite file RevOperations::updateStaticCss($static); } else { //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } else { } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = $wpdb->insert_id; //-------- Slides Handle ----------- //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { //import if exists in zip folder if (trim($params["image"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $wpdb->insert(GlobalsRevSlider::$table_slides, $arrCreate); //} } } } // Set reading options $homepage = get_page_by_title($homepage_title); if (isset($homepage) && $homepage->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); // Front Page } // Fusion Sliders Import if ($fs_exists == true) { @avada_import_fsliders($fs_url); } echo 'imported'; exit; } } }
function hb_importer() { global $wpdb; if (current_user_can('manage_options') && isset($_GET['import_content_data'])) { if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } // we are loading importers if (!class_exists('WP_Importer')) { // if main importer class doesn't exist $wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; include $wp_importer; } if (!class_exists('WP_Import')) { // if WP importer doesn't exist $wp_import = get_template_directory() . '/includes/plugins/importer/wordpress-importer.php'; include $wp_import; } if (class_exists('WP_Importer') && class_exists('WP_Import')) { // check for main import class and wp import class $importer = new WP_Import(); $hb_import_attachments = true; if (isset($_GET['light_import']) && $_GET['light_import'] == 'yes') { $hb_import_attachments = false; } /* Delete menus to prevent menu duplication */ wp_delete_nav_menu('Main Menu'); wp_delete_nav_menu('Footer Menu'); wp_delete_nav_menu('One Page Menu'); wp_delete_nav_menu('Shortcodes Menu'); wp_delete_nav_menu('Sidebar Navigation1'); /* First Import Posts, Pages, Portfolio Content, FAQ, Images, Menus */ $theme_xml = get_template_directory() . '/includes/plugins/importer/data/highend.xml.gz'; $importer->fetch_attachments = $hb_import_attachments; ob_start(); $importer->import($theme_xml); ob_end_clean(); /* Import Woocommerce if WooCommerce Exists if( class_exists('Woocommerce') ) { $importer = new WP_Import(); $theme_xml = get_template_directory() . '/includes/plugins/importer/data/wooproducts.xml.gz'; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); // Set pages $woopages = array( 'woocommerce_shop_page_id' => 'Shop', 'woocommerce_cart_page_id' => 'Cart', 'woocommerce_checkout_page_id' => 'Checkout', 'woocommerce_pay_page_id' => 'Checkout → Pay', 'woocommerce_thanks_page_id' => 'Order Received', 'woocommerce_myaccount_page_id' => 'My Account', 'woocommerce_edit_address_page_id' => 'Edit My Address', 'woocommerce_view_order_page_id' => 'View Order', 'woocommerce_change_password_page_id' => 'Change Password', 'woocommerce_logout_page_id' => 'Logout', 'woocommerce_lost_password_page_id' => 'Lost Password' ); foreach($woopages as $woo_page_name => $woo_page_title) { $woopage = get_page_by_title( $woo_page_title ); if($woopage->ID) { update_option($woo_page_name, $woopage->ID); // Front Page } } // We no longer need to install pages delete_option( '_wc_needs_pages' ); delete_transient( '_wc_activation_redirect' ); // Flush rules after install flush_rewrite_rules(); } */ // Set imported menus to registered theme locations $locations = get_theme_mod('nav_menu_locations'); // registered menu locations in theme $menus = wp_get_nav_menus(); // registered menus if ($menus) { foreach ($menus as $menu) { // assign menus to theme locations if ($menu->name == 'Main Menu') { $locations['main-menu'] = $menu->term_id; $locations['mobile-menu'] = $menu->term_id; } else { if ($menu->name == 'Footer Menu') { $locations['footer-menu'] = $menu->term_id; } else { if ($menu->name == 'One Page Menu') { $locations['one-page-menu'] = $menu->term_id; } } } } } set_theme_mod('nav_menu_locations', $locations); // set menus to locations // Set reading options $homepage = get_page_by_title('Home'); if ($homepage != null && $homepage->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); // Front Page } if (class_exists('Woocommerce')) { // Add sidebar widget areas $sidebars = array('ShopWidget1' => 'Show Widget 1', 'ShopWidget2' => 'Show Widget 2', 'ShopWidget3' => 'Show Widget 3', 'ShopWidget4' => 'Show Widget 4', 'DefaultPageSidebar' => 'Default Page Sidebar', 'SidebarNavigation1' => 'Sidebar Navigation 1', 'PortfolioSingleSidebar' => 'Portfolio Single Sidebar', 'ShortcodesSidebar' => 'Shortcodes Sidebar', 'ShopSidebar' => 'Shop Sidebar'); } else { // Add sidebar widget areas $sidebars = array('DefaultPageSidebar' => 'Default Page Sidebar', 'SidebarNavigation1' => 'Sidebar Navigation 1', 'PortfolioSingleSidebar' => 'Portfolio Single Sidebar', 'ShortcodesSidebar' => 'Shortcodes Sidebar'); } update_option('sbg_sidebars', $sidebars); foreach ($sidebars as $sidebar) { $sidebar_class = hb_name_to_class($sidebar); register_sidebar(array('name' => $sidebar, 'id' => 'hb-custom-sidebar-' . strtolower($sidebar_class), 'before_widget' => '<div id="%1$s" class="widget-item %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4>', 'after_title' => '</h4>')); } // Add data to widgets $widgets_json = get_template_directory_uri() . '/includes/plugins/importer/data/widgets.json'; // widgets data file $widgets_json = wp_remote_get($widgets_json); $widget_data = $widgets_json['body']; $import_widgets = hb_import_widget_data($widget_data); /* Import Layerslider if( function_exists( 'layerslider_import_sample_slider' ) && $hb_import_attachments == true ) { // if layerslider is activated // Get importUtil include WP_PLUGIN_DIR . '/LayerSlider/classes/class.ls.importutil.php'; $layer_directory = get_template_directory() . '/includes/plugins/importer/data/layersliders/'; // layerslider data dir foreach( glob( $layer_directory . '*.zip' ) as $filename ) { // get all files from revsliders data dir $filename = basename($filename); $layer_files[] = get_template_directory() . '/includes/plugins/importer/data/layersliders/' . $filename ; } foreach( $layer_files as $layer_file ) { // finally import layer slider $import = new LS_ImportUtil($layer_file); } // Get all sliders // Table name $table_name = $wpdb->prefix . "layerslider"; // Get sliders $sliders = $wpdb->get_results( "SELECT * FROM $table_name WHERE flag_hidden = '0' AND flag_deleted = '0' ORDER BY date_c ASC" ); if(!empty($sliders)): foreach($sliders as $key => $item): $slides[$item->id] = $item->name; endforeach; endif; if($slides){ foreach($slides as $key => $val){ $slides_array[$val] = $key; } } }*/ // Import Revslider if (class_exists('UniteFunctionsRev') && $hb_import_attachments == true) { // if revslider is activated // Download Rev Sliders imports to local $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/jobs-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/jobs-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/boxed-corporate-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/boxed-corporate-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/corporate-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/corporate-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/home-classic-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/home-classic-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/home-default-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/home-default-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/home-special-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/home-special-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/one-page-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/one-page-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } $url = get_template_directory() . '/includes/plugins/importer/data/revsliders/shop-slider.zip'; if (!file_exists($url)) { $d_url = 'http://hb-themes.com/repository/import/highend/revsliders/shop-slider.zip'; $src = fopen($d_url, 'r'); $dest = fopen($url, 'w'); stream_copy_to_stream($src, $dest); fclose($d_url); fclose($url); } // END REV SLIDER IMPORTS $rev_directory = get_template_directory() . '/includes/plugins/importer/data/revsliders/'; // layerslider data dir foreach (glob($rev_directory . '*.zip') as $filename) { // get all files from revsliders data dir $filename = basename($filename); $rev_files[] = get_template_directory() . '/includes/plugins/importer/data/revsliders/' . $filename; } foreach ($rev_files as $rev_file) { // finally import rev slider data files $filepath = $rev_file; //if(file_exists($filepath) == false) //UniteFunctionsRev::throwError("Import file not found!!!"); //check if zip file or fallback to old, if zip, check if all files exist $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if ($importZip === true) { //true or integer. If integer, its not a correct zip file //check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); //if(!$slider_export) UniteFunctionsRev::throwError("slider_export.txt does not exist!"); //if(!$custom_animations) UniteFunctionsRev::throwError("custom_animations.txt does not exist!"); //if(!$dynamic_captions) UniteFunctionsRev::throwError("dynamic-captions.css does not exist!"); //if(!$static_captions) UniteFunctionsRev::throwError("static-captions.css does not exist!"); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID if ($updateAnim == "true") { //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert with new handle $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } //dmp(__("animations imported!",REVSLIDER_TEXTDOMAIN)); } else { //dmp(__("no custom animations found, if slider uses custom animations, the provided export may be broken...",REVSLIDER_TEXTDOMAIN)); } //overwrite/append static-captions.css if (!empty($static)) { if ($updateStatic == "true") { //overwrite file RevOperations::updateStaticCss($static); } else { //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } //dmp(__("dynamic styles imported!",REVSLIDER_TEXTDOMAIN)); } else { //dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...",REVSLIDER_TEXTDOMAIN)); } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = $wpdb->insert_id; //-------- Slides Handle ----------- //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { //import if exists in zip folder if (trim($params["image"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $wpdb->insert(GlobalsRevSlider::$table_slides, $arrCreate); //} } } } // finally redirect to success page wp_redirect(admin_url('themes.php?page=highend_options&imported=success#_hb_general_settings')); } } }
public function previewOutputMarkup($sliderID, $output = null) { if ($sliderID == "empty_output") { $this->loadingMessageOutput(); exit; } if ($output == null) { $output = new RevSliderOutput(); } $slider = new RevSlider(); $slider->initByID($sliderID); $isWpmlExists = UniteWpmlRev::isWpmlExists(); $useWpml = $slider->getParam("use_wpml", "off"); $wpmlActive = false; if ($isWpmlExists && $useWpml == "on") { $wpmlActive = true; $arrLanguages = UniteWpmlRev::getArrLanguages(false); //set current lang to output $currentLang = UniteFunctionsRev::getPostGetVariable("lang"); if (empty($currentLang)) { $currentLang = UniteWpmlRev::getCurrentLang(); } if (empty($currentLang)) { $currentLang = $arrLanguages[0]; } $output->setLang($currentLang); $selectLangChoose = UniteFunctionsRev::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true); } $output->setPreviewMode(); //put the output html $urlPlugin = "http://yourpluginpath/"; $urlPreviewPattern = UniteBaseClassRev::$url_ajax_actions . "&client_action=preview_slider&only_markup=true&sliderid=" . $sliderID . "&lang=[lang]&nonce=[nonce]"; $nonce = wp_create_nonce("revslider_actions"); $setBase = is_ssl() ? "https://" : "http://"; $f = new ThemePunch_Fonts(); $my_fonts = $f->get_all_fonts(); ?> <html> <head> <script type='text/javascript' src='<?php echo $setBase; ?> ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script> </head> <body style="padding:0px;margin:0px;"> <?php if ($wpmlActive == true) { ?> <div style="margin-bottom:10px;text-align:center;"> <?php _e("Choose language", REVSLIDER_TEXTDOMAIN); ?> : <?php echo $selectLangChoose; ?> </div> <script type="text/javascript"> var g_previewPattern = '<?php echo $urlPreviewPattern; ?> '; jQuery("#select_langs").change(function(){ var lang = this.value; var nonce = "<?php echo $nonce; ?> "; var pattern = g_previewPattern; var urlPreview = pattern.replace("[lang]",lang).replace("[nonce]",nonce); location.href = urlPreview; }); jQuery('body').on('click', '#rev_replace_images', function(){ var from = jQuery('input[name="orig_image_path"]').val(); var to = jQuery('input[name="replace_image_path"]').val(); jQuery('#rev_script_content').val(jQuery('#rev_script_content').val().replace(from, to)); jQuery('#rev_the_content').val(jQuery('#rev_the_content').val().replace(from, to)); jQuery('#rev_style_content').val(jQuery('#rev_style_content').val().replace(from, to)); jQuery('#rev_head_content').val(jQuery('#rev_head_content').val().replace(from, to)); }); </script> <?php } ?> <?php //UniteBaseClassRev::$url_plugin ob_start(); ?> <link rel='stylesheet' href='<?php echo $urlPlugin; ?> css/settings.css?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?> ' type='text/css' media='all' /> <?php $http = is_ssl() ? 'https' : 'http'; if (!empty($my_fonts)) { foreach ($my_fonts as $c_font) { ?> <link rel='stylesheet' href="<?php echo $http . '://fonts.googleapis.com/css?family=' . strip_tags($c_font['url']); ?> " type='text/css' /><?php echo "\n"; } } ?> <script type='text/javascript' src='<?php echo $urlPlugin; ?> js/jquery.themepunch.tools.min.js?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?> '></script> <script type='text/javascript' src='<?php echo $urlPlugin; ?> js/jquery.themepunch.revolution.min.js?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?> '></script> <?php $head_content = ob_get_contents(); ob_clean(); ob_end_clean(); ob_start(); $custom_css = RevOperations::getStaticCss(); echo $custom_css . "\n\n"; echo '/*****************' . "\n"; echo ' ** ' . __('CAPTIONS CSS', REVSLIDER_TEXTDOMAIN) . "\n"; echo ' ****************/' . "\n\n"; $db = new UniteDBRev(); $styles = $db->fetch(GlobalsRevSlider::$table_css); echo UniteCssParserRev::parseDbArrayToCss($styles, "\n"); $style_content = ob_get_contents(); ob_clean(); ob_end_clean(); ob_start(); $output->putSliderBase($sliderID); $content = ob_get_contents(); ob_clean(); ob_end_clean(); $script_content = substr($content, strpos($content, '<script type="text/javascript">'), strpos($content, '</script>') + 9 - strpos($content, '<script type="text/javascript">')); $content = htmlentities(str_replace($script_content, '', $content)); $script_content = str_replace(' ', '', $script_content); $script_content = str_replace(array('<script type="text/javascript">', '</script>'), '', $script_content); ?> <style> body { font-family:sans-serif; font-size:12px;} textarea { background:#f1f1f1; border:#ddd; font-size:10px; line-height:16px; margin-bottom:40px; padding:10px;} .rev_cont_title { color:#000; text-decoration:none;font-size:14px; line-height:24px; font-weight:800;background: #D5D5D5;padding: 10px;} .rev_cont_title a, .rev_cont_title a:visited { margin-left:25px;font-size:12px;line-height:12px;float:right;background-color:#8e44ad; color:#fff; padding:8px 10px;text-decoration:none;} .rev_cont_title a:hover { background-color:#9b59b6} </style> <p><?php $dir = wp_upload_dir(); ?> <?php _e('Replace image path:', REVSLIDER_TEXTDOMAIN); ?> <?php _e('From:', REVSLIDER_TEXTDOMAIN); ?> <input type="text" name="orig_image_path" value="<?php echo @$dir['baseurl']; ?> " /> <?php _e('To:', REVSLIDER_TEXTDOMAIN); ?> <input type="text" name="replace_image_path" value="" /> <input id="rev_replace_images" type="button" name="replace_images" value="<?php _e('Replace', REVSLIDER_TEXTDOMAIN); ?> " /> </p> <div class="rev_cont_title"><?php _e('Header', REVSLIDER_TEXTDOMAIN); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_head_content" href="javascript:void(0);" original-title=""><?php _e('Mark to Copy', REVSLIDER_TEXTDOMAIN); ?> </a><div style="clear:both"></div></div> <textarea id="rev_head_content" readonly="true" style="width: 100%; height: 100px; color:#3498db"><?php echo $head_content; ?> </textarea> <div class="rev_cont_title"><?php _e('CSS', REVSLIDER_TEXTDOMAIN); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_style_content" href="javascript:void(0);" original-title=""><?php _e('Mark to Copy', REVSLIDER_TEXTDOMAIN); ?> </a></div> <textarea id="rev_style_content" readonly="true" style="width: 100%; height: 100px;"><?php echo $style_content; ?> </textarea> <div class="rev_cont_title"><?php _e('Body', REVSLIDER_TEXTDOMAIN); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_the_content" href="javascript:void(0);" original-title=""><?php _e('Mark to Copy', REVSLIDER_TEXTDOMAIN); ?> </a></div> <textarea id="rev_the_content" readonly="true" style="width: 100%; height: 100px;"><?php echo $content; ?> </textarea> <div class="rev_cont_title"><?php _e('Script', REVSLIDER_TEXTDOMAIN); ?> <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_script_content" href="javascript:void(0);" original-title=""><?php _e('Mark to Copy', REVSLIDER_TEXTDOMAIN); ?> </a></div> <textarea id="rev_script_content" readonly="true" style="width: 100%; height: 100px;"><?php echo $script_content; ?> </textarea> <script> jQuery('body').on('click','.copytoclip',function() { jQuery("#"+jQuery(this).data('idt')).select(); }); </script> </body> </html> <?php exit; }
function import_revolution_slider() { if (class_exists('UniteFunctionsRev') && class_exists('ZipArchive')) { global $wpdb; $updateAnim = true; $updateStatic = true; $rev_directory = get_template_directory() . '/framework/importer/data/revsliders/'; foreach (glob($rev_directory . '*.zip') as $filename) { $filename = basename($filename); $rev_files[] = get_template_directory() . '/framework/importer/data/revsliders/' . $filename; } foreach ($rev_files as $rev_file) { $filepath = $rev_file; $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if ($importZip === true) { $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } } else { $content = @file_get_contents($filepath); } if ($importZip === true) { $db = new UniteDBRev(); $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { if ($updateAnim == 'true') { $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } } else { } if (!empty($static)) { if (isset($updateStatic) && $updateStatic == 'true') { RevOperations::updateStaticCss($static); } else { $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { continue; } if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } else { } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = $wpdb->insert_id; /* create all slides */ $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; if (isset($params["image"])) { if (trim($params["image"]) !== '') { if ($importZip === true) { $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { if (trim($layer["image_url"]) !== '') { if ($importZip === true) { $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } /* create new slide */ $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $wpdb->insert(GlobalsRevSlider::$table_slides, $arrCreate); } } } }