Beispiel #1
0
 /**
  *
  * 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;
 }