/** * * onAjax action handler */ public static function onAjaxAction() { $slider = new RevSlider(); $slide = new RevSlide(); $operations = new RevSliderOperations(); $action = self::getPostGetVar("client_action"); $data = self::getPostGetVar("data"); $nonce = self::getPostGetVar("nonce"); if (empty($nonce)) { $nonce = self::getPostGetVar("rs-nonce"); } try { //verify the nonce $isVerified = wp_verify_nonce($nonce, "revslider_actions"); if ($isVerified == false) { RevSliderFunctions::throwError("Wrong request"); } switch ($action) { case 'add_new_preset': if (!isset($data['settings']) || !isset($data['values'])) { self::ajaxResponseError(__('Missing values to add preset', 'revslider'), false); } $result = $operations->add_preset_setting($data); if ($result === true) { $presets = $operations->get_preset_settings(); self::ajaxResponseSuccess(__('Preset created', 'revslider'), array('data' => $presets)); } else { self::ajaxResponseError($result, false); } exit; break; case 'update_preset': if (!isset($data['name']) || !isset($data['values'])) { self::ajaxResponseError(__('Missing values to update preset', 'revslider'), false); } $result = $operations->update_preset_setting($data); if ($result === true) { $presets = $operations->get_preset_settings(); self::ajaxResponseSuccess(__('Preset created', 'revslider'), array('data' => $presets)); } else { self::ajaxResponseError($result, false); } exit; break; case 'remove_preset': if (!isset($data['name'])) { self::ajaxResponseError(__('Missing values to remove preset', 'revslider'), false); } $result = $operations->remove_preset_setting($data); if ($result === true) { $presets = $operations->get_preset_settings(); self::ajaxResponseSuccess(__('Preset deleted', 'revslider'), array('data' => $presets)); } else { self::ajaxResponseError($result, false); } exit; break; case "export_slider": $sliderID = self::getGetVar("sliderid"); $dummy = self::getGetVar("dummy"); $slider->initByID($sliderID); $slider->exportSlider($dummy); break; case "import_slider": $updateAnim = self::getPostGetVar("update_animations"); $updateNav = self::getPostGetVar("update_navigations"); $updateStatic = self::getPostGetVar("update_static_captions"); self::importSliderHandle(null, $updateAnim, $updateStatic, $updateNav); break; case "import_slider_slidersview": $viewBack = self::getViewUrl(self::VIEW_SLIDERS); $updateAnim = self::getPostGetVar("update_animations"); $updateNav = self::getPostGetVar("update_navigations"); $updateStatic = self::getPostGetVar("update_static_captions"); self::importSliderHandle($viewBack, $updateAnim, $updateStatic, $updateNav); break; case "import_slider_online_template_slidersview": $viewBack = self::getViewUrl(self::VIEW_SLIDERS); self::importSliderOnlineTemplateHandle($viewBack, 'true', 'none'); break; case "import_slide_online_template_slidersview": $redirect_id = esc_attr(self::getPostGetVar("redirect_id")); $viewBack = self::getViewUrl(self::VIEW_SLIDE, "id={$redirect_id}"); $slidenum = intval(self::getPostGetVar("slidenum")); $sliderid = intval(self::getPostGetVar("slider_id")); self::importSliderOnlineTemplateHandle($viewBack, 'true', 'none', array('slider_id' => $sliderid, 'slide_id' => $slidenum)); break; case "import_slider_template_slidersview": $viewBack = self::getViewUrl(self::VIEW_SLIDERS); $updateAnim = self::getPostGetVar("update_animations"); $updateStatic = self::getPostGetVar("update_static_captions"); self::importSliderTemplateHandle($viewBack, $updateAnim, $updateStatic); break; case "import_slide_template_slidersview": $redirect_id = esc_attr(self::getPostGetVar("redirect_id")); $viewBack = self::getViewUrl(self::VIEW_SLIDE, "id={$redirect_id}"); $updateAnim = self::getPostGetVar("update_animations"); $updateStatic = self::getPostGetVar("update_static_captions"); $slidenum = intval(self::getPostGetVar("slidenum")); $sliderid = intval(self::getPostGetVar("slider_id")); self::importSliderTemplateHandle($viewBack, $updateAnim, $updateStatic, array('slider_id' => $sliderid, 'slide_id' => $slidenum)); break; case "create_slider": $data = $operations->modifyCustomSliderParams($data); $newSliderID = $slider->createSliderFromOptions($data); self::ajaxResponseSuccessRedirect(__("Slider created", 'revslider'), self::getViewUrl(self::VIEW_SLIDE, 'id=new&slider=' . esc_attr($newSliderID))); //redirect to slide now break; case "update_slider": $data = $operations->modifyCustomSliderParams($data); $slider->updateSliderFromOptions($data); self::ajaxResponseSuccess(__("Slider updated", 'revslider')); break; case "delete_slider": case "delete_slider_stay": $isDeleted = $slider->deleteSliderFromData($data); if (is_array($isDeleted)) { $isDeleted = implode(', ', $isDeleted); self::ajaxResponseError(__("Template can't be deleted, it is still being used by the following Sliders: ", 'revslider') . $isDeleted); } else { if ($action == 'delete_slider_stay') { self::ajaxResponseSuccess(__("Slider deleted", 'revslider')); } else { self::ajaxResponseSuccessRedirect(__("Slider deleted", 'revslider'), self::getViewUrl(self::VIEW_SLIDERS)); } } break; case "duplicate_slider": $slider->duplicateSliderFromData($data); self::ajaxResponseSuccessRedirect(__("Success! Refreshing page...", 'revslider'), self::getViewUrl(self::VIEW_SLIDERS)); break; case "add_slide": case "add_bulk_slide": $numSlides = $slider->createSlideFromData($data); $sliderID = $data["sliderid"]; if ($numSlides == 1) { $responseText = __("Slide Created", 'revslider'); } else { $responseText = $numSlides . " " . __("Slides Created", 'revslider'); } $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id=new&slider={$sliderID}"); self::ajaxResponseSuccessRedirect($responseText, $urlRedirect); break; case "add_slide_fromslideview": $slideID = $slider->createSlideFromData($data, true); $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}"); $responseText = __("Slide Created, redirecting...", 'revslider'); self::ajaxResponseSuccessRedirect($responseText, $urlRedirect); break; case 'copy_slide_to_slider': $slideID = isset($data['redirect_id']) ? $data['redirect_id'] : -1; if ($slideID === -1) { RevSliderFunctions::throwError(__('Missing redirect ID!', 'revslider')); } $return = $slider->copySlideToSlider($data); if ($return !== true) { RevSliderFunctions::throwError($return); } $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}"); $responseText = __("Slide copied to current Slider, redirecting...", 'revslider'); self::ajaxResponseSuccessRedirect($responseText, $urlRedirect); break; case "update_slide": $slide->updateSlideFromData($data); self::ajaxResponseSuccess(__("Slide updated", 'revslider')); break; case "update_static_slide": $slide->updateStaticSlideFromData($data); self::ajaxResponseSuccess(__("Static Global Layers updated", 'revslider')); break; case "delete_slide": case "delete_slide_stay": $isPost = $slide->deleteSlideFromData($data); if ($isPost) { $message = __("Post deleted", 'revslider'); } else { $message = __("Slide deleted", 'revslider'); } $sliderID = RevSliderFunctions::getVal($data, "sliderID"); if ($action == 'delete_slide_stay') { self::ajaxResponseSuccess($message); } else { self::ajaxResponseSuccessRedirect($message, self::getViewUrl(self::VIEW_SLIDE, "id=new&slider={$sliderID}")); } break; case "duplicate_slide": case "duplicate_slide_stay": $return = $slider->duplicateSlideFromData($data); if ($action == 'duplicate_slide_stay') { self::ajaxResponseSuccess(__("Slide duplicated", 'revslider'), array('id' => $return[1])); } else { self::ajaxResponseSuccessRedirect(__("Slide duplicated", 'revslider'), self::getViewUrl(self::VIEW_SLIDE, "id=new&slider=" . $return[0])); } break; case "copy_move_slide": case "copy_move_slide_stay": $sliderID = $slider->copyMoveSlideFromData($data); if ($action == 'copy_move_slide_stay') { self::ajaxResponseSuccess(__("Success!", 'revslider')); } else { self::ajaxResponseSuccessRedirect(__("Success! Refreshing page...", 'revslider'), self::getViewUrl(self::VIEW_SLIDE, "id=new&slider={$sliderID}")); } break; case "add_slide_to_template": $template = new RevSliderTemplate(); if (!isset($data['slideID']) || intval($data['slideID']) == 0) { RevSliderFunctions::throwError(__('No valid Slide ID given', 'revslider')); exit; } if (!isset($data['title']) || strlen(trim($data['title'])) < 3) { RevSliderFunctions::throwError(__('No valid title given', 'revslider')); exit; } if (!isset($data['settings']) || !isset($data['settings']['width']) || !isset($data['settings']['height'])) { RevSliderFunctions::throwError(__('No valid title given', 'revslider')); exit; } $return = $template->copySlideToTemplates($data['slideID'], $data['title'], $data['settings']); if ($return == false) { RevSliderFunctions::throwError(__('Could not save Slide as Template', 'revslider')); exit; } //get HTML for template section ob_start(); $rs_disable_template_script = true; //disable the script output of template selector file include RS_PLUGIN_PATH . 'admin/views/templates/template-selector.php'; $html = ob_get_contents(); ob_clean(); ob_end_clean(); self::ajaxResponseSuccess(__('Slide added to Templates', 'revslider'), array('HTML' => $html)); exit; break; break; case "get_static_css": $contentCSS = $operations->getStaticCss(); self::ajaxResponseData($contentCSS); break; case "get_dynamic_css": $contentCSS = $operations->getDynamicCss(); self::ajaxResponseData($contentCSS); break; case "insert_captions_css": $arrCaptions = $operations->insertCaptionsContentData($data); if ($arrCaptions !== false) { $db = new RevSliderDB(); $styles = $db->fetch(RevSliderGlobals::$table_css); $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n"); $styles = RevSliderCssParser::compress_css($styles); $custom_css = RevSliderOperations::getStaticCss(); $custom_css = RevSliderCssParser::compress_css($custom_css); $arrCSS = $operations->getCaptionsContentArray(); $arrCssStyles = RevSliderFunctions::jsonEncodeForClientSide($arrCSS); $arrCssStyles = $arrCSS; self::ajaxResponseSuccess(__("CSS saved", 'revslider'), array("arrCaptions" => $arrCaptions, 'compressed_css' => $styles . $custom_css, 'initstyles' => $arrCssStyles)); } RevSliderFunctions::throwError(__('CSS could not be saved', 'revslider')); exit; break; case "update_captions_css": $arrCaptions = $operations->updateCaptionsContentData($data); if ($arrCaptions !== false) { $db = new RevSliderDB(); $styles = $db->fetch(RevSliderGlobals::$table_css); $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n"); $styles = RevSliderCssParser::compress_css($styles); $custom_css = RevSliderOperations::getStaticCss(); $custom_css = RevSliderCssParser::compress_css($custom_css); $arrCSS = $operations->getCaptionsContentArray(); $arrCssStyles = RevSliderFunctions::jsonEncodeForClientSide($arrCSS); $arrCssStyles = $arrCSS; self::ajaxResponseSuccess(__("CSS saved", 'revslider'), array("arrCaptions" => $arrCaptions, 'compressed_css' => $styles . $custom_css, 'initstyles' => $arrCssStyles)); } RevSliderFunctions::throwError(__('CSS could not be saved', 'revslider')); exit; break; case "update_captions_advanced_css": $arrCaptions = $operations->updateAdvancedCssData($data); if ($arrCaptions !== false) { $db = new RevSliderDB(); $styles = $db->fetch(RevSliderGlobals::$table_css); $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n"); $styles = RevSliderCssParser::compress_css($styles); $custom_css = RevSliderOperations::getStaticCss(); $custom_css = RevSliderCssParser::compress_css($custom_css); $arrCSS = $operations->getCaptionsContentArray(); $arrCssStyles = RevSliderFunctions::jsonEncodeForClientSide($arrCSS); $arrCssStyles = $arrCSS; self::ajaxResponseSuccess(__("CSS saved", 'revslider'), array("arrCaptions" => $arrCaptions, 'compressed_css' => $styles . $custom_css, 'initstyles' => $arrCssStyles)); } RevSliderFunctions::throwError(__('CSS could not be saved', 'revslider')); exit; break; case "rename_captions_css": //rename all captions in all sliders with new handle if success $arrCaptions = $operations->renameCaption($data); $db = new RevSliderDB(); $styles = $db->fetch(RevSliderGlobals::$table_css); $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n"); $styles = RevSliderCssParser::compress_css($styles); $custom_css = RevSliderOperations::getStaticCss(); $custom_css = RevSliderCssParser::compress_css($custom_css); $arrCSS = $operations->getCaptionsContentArray(); $arrCssStyles = RevSliderFunctions::jsonEncodeForClientSide($arrCSS); $arrCssStyles = $arrCSS; self::ajaxResponseSuccess(__("Class name renamed", 'revslider'), array("arrCaptions" => $arrCaptions, 'compressed_css' => $styles . $custom_css, 'initstyles' => $arrCssStyles)); break; case "delete_captions_css": $arrCaptions = $operations->deleteCaptionsContentData($data); $db = new RevSliderDB(); $styles = $db->fetch(RevSliderGlobals::$table_css); $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n"); $styles = RevSliderCssParser::compress_css($styles); $custom_css = RevSliderOperations::getStaticCss(); $custom_css = RevSliderCssParser::compress_css($custom_css); $arrCSS = $operations->getCaptionsContentArray(); $arrCssStyles = RevSliderFunctions::jsonEncodeForClientSide($arrCSS); $arrCssStyles = $arrCSS; self::ajaxResponseSuccess(__("Style deleted!", 'revslider'), array("arrCaptions" => $arrCaptions, 'compressed_css' => $styles . $custom_css, 'initstyles' => $arrCssStyles)); break; case "update_static_css": $staticCss = $operations->updateStaticCss($data); $db = new RevSliderDB(); $styles = $db->fetch(RevSliderGlobals::$table_css); $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n"); $styles = RevSliderCssParser::compress_css($styles); $custom_css = RevSliderOperations::getStaticCss(); $custom_css = RevSliderCssParser::compress_css($custom_css); self::ajaxResponseSuccess(__("CSS saved", 'revslider'), array("css" => $staticCss, 'compressed_css' => $styles . $custom_css)); break; case "insert_custom_anim": $arrAnims = $operations->insertCustomAnim($data); //$arrCaptions = self::ajaxResponseSuccess(__("Animation saved", 'revslider'), $arrAnims); //,array("arrCaptions"=>$arrCaptions) break; case "update_custom_anim": $arrAnims = $operations->updateCustomAnim($data); self::ajaxResponseSuccess(__("Animation saved", 'revslider'), $arrAnims); //,array("arrCaptions"=>$arrCaptions) break; case "update_custom_anim_name": $arrAnims = $operations->updateCustomAnimName($data); self::ajaxResponseSuccess(__("Animation saved", 'revslider'), $arrAnims); //,array("arrCaptions"=>$arrCaptions) break; case "delete_custom_anim": $arrAnims = $operations->deleteCustomAnim($data); self::ajaxResponseSuccess(__("Animation deleted", 'revslider'), $arrAnims); //,array("arrCaptions"=>$arrCaptions) break; case "update_slides_order": $slider->updateSlidesOrderFromData($data); self::ajaxResponseSuccess(__("Order updated", 'revslider')); break; case "change_slide_title": $slide->updateTitleByID($data); self::ajaxResponseSuccess(__('Title updated', 'revslider')); break; case "change_slide_image": $slide->updateSlideImageFromData($data); $sliderID = RevSliderFunctions::getVal($data, "slider_id"); self::ajaxResponseSuccessRedirect(__("Slide changed", 'revslider'), self::getViewUrl(self::VIEW_SLIDE, "id=new&slider={$sliderID}")); break; case "preview_slide": $operations->putSlidePreviewByData($data); break; case "preview_slider": $sliderID = RevSliderFunctions::getPostGetVariable("sliderid"); $do_markup = RevSliderFunctions::getPostGetVariable("only_markup"); if ($do_markup == 'true') { $operations->previewOutputMarkup($sliderID); } else { $operations->previewOutput($sliderID); } break; case "toggle_slide_state": $currentState = $slide->toggleSlideStatFromData($data); self::ajaxResponseData(array("state" => $currentState)); break; case "toggle_hero_slide": $currentHero = $slider->setHeroSlide($data); self::ajaxResponseSuccess(__('Slide is now the new active Hero Slide', 'revslider')); break; case "slide_lang_operation": $responseData = $slide->doSlideLangOperation($data); self::ajaxResponseData($responseData); break; case "update_general_settings": $operations->updateGeneralSettings($data); self::ajaxResponseSuccess(__("General settings updated", 'revslider')); break; case "update_posts_sortby": $slider->updatePostsSortbyFromData($data); self::ajaxResponseSuccess(__("Sortby updated", 'revslider')); break; case "replace_image_urls": $slider->replaceImageUrlsFromData($data); self::ajaxResponseSuccess(__("Image urls replaced", 'revslider')); break; case "reset_slide_settings": $slider->resetSlideSettings($data); self::ajaxResponseSuccess(__("Settings in all Slides changed", 'revslider')); break; case "activate_purchase_code": $result = false; if (!empty($data['code'])) { $result = $operations->checkPurchaseVerification($data); } else { RevSliderFunctions::throwError(__('The API key, the Purchase Code and the Username need to be set!', 'revslider')); exit; } if ($result) { self::ajaxResponseSuccessRedirect(__("Purchase Code Successfully Activated", 'revslider'), self::getViewUrl(self::VIEW_SLIDERS)); } else { RevSliderFunctions::throwError(__('Purchase Code is invalid', 'revslider')); } break; case "deactivate_purchase_code": $result = $operations->doPurchaseDeactivation($data); if ($result) { self::ajaxResponseSuccessRedirect(__("Successfully removed validation", 'revslider'), self::getViewUrl(self::VIEW_SLIDERS)); } else { RevSliderFunctions::throwError(__('Could not remove Validation!', 'revslider')); } break; case 'dismiss_notice': update_option('revslider-valid-notice', 'false'); self::ajaxResponseSuccess(__(".", 'revslider')); break; case 'dismiss_dynamic_notice': $notices_discarded = get_option('revslider-notices-dc', array()); $notices_discarded[] = esc_attr(trim($data['id'])); update_option('revslider-notices-dc', $notices_discarded); self::ajaxResponseSuccess(__(".", 'revslider')); break; case 'toggle_favorite': if (isset($data['id']) && intval($data['id']) > 0) { $return = self::toggle_favorite_by_id($data['id']); if ($return === true) { self::ajaxResponseSuccess(__('Setting Changed!', 'revslider')); } else { $error = $return; } } else { $error = __('No ID given', 'revslider'); } self::ajaxResponseError($error); break; case "subscribe_to_newsletter": if (isset($data['email']) && !empty($data['email'])) { $return = ThemePunch_Newsletter::subscribe($data['email']); if ($return !== false) { if (!isset($return['status']) || $return['status'] === 'error') { $error = isset($return['message']) && !empty($return['message']) ? $return['message'] : __('Invalid Email', 'revslider'); self::ajaxResponseError($error); } else { self::ajaxResponseSuccess(__("Success! Please check your Emails to finish the subscription", 'revslider'), $return); } } else { self::ajaxResponseError(__('Invalid Email/Could not connect to the Newsletter server', 'revslider')); } } else { self::ajaxResponseError(__('No Email given', 'revslider')); } break; case "unsubscribe_to_newsletter": if (isset($data['email']) && !empty($data['email'])) { $return = ThemePunch_Newsletter::unsubscribe($data['email']); if ($return !== false) { if (!isset($return['status']) || $return['status'] === 'error') { $error = isset($return['message']) && !empty($return['message']) ? $return['message'] : __('Invalid Email', 'revslider'); self::ajaxResponseError($error); } else { self::ajaxResponseSuccess(__("Success! Please check your Emails to finish the process", 'revslider'), $return); } } else { self::ajaxResponseError(__('Invalid Email/Could not connect to the Newsletter server', 'revslider')); } } else { self::ajaxResponseError(__('No Email given', 'revslider')); } break; case 'change_specific_navigation': $nav = new RevSliderNavigation(); $found = false; $navigations = $nav->get_all_navigations(); foreach ($navigations as $navig) { if ($data['id'] == $navig['id']) { $found = true; break; } } if ($found) { $nav->create_update_navigation($data, $data['id']); } else { $nav->create_update_navigation($data); } self::ajaxResponseSuccess(__('Navigation saved/updated', 'revslider'), array('navs' => $nav->get_all_navigations())); break; case 'change_navigations': $nav = new RevSliderNavigation(); $nav->create_update_full_navigation($data); self::ajaxResponseSuccess(__('Navigations updated', 'revslider'), array('navs' => $nav->get_all_navigations())); break; case 'delete_navigation': $nav = new RevSliderNavigation(); if (isset($data) && intval($data) > 0) { $return = $nav->delete_navigation($data); if ($return !== true) { self::ajaxResponseError($return); } else { self::ajaxResponseSuccess(__('Navigation deleted', 'revslider'), array('navs' => $nav->get_all_navigations())); } } self::ajaxResponseError(__('Wrong ID given', 'revslider')); break; case "get_facebook_photosets": if (!empty($data['url'])) { $facebook = new RevSliderFacebook(); $return = $facebook->get_photo_set_photos_options($data['url'], $data['album'], $data['app_id'], $data['app_secret']); if (!empty($return)) { self::ajaxResponseSuccess(__('Successfully fetched Facebook albums', 'revslider'), array('html' => implode(' ', $return))); } else { $error = __('Could not fetch Facebook albums', 'revslider'); self::ajaxResponseError($error); } } else { self::ajaxResponseSuccess(__('Cleared Albums', 'revslider'), array('html' => implode(' ', $return))); } break; case "get_flickr_photosets": if (!empty($data['url']) && !empty($data['key'])) { $flickr = new RevSliderFlickr($data['key']); $user_id = $flickr->get_user_from_url($data['url']); $return = $flickr->get_photo_sets($user_id, $data['count'], $data['set']); if (!empty($return)) { self::ajaxResponseSuccess(__('Successfully fetched flickr photosets', 'revslider'), array("data" => array('html' => implode(' ', $return)))); } else { $error = __('Could not fetch flickr photosets', 'revslider'); self::ajaxResponseError($error); } } else { if (empty($data['url']) && empty($data['key'])) { self::ajaxResponseSuccess(__('Cleared Photosets', 'revslider'), array('html' => implode(' ', $return))); } elseif (empty($data['url'])) { $error = __('No User URL - Could not fetch flickr photosets', 'revslider'); self::ajaxResponseError($error); } else { $error = __('No API KEY - Could not fetch flickr photosets', 'revslider'); self::ajaxResponseError($error); } } break; case "get_youtube_playlists": if (!empty($data['id'])) { $youtube = new RevSliderYoutube(trim($data['api']), trim($data['id'])); $return = $youtube->get_playlist_options($data['playlist']); self::ajaxResponseSuccess(__('Successfully fetched YouTube playlists', 'revslider'), array("data" => array('html' => implode(' ', $return)))); } else { $error = __('Could not fetch YouTube playlists', 'revslider'); self::ajaxResponseError($error); } break; case 'rs_get_store_information': global $wp_version; $code = get_option('revslider-code', ''); $shop_version = RevSliderTemplate::SHOP_VERSION; $validated = get_option('revslider-valid', 'false'); if ($validated == 'false') { $api_key = ''; $username = ''; $code = ''; } $rattr = array('code' => urlencode($code), 'product' => urlencode('revslider'), 'shop_version' => urlencode($shop_version), 'version' => urlencode(RevSliderGlobals::SLIDER_REVISION)); $request = wp_remote_post('http://templates.themepunch.tools/revslider/store.php', array('user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'), 'body' => $rattr)); $response = ''; if (!is_wp_error($request)) { $response = json_decode(@$request['body'], true); } self::ajaxResponseData(array("data" => $response)); break; default: self::ajaxResponseError("wrong ajax action: {$action}"); break; } } catch (Exception $e) { $message = $e->getMessage(); if ($action == "preview_slide" || $action == "preview_slider") { echo $message; exit; } self::ajaxResponseError($message); } //it's an ajax action, so exit self::ajaxResponseError("No response output on {$action} action. please check with the developer."); exit; }
<?php if (!defined('ABSPATH')) { exit; } $tmpl = new RevSliderTemplate(); $templates = $tmpl->getTemplateSlides(); $tp_templates = $tmpl->getThemePunchTemplateSlides(); $tp_template_slider = $tmpl->getThemePunchTemplateSliders(); $tmp_slider = new RevSlider(); $all_slider = $tmp_slider->getArrSliders(); ?> <!-- THE TEMPLATE AREA --> <div id="template_area"> <div id="template_header_part"> <h2><span class="revlogo-mini" style="margin-right:15px;"></span><?php _e('Slider Template Library', REVSLIDER_TEXTDOMAIN); ?> </h2> <div id="close-template"></div> <div class="revolution-template-switcher"> <span data-showgroup="revolution-basic-templates" class="revolution-templatebutton selected"><?php _e('Revolution Base', REVSLIDER_TEXTDOMAIN); ?> </span> <span data-showgroup="revolution-all-slides-templates" class="revolution-templatebutton"><?php _e('All Slides', REVSLIDER_TEXTDOMAIN); ?> </span>
/** * * 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); }
<?php if (!defined('ABSPATH')) { exit; } $tmpl = new RevSliderTemplate(); $tp_template_slider = $tmpl->getThemePunchTemplateSliders(); $author_template_slider = $tmpl->getDefaultTemplateSliders(); $tmp_slider = new RevSlider(); $all_slider = $tmp_slider->getArrSliders(); ?> <!-- THE TEMPLATE AREA --> <div id="template_area"> <div id="template_header_part"> <h2><span class="revlogo-mini" style="margin-right:15px;"></span><?php _e('Slider Template Library', REVSLIDER_TEXTDOMAIN); ?> </h2> <div id="close-template"></div> <div class="revolution-template-switcher"> <span data-showgroup="revolution-basic-templates" class="revolution-templatebutton selected"><?php _e('Revolution Base', REVSLIDER_TEXTDOMAIN); ?> </span> <span data-showgroup="revolution-premium-templates" class="revolution-templatebutton premium-templatebutton"><i class="eg-icon-basket"></i><?php _e('Premium Sliders', REVSLIDER_TEXTDOMAIN); ?> </span> <?php
/** * delete slider from input data * @since: 5.2.5 */ public function duplicateSliderPackageFromData($data) { $tmpl = new RevSliderTemplate(); $slider_uid = RevSliderFunctions::getVal($data, "slideruid"); $uids = $tmpl->get_package_uids($slider_uid); foreach ($uids as $sid => $uid) { if ($sid < 0) { //one or more still needs to be downloaded... return __('Please install Package first to use this feature', 'revslider'); } } foreach ($uids as $sliderID => $uid) { $slider = new RevSlider(); $slider->initByID($sliderID); $slider->duplicateSlider(RevSliderFunctions::getVal($data, "title"), true); } return true; }
<?php if (!defined('ABSPATH')) { exit; } $tmpl = new RevSliderTemplate(); $tp_template_slider = $tmpl->getThemePunchTemplateSliders(); $author_template_slider = $tmpl->getDefaultTemplateSliders(); $tmp_slider = new RevSlider(); $all_slider = $tmp_slider->getArrSliders(); ?> <!-- THE TEMPLATE AREA --> <div id="template_area"> <div id="template_header_part"> <h2><span class="revlogo-mini" style="margin-right:15px;"></span><?php _e('Slider Template Library', 'revslider'); ?> </h2> <div id="close-template"></div> <div class="revolution-template-switcher"> <span style="display:table-cell;vertical-align:top"> <?php if (!empty($author_template_slider) && is_array($author_template_slider)) { foreach ($author_template_slider as $name => $v) { ?> <span data-type="temp_<?php echo sanitize_title($name); ?> " class="template_filter_button"><?php