Пример #1
0
 /**
  * 
  * import slider from multipart form
  */
 public function importSliderFromPost($updateAnim = true, $updateStatic = true, $exactfilepath = false, $is_template = false, $single_slide = false)
 {
     try {
         $sliderID = RevSliderFunctions::getPostVariable("sliderid");
         $sliderExists = !empty($sliderID);
         if ($sliderExists) {
             $this->initByID($sliderID);
         }
         if ($exactfilepath !== false) {
             $filepath = $exactfilepath;
         } else {
             switch ($_FILES['import_file']['error']) {
                 case UPLOAD_ERR_OK:
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     RevSliderFunctions::throwError(__('No file sent.', REVSLIDER_TEXTDOMAIN));
                 case UPLOAD_ERR_INI_SIZE:
                 case UPLOAD_ERR_FORM_SIZE:
                     RevSliderFunctions::throwError(__('Exceeded filesize limit.', REVSLIDER_TEXTDOMAIN));
                 default:
                     break;
             }
             $filepath = $_FILES["import_file"]["tmp_name"];
         }
         if (file_exists($filepath) == false) {
             RevSliderFunctions::throwError("Import file not found!!!");
         }
         //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);
         }
         // Added by ThemeFuzz ( Stefan )
         if ($importZip === 0 || !$zip->getStream('slider_export.txt')) {
             if (!$zip->getStream('slider_export.txt')) {
                 $upload_dir = wp_upload_dir();
                 $new_path = $upload_dir['basedir'] . '/' . $_FILES['import_file']['name'];
                 move_uploaded_file($_FILES["import_file"]["tmp_name"], $new_path);
                 $importZip = $zip->open($new_path, ZIPARCHIVE::CREATE);
             }
         }
         if ($is_template !== false && $importZip !== true) {
             return array("success" => false, "error" => __('Please select the correct zip file', REVSLIDER_TEXTDOMAIN));
         }
         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');
             $uid_file = $zip->getStream('info.cfg');
             $uid_check = '';
             if ($uid_file) {
                 while (!feof($uid_file)) {
                     $uid_check .= fread($uid_file, 1024);
                 }
             }
             if ($is_template !== false) {
                 if ($uid_check != $is_template) {
                     return array("success" => false, "error" => __('Please select the correct zip file, checksum failed!', REVSLIDER_TEXTDOMAIN));
                 }
             } else {
                 //someone imported a template base Slider, check if it is existing in Base Sliders, if yes, check if it was imported
                 if ($uid_check !== '') {
                     $tmpl = new RevSliderTemplate();
                     $tmpl_slider = $tmpl->getThemePunchTemplateSliders();
                     foreach ($tmpl_slider as $tp_slider) {
                         if (!isset($tp_slider['installed'])) {
                             continue;
                         }
                         if ($tp_slider['uid'] == $uid_check) {
                             $is_template = $uid_check;
                             break;
                         }
                     }
                 }
             }
             if (!$slider_export) {
                 RevSliderFunctions::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);
             }
             //check for images!
         } else {
             //check if fallback
             //get content array
             $content = @file_get_contents($filepath);
         }
         if ($importZip === true) {
             //we have a zip
             $db = new RevSliderDB();
             //update/insert custom animations
             $animations = @unserialize($animations);
             if (!empty($animations)) {
                 foreach ($animations as $key => $animation) {
                     //$animation['id'], $animation['handle'], $animation['params']
                     $exist = $db->fetch(RevSliderGlobals::$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(RevSliderGlobals::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle']));
                             $anim_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'])));
                             $anim_id = $db->insert(RevSliderGlobals::$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'])));
                         $anim_id = $db->insert(RevSliderGlobals::$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-' . $anim_id . '"', 'customout-' . $anim_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
                     RevSliderOperations::updateStaticCss($static);
                 } elseif ($updateStatic == 'none') {
                     //do nothing
                 } else {
                     //append
                     $static_cur = RevSliderOperations::getStaticCss();
                     $static = $static_cur . "\n" . $static;
                     RevSliderOperations::updateStaticCss($static);
                 }
             }
             //overwrite/create dynamic-captions.css
             //parse css to classes
             $dynamicCss = RevSliderCssParser::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, ',') !== false && strpos($class, '.tp-caption') !== false) {
                         //we have something like .tp-caption.redclass, .redclass
                         $class_t = explode(',', $class);
                         foreach ($class_t as $k => $cl) {
                             if (strpos($cl, '.tp-caption') !== false) {
                                 $class = $cl;
                             }
                         }
                     }
                     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);
                         $arrInsert["settings"] = '';
                     }
                     //check if class exists
                     $result = $db->fetch(RevSliderGlobals::$table_css, "handle = '" . $class . "'");
                     if (!empty($result)) {
                         //update
                         $db->update(RevSliderGlobals::$table_css, $arrInsert, array('handle' => $class));
                     } else {
                         //insert
                         $arrInsert["handle"] = $class;
                         $db->insert(RevSliderGlobals::$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 //deprecated in newest php version
         $content = preg_replace_callback('!s:(\\d+):"(.*?)";!', array('RevSlider', 'clear_error_in_string'), $content);
         //clear errors in string
         $arrSlider = @unserialize($content);
         if (empty($arrSlider)) {
             RevSliderFunctions::throwError("Wrong export slider file format! This could be caused because the ZipArchive extension is not enabled.");
         }
         //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"] = RevSliderFunctionsWP::getImageUrlFromPath($sliderParams["background_image"]);
         }
         $import_statics = true;
         if (isset($sliderParams['enable_static_layers'])) {
             if ($sliderParams['enable_static_layers'] == 'off') {
                 $import_statics = false;
             }
             unset($sliderParams['enable_static_layers']);
         }
         $json_params = json_encode($sliderParams);
         //update slider or create new
         if ($sliderExists) {
             $arrUpdate = array("params" => $json_params);
             $this->db->update(RevSliderGlobals::$table_sliders, $arrUpdate, array("id" => $sliderID));
         } else {
             //new slider
             $arrInsert = array();
             $arrInsert['params'] = $json_params;
             //check if Slider with title and/or alias exists, if yes change both to stay unique
             $arrInsert['title'] = RevSliderFunctions::getVal($sliderParams, 'title', 'Slider1');
             $arrInsert['alias'] = RevSliderFunctions::getVal($sliderParams, 'alias', 'slider1');
             if ($is_template === false) {
                 //we want to stay at the given alias if we are a template
                 $talias = $arrInsert['alias'];
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $arrInsert['alias'] . $ti;
                     $ti++;
                 }
                 if ($talias !== $arrInsert['alias']) {
                     $arrInsert['title'] = $talias;
                     $arrInsert['alias'] = $talias;
                 }
             }
             if ($is_template !== false) {
                 //add that we are an template
                 $arrInsert['type'] = 'template';
             }
             $sliderID = $this->db->insert(RevSliderGlobals::$table_sliders, $arrInsert);
         }
         //-------- Slides Handle -----------
         //delete current slides
         if ($sliderExists) {
             $this->deleteAllSlides();
         }
         //create all slides
         $arrSlides = $arrSlider["slides"];
         $alreadyImported = array();
         //wpml compatibility
         $slider_map = array();
         foreach ($arrSlides as $sl_key => $slide) {
             $params = $slide["params"];
             $layers = $slide["layers"];
             $settings = @$slide["settings"];
             //convert params images:
             if ($importZip === true) {
                 //we have a zip, check if exists
                 if (isset($params["image"])) {
                     $params["image"] = RevSliderBase::check_file_in_zip($zip, $params["image"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
                 }
                 if (isset($params["background_image"])) {
                     $params["background_image"] = RevSliderBase::check_file_in_zip($zip, $params["background_image"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["background_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["background_image"]);
                 }
                 if (isset($params["slide_thumb"])) {
                     $params["slide_thumb"] = RevSliderBase::check_file_in_zip($zip, $params["slide_thumb"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["slide_thumb"] = RevSliderFunctionsWP::getImageUrlFromPath($params["slide_thumb"]);
                 }
                 if (isset($params["show_alternate_image"])) {
                     $params["show_alternate_image"] = RevSliderBase::check_file_in_zip($zip, $params["show_alternate_image"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["show_alternate_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["show_alternate_image"]);
                 }
                 if (isset($params['background_type']) && $params['background_type'] == 'html5') {
                     if (isset($params['slide_bg_html_mpeg']) && $params['slide_bg_html_mpeg'] != '') {
                         $params['slide_bg_html_mpeg'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $params["slide_bg_html_mpeg"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_webm']) && $params['slide_bg_html_webm'] != '') {
                         $params['slide_bg_html_webm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $params["slide_bg_html_webm"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_ogv']) && $params['slide_bg_html_ogv'] != '') {
                         $params['slide_bg_html_ogv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $params["slide_bg_html_ogv"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                     }
                 }
             }
             //convert layers images:
             foreach ($layers as $key => $layer) {
                 //import if exists in zip folder
                 if ($importZip === true) {
                     //we have a zip, check if exists
                     if (isset($layer["image_url"])) {
                         $layer["image_url"] = RevSliderBase::check_file_in_zip($zip, $layer["image_url"], $filepath, $sliderParams["alias"], $alreadyImported);
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                     }
                     if (isset($layer['type']) && $layer['type'] == 'video') {
                         $video_data = isset($layer['video_data']) ? (array) $layer['video_data'] : array();
                         if (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] == 'html5') {
                             if (isset($video_data['urlPoster']) && $video_data['urlPoster'] != '') {
                                 $video_data['urlPoster'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlPoster"], $filepath, $sliderParams["alias"], $alreadyImported));
                             }
                             if (isset($video_data['urlMp4']) && $video_data['urlMp4'] != '') {
                                 $video_data['urlMp4'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlMp4"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlWebm']) && $video_data['urlWebm'] != '') {
                                 $video_data['urlWebm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlWebm"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlOgv']) && $video_data['urlOgv'] != '') {
                                 $video_data['urlOgv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlOgv"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                             }
                         } elseif (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] != 'html5') {
                             //video cover image
                             if (isset($video_data['previewimage']) && $video_data['previewimage'] != '') {
                                 $video_data['previewimage'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["previewimage"], $filepath, $sliderParams["alias"], $alreadyImported));
                             }
                         }
                         $layer['video_data'] = $video_data;
                     }
                 }
                 $layer['text'] = stripslashes($layer['text']);
                 $layers[$key] = $layer;
             }
             $arrSlides[$sl_key]['layers'] = $layers;
             //create new slide
             $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));
             }
             $my_settings = json_encode($settings);
             if (empty($my_settings)) {
                 $my_settings = stripslashes(json_encode($settings));
             }
             $arrCreate["layers"] = $my_layers;
             $arrCreate["params"] = $my_params;
             $arrCreate["settings"] = $my_settings;
             $last_id = $this->db->insert(RevSliderGlobals::$table_slides, $arrCreate);
             if (isset($slide['id'])) {
                 $slider_map[$slide['id']] = $last_id;
             }
         }
         //change for WPML the parent IDs if necessary
         if (!empty($slider_map)) {
             foreach ($arrSlides as $sl_key => $slide) {
                 if (isset($slide['params']['parentid']) && isset($slider_map[$slide['params']['parentid']])) {
                     $update_id = $slider_map[$slide['id']];
                     $parent_id = $slider_map[$slide['params']['parentid']];
                     $arrCreate = array();
                     $arrCreate["params"] = $slide['params'];
                     $arrCreate["params"]['parentid'] = $parent_id;
                     $my_params = json_encode($arrCreate["params"]);
                     if (empty($my_params)) {
                         $my_params = stripslashes(json_encode($arrCreate["params"]));
                     }
                     $arrCreate["params"] = $my_params;
                     $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $update_id));
                 }
                 $did_change = false;
                 foreach ($slide['layers'] as $key => $value) {
                     if (isset($value['layer_action'])) {
                         if (isset($value['layer_action']->jump_to_slide) && !empty($value['layer_action']->jump_to_slide)) {
                             $value['layer_action']->jump_to_slide = (array) $value['layer_action']->jump_to_slide;
                             foreach ($value['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $slide['layers'][$key]['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                     $did_change = true;
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($value, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($slide['layers'][$key]['layer_action'])) {
                             $slide['layers'][$key]['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($value, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($value, 'link_open_in');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'link');
                                 $slide['layers'][$key]['layer_action']->link_type = array('a' => 'a');
                                 $slide['layers'][$key]['layer_action']->image_link = array('a' => $link);
                                 $slide['layers'][$key]['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($slide['layers'][$key]['link']);
                                 unset($slide['layers'][$key]['link_open_in']);
                             case 'next':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'scroll_under');
                                 $slide['layers'][$key]['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($slide['layers'][$key]['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'jumpto');
                                 $slide['layers'][$key]['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $slide['layers'][$key]['layer_action']->tooltip_event = array('a' => 'click');
                         unset($slide['layers'][$key]['link_slide']);
                         $did_change = true;
                     }
                     if ($did_change === true) {
                         $arrCreate = array();
                         $my_layers = json_encode($slide['layers']);
                         if (empty($my_layers)) {
                             $my_layers = stripslashes(json_encode($layers));
                         }
                         $arrCreate['layers'] = $my_layers;
                         $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $slider_map[$slide['id']]));
                     }
                 }
             }
         }
         //check if static slide exists and import
         if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides']) && $import_statics) {
             $static_slide = $arrSlider['static_slides'];
             foreach ($static_slide as $slide) {
                 $params = $slide["params"];
                 $layers = $slide["layers"];
                 $settings = @$slide["settings"];
                 //convert params images:
                 if (isset($params["image"])) {
                     //import if exists in zip folder
                     if (strpos($params["image"], 'http') !== false) {
                     } else {
                         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>', REVSLIDER_TEXTDOMAIN);
                                 } else {
                                     if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) {
                                         $importImage = RevSliderFunctionsWP::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"] = RevSliderFunctionsWP::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 (strpos($layer["image_url"], 'http') !== false) {
                             } else {
                                 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 = RevSliderFunctionsWP::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"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                         $layer['text'] = stripslashes($layer['text']);
                     }
                     if (isset($layer['layer_action'])) {
                         if (isset($layer['layer_action']->jump_to_slide) && !empty($layer['layer_action']->jump_to_slide)) {
                             foreach ($layer['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $layer['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($value, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($layer['layer_action'])) {
                             $layer['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($value, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($value, 'link_open_in');
                                 $layer['layer_action']->action = array('a' => 'link');
                                 $layer['layer_action']->link_type = array('a' => 'a');
                                 $layer['layer_action']->image_link = array('a' => $link);
                                 $layer['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($layer['link']);
                                 unset($layer['link_open_in']);
                             case 'next':
                                 $layer['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $layer['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $layer['layer_action']->action = array('a' => 'scroll_under');
                                 $layer['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($layer['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $layer['layer_action']->action = array('a' => 'jumpto');
                                 $layer['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $layer['layer_action']->tooltip_event = array('a' => 'click');
                         unset($layer['link_slide']);
                         $did_change = true;
                     }
                     $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));
                 }
                 $my_settings = json_encode($settings);
                 if (empty($my_settings)) {
                     $my_settings = stripslashes(json_encode($settings));
                 }
                 $arrCreate["layers"] = $my_layers;
                 $arrCreate["params"] = $my_params;
                 $arrCreate["settings"] = $my_settings;
                 if ($sliderExists) {
                     unset($arrCreate["slider_id"]);
                     $this->db->update(RevSliderGlobals::$table_static_slides, $arrCreate, array("slider_id" => $sliderID));
                 } else {
                     $this->db->insert(RevSliderGlobals::$table_static_slides, $arrCreate);
                 }
             }
         }
         $c_slider = new RevSliderSlider();
         $c_slider->initByID($sliderID);
         //check to convert styles to latest versions
         RevSliderPluginUpdate::update_css_styles();
         //set to version 5
         RevSliderPluginUpdate::add_animation_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_style_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::change_settings_on_layers($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_general_settings($c_slider);
         //set to version 5
         $cus_js = $c_slider->getParam('custom_javascript', '');
         if (strpos($cus_js, 'revapi') !== false) {
             if (preg_match_all('/revapi[0-9]*./', $cus_js, $results)) {
                 if (isset($results[0]) && !empty($results[0])) {
                     foreach ($results[0] as $replace) {
                         $cus_js = str_replace($replace, 'revapi' . $sliderID . '.', $cus_js);
                     }
                 }
                 $c_slider->updateParam(array('custom_javascript' => $cus_js));
             }
         }
         if ($is_template !== false) {
             //duplicate the slider now, as we just imported the "template"
             if ($single_slide !== false) {
                 //add now one Slide to the current Slider
                 $mslider = new RevSlider();
                 //change slide_id to correct, as it currently is just a number beginning from 0 as we did not have a correct slide ID yet.
                 $i = 0;
                 $changed = false;
                 foreach ($slider_map as $value) {
                     if ($i == $single_slide['slide_id']) {
                         $single_slide['slide_id'] = $value;
                         $changed = true;
                         break;
                     }
                     $i++;
                 }
                 if ($changed) {
                     $return = $mslider->copySlideToSlider($single_slide);
                 } else {
                     return array("success" => false, "error" => __('could not find correct Slide to copy, please try again.', REVSLIDER_TEXTDOMAIN), "sliderID" => $sliderID);
                 }
             } else {
                 $mslider = new RevSlider();
                 $title = RevSliderFunctions::getVal($sliderParams, 'title', 'slider1');
                 $talias = $title;
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $title . $ti;
                     $ti++;
                 }
                 $mslider->duplicateSliderFromData(array('sliderid' => $sliderID, 'title' => $talias));
             }
         }
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
         return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID);
     }
     return array("success" => true, "sliderID" => $sliderID);
 }
Пример #2
0
    /**
     * view the estimated speed of the Slider
     * @since: 5.0
     */
    public static function get_slider_speed($sliderID)
    {
        //$data = wp_get_attachment_metadata($cur_img_id);
        ob_start();
        $total_size = 0;
        $do_ssl = is_ssl() ? 'http:' : 'https:';
        $slider = new RevSliderSlider();
        $slider->initByID($sliderID);
        $slides = $slider->getSlidesForExport();
        $static_slides = $slider->getStaticSlideForExport();
        if (!empty($static_slides) && is_array($static_slides)) {
            foreach ($static_slides as $s_slide) {
                $slides[] = $s_slide;
            }
        }
        $used_images = array();
        $used_videos = array();
        $used_captions = array();
        $using_kenburns = false;
        $using_parallax = false;
        $using_carousel = false;
        $using_navigation = false;
        $using_videos = false;
        $using_actions = false;
        $using_layeranim = false;
        $img_size = 0;
        $video_size = 0;
        $slide_counter = 0;
        $firstslide_size = 0;
        $smartslide_size = 0;
        if ($slider->getParam("use_parallax", "off") == 'on') {
            $using_parallax = true;
        }
        if ($slider->getParam("slider-type", "standard") == 'carousel') {
            $using_carousel = true;
        }
        $enable_arrows = $slider->getParam('enable_arrows', 'off');
        $enable_bullets = $slider->getParam('enable_bullets', 'off');
        $enable_tabs = $slider->getParam('enable_tabs', 'off');
        $enable_thumbnails = $slider->getParam('enable_thumbnails', 'off');
        if ($enable_arrows == 'on' || $enable_bullets == 'on' || $enable_tabs == 'on' || $enable_thumbnails == 'on') {
            $using_navigation = true;
        }
        if (!empty($slides) && count($slides) > 0) {
            foreach ($slides as $key => $slide) {
                if (isset($slide['params']['state']) && $slide['params']['state'] != 'published') {
                    continue;
                }
                if (!isset($slide['id'])) {
                    continue;
                }
                $slide_counter++;
                $slide_id = $slide['id'];
                if (isset($slide['params']['kenburn_effect']) && $slide['params']['kenburn_effect'] == 'on') {
                    $using_kenburns = true;
                }
                if (!isset($slide['params']['image_source_type'])) {
                    $slide['params']['image_source_type'] = 'full';
                }
                if (isset($slide['params']['image']) && $slide['params']['image'] != '') {
                    //add infos of image to an array
                    $infos = array();
                    $urlImage = false;
                    switch ($slide['params']['background_type']) {
                        case 'streamyoutube':
                        case 'streaminstagram':
                        case 'streamvimeo':
                        case 'youtube':
                        case 'vimeo':
                            $using_videos = true;
                            break;
                    }
                    if (isset($slide['params']['image_id'])) {
                        $cur_img_id = $slide['params']['image_id'];
                        //get image sizes by ID
                        $urlImage = wp_get_attachment_image_src($slide['params']['image_id'], $slide['params']['image_source_type']);
                    }
                    if ($urlImage === false) {
                        $cur_img_id = RevSliderFunctionsWP::get_image_id_by_url($slide['params']['image']);
                        if ($cur_img_id !== false) {
                            $urlImage = wp_get_attachment_image_src($cur_img_id, $slide['params']['image_source_type']);
                        }
                    }
                    if ($urlImage !== false) {
                        $infos['id'] = $cur_img_id;
                        $file = get_attached_file($cur_img_id);
                        $infos['info'] = pathinfo($file);
                        if (file_exists($file)) {
                            $infos['size'] = filesize($file);
                            $infos['size-format'] = size_format($infos['size'], 2);
                            $img_size += $infos['size'];
                            if ($slide_counter == 1) {
                                $firstslide_size += $infos['size'];
                            }
                            if ($slide_counter == 1 || $slide_counter == 2 || $slide_counter == count($slides)) {
                                $smartslide_size += $infos['size'];
                            }
                        } else {
                            $infos['id'] = false;
                        }
                    } else {
                        $infos['id'] = 'external';
                    }
                    if (strpos($slide_id, 'static_') !== false) {
                        $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=static_' . $sliderID);
                    } else {
                        $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=' . $slide_id);
                    }
                    $used_images[$slide['params']['image']] = $infos;
                }
                if (isset($slide['layers']) && !empty($slide['layers']) && count($slide['layers']) > 0) {
                    $using_layeranim = true;
                    foreach ($slide['layers'] as $lKey => $layer) {
                        switch ($layer['type']) {
                            case 'image':
                                $infos = array();
                                if (isset($layer['image_url']) && trim($layer['image_url']) != '') {
                                    $cur_img_id = RevSliderFunctionsWP::get_image_id_by_url($layer['image_url']);
                                    if ($cur_img_id !== false) {
                                        if (!isset($layer['layer-image-size']) || $layer['layer-image-size'] == 'auto') {
                                            $layer['layer-image-size'] = $slide['params']['image_source_type'];
                                        }
                                        $urlImage = wp_get_attachment_image_src($cur_img_id, $layer['layer-image-size']);
                                        if ($urlImage !== false) {
                                            $infos['id'] = $cur_img_id;
                                            $file = get_attached_file($cur_img_id);
                                            $infos['info'] = pathinfo($file);
                                            if (file_exists($file)) {
                                                $infos['size'] = filesize($file);
                                                $infos['size-format'] = size_format($infos['size'], 2);
                                                $img_size += $infos['size'];
                                                if ($slide_counter == 1) {
                                                    $firstslide_size += $infos['size'];
                                                }
                                                if ($slide_counter == 1 || $slide_counter == 2 || $slide_counter == count($slides)) {
                                                    $smartslide_size += $infos['size'];
                                                }
                                            } else {
                                                $infos['id'] = false;
                                            }
                                        } else {
                                            $infos['id'] = 'external';
                                        }
                                    } else {
                                        $infos['id'] = 'external';
                                    }
                                    if (strpos($slide_id, 'static_') !== false) {
                                        $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=static_' . $sliderID);
                                    } else {
                                        $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=' . $slide_id);
                                    }
                                    $used_images[$layer['image_url']] = $infos;
                                    //image_url if image caption
                                }
                                break;
                            case 'video':
                                $using_videos = true;
                                //get cover image if existing
                                $infos = array();
                                $poster_img = array();
                                if (isset($layer['video_data']) && isset($layer['video_data']->urlPoster)) {
                                    $poster_img[] = $layer['video_data']->urlPoster;
                                }
                                if (isset($layer['video_image_url']) && isset($layer['video_image_url'])) {
                                    $poster_img[] = $layer['video_image_url'];
                                }
                                if (!empty($poster_img)) {
                                    foreach ($poster_img as $img) {
                                        if (trim($img) == '') {
                                            continue;
                                        }
                                        $cur_img_id = RevSliderFunctionsWP::get_image_id_by_url($img);
                                        if ($cur_img_id !== false) {
                                            if (!isset($layer['layer-image-size']) || $layer['layer-image-size'] == 'auto') {
                                                $layer['layer-image-size'] = $slide['params']['image_source_type'];
                                            }
                                            $urlImage = wp_get_attachment_image_src($cur_img_id, $layer['layer-image-size']);
                                            if ($urlImage !== false) {
                                                $infos['id'] = $cur_img_id;
                                                $file = get_attached_file($cur_img_id);
                                                $infos['info'] = pathinfo($file);
                                                if (file_exists($file)) {
                                                    $infos['size'] = filesize($file);
                                                    $infos['size-format'] = size_format($infos['size'], 2);
                                                    $img_size += $infos['size'];
                                                    if ($slide_counter == 1) {
                                                        $firstslide_size += $infos['size'];
                                                    }
                                                    if ($slide_counter == 1 || $slide_counter == 2 || $slide_counter == count($slides)) {
                                                        $smartslide_size += $infos['size'];
                                                    }
                                                } else {
                                                    $infos['id'] = false;
                                                }
                                            } else {
                                                $infos['id'] = 'external';
                                            }
                                        } else {
                                            $infos['id'] = 'external';
                                        }
                                        if (strpos($slide_id, 'static_') !== false) {
                                            $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=static_' . $sliderID);
                                        } else {
                                            $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=' . $slide_id);
                                        }
                                        $used_images[$img] = $infos;
                                        //image_url if image caption
                                    }
                                }
                                $infos = array();
                                if (isset($layer['video_type'])) {
                                    //add videos and try to get video size
                                    if (isset($layer['video_data'])) {
                                        $video_arr = array();
                                        $max_video_size = 0;
                                        if (strpos($slide_id, 'static_') !== false) {
                                            $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=static_' . $sliderID);
                                        } else {
                                            $infos['url'] = RevSliderBaseAdmin::getViewUrl(RevSliderAdmin::VIEW_SLIDE, 'id=' . $slide_id);
                                        }
                                        switch ($layer['video_type']) {
                                            case 'html5':
                                                if (isset($layer['video_data']->urlMp4) && !empty($layer['video_data']->urlMp4)) {
                                                    $video_arr['mp4'] = $layer['video_data']->urlMp4;
                                                }
                                                if (isset($layer['video_data']->urlWebm) && !empty($layer['video_data']->urlWebm)) {
                                                    $video_arr['webm'] = $layer['video_data']->urlWebm;
                                                }
                                                if (isset($layer['video_data']->urlOgv) && !empty($layer['video_data']->urlOgv)) {
                                                    $video_arr['mp4'] = $layer['video_data']->urlOgv;
                                                }
                                                if (!empty($video_arr)) {
                                                    foreach ($video_arr as $type => $url) {
                                                        $cur_id = RevSliderFunctionsWP::get_image_id_by_url($url);
                                                        if ($cur_id !== false) {
                                                            $infos['id'] = $cur_id;
                                                            $file = get_attached_file($cur_id);
                                                            $infos['info'] = pathinfo($file);
                                                            if (file_exists($file)) {
                                                                $infos['size'] = filesize($file);
                                                                $infos['size-format'] = size_format($infos['size'], 2);
                                                                if ($infos['size'] > $max_video_size) {
                                                                    $max_video_size = $infos['size'];
                                                                }
                                                                //add only the largest video of the three here as each browser loads only one file and we can add here the biggest
                                                            } else {
                                                                $infos['id'] = 'external';
                                                            }
                                                        } else {
                                                            $infos['id'] = 'external';
                                                        }
                                                        $used_videos[$url] = $infos;
                                                    }
                                                    $video_size += $max_video_size;
                                                }
                                                break;
                                            case 'youtube':
                                                $infos['id'] = 'external';
                                                if (!isset($layer['video_data']->id) || empty($layer['video_data']->id)) {
                                                    continue;
                                                }
                                                $used_videos[$do_ssl . '//www.youtube.com/watch?v=' . $layer['video_data']->id] = $infos;
                                                break;
                                            case 'vimeo':
                                                if (!isset($layer['video_data']->id) || empty($layer['video_data']->id)) {
                                                    continue;
                                                }
                                                $infos['id'] = 'external';
                                                $used_videos[$do_ssl . '//vimeo.com/' . $layer['video_data']->id] = $infos;
                                                break;
                                        }
                                    }
                                }
                                break;
                        }
                        //check captions for actions
                        if (isset($layer['layer_action']) && !empty($layer['layer_action'])) {
                            $a_action = RevSliderFunctions::cleanStdClassToArray(RevSliderFunctions::getVal($layer['layer_action'], 'action', array()));
                            $a_link_type = RevSliderFunctions::cleanStdClassToArray(RevSliderFunctions::getVal($layer['layer_action'], 'link_type', array()));
                            if (!empty($a_action)) {
                                foreach ($a_action as $num => $action) {
                                    if ($using_actions == true) {
                                        break;
                                    }
                                    if ($action !== 'link') {
                                        $using_actions = true;
                                    } else {
                                        //check if jQuery or a tag
                                        if ($a_link_type[$num] == 'jquery') {
                                            $using_actions = true;
                                        }
                                    }
                                }
                            }
                        }
                        if (isset($layer['style']) && $layer['style'] != '') {
                            $used_captions[$layer['style']] = true;
                        }
                    }
                }
            }
        }
        $total_size += $img_size;
        $img_counter = 0;
        $issues = "";
        //$total_size += $video_size;
        ?>

		<span class="tp-clearfix" style="height:15px"></span>
		<hr>
		<span class="tp-clearfix" style="height:25px"></span>
		
		<!-- HEADER OF MONITORING -->
		<span class="tp-monitor-performance-title"><?php 
        echo __("Overall Slider Performance", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
		<span class="tp-monitor-performace-wrap">
			<span id="image-performace-bar" style="width: %overall_performance%%" class="tp-monitor-performance-bar mo-%overall_color%-col"></span>
			<span class="tp-monitor-slow"><?php 
        echo __("Slow", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-ok"><?php 
        echo __("Ok", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-fast"><?php 
        echo __("Fast", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
		</span>
		<span class="tp-clearfix" style="height:50px"></span>
		
		<span  class="tp-monitor-speed-table tp-monitor-single-speed">
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed UMTS:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="umts-speed">%umtsspeed-single%</span>
			</span>
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed DSL:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="dsl-speed">%dslspeed-single%</span>
			</span>
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed T1:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="t1-speed">%t1speed-single%</span>
			</span>
		</span>

		<span  class="tp-monitor-speed-table tp-monitor-smart-speed">
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed UMTS:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="umts-speed">%umtsspeed-smart%</span>
			</span>
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed DSL:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="dsl-speed">%dslspeed-smart%</span>
			</span>
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed T1:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="t1-speed">%t1speed-smart%</span>
			</span>
		</span>

		<span class="tp-monitor-speed-table tp-monitor-all-speed">
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed UMTS:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="umts-speed">%umtsspeed-all%</span>
			</span>
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed DSL:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="dsl-speed">%dslspeed-all%</span>
			</span>
			<span class="tp-monitor-speed-cell">
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Load Speed T1:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-total-subsize" id="t1-speed">%t1speed-all%</span>
			</span>
		</span>

		<span class="tp-clearfix" style="height:25px"></span>
		<span style="float:left;width:165px">
			<span class="tp-monitor-smalllabel"><?php 
        echo __("Total Slider Size:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-fullsize">%overall_size%</span>
			<a class="button-primary revblue tp-monitor-showdetails" data-target="#performance_overall_details" style="float:right; width:160px;vertical-align:top"><i class="eg-icon-chart-bar"></i>Show Full Statistics</a>
		</span>
		<span style="float:right; width:165px">
			<span class="tp-monitor-smalllabel"><?php 
        echo __("Preloaded Slides Size:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-fullsize tp-monitor-single-speed">%firstslide_size%</span>
			<span class="tp-monitor-fullsize tp-monitor-smart-speed">%smartslide_size%</span>
			<span class="tp-monitor-fullsize tp-monitor-all-speed">%allslide_size%</span>		
			<a class="button-primary revred tp-monitor-showdetails" data-target="#monitor-problems" style="float:right; width:160px;vertical-align:top;"><i class="eg-icon-info"></i>Show All Issues</a>
		</span>		
		<span class="tp-clearfix" style="height:15px"></span>
		<hr>
		<span class="tp-clearfix" style="height:25px"></span>
		
		<!-- THE IMAGE PERFORMANCE MESSING -->
		<div id="monitor-problems" style="display:none">
			<span class="tp-monitor-performance-title"><?php 
        echo __("Need Some Attention", REVSLIDER_TEXTDOMAIN);
        ?>
</span>			
			<span class="tp-clearfix" style="height:25px"></span>
			<ul class="tp-monitor-list" id="monitor-problem-details" style="margin-bottom:15px;">
			%issues%
			</ul>
			<span class="tp-clearfix" style="height:15px"></span>
			<hr>
			<span class="tp-clearfix" style="height:25px"></span>
		</div>

		<div id="performance_overall_details" style="display:none">

		<!-- IMAGE LIST -->
		<?php 
        if (!empty($used_images)) {
            ?>
			<!-- THE IMAGE PERFORMANCE MESSING -->
			<span class="tp-monitor-performance-title"><?php 
            echo __("Image Performance", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
			<span class="tp-monitor-performace-wrap">
				<span id="image-performace-bar" style="width: %image_performance%%" class="tp-monitor-performance-bar mo-%image_color%-col"></span>
				<span class="tp-monitor-slow"><?php 
            echo __("Slow", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
				<span class="tp-monitor-ok"><?php 
            echo __("Ok", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
				<span class="tp-monitor-fast"><?php 
            echo __("Fast", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
			</span>

			<span class="tp-clearfix" style="height:35px"></span>

			<!-- FULL SIZE OF SUBCATEGORY && SHOW/HIDE LIST -->
			<span style="float:left;width:40%">
				<span class="tp-monitor-smalllabel"><?php 
            echo __("Images Loaded:", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
				<span class="tp-monitor-imageicon"></span>
				<span id="image_sub_size" class="tp-monitor-total-subsize"><?php 
            echo size_format($img_size, 2);
            ?>
</span>
				</span>
			<span style="float:left;width:60%; text-align:right;">
				<span class="tp-monitor-showdetails" data-target="#monitor-image-details" data-open="</span><?php 
            echo __("Hide Details", REVSLIDER_TEXTDOMAIN);
            ?>
" data-close="</span><?php 
            echo __("Show Details", REVSLIDER_TEXTDOMAIN);
            ?>
"><span class="tp-monitor-openclose"></span><span class="tp-show-inner-btn"><?php 
            echo __("Show Details", REVSLIDER_TEXTDOMAIN);
            ?>
</span></span>
			</span>
			<span class="tp-clearfix" style="height:15px"></span>
			<!-- THE IMAGE LIST -->
			
				<ul class="tp-monitor-list" id="monitor-image-details" style="display:none;margin-bottom:15px;">
				<?php 
            foreach ($used_images as $path => $image) {
                $_li = '<li class="tp-monitor-listli">';
                if (isset($image['size'])) {
                    $img_counter++;
                    if ($image['size'] < 200000) {
                        $_li .= '<span class="tp-monitor-good"></span>';
                    } else {
                        if ($image['size'] < 400000) {
                            $_li .= '<span class="tp-monitor-well"></span>';
                        } else {
                            $_li .= '<span class="tp-monitor-warning"></span>';
                        }
                    }
                    if ($image['size'] > 1000000) {
                        $_li .= '<span class="tp-monitor-size">' . size_format($image['size'], 2) . '</span>';
                    } else {
                        $_li .= '<span class="tp-monitor-size">' . size_format($image['size'], 0) . '</span>';
                    }
                } else {
                    if ($image['id'] == 'external') {
                        $_li .= '<span class="tp-monitor-neutral"></span><span class="tp-monitor-size">' . __('extern', REVSLIDER_TEXTDOMAIN) . '</span>';
                    } else {
                        $_li .= '<span class="tp-monitor-warning"></span><span class="tp-monitor-size">' . __('missing', REVSLIDER_TEXTDOMAIN) . '</span>';
                    }
                }
                $_li .= '<span class="tp-monitor-file">';
                if (!isset($image['info']['basename']) || empty($image['info']['basename'])) {
                    $_li .= '...' . substr($path, -20);
                } else {
                    $_li .= substr($image['info']['basename'], -20);
                }
                $_li .= '</span>';
                if (isset($image['url'])) {
                    //$_li .=   ' <a href="'.$image['url'].'" target="_blank" class="tp-monitor-showimage"></a>';
                    $_li .= ' <a href="' . $image['url'] . '" target="_blank" class="tp-monitor-linktoslide"></a>';
                }
                $_li .= '</li>';
                echo $_li;
                if (isset($image['size']) && $image['size'] > 199999 || !isset($image['size']) && !$image['id'] == 'external') {
                    $issues .= $_li;
                }
            }
            ?>
				</ul>

			<?php 
        }
        ?>
			
		<!-- VIDEO LIST -->
		<?php 
        if (!empty($used_videos)) {
            ?>
			<span class="tp-clearfix" style="height:15px"></span>
			<hr>
			<span class="tp-clearfix" style="height:25px"></span>
			
			<!-- THE VIDEO PERFORMANCE MESSING -->
			<span class="tp-monitor-performance-title"><?php 
            echo __("Video Performance", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
			<span class="tp-monitor-performace-wrap">
				<span id="video-performace-bar" style="width:50%" class="tp-monitor-performance-bar mo-neutral-col"></span>
				<span class="tp-monitor-slow"><?php 
            echo __("Slow", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
				<span class="tp-monitor-ok"><?php 
            echo __("Ok", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
				<span class="tp-monitor-fast"><?php 
            echo __("Fast", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
			</span>
			
			<span class="tp-clearfix" style="height:35px"></span>

			<!-- FULL SIZE OF SUBCATEGORY && SHOW/HIDE LIST -->
			<span style="float:left;width:40%; display:block">				
				<span class="tp-monitor-smalllabel"><?php 
            echo __("Videos Loaded (max):", REVSLIDER_TEXTDOMAIN);
            ?>
</span>
				<?php 
            if ($video_size > 0) {
                ?>
				
					<span class="tp-monitor-imageicon"></span>
					<span id="video_sub_size" class="tp-monitor-total-subsize"><?php 
                echo size_format($video_size, 2);
                ?>
</span>
				<?php 
            } else {
                ?>
					<span class="tp-monitor-imageicon"></span>
					<span class="tp-monitor-total-subsize"><?php 
                echo __("Unknown", REVSLIDER_TEXTDOMAIN);
                ?>
</span>
				<?php 
            }
            ?>
			</span>
			<span style="float:left;width:60%; text-align:right;">
				<span class="tp-monitor-showdetails" data-target="#monitor-video-details" data-open="</span><?php 
            echo __("Hide Details", REVSLIDER_TEXTDOMAIN);
            ?>
" data-close="</span><?php 
            echo __("Show Details", REVSLIDER_TEXTDOMAIN);
            ?>
"><span class="tp-monitor-openclose"></span><span class="tp-show-inner-btn"><?php 
            echo __("Show Details", REVSLIDER_TEXTDOMAIN);
            ?>
</span></span>
			</span>
			<span class="tp-clearfix" style="height:15px"></span>
			
			<ul class="tp-monitor-list" id="monitor-video-details" style="margin-bottom:15px;display:none;">
			<?php 
            foreach ($used_videos as $path => $video) {
                $_li = '<li class="tp-monitor-listli">';
                if (isset($video['size'])) {
                    $_li .= '	<span class="tp-monitor-neutral"></span>';
                    if ($video['size'] > 1000000) {
                        $_li .= '<span class="tp-monitor-size">' . size_format($video['size'], 2) . '</span>';
                    } else {
                        $_li .= '<span class="tp-monitor-size">' . size_format($video['size'], 0) . '</span>';
                    }
                } else {
                    if ($video['id'] == 'external') {
                        $_li .= '<span class="tp-monitor-neutral"></span><span class="tp-monitor-size">' . __('extern', REVSLIDER_TEXTDOMAIN) . '</span>';
                    } else {
                        $_li .= '<span class="tp-monitor-warning"></span><span class="tp-monitor-size">' . __('missing', REVSLIDER_TEXTDOMAIN) . '</span>';
                    }
                }
                $_li .= '<span class="tp-monitor-file">';
                if (!isset($video['info']['basename']) || empty($video['info']['basename'])) {
                    $_li .= '...' . substr($path, -20);
                } else {
                    $_li .= substr($video['info']['basename'], -20);
                }
                $_li .= '</span>';
                if (isset($image['url'])) {
                    $_li .= ' <a href="' . $video['url'] . '" target="_blank" class="tp-monitor-linktoslide"></a>';
                }
                $_li .= '</li>';
                if (!isset($video['size']) && !$video['id'] == 'external') {
                    $issues .= $_li;
                }
                echo $_li;
            }
            ?>
			</ul>
			<?php 
        }
        $css_size = 0;
        ?>

		<span class="tp-clearfix" style="height:15px"></span>
		<hr>
		<span class="tp-clearfix" style="height:25px"></span>

		<!-- THE IMAGE PERFORMANCE MESSING -->
		<span class="tp-monitor-performance-title"><?php 
        echo __("CSS Performance", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
		<span class="tp-monitor-performace-wrap">
			<span id="image-performace-bar" style="width:%css_performance%%" class="tp-monitor-performance-bar mo-%css_color%-col"></span>
			<span class="tp-monitor-slow"><?php 
        echo __("Slow", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-ok"><?php 
        echo __("Ok", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-fast"><?php 
        echo __("Fast", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
		</span>

		<span class="tp-clearfix" style="height:35px"></span>

		<!-- FULL SIZE OF SUBCATEGORY && SHOW/HIDE LIST -->
		<span style="float:left;width:40%">
			<span class="tp-monitor-smalllabel"><?php 
        echo __("CSS Loaded:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-cssicon"></span><span id="css_sub_size" class="tp-monitor-total-subsize">%css_size%</span>
			</span>
		<span style="float:left;width:60%; text-align:right;">
			<span class="tp-monitor-showdetails" data-target="#monitor-CSS-details" data-open="</span><?php 
        echo __("Hide Details", REVSLIDER_TEXTDOMAIN);
        ?>
" data-close="</span><?php 
        echo __("Show Details", REVSLIDER_TEXTDOMAIN);
        ?>
"><span class="tp-monitor-openclose"></span><span class="tp-show-inner-btn"><?php 
        echo __("Show Details", REVSLIDER_TEXTDOMAIN);
        ?>
</span></span>
		</span>
		<span class="tp-clearfix" style="height:15px"></span>

		<?php 
        //get css files
        echo '<ul class="tp-monitor-list" id="monitor-CSS-details" style="margin-bottom:15px;display:none;">';
        if (file_exists(RS_PLUGIN_PATH . '/public/assets/css/settings.css')) {
            $fs = filesize(RS_PLUGIN_PATH . '/public/assets/css/settings.css');
            $_li = '<li class="tp-monitor-listli">';
            if ($fs < 60000) {
                $_li .= '<span class="tp-monitor-good"></span>';
            } else {
                if ($fs < 100000) {
                    $_li .= '<span class="tp-monitor-well"></span>';
                } else {
                    $_li .= '<span class="tp-monitor-warning"></span>';
                }
            }
            $_li .= '<span class="tp-monitor-size">' . size_format($fs, 0) . '</span>';
            $_li .= '<span class="tp-monitor-file">';
            $_li .= __('css/settings.css', REVSLIDER_TEXTDOMAIN);
            $_li .= '</span>';
            $_li .= '</li>';
            if ($fs > 99999) {
                $issues .= $_li;
            }
            echo $_li;
            $total_size += $fs;
            $css_size += $fs;
        }
        $custom_css = RevSliderOperations::getStaticCss();
        $custom_css = RevSliderCssParser::compress_css($custom_css);
        $_li = '<li class="tp-monitor-listli">';
        if (strlen($custom_css) < 50000) {
            $_li .= '<span class="tp-monitor-good"></span>';
        } else {
            if (strlen($custom_css) < 100000) {
                $_li .= '<span class="tp-monitor-well"></span>';
            } else {
                $_li .= '<span class="tp-monitor-warning"></span>';
            }
        }
        $_li .= '<span class="tp-monitor-size">' . size_format(strlen($custom_css), 0) . '</span>';
        $_li .= '<span class="tp-monitor-file">';
        $_li .= __('Static Styles', REVSLIDER_TEXTDOMAIN);
        $_li .= '</span>';
        $_li .= '</li>';
        if (strlen($custom_css) > 49999) {
            $issues .= $_li;
        }
        echo $_li;
        $total_size += strlen($custom_css);
        $css_size += strlen($custom_css);
        if (!empty($used_captions)) {
            $captions = array();
            foreach ($used_captions as $class => $val) {
                $cap = RevSliderOperations::getCaptionsContentArray($class);
                if (!empty($cap)) {
                    $captions[] = $cap;
                }
            }
            $styles = RevSliderCssParser::parseArrayToCss($captions, "\n");
            $styles = RevSliderCssParser::compress_css($styles);
            $_li = '<li class="tp-monitor-listli">';
            if (strlen($styles) < 50000) {
                $_li .= '<span class="tp-monitor-good"></span>';
            } else {
                if (strlen($styles) < 100000) {
                    $_li .= '<span class="tp-monitor-well"></span>';
                } else {
                    $_li .= '<span class="tp-monitor-warning"></span>';
                }
            }
            $_li .= '<span class="tp-monitor-size">' . size_format(strlen($styles), 0) . '</span>';
            $_li .= '<span class="tp-monitor-file">';
            $_li .= __('Dynamic Styles', REVSLIDER_TEXTDOMAIN);
            $_li .= '</span>';
            $_li .= '</li>';
            if (strlen($styles) > 49999) {
                $issues .= $_li;
            }
            echo $_li;
            $total_size += strlen($styles);
            $css_size += strlen($styles);
        }
        echo '</ul>';
        echo ' <span style="display:none" id="css-size-hidden">' . size_format($css_size, 2) . '</span>';
        $js_size = 0;
        ?>
		<span class="tp-clearfix" style="height:15px"></span>
			<hr>
			<span class="tp-clearfix" style="height:25px"></span>
			
			<!-- THE jQuery PERFORMANCE MESSING -->
			<span class="tp-monitor-performance-title"><?php 
        echo __("jQuery Performance", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-performace-wrap">
				<span id="video-performace-bar" style="width:%js_performance%%" class="tp-monitor-performance-bar mo-%js_color%-col"></span>
				<span class="tp-monitor-slow"><?php 
        echo __("Slow", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-ok"><?php 
        echo __("Ok", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-fast"><?php 
        echo __("Fast", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			</span>
			
			<span class="tp-clearfix" style="height:35px"></span>

			<!-- FULL SIZE OF SUBCATEGORY && SHOW/HIDE LIST -->
			<span style="float:left;width:40%; display:block">				
				<span class="tp-monitor-smalllabel"><?php 
        echo __("jQuery Loaded:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>				
				<span class="tp-monitor-imageicon"></span><span id="jquery_sub_size" class="tp-monitor-total-subsize">%js_size%</span>				
			</span>
			<span style="float:left;width:60%; text-align:right;">
				<span class="tp-monitor-showdetails" data-target="#monitor-jquery-details" data-open="</span><?php 
        echo __("Hide Details", REVSLIDER_TEXTDOMAIN);
        ?>
" data-close="</span><?php 
        echo __("Show Details", REVSLIDER_TEXTDOMAIN);
        ?>
"><span class="tp-monitor-openclose"></span><span class="tp-show-inner-btn"><?php 
        echo __("Show Details", REVSLIDER_TEXTDOMAIN);
        ?>
</span></span>
			</span>
			<span class="tp-clearfix" style="height:15px"></span>
		
		<?php 
        echo '<ul class="tp-monitor-list" id="monitor-jquery-details" style="margin-bottom:15px;display:none">';
        $jsfiles = array('jquery.themepunch.tools.min.js' => RS_PLUGIN_PATH . '/public/assets/js/jquery.themepunch.tools.min.js', 'jquery.themepunch.revolution.min.js' => RS_PLUGIN_PATH . '/public/assets/js/jquery.themepunch.revolution.min.js');
        //check which js files will be used by the Slider
        if ($using_kenburns == true) {
            $jsfiles['revolution.extension.kenburn.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.kenburn.min.js';
        }
        if ($using_parallax == true) {
            $jsfiles['revolution.extension.parallax.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.parallax.js';
        }
        if ($using_navigation == true) {
            $jsfiles['revolution.extension.navigation.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.navigation.min.js';
        }
        if ($using_videos == true) {
            $jsfiles['revolution.extension.video.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.video.min.js';
        }
        if ($using_actions == true) {
            $jsfiles['revolution.extension.actions.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.actions.min.js';
        }
        if ($using_layeranim == true) {
            $jsfiles['revolution.extension.layeranimation.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.layeranimation.min.js';
        }
        if ($using_carousel == true) {
            $jsfiles['revolution.extension.carousel.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.carousel.min.js';
        } else {
            $jsfiles['revolution.extension.slideanims.min.js'] = RS_PLUGIN_PATH . '/public/assets/js/extensions/revolution.extension.slideanims.min.js';
        }
        //get the js files
        foreach ($jsfiles as $name => $path) {
            if (file_exists($path)) {
                $fs = filesize($path);
                echo '<li class="tp-monitor-listli">';
                echo '<span class="tp-monitor-good"></span>';
                echo '<span class="tp-monitor-size">' . size_format($fs, 0) . '</span>';
                echo '<span class="tp-monitor-file">';
                echo $name;
                echo '</span>';
                echo '</li>';
                $total_size += $fs;
                $js_size += $fs;
            }
        }
        echo '</ul>';
        echo ' <span style="display:none" id="css-size-hidden">' . size_format($js_size, 2) . '</span>';
        $http = is_ssl() ? 'https' : 'http';
        $operations = new RevSliderOperations();
        $arrValues = $operations->getGeneralSettingsValues();
        $set_diff_font = RevSliderFunctions::getVal($arrValues, "change_font_loading", '');
        if ($set_diff_font !== '') {
            $font_url = $set_diff_font;
        } else {
            $font_url = $http . '://fonts.googleapis.com/css?family=';
        }
        $my_fonts = $slider->getParam('google_font', array());
        ?>
		<span class="tp-clearfix" style="height:15px"></span>
			<hr>
			<span class="tp-clearfix" style="height:25px"></span>
			
			<!-- THE Fonts PERFORMANCE MESSING -->
			<span class="tp-monitor-performance-title"><?php 
        echo __("Google Fonts Performance", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			<span class="tp-monitor-performace-wrap">
				<span id="video-performace-bar" style="width:%font_performance%%" class="tp-monitor-performance-bar mo-%font_color%-col"></span>
				<span class="tp-monitor-slow"><?php 
        echo __("Slow", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-ok"><?php 
        echo __("Ok", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
				<span class="tp-monitor-fast"><?php 
        echo __("Fast", REVSLIDER_TEXTDOMAIN);
        ?>
</span>
			</span>
			
			<span class="tp-clearfix" style="height:35px"></span>

			<!-- FULL SIZE OF SUBCATEGORY && SHOW/HIDE LIST -->
			<span style="float:left;width:40%; display:block">				
				<span class="tp-monitor-smalllabel"><?php 
        echo __("Fonts Loaded:", REVSLIDER_TEXTDOMAIN);
        ?>
</span>				
				<span class="tp-monitor-jsicon"></span><span class="tp-monitor-total-subsize">%font_size%</span>				
			</span>
			<span style="float:left;width:60%; text-align:right;">
				<span class="tp-monitor-showdetails" data-target="#monitor-fonts-details" data-open="</span><?php 
        echo __("Hide Details", REVSLIDER_TEXTDOMAIN);
        ?>
" data-close="</span><?php 
        echo __("Show Details", REVSLIDER_TEXTDOMAIN);
        ?>
"><span class="tp-monitor-openclose"></span><span class="tp-show-inner-btn"><?php 
        echo __("Show Details", REVSLIDER_TEXTDOMAIN);
        ?>
</span></span>
			</span>
			<span class="tp-clearfix" style="height:15px"></span>
		
		<?php 
        //echo '<span class="tp-monitor-smalllabel">'.$font_url.'</span>';
        echo '<ul class="tp-monitor-list" id="monitor-fonts-details" style="margin-bottom:15px;display:none">';
        $all_font_count = 0;
        if (!empty($my_fonts)) {
            foreach ($my_fonts as $c_font) {
                $fcount = RevSliderBase::get_font_weight_count($c_font);
                $_li = '<li class="tp-monitor-listli">';
                if ($fcount < 4) {
                    $_li .= '<span class="tp-monitor-good"></span>';
                } else {
                    if ($fcount < 7) {
                        $_li .= '<span class="tp-monitor-well"></span>';
                    } else {
                        $_li .= '<span class="tp-monitor-warning"></span>';
                    }
                }
                $_li .= '<span class="tp-monitor-file">';
                $_li .= strip_tags($c_font);
                $_li .= '</span>';
                $_li .= '</li>';
                if ($fcount > 4) {
                    $issues .= $_li;
                }
                echo $_li;
                $all_font_count += $fcount;
            }
        }
        echo '</ul>';
        ?>
		</div><!-- END OF OVERALL Div-->
		
		<script>
			jQuery(document).on("ready",function() {
				
				jQuery('body').on('click','.tp-monitor-showdetails',function() {
					var bt = jQuery(this);
					if (bt.hasClass("selected")) {
						bt.find('.tp-show-inner-btn').html(bt.data('close'));
						bt.removeClass("selected");
						jQuery(bt.data('target')).slideUp(200);
					} else {
						bt.find('.tp-show-inner-btn').html(bt.data('open'));
						bt.addClass("selected");
						jQuery(bt.data('target')).slideDown(200);
					}
					
				})
			})
		</script>
		<?php 
        $content = ob_get_contents();
        ob_end_clean();
        if ($img_counter == 0) {
            $img_counter = 1;
        }
        if ($slide_counter == 0) {
            $slide_counter = 1;
        }
        $overall = RevSliderOperations::get_performance($total_size / $slide_counter, 0, 400000);
        // 400KB / Slide is ok
        $image = RevSliderOperations::get_performance($img_size / $img_counter, 0, 100000);
        // 100KB Image OK
        $css = RevSliderOperations::get_performance($css_size, 0, 150000);
        // 150KB CSS OK
        $js = RevSliderOperations::get_performance($js_size, 0, 250000);
        // 250KB Image OK
        $font = RevSliderOperations::get_performance($all_font_count, 0, 15);
        // 250KB Image OK
        $firstslide_size += $js_size;
        $firstslide_size += $css_size;
        $smartslide_size += $js_size;
        $smartslide_size += $css_size;
        $content = str_replace("%overall_performance%", $overall["proc"], $content);
        $content = str_replace("%overall_color%", $overall["col"], $content);
        $content = str_replace("%overall_size%", size_format($total_size, 2), $content);
        $content = str_replace("%image_performance%", $image["proc"], $content);
        $content = str_replace("%image_color%", $image["col"], $content);
        $content = str_replace("%css_performance%", $css["proc"], $content);
        $content = str_replace("%css_color%", $css["col"], $content);
        $content = str_replace("%css_size%", size_format($css_size, 2), $content);
        $content = str_replace("%js_performance%", $js["proc"], $content);
        $content = str_replace("%js_color%", $js["col"], $content);
        $content = str_replace("%js_size%", size_format($js_size, 2), $content);
        $content = str_replace("%font_performance%", $font["proc"], $content);
        $content = str_replace("%font_color%", $font["col"], $content);
        $content = str_replace("%font_size%", $all_font_count, $content);
        $content = str_replace("%issues%", $issues, $content);
        $content = str_replace("%firstslide_size%", size_format($firstslide_size, 2), $content);
        $content = str_replace("%smartslide_size%", size_format($smartslide_size, 2), $content);
        $content = str_replace("%allslide_size%", size_format($total_size, 2), $content);
        $total_size = $total_size / 1000;
        $content = str_replace("%umtsspeed-all%", gmdate('i:s', $total_size / 48), $content);
        $content = str_replace("%dslspeed-all%", gmdate('i:s', $total_size / 307), $content);
        $content = str_replace("%t1speed-all%", gmdate('i:s', $total_size / 1180), $content);
        $firstslide_size = $firstslide_size / 1000;
        $content = str_replace("%umtsspeed-single%", gmdate('i:s', $firstslide_size / 48), $content);
        $content = str_replace("%dslspeed-single%", gmdate('i:s', $firstslide_size / 307), $content);
        $content = str_replace("%t1speed-single%", gmdate('i:s', $firstslide_size / 1180), $content);
        $smartslide_size = $smartslide_size / 1000;
        $content = str_replace("%umtsspeed-smart%", gmdate('i:s', $smartslide_size / 48), $content);
        $content = str_replace("%dslspeed-smart%", gmdate('i:s', $smartslide_size / 307), $content);
        $content = str_replace("%t1speed-smart%", gmdate('i:s', $smartslide_size / 1180), $content);
        echo $content;
    }
Пример #3
0
 /**
  * 
  * import slider from multipart form
  */
 public function importSliderFromPost($updateAnim = true, $updateStatic = true, $exactfilepath = false, $is_template = false, $single_slide = false, $updateNavigation = true)
 {
     try {
         $sliderID = RevSliderFunctions::getPostVariable("sliderid");
         $sliderExists = !empty($sliderID);
         if ($sliderExists) {
             $this->initByID($sliderID);
         }
         if ($exactfilepath !== false) {
             $filepath = $exactfilepath;
         } else {
             switch ($_FILES['import_file']['error']) {
                 case UPLOAD_ERR_OK:
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     RevSliderFunctions::throwError(__('No file sent.', 'revslider'));
                 case UPLOAD_ERR_INI_SIZE:
                 case UPLOAD_ERR_FORM_SIZE:
                     RevSliderFunctions::throwError(__('Exceeded filesize limit.', 'revslider'));
                 default:
                     break;
             }
             $filepath = $_FILES["import_file"]["tmp_name"];
         }
         if (file_exists($filepath) == false) {
             RevSliderFunctions::throwError(__('Import file not found!!!', 'revslider'));
         }
         $importZip = false;
         WP_Filesystem();
         global $wp_filesystem;
         $upload_dir = wp_upload_dir();
         $d_path = $upload_dir['basedir'] . '/rstemp/';
         $unzipfile = unzip_file($filepath, $d_path);
         if (is_wp_error($unzipfile)) {
             define('FS_METHOD', 'direct');
             //lets try direct.
             WP_Filesystem();
             //WP_Filesystem() needs to be called again since now we use direct !
             //@chmod($filepath, 0775);
             $unzipfile = unzip_file($filepath, $d_path);
             if (is_wp_error($unzipfile)) {
                 $d_path = RS_PLUGIN_PATH . 'rstemp/';
                 $unzipfile = unzip_file($filepath, $d_path);
                 if (is_wp_error($unzipfile)) {
                     $f = basename($filepath);
                     $d_path = str_replace($f, '', $filepath);
                     $unzipfile = unzip_file($filepath, $d_path);
                 }
             }
         }
         if (!is_wp_error($unzipfile)) {
             $importZip = true;
             //raus damit..
             //read all files needed
             $content = $wp_filesystem->exists($d_path . 'slider_export.txt') ? $wp_filesystem->get_contents($d_path . 'slider_export.txt') : '';
             if ($content == '') {
                 RevSliderFunctions::throwError(__('slider_export.txt does not exist!', 'revslider'));
             }
             $animations = $wp_filesystem->exists($d_path . 'custom_animations.txt') ? $wp_filesystem->get_contents($d_path . 'custom_animations.txt') : '';
             $dynamic = $wp_filesystem->exists($d_path . 'dynamic-captions.css') ? $wp_filesystem->get_contents($d_path . 'dynamic-captions.css') : '';
             $static = $wp_filesystem->exists($d_path . 'static-captions.css') ? $wp_filesystem->get_contents($d_path . 'static-captions.css') : '';
             $navigations = $wp_filesystem->exists($d_path . 'navigation.txt') ? $wp_filesystem->get_contents($d_path . 'navigation.txt') : '';
             $uid_check = $wp_filesystem->exists($d_path . 'info.cfg') ? $wp_filesystem->get_contents($d_path . 'info.cfg') : '';
             $version_check = $wp_filesystem->exists($d_path . 'version.cfg') ? $wp_filesystem->get_contents($d_path . 'version.cfg') : '';
             if ($is_template !== false) {
                 if ($uid_check != $is_template) {
                     return array("success" => false, "error" => __('Please select the correct zip file, checksum failed!', 'revslider'));
                 }
             } else {
                 //someone imported a template base Slider, check if it is existing in Base Sliders, if yes, check if it was imported
                 if ($uid_check !== '') {
                     $tmpl = new RevSliderTemplate();
                     $tmpl_slider = $tmpl->getThemePunchTemplateSliders();
                     foreach ($tmpl_slider as $tp_slider) {
                         if (!isset($tp_slider['installed'])) {
                             continue;
                         }
                         if ($tp_slider['uid'] == $uid_check) {
                             $is_template = $uid_check;
                             break;
                         }
                     }
                 }
             }
             $db = new RevSliderDB();
             //update/insert custom animations
             $animations = @unserialize($animations);
             if (!empty($animations)) {
                 foreach ($animations as $key => $animation) {
                     //$animation['id'], $animation['handle'], $animation['params']
                     $exist = $db->fetch(RevSliderGlobals::$table_layer_anims, $db->prepare("handle = %s", array($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(RevSliderGlobals::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle']));
                             $anim_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'])));
                             $anim_id = $db->insert(RevSliderGlobals::$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'])));
                         $anim_id = $db->insert(RevSliderGlobals::$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-' . $anim_id . '"', 'customout-' . $anim_id . '"'), $content);
                 }
                 dmp(__("animations imported!", 'revslider'));
             }
             //overwrite/append static-captions.css
             if (!empty($static)) {
                 if ($updateStatic == "true") {
                     //overwrite file
                     RevSliderOperations::updateStaticCss($static);
                 } elseif ($updateStatic == 'none') {
                     //do nothing
                 } else {
                     //append
                     $static_cur = RevSliderOperations::getStaticCss();
                     $static = $static_cur . "\n" . $static;
                     RevSliderOperations::updateStaticCss($static);
                 }
             }
             //overwrite/create dynamic-captions.css
             //parse css to classes
             $dynamicCss = RevSliderCssParser::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, ',') !== false && strpos($class, '.tp-caption') !== false) {
                         //we have something like .tp-caption.redclass, .redclass
                         $class_t = explode(',', $class);
                         foreach ($class_t as $k => $cl) {
                             if (strpos($cl, '.tp-caption') !== false) {
                                 $class = $cl;
                             }
                         }
                     }
                     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);
                         $arrInsert["settings"] = '';
                     }
                     //check if class exists
                     $result = $db->fetch(RevSliderGlobals::$table_css, $db->prepare("handle = %s", array($class)));
                     if (!empty($result)) {
                         //update
                         $db->update(RevSliderGlobals::$table_css, $arrInsert, array('handle' => $class));
                     } else {
                         //insert
                         $arrInsert["handle"] = $class;
                         $db->insert(RevSliderGlobals::$table_css, $arrInsert);
                     }
                 }
                 dmp(__("dynamic styles imported!", 'revslider'));
             }
             //update/insert custom animations
             $navigations = @unserialize($navigations);
             if (!empty($navigations)) {
                 foreach ($navigations as $key => $navigation) {
                     $exist = $db->fetch(RevSliderGlobals::$table_navigation, $db->prepare("handle = %s", array($navigation['handle'])));
                     unset($navigation['id']);
                     $rh = $navigation["handle"];
                     if (!empty($exist)) {
                         //create new navigation, get the ID
                         if ($updateNavigation == "true") {
                             //overwrite navigation if exists
                             unset($navigation['handle']);
                             $db->update(RevSliderGlobals::$table_navigation, $navigation, array('handle' => $rh));
                         } else {
                             //insert with new handle
                             $navigation["handle"] = $navigation['handle'] . '-' . date('is');
                             $navigation["name"] = $navigation['name'] . '-' . date('is');
                             $content = str_replace($rh . '"', $navigation["handle"] . '"', $content);
                             $navigation["css"] = str_replace('.' . $rh, '.' . $navigation["handle"], $navigation["css"]);
                             //change css class to the correct new class
                             $navi_id = $db->insert(RevSliderGlobals::$table_navigation, $navigation);
                         }
                     } else {
                         $navi_id = $db->insert(RevSliderGlobals::$table_navigation, $navigation);
                     }
                 }
                 dmp(__("navigations imported!", 'revslider'));
             }
         } else {
             $message = $unzipfile->get_error_message();
             $wp_filesystem->delete($d_path, true);
             return array("success" => false, "error" => $message);
         }
         //$content = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $content); //clear errors in string //deprecated in newest php version
         $content = preg_replace_callback('!s:(\\d+):"(.*?)";!', array('RevSliderSlider', 'clear_error_in_string'), $content);
         //clear errors in string
         $arrSlider = @unserialize($content);
         if (empty($arrSlider)) {
             $wp_filesystem->delete($d_path, true);
             RevSliderFunctions::throwError(__('Wrong export slider file format! Please make sure that the uploaded file is either a zip file with a correct slider_export.txt in the root of it or an valid slider_export.txt file.', 'revslider'));
         }
         //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"] = RevSliderFunctionsWP::getImageUrlFromPath($sliderParams["background_image"]);
         }
         $import_statics = true;
         if (isset($sliderParams['enable_static_layers'])) {
             if ($sliderParams['enable_static_layers'] == 'off') {
                 $import_statics = false;
             }
             unset($sliderParams['enable_static_layers']);
         }
         $sliderParams['version'] = $version_check;
         $json_params = json_encode($sliderParams);
         //update slider or create new
         if ($sliderExists) {
             $arrUpdate = array("params" => $json_params);
             $this->db->update(RevSliderGlobals::$table_sliders, $arrUpdate, array("id" => $sliderID));
         } else {
             //new slider
             $arrInsert = array();
             $arrInsert['params'] = $json_params;
             //check if Slider with title and/or alias exists, if yes change both to stay unique
             $arrInsert['title'] = RevSliderFunctions::getVal($sliderParams, 'title', 'Slider1');
             $arrInsert['alias'] = RevSliderFunctions::getVal($sliderParams, 'alias', 'slider1');
             if ($is_template === false) {
                 //we want to stay at the given alias if we are a template
                 $talias = $arrInsert['alias'];
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $arrInsert['alias'] . $ti;
                     $ti++;
                 }
                 if ($talias !== $arrInsert['alias']) {
                     $sliderParams['title'] = $talias;
                     $sliderParams['alias'] = $talias;
                     $arrInsert['title'] = $talias;
                     $arrInsert['alias'] = $talias;
                     $json_params = json_encode($sliderParams);
                     $arrInsert['params'] = $json_params;
                 }
             }
             if ($is_template !== false) {
                 //add that we are an template
                 $arrInsert['type'] = 'template';
                 $sliderParams['uid'] = $is_template;
                 $json_params = json_encode($sliderParams);
                 $arrInsert['params'] = $json_params;
             }
             $sliderID = $this->db->insert(RevSliderGlobals::$table_sliders, $arrInsert);
         }
         //-------- Slides Handle -----------
         //delete current slides
         if ($sliderExists) {
             $this->deleteAllSlides();
         }
         //create all slides
         $arrSlides = $arrSlider["slides"];
         $alreadyImported = array();
         //$content_url = content_url();
         $upload_dir = wp_upload_dir();
         $content_url = $upload_dir['baseurl'] . '/revslider/assets/svg/';
         //wpml compatibility
         $slider_map = array();
         foreach ($arrSlides as $sl_key => $slide) {
             $params = $slide["params"];
             $layers = $slide["layers"];
             $settings = isset($slide["settings"]) ? $slide["settings"] : '';
             //convert params images:
             if ($importZip === true) {
                 //we have a zip, check if exists
                 //remove image_id as it is not needed in import
                 if (isset($params['image_id'])) {
                     unset($params['image_id']);
                 }
                 if (isset($params["image"])) {
                     $params["image"] = RevSliderBase::check_file_in_zip($d_path, $params["image"], $sliderParams["alias"], $alreadyImported);
                     $params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
                 }
                 if (isset($params["background_image"])) {
                     $params["background_image"] = RevSliderBase::check_file_in_zip($d_path, $params["background_image"], $sliderParams["alias"], $alreadyImported);
                     $params["background_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["background_image"]);
                 }
                 if (isset($params["slide_thumb"])) {
                     $params["slide_thumb"] = RevSliderBase::check_file_in_zip($d_path, $params["slide_thumb"], $sliderParams["alias"], $alreadyImported);
                     $params["slide_thumb"] = RevSliderFunctionsWP::getImageUrlFromPath($params["slide_thumb"]);
                 }
                 if (isset($params["show_alternate_image"])) {
                     $params["show_alternate_image"] = RevSliderBase::check_file_in_zip($d_path, $params["show_alternate_image"], $sliderParams["alias"], $alreadyImported);
                     $params["show_alternate_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["show_alternate_image"]);
                 }
                 if (isset($params['background_type']) && $params['background_type'] == 'html5') {
                     if (isset($params['slide_bg_html_mpeg']) && $params['slide_bg_html_mpeg'] != '') {
                         $params['slide_bg_html_mpeg'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $params["slide_bg_html_mpeg"], $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_webm']) && $params['slide_bg_html_webm'] != '') {
                         $params['slide_bg_html_webm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $params["slide_bg_html_webm"], $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_ogv']) && $params['slide_bg_html_ogv'] != '') {
                         $params['slide_bg_html_ogv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $params["slide_bg_html_ogv"], $sliderParams["alias"], $alreadyImported, true));
                     }
                 }
             }
             //convert layers images:
             foreach ($layers as $key => $layer) {
                 //import if exists in zip folder
                 if ($importZip === true) {
                     //we have a zip, check if exists
                     if (isset($layer["image_url"])) {
                         $layer["image_url"] = RevSliderBase::check_file_in_zip($d_path, $layer["image_url"], $sliderParams["alias"], $alreadyImported);
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                     }
                     if (isset($layer['type']) && ($layer['type'] == 'video' || $layer['type'] == 'audio')) {
                         $video_data = isset($layer['video_data']) ? (array) $layer['video_data'] : array();
                         if (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] == 'html5') {
                             if (isset($video_data['urlPoster']) && $video_data['urlPoster'] != '') {
                                 $video_data['urlPoster'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlPoster"], $sliderParams["alias"], $alreadyImported));
                             }
                             if (isset($video_data['urlMp4']) && $video_data['urlMp4'] != '') {
                                 $video_data['urlMp4'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlMp4"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlWebm']) && $video_data['urlWebm'] != '') {
                                 $video_data['urlWebm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlWebm"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlOgv']) && $video_data['urlOgv'] != '') {
                                 $video_data['urlOgv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlOgv"], $sliderParams["alias"], $alreadyImported, true));
                             }
                         } elseif (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] != 'html5') {
                             //video cover image
                             if ($video_data['video_type'] == 'audio') {
                                 if (isset($video_data['urlAudio']) && $video_data['urlAudio'] != '') {
                                     $video_data['urlAudio'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlAudio"], $sliderParams["alias"], $alreadyImported, true));
                                 }
                             } else {
                                 if (isset($video_data['previewimage']) && $video_data['previewimage'] != '') {
                                     $video_data['previewimage'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["previewimage"], $sliderParams["alias"], $alreadyImported));
                                 }
                             }
                         }
                         $layer['video_data'] = $video_data;
                     }
                     if (isset($layer['type']) && $layer['type'] == 'svg') {
                         if (isset($layer['svg']) && isset($layer['svg']->src)) {
                             if (strpos($layer['svg']->src, 'revslider-whiteboard-addon') !== false) {
                                 $layer['svg']->src = content_url() . $layer['svg']->src;
                             } else {
                                 $layer['svg']->src = str_replace('/plugins/revslider/public/assets/assets/svg/', '', $content_url . $layer['svg']->src);
                             }
                         }
                     }
                 }
                 $layer['text'] = stripslashes($layer['text']);
                 $layers[$key] = $layer;
             }
             $arrSlides[$sl_key]['layers'] = $layers;
             //create new slide
             $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));
             }
             $my_settings = json_encode($settings);
             if (empty($my_settings)) {
                 $my_settings = stripslashes(json_encode($settings));
             }
             $arrCreate["layers"] = $my_layers;
             $arrCreate["params"] = $my_params;
             $arrCreate["settings"] = $my_settings;
             $last_id = $this->db->insert(RevSliderGlobals::$table_slides, $arrCreate);
             if (isset($slide['id'])) {
                 $slider_map[$slide['id']] = $last_id;
             }
         }
         //change for WPML the parent IDs if necessary
         if (!empty($slider_map)) {
             foreach ($arrSlides as $sl_key => $slide) {
                 if (isset($slide['params']['parentid']) && isset($slider_map[$slide['params']['parentid']])) {
                     $update_id = $slider_map[$slide['id']];
                     $parent_id = $slider_map[$slide['params']['parentid']];
                     $arrCreate = array();
                     $arrCreate["params"] = $slide['params'];
                     $arrCreate["params"]['parentid'] = $parent_id;
                     $my_params = json_encode($arrCreate["params"]);
                     if (empty($my_params)) {
                         $my_params = stripslashes(json_encode($arrCreate["params"]));
                     }
                     $arrCreate["params"] = $my_params;
                     $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $update_id));
                 }
                 $did_change = false;
                 foreach ($slide['layers'] as $key => $value) {
                     if (isset($value['layer_action'])) {
                         if (isset($value['layer_action']->jump_to_slide) && !empty($value['layer_action']->jump_to_slide)) {
                             $value['layer_action']->jump_to_slide = (array) $value['layer_action']->jump_to_slide;
                             foreach ($value['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $slide['layers'][$key]['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                     $did_change = true;
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($value, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($slide['layers'][$key]['layer_action'])) {
                             $slide['layers'][$key]['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($value, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($value, 'link_open_in');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'link');
                                 $slide['layers'][$key]['layer_action']->link_type = array('a' => 'a');
                                 $slide['layers'][$key]['layer_action']->image_link = array('a' => $link);
                                 $slide['layers'][$key]['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($slide['layers'][$key]['link']);
                                 unset($slide['layers'][$key]['link_open_in']);
                             case 'next':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'scroll_under');
                                 $slide['layers'][$key]['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($slide['layers'][$key]['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'jumpto');
                                 $slide['layers'][$key]['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $slide['layers'][$key]['layer_action']->tooltip_event = array('a' => 'click');
                         unset($slide['layers'][$key]['link_slide']);
                         $did_change = true;
                     }
                     if ($did_change === true) {
                         $arrCreate = array();
                         $my_layers = json_encode($slide['layers']);
                         if (empty($my_layers)) {
                             $my_layers = stripslashes(json_encode($layers));
                         }
                         $arrCreate['layers'] = $my_layers;
                         $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $slider_map[$slide['id']]));
                     }
                 }
             }
         }
         //check if static slide exists and import
         if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides']) && $import_statics) {
             $static_slide = $arrSlider['static_slides'];
             foreach ($static_slide as $slide) {
                 $params = $slide["params"];
                 $layers = $slide["layers"];
                 $settings = isset($slide["settings"]) ? $slide["settings"] : '';
                 //remove image_id as it is not needed in import
                 if (isset($params['image_id'])) {
                     unset($params['image_id']);
                 }
                 //convert params images:
                 if (isset($params["image"])) {
                     //import if exists in zip folder
                     if (strpos($params["image"], 'http') !== false) {
                     } else {
                         if (trim($params["image"]) !== '') {
                             if ($importZip === true) {
                                 //we have a zip, check if exists
                                 $image = $wp_filesystem->exists($d_path . 'images/' . $params["image"]);
                                 if (!$image) {
                                     echo $params["image"] . __(' not found!<br>', 'revslider');
                                 } else {
                                     if (!isset($alreadyImported['images/' . $params["image"]])) {
                                         $importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $params["image"], $sliderParams["alias"] . '/');
                                         if ($importImage !== false) {
                                             $alreadyImported['images/' . $params["image"]] = $importImage['path'];
                                             $params["image"] = $importImage['path'];
                                         }
                                     } else {
                                         $params["image"] = $alreadyImported['images/' . $params["image"]];
                                     }
                                 }
                             }
                         }
                         $params["image"] = RevSliderFunctionsWP::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 (strpos($layer["image_url"], 'http') !== false) {
                             } else {
                                 if ($importZip === true) {
                                     //we have a zip, check if exists
                                     $image_url = $wp_filesystem->exists($d_path . 'images/' . $layer["image_url"]);
                                     if (!$image_url) {
                                         echo $layer["image_url"] . __(' not found!<br>');
                                     } else {
                                         if (!isset($alreadyImported['images/' . $layer["image_url"]])) {
                                             $importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/');
                                             if ($importImage !== false) {
                                                 $alreadyImported['images/' . $layer["image_url"]] = $importImage['path'];
                                                 $layer["image_url"] = $importImage['path'];
                                             }
                                         } else {
                                             $layer["image_url"] = $alreadyImported['images/' . $layer["image_url"]];
                                         }
                                     }
                                 }
                             }
                         }
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                     }
                     $layer['text'] = stripslashes($layer['text']);
                     if (isset($layer['type']) && ($layer['type'] == 'video' || $layer['type'] == 'audio')) {
                         $video_data = isset($layer['video_data']) ? (array) $layer['video_data'] : array();
                         if (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] == 'html5') {
                             if (isset($video_data['urlPoster']) && $video_data['urlPoster'] != '') {
                                 $video_data['urlPoster'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlPoster"], $sliderParams["alias"], $alreadyImported));
                             }
                             if (isset($video_data['urlMp4']) && $video_data['urlMp4'] != '') {
                                 $video_data['urlMp4'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlMp4"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlWebm']) && $video_data['urlWebm'] != '') {
                                 $video_data['urlWebm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlWebm"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlOgv']) && $video_data['urlOgv'] != '') {
                                 $video_data['urlOgv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlOgv"], $sliderParams["alias"], $alreadyImported, true));
                             }
                         } elseif (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] != 'html5') {
                             //video cover image
                             if ($video_data['video_type'] == 'audio') {
                                 if (isset($video_data['urlAudio']) && $video_data['urlAudio'] != '') {
                                     $video_data['urlAudio'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlAudio"], $sliderParams["alias"], $alreadyImported, true));
                                 }
                             } else {
                                 if (isset($video_data['previewimage']) && $video_data['previewimage'] != '') {
                                     $video_data['previewimage'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["previewimage"], $sliderParams["alias"], $alreadyImported));
                                 }
                             }
                         }
                         $layer['video_data'] = $video_data;
                     }
                     if (isset($layer['type']) && $layer['type'] == 'svg') {
                         if (isset($layer['svg']) && isset($layer['svg']->src)) {
                             $layer['svg']->src = str_replace('/plugins/revslider/public/assets/assets/svg/', '', $content_url . $layer['svg']->src);
                         }
                     }
                     if (isset($layer['layer_action'])) {
                         if (isset($layer['layer_action']->jump_to_slide) && !empty($layer['layer_action']->jump_to_slide)) {
                             foreach ($layer['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $layer['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($layer, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($layer['layer_action'])) {
                             $layer['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($layer, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($layer, 'link_open_in');
                                 $layer['layer_action']->action = array('a' => 'link');
                                 $layer['layer_action']->link_type = array('a' => 'a');
                                 $layer['layer_action']->image_link = array('a' => $link);
                                 $layer['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($layer['link']);
                                 unset($layer['link_open_in']);
                             case 'next':
                                 $layer['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $layer['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $layer['layer_action']->action = array('a' => 'scroll_under');
                                 $layer['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($layer['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $layer['layer_action']->action = array('a' => 'jumpto');
                                 $layer['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $layer['layer_action']->tooltip_event = array('a' => 'click');
                         unset($layer['link_slide']);
                         $did_change = true;
                     }
                     $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));
                 }
                 $my_settings = json_encode($settings);
                 if (empty($my_settings)) {
                     $my_settings = stripslashes(json_encode($settings));
                 }
                 $arrCreate["layers"] = $my_layers;
                 $arrCreate["params"] = $my_params;
                 $arrCreate["settings"] = $my_settings;
                 if ($sliderExists) {
                     unset($arrCreate["slider_id"]);
                     $this->db->update(RevSliderGlobals::$table_static_slides, $arrCreate, array("slider_id" => $sliderID));
                 } else {
                     $this->db->insert(RevSliderGlobals::$table_static_slides, $arrCreate);
                 }
             }
         }
         $c_slider = new RevSliderSlider();
         $c_slider->initByID($sliderID);
         //check to convert styles to latest versions
         RevSliderPluginUpdate::update_css_styles();
         //set to version 5
         RevSliderPluginUpdate::add_animation_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_style_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::change_settings_on_layers($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_general_settings($c_slider);
         //set to version 5
         RevSliderPluginUpdate::change_general_settings_5_0_7($c_slider);
         //set to version 5.0.7
         RevSliderPluginUpdate::change_layers_svg_5_2_5_4($c_slider);
         //set to version 5.2.5.4
         $cus_js = $c_slider->getParam('custom_javascript', '');
         if (strpos($cus_js, 'revapi') !== false) {
             if (preg_match_all('/revapi[0-9]*/', $cus_js, $results)) {
                 if (isset($results[0]) && !empty($results[0])) {
                     foreach ($results[0] as $replace) {
                         $cus_js = str_replace($replace, 'revapi' . $sliderID, $cus_js);
                     }
                 }
                 $c_slider->updateParam(array('custom_javascript' => $cus_js));
             }
         }
         if ($is_template !== false) {
             //duplicate the slider now, as we just imported the "template"
             if ($single_slide !== false) {
                 //add now one Slide to the current Slider
                 $mslider = new RevSlider();
                 //change slide_id to correct, as it currently is just a number beginning from 0 as we did not have a correct slide ID yet.
                 $i = 0;
                 $changed = false;
                 foreach ($slider_map as $value) {
                     if ($i == $single_slide['slide_id']) {
                         $single_slide['slide_id'] = $value;
                         $changed = true;
                         break;
                     }
                     $i++;
                 }
                 if ($changed) {
                     $return = $mslider->copySlideToSlider($single_slide);
                 } else {
                     return array("success" => false, "error" => __('could not find correct Slide to copy, please try again.', 'revslider'), "sliderID" => $sliderID);
                 }
             } else {
                 $mslider = new RevSlider();
                 $title = RevSliderFunctions::getVal($sliderParams, 'title', 'slider1');
                 $talias = $title;
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $title . $ti;
                     $ti++;
                 }
                 $mslider->duplicateSliderFromData(array('sliderid' => $sliderID, 'title' => $talias));
             }
         }
         $wp_filesystem->delete($d_path, true);
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
         if (isset($d_path)) {
             $wp_filesystem->delete($d_path, true);
         }
         return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID);
     }
     return array("success" => true, "sliderID" => $sliderID);
 }