* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2024 ThemePunch
if(!defined('ABSPATH')) exit();
class RevSliderPluginUpdate extends RevSliderFunctions {
public $upgrade_layer_type = false; //holds the type of the layer, for the _compare function to
public $add_to_transition_speed = array('slotslide-horizontal' => 200, 'slotslide-vertical' => 200, 'slotzoom-horizontal' => 400, 'slotfade-horizontal' => 1000, 'slotfade-vertical' => 1000, 'fade' => 300, 'crossfade' => 300, 'fadethroughdark' => 300, 'fadethroughlight' => 300, 'fadethroughtransparent' => 300, 'papercut' => 600, '3dcurtain-horizontal' => 100, '3dcurtain-vertical' => 100, 'cubic' => 600, 'cube' => 600, 'flyin' => 600, 'turnoff' => 500, 'incube' => 200, 'cubic-horizontal' => 500, 'cube-horizontal' => 500, 'incube-horizontal' => 500, 'turnoff-vertical' => 200, 'grayscale' => 300, 'grayscalecross' => 300, 'brightness' => 300, 'brightnesscross' => 300, 'blurlight' => 300, 'blurlightcross' => 300, 'blurstrong' => 300, 'blurstrongcross' => 300);
public $_respsizesold = array('desktop', 'notebook', 'tablet', 'mobile');
public $_respsizes = array('d', 'n', 't', 'm');
public $_corners = array('cornerLeft' => array('nothing' => 'none', 'curved' => 'rs-fcr', 'reverced' => 'rs-fcrt'), 'cornerRight' => array('nothing' => 'none', 'curved' => 'rs-bcr', 'reverced' => 'rs-bcrt'));
public $_metas = array('home_url', 'current_page_link', 'link', 'title', 'excerpt', 'alias', 'content', 'link', 'date', 'date_modified', 'author_name', 'author_posts', 'author_website', 'num_comments', 'catlist', 'catlist_raw', 'taglist', 'id', 'wc_full_price', 'wc_price', 'wc_price_no_cur', 'wc_stock', 'wc_rating', 'wc_star_rating', 'wc_categories', 'wc_add_to_cart', 'wc_add_to_cart_button', 'wc_sku', 'wc_stock_quantity', 'wc_rating_count', 'wc_review_count', 'wc_tags', 'link', 'title', 'excerpt', 'description', 'alias', 'content', 'link', 'date_published', 'date_modified', 'author_name', 'num_comments', 'catlist', 'catlist_raw', 'taglist', 'likes', 'retweet_count', 'favorite_count', 'views', 't_days', 't_hours', 't_minutes', 't_seconds', 'event_start_date', 'event_end_date', 'event_start_tim', 'event_end_time', 'event_event_id', 'event_location_name', 'event_location_slug', 'event_location_address', 'event_location_town', 'event_location_state', 'event_location_postcode', 'event_location_region', 'event_location_country', 'param1', 'param2', 'param3', 'param4', 'param5', 'param6', 'param7', 'param8', 'param9', 'param10', '/%meta:\w+%/', '/%content:\w+[\:]\w+%/', '/%author_avatar:\w+%/', '/%image_url_\w+%/', '/%image_\w+%/', '/%featured_image_url_\w+%/', '/%featured_image_\w+%/');
public $navtypes = array('arrows', 'thumbs', 'bullets', 'tabs', 'scrubber');
public $blank_slide = false; //holds a blank slide to remove unneeded values in slides as a compare
public $blank_layer = array(); //holds a blank layer to remove unneeded values in layers as a compare, as more than one type of layer exists, it fills with keys as the type
public $current_parent = false; //holds the parent key for the compare function, which allows for deeper checks to remove/not remove keys depending on where in the tree we are
public $css_navigations = array(); //holds css navigations
public $googlefonts = array(); //holds googlefonts
public $upd_animations = array(); //holds animations
* for update to 6.0 added.
* These 4 are set by each Slider and depending on their setting.
* the layer effects are set to true/false
public $on_layers = false;
public $on_static_layers = false;
public $on_parallax_layers = false;
public $on_parallax_static_layers = false;
public $static_slide = false;
public $parallax_slider = false;
* it holds all layers that are triggered in an action
public $slide_action_map = array();
* holds variables needed for certain updates
* it holds all easing names that need to be replaced whereever easings are used
'ease_replace_adv' => array('Power0' => 'power0', 'Power1' => 'power1', 'Power2' => 'power2', 'Power3' => 'power3', 'Power4' => 'power4', 'Back' => 'back', 'Bounce' => 'bounce', 'Circ' => 'circ', 'Elastic' => 'elastic', 'Expo' => 'expo', 'Sine' => 'sine'),
'ease_adv_modifier' => array('easeIn' => 'in', 'easeOut' => 'out', 'easeInOut' => 'inOut'),
'ease_adv_from' => array('Linear.easeNone', 'SlowMo.ease'),
'ease_adv_to' => array('none', 'slow')
* it holds all file path that need to be changed inside the sliders
'\/public\/assets\/assets\/dummy.png',
'\/public\/assets\/assets\/coloredbg-old.png',
'\/public\/assets\/assets\/coloredbg.png',
'\/public\/assets\/assets\/gridtile_3x3_white.png',
'\/public\/assets\/assets\/gridtile_3x3.png',
'\/public\/assets\/assets\/gridtile_white.png',
'\/public\/assets\/assets\/gridtile.png',
'\/public\/assets\/assets\/loader.gif',
'\/public\/assets\/assets\/transparent.png',
'\/public\/assets\/assets\/svg/',
'\/public\/assets\/assets\/sources/'
'\/sr6\/assets\/assets\/dummy.png',
'\/sr6\/assets\/assets\/coloredbg-old.png',
'\/sr6\/assets\/assets\/coloredbg.png',
'\/sr6\/assets\/assets\/gridtile_3x3_white.png',
'\/sr6\/assets\/assets\/gridtile_3x3.png',
'\/sr6\/assets\/assets\/gridtile_white.png',
'\/sr6\/assets\/assets\/gridtile.png',
'\/sr6\/assets\/assets\/loader.gif',
'\/sr6\/assets\/assets\/transparent.png',
'\/public\/assets\/svg\/',
'\/public\/assets\/sources\/'
* holds wheter we are importing an Slider or if we are updating existing Sliders
* this is needed for update routines that should either be done on one of the two Slider types
* like in the introduction of it in 6.5.30, where we changed the default of the adpr only for new Sliders!
public function __construct(){
$this->revision = get_option('revslider_update_version', '6.0.0');
foreach($this->update['620']['ease_replace_adv'] as $a_f => $a_t){
foreach($this->update['620']['ease_adv_modifier'] as $a_m_f => $a_m_t){
$this->update['620']['ease_adv_from'][] = $a_f.'.'.$a_m_f;
$this->update['620']['ease_adv_to'][] = $a_t.'.'.$a_m_t;
public function init_animations(){
if(empty($this->upd_animations)){
$this->upd_animations = $this->get_layer_animations();
public function init_googlefonts(){
if(empty($this->googlefonts)){
//direct inclusion for direct searching of google font
include(RS_PLUGIN_PATH.'includes/googlefonts.php');
$this->googlefonts = $googlefonts;
* return version of installation
public function get_version(){
$real_version = get_option('revslider_update_version', 1.0);
if(in_array($real_version, array('6.10.0', '6.10.1'), true)) $real_version = '6.6.20'; //this were dev versions
* set version of installation
public function set_version($set_to){
update_option('revslider_update_version', $set_to);
public function set_import($import){
* check for updates and proceed if needed
public static function do_update_checks(){
$upd = new RevSliderPluginUpdate();
$version = $upd->get_version();
if(version_compare($version, 5.0, '<')){
$upd->update_css_styles(); //update styles to the new 5.0 way
$upd->add_v5_styles(); //add the version 5 styles that are new!
$upd->check_settings_table(); //remove the usage of the settings table
$upd->add_animation_settings_to_layer(); //set missing animation fields to the slides layers
$upd->add_style_settings_to_layer(); //set missing styling fields to the slides layers
$upd->change_settings_on_layers(); //change settings on layers, for example, add the new structure of actions
$upd->add_general_settings(); //set general settings
$upd->translate_navigation_to_v5(); //set the navigation from v4.** to v5
$upd->remove_static_slides(); //remove static slides if the slider was v4 and had static slides which were not enabled
$upd->set_version($version);
if(version_compare($version, '5.0.7', '<')){
$upd->change_general_settings_5_0_7();
$upd->set_version($version);
if(version_compare($version, '5.1.1', '<')){
$upd->change_slide_settings_5_1_1();
$upd->set_version($version);
if(version_compare($version, '5.2.5.5', '<')){
$upd->change_layers_svg_5_2_5_5();
$upd->set_version($version);
//with 6.0, the slider, slide, layer changes are done at a background process if possible, not automatically
//only push global changes in here outside of slider, slides and layers
if(version_compare($version, '6.0', '<')){
$upd->change_global_settings_to_6_0();
$upd->change_navigation_settings_to_6_0();
$upd->change_animations_settings_to_6_0();
// new addition for global addons
$upd->change_global_addon_settings_to_6_0();
$upd->set_version($version);
//with 6.1.4, we check the animations again for custom animations
if(version_compare($version, '6.1.4', '<')){
$upd->change_animations_settings_to_6_0();
$upd->set_version($version);
//with 6.1.6, we only set the version and upgrade_slider_to_latest() will do the rest
if(version_compare($version, '6.1.6', '<')){
$upd->set_version($version);
//with 6.2.0, we check the animations handles again and change them to a new format
if(version_compare($version, '6.2.0', '<')){
$upd->change_animations_settings_to_6_2_0();
$upd->change_global_settings_to_6_2_0();
$upd->set_version($version);
//add this so that sliders will be updated if under 6.4.0
if(version_compare($version, '6.4.0', '<')){
$upd->set_version('6.4.0');
//add this so that sliders will be updated if under 6.4.10
if(version_compare($version, '6.4.10', '<')){
$upd->change_navigation_settings_to_6_4_10();
$upd->set_version('6.4.10');
if(version_compare($version, '6.5.12', '<')){
//$upd->set_version('6.5.12');
if(version_compare($version, '6.5.20', '<')){
$upd->set_version('6.5.20');
if(version_compare($version, '6.5.26', '<')){
$upd->set_version('6.5.26');
if(version_compare($version, '6.6.0', '<')){
$upd->set_version('6.6.0');
if(version_compare($version, '6.6.10', '<')){
//remove templates from the database
$upd->remove_template_sliders();
$upd->set_version('6.6.10');
if(version_compare($version, '6.6.20', '<')){
$upd->set_version('6.6.20');
if(version_compare($version, '6.6.21', '<')){
$upd->set_version('6.6.21');
if(version_compare($version, '6.7.24', '<')){
$upd->update_post_slide_template_v7();
$upd->set_version('6.7.24');
* check to convert the given Slider to latest versions
public function upgrade_slider_to_latest($slider){
$version = $slider->get_setting('version', '1.0.0');
if(in_array($version, array('6.10.0', '6.10.1'), true)) $version = '6.6.20'; //this were dev versions
if(version_compare($version, '6.0.0', '<')){
//$this->update_css_styles(); //set to version 5
$this->add_animation_settings_to_layer($slider); //set to version 5
$this->add_style_settings_to_layer($slider); //set to version 5
$this->change_settings_on_layers($slider); //set to version 5
$this->add_general_settings($slider); //set to version 5
$this->change_general_settings_5_0_7($slider); //set to version 5.0.7
$this->change_layers_svg_5_2_5_5($slider); //set to version 5.2.5.5
$this->change_animations_settings_to_6_0(); //check if new navigations are added through import
$this->upgrade_slider_to_6_0($slider);
if(version_compare($version, '6.1.4', '<')){
$this->upgrade_slider_to_6_1_4($slider);
if(version_compare($version, '6.1.6', '<')){
$this->upgrade_slider_to_6_1_6($slider);
if(version_compare($version, '6.2.0', '<')){
$this->change_animations_settings_to_6_2_0(); //check if new navigations are added through import
$this->upgrade_slider_to_6_2_0($slider);
if(version_compare($version, '6.4.0', '<')){
$this->upgrade_slider_to_6_4_0($slider);
if(version_compare($version, '6.4.10', '<')){
$this->change_navigation_settings_to_6_4_10();
$this->upgrade_slider_to_6_4_10($slider);
if(version_compare($version, '6.5.12', '<')){
$this->upgrade_slider_to_6_5_12($slider);
if($this->import === false){
if(version_compare($version, '6.5.26', '<')){
$this->upgrade_slider_to_6_5_26($slider);
if(version_compare($version, '6.6.0', '<')){
$this->upgrade_slider_to_6_6_0($slider);
if(version_compare($version, '6.6.10', '<')){
$this->upgrade_slider_to_6_6_10($slider);
if(version_compare($version, '6.6.20', '<')){
$this->upgrade_slider_to_6_6_20($slider);
if(version_compare($version, '6.7.21', '<')){
$this->upgrade_slider_to_6_7_21($slider);
if(version_compare($version, '6.7.24', '<')){
$this->upgrade_slider_to_6_7_24($slider);
* get the CSS Navigation advanced styles, needed for 6.0
public function get_css_navigations(){
if(empty($this->css_navigations)){
$css_parser = RevSliderGlobals::instance()->get('RevSliderCssParser');
$this->css_navigations = $css_parser->get_database_classes(true);
return $this->css_navigations;
* check if there are still Slider below latest version, if yes then add JavaScript to the header
public function slider_need_update_checks(){
$finished = get_option('revslider_update_revision_current', '1.0.0');
if(in_array($finished, array('6.10.0', '6.10.1'), true)) $finished = '6.6.20'; //this were dev versions
return (version_compare($finished, $this->revision, '<')) ? true : false;
* get the next slider that is not on the latest version and update it to the latest
* @since: 6.2.0: added template sliders to the update routine
public function upgrade_next_slider(){
$slr = new RevSliderSlider();
$sliders = $slr->get_sliders();
foreach($sliders as $slider){
$version = $this->get_val($slider, array('settings', 'version'));
if(in_array($version, array('6.10.0', '6.10.1'), true)) $version = '6.6.20'; //this were dev versions
if(version_compare($version, $this->revision, '<')){
$this->upgrade_slider_to_latest($slider);
return array('status' => 'next');
//we can only get to this point, after all Sliders have been updated to the latest revision
update_option('revslider_update_revision_current', $this->revision);
return array('status' => 'finished');
* check to convert the given Slider to latest versions
public function upgrade_slider_to_6_0($slider){
ini_set('max_execution_time', 300);
$upd = new RevSliderPluginUpdate();
$upd->change_navigation_slider_to_6_0($slider);
$upd->change_slider_settings_to_6_0($slider); //set to version 6.0
$upd->change_slide_settings_to_6_0($slider); //set to version 6.0
$upd->change_layer_settings_to_6_0($slider); //set to version 6.0
$upd->remove_unneeded_slider_settings($slider);
* check to convert the given Slider to latest versions
* reverse the carousel.scaleDown value. If it was 85, change it to 15 and vice versa
public function upgrade_slider_to_6_1_4($sliders = false){
$sr = new RevSliderSlider();
$sliders = ($sliders === false) ? $sr->get_sliders() : array($sliders); //do it on all Sliders if false
if(!empty($sliders) && is_array($sliders)){
foreach($sliders as $slider){
$carousel = $slider->get_param('carousel', array());
$scale_down = $this->get_val($carousel, 'scaleDown');
if($scale_down !== false){
$carousel['scaleDown'] = 100 - intval($scale_down);
$slider->update_params(array('carousel' => $carousel));
$slider->update_settings(array('version' => '6.1.4'));
* check to convert the given Slider to latest versions
* check in the slide transitions, if we have a transition with a ","
* if this is the case, split it up
public function upgrade_slider_to_6_1_6($sliders = false){
$sr = new RevSliderSlider();
$sl = new RevSliderSlide();
$sliders = ($sliders === false) ? $sr->get_sliders() : array($sliders); //do it on all Sliders if false
if(!empty($sliders) && is_array($sliders)){
foreach($sliders as $slider){
$slides = $slider->get_slides(false, true);
$static_id = $sl->get_static_slide_id($slider->get_id());
if($static_id !== false){
$msl = new RevSliderSlide();
if(strpos($static_id, 'static_') === false){
$static_id = 'static_'. $static_id; //$slider->get_id();
$msl->init_by_id($static_id);
if($msl->get_id() !== ''){
$slides = array_merge($slides, array($msl));
if(!empty($slides) && is_array($slides)){
foreach($slides as $slide){
$settings = $slide->get_settings();
if(version_compare($this->get_val($settings, 'version', '1.0.0'), '6.1.6', '<')){
$params = $slide->get_params();
$transitions = $this->get_val($params, array('timeline', 'transition'), array());
$new_transitions = array();
if(!empty($transitions) && is_array($transitions)){
foreach($transitions as $t => $v){
if(strpos($v, ',') !== false){
foreach($_v as $k => $__v){
$new_transitions[] = $__v;
$this->set_val($params, array('timeline', 'transition'), $new_transitions);
$slide->set_params($params);