* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2024 ThemePunch
if(!defined('ABSPATH')) exit();
const CACHE_GROUP = 'revslider';
const CACHE_NS_KEY = 'revslider_namespace_key';
* wp cache does not support group delete
* this var hold the num to generate unique keys
* when data changed - key increased and invalidate old data
protected $_cache_ns_key;
* @var array hold revslider tables names
protected $_rs_tables_pattern;
public function __construct()
$this->_rs_tables = RevSliderGlobals::instance()->get_rs_tables();
$this->_rs_tables_pattern = "/^\s*(insert|update|replace|delete).+(".implode('|', $this->_rs_tables).")/i";
$this->_cache_ns_key = wp_cache_get(self::CACHE_NS_KEY, self::CACHE_GROUP);
if (false === $this->_cache_ns_key) {
$this->_cache_ns_key = 1;
wp_cache_set(self::CACHE_NS_KEY, $this->_cache_ns_key, self::CACHE_GROUP);
$query_filter = RevSliderGlobals::instance()->get('rs_data_query_fiter');
add_filter('query', array($this, 'add_query_fiter'), 10, 1);
RevSliderGlobals::instance()->add('rs_data_query_fiter', true);
* invalidate group cache if we modify rs data
public function add_query_fiter($sql)
if (preg_match($this->_rs_tables_pattern, $sql)) {
$this->invalidate_group_cache();
* invalidate group keys by increase namespace key
public function invalidate_group_cache()
$this->_cache_ns_key += 1;
wp_cache_set(self::CACHE_NS_KEY, $this->_cache_ns_key, self::CACHE_GROUP);
* @param string $fname cache key name ( usually function name )
* @param mixed $data additional cache key data ( usually functions parameters )
public function get_wp_cache_key($fname, $data){
return sprintf('%s_%s_%s_%s', get_class($this), $fname, $this->_cache_ns_key, md5(serialize($data)));
* try to load cached result
public function get_wp_cache($method, $args = array())
if (!is_array($args)) $args = array($args);
//disable cache for admin
if (is_admin()) return call_user_func_array(array($this, $method), $args);
$cache_key = $this->get_wp_cache_key($method, $args);
$data = wp_cache_get($cache_key, self::CACHE_GROUP);
$data = call_user_func_array(array($this, $method), $args);
wp_cache_set($cache_key, $data, self::CACHE_GROUP);
public function delete_wp_cache($method, $args = array())
if (!is_array($args)) $args = array($args);
$cache_key = $this->get_wp_cache_key($method, $args);
wp_cache_delete($cache_key, self::CACHE_GROUP);
public function flush_wp_cache()
* get cache attempt of _get_font_familys
public function get_font_familys(){
return $this->get_wp_cache('_get_font_familys');
* get all font family types
* before: RevSliderOperations::getArrFontFamilys()
protected function _get_font_familys(){
$gs = $this->get_global_settings();
$cfl = $this->get_val($gs, 'customFontList', array());
if(!empty($cfl) && is_array($cfl)){
'version' => __('Custom Fonts', 'revslider'),
'url' => $this->get_val($_cfl, 'url'),
'frontend' => $this->_truefalse($this->get_val($_cfl, 'frontend', false)),
'backend' => $this->_truefalse($this->get_val($_cfl, 'backend', true)),
'label' => $this->get_val($_cfl, 'family'),
'variants' => explode(',', $this->get_val($_cfl, 'weights')),
$fonts[] = array('type' => 'websafe', 'version' => __('Loaded Google Fonts', 'revslider'), 'label' => 'Dont Show Me');
$fonts[] = array('type' => 'websafe', 'version' => __('Serif Fonts', 'revslider'), 'label' => 'Georgia, serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Serif Fonts', 'revslider'), 'label' => '\'Palatino Linotype\', \'Book Antiqua\', Palatino, serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Serif Fonts', 'revslider'), 'label' => '\'Times New Roman\', Times, serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Arial, Helvetica, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '\'Arial Black\', Gadget, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '\'Comic Sans MS\', cursive, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Impact, Charcoal, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Tahoma, Geneva, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => '\'Trebuchet MS\', Helvetica, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Sans-Serif Fonts', 'revslider'), 'label' => 'Verdana, Geneva, sans-serif');
$fonts[] = array('type' => 'websafe', 'version' => __('Monospace Fonts', 'revslider'), 'label' => '\'Courier New\', Courier, monospace');
$fonts[] = array('type' => 'websafe', 'version' => __('Monospace Fonts', 'revslider'), 'label' => '\'Lucida Console\', Monaco, monospace');
//push all variants to the websafe fonts
foreach($fonts as $f => $font){
if(!empty($cfl) && is_array($cfl) && $font['type'] === 'custom') continue; //already manually added before on these
$font[$f]['variants'] = array('100', '100italic', '200', '200italic', '300', '300italic', '400', '400italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic');
include(RS_PLUGIN_PATH . 'includes/googlefonts.php');
foreach($googlefonts as $f => $val){
$fonts[] = array('type' => 'googlefont', 'version' => __('Google Fonts', 'revslider'), 'label' => $f, 'variants' => $val['variants'], 'subsets' => $val['subsets'], 'category' => $val['category']);
return apply_filters('revslider_data_get_font_familys', apply_filters('revslider_operations_getArrFontFamilys', $fonts));
* @before: RevSliderOperations::getArrAnimations();
public function get_animations(){
return $this->get_custom_animations_full_pre('in');
* get "end" animations array
* @before: RevSliderOperations::getArrEndAnimations();
public function get_end_animations(){
return $this->get_custom_animations_full_pre('out');
public function get_loop_animations(){
return $this->get_custom_animations_full_pre('loop');
* get the version 5 animations only, if available
public function get_animations_v5(){
$this->fill_animations();
foreach($SR_GLOBALS['animations'] as $value){
$type = $this->get_val($value, array('params', 'type'), '');
if(!in_array($type, array('customout', 'customin'))) continue;
$settings = $this->get_val($value, 'settings', '');
$type = $this->get_val($value, 'type', '');
if($type == '' && $settings == ''){
$temp[$value['id']] = $value;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
foreach ($sort as $k => $v){
* @before: RevSliderOperations::getCustomAnimationsFullPre()
public function get_custom_animations_full_pre($pre = 'in'){
$this->fill_animations();
foreach($SR_GLOBALS['animations'] as $value){
$settings = $this->get_val($value, 'settings', '');
$type = $this->get_val($value, 'type', '');
if($type == '' && $settings == '' || $type == $pre){
$temp[$value['id']] = $value;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
if($settings == 'in' && $pre == 'in' || $settings == 'out' && $pre == 'out' || $settings == 'loop' && $pre == 'loop'){
$temp[$value['id']] = $value['params'];
$temp[$value['id']]['settings'] = $settings;
$temp[$value['id']]['id'] = $value['id'];
$sort[$value['id']] = $value['handle'];
foreach($sort as $k => $v){
* Fetch all Custom Animations only one time
* @before: RevSliderOperations::fillAnimations();
public function fill_animations(){
if(empty($SR_GLOBALS['animations'])){
$result = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . RevSliderFront::TABLE_LAYER_ANIMATIONS, ARRAY_A);
$SR_GLOBALS['animations'] = (!empty($result)) ? $result : array();
if(!empty($SR_GLOBALS['animations'])){
foreach($SR_GLOBALS['animations'] as $ak => $av){
$SR_GLOBALS['animations'][$ak]['params'] = json_decode(str_replace("'", '"', $av['params']), true);
if(!empty($SR_GLOBALS['animations'])){
array_walk_recursive($SR_GLOBALS['animations'], array('RevSliderData', 'force_to_boolean'));
* make sure that all false and true are really boolean
public static function force_to_boolean(&$a, $b){
$a = ($a === 'false') ? false : $a;
$a = ($a === 'true') ? true : $a;
$b = ($b === 'false') ? false : $b;
$b = ($b === 'true') ? true : $b;
* get contents of the css table as an array
* before: RevSliderOperations::getCaptionsContentArray();
public function get_captions_array($handle = false){
$css = RevSliderGlobals::instance()->get('RevSliderCssParser');
return $css->db_array_to_array($this->css, $handle);
* Fetch all Custom CSS only one time
* before: RevSliderOperations::fillCSS();
public function fill_css(){
$css_data = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . RevSliderFront::TABLE_CSS, ARRAY_A);
$this->css = (!empty($css_data)) ? $css_data : array();
* Get all images sizes + custom added sizes
* @before: RevSliderBase::get_all_image_sizes($type);
public function get_all_image_sizes($type = 'gallery'){
'original' => __('Original', 'revslider'),
'large' => __('Large', 'revslider'),
'large-square' => __('Large Square', 'revslider'),
'medium' => __('Medium', 'revslider'),
'medium-800' => __('Medium 800', 'revslider'),
'medium-640' => __('Medium 640', 'revslider'),
'small' => __('Small', 'revslider'),
'small-320' => __('Small 320', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'square' => __('Square', 'revslider'),
'standard_resolution' => __('Standard Resolution', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'low_resolution' => __('Low Resolution', 'revslider'),
'original_size' => __('Original Size', 'revslider'),
'large' => __('Large Size', 'revslider'),
'full' => __('Original Size', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'high' => __('High', 'revslider'),
'medium' => __('Medium', 'revslider'),
'default' => __('Default', 'revslider'),
'standard' => __('Standard', 'revslider'),
'maxres' => __('Max. Res.', 'revslider'),
'thumbnail_large' => __('Large', 'revslider'),
'thumbnail_medium' => __('Medium', 'revslider'),
'thumbnail_small' => __('Small', 'revslider'),
$added_image_sizes = get_intermediate_image_sizes();
if(!empty($added_image_sizes) && is_array($added_image_sizes)){
foreach($added_image_sizes as $key => $img_size_handle){
$custom_sizes[$img_size_handle] = ucwords(str_replace('_', ' ', $img_size_handle));
$img_orig_sources = array(
'full' => __('Original Size', 'revslider'),
'thumbnail' => __('Thumbnail', 'revslider'),
'medium' => __('Medium', 'revslider'),
'large' => __('Large', 'revslider'),
$custom_sizes = array_merge($img_orig_sources, $custom_sizes);
* get the default layer animations
public function get_layer_animations($raw = false){
$custom_in = $this->get_animations();
$custom_out = $this->get_end_animations();
$custom_loop = $this->get_loop_animations();
"custom":{"group":"Custom","custom":true,"transitions":' .
"group":"Block Transitions (SFX)",
"blockfromleft":{"name":"Block from Left","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktoright","color":"#ffffff"},"timeline":{"ease":"power4.inOut","speed":1200}}},
"blockfromright":{"name":"Block from Right","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktoleft","color":"#ffffff"},"timeline":{"ease":"power4.inOut","speed":1200}}},
"blockfromtop":{"name":"Block from Top","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktobottom","color":"#ffffff"},"timeline":{"ease":"power4.inOut","speed":1200}}},
"blockfrombottom":{"name":"Block from Bottom","frame_0":{"transform":{"opacity":0}},"frame_1":{"transform":{"opacity":1},"sfx":{"effect":"blocktotop","color":"#ffffff"},"timeline":{"ease":"power4.inOut","speed":1200}}}
"group":"Letter Transitions",
"LettersFlyInFromLeft":{"name":"Letters Fly In From Left","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"x":"-105%","opacity":"0","rotationZ":"-90deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"power4.inOut","use":true,"direction":"backward","delay":10,"x":0,"opacity":1,"rotationZ":"0deg"},"mask":{"use":true}}},
"LettersFlyInFromRight":{"name":"Letters Fly In From Right","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"x":"105%","opacity":"1","rotationY":"45deg","rotationZ":"90deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"power4.inOut","use":true,"direction":"forward","delay":10,"x":0,"opacity":1,"rotationY":0,"rotationZ":"0deg"},"mask":{"use":true}}},
"LettersFlyInFromTop":{"name":"Letters Fly In From Top","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"y":"-100%","opacity":"0","rotationZ":"35deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"power4.inOut","use":true,"direction":"forward","delay":10,"y":0,"opacity":1,"rotationZ":"0deg"},"mask":{"use":true}}},
"LettersFlyInFromBottom":{"name":"Letters Fly In From Bottom","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"y":"100%","opacity":"0","rotationZ":"-35deg"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200},"transform":{"opacity":1},"chars":{"ease":"power4.inOut","use":true,"direction":"forward","delay":10,"y":0,"opacity":1,"rotationZ":"0deg"},"mask":{"use":true}}},
"LetterFlipFromTop":{"name":"Letter Flip From Top","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"opacity":0,"rotationX":"90deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750},"chars":{"use":true,"opacity":1,"rotationX":0,"delay":10,"originZ":"-50","ease":"power4.inOut"}}},
"LetterFlipFromBottom":{"name":"Letter Flip From Bottom","frame_0":{"transform":{"opacity":1},"chars":{"use":true,"opacity":0,"rotationX":"-90deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750},"chars":{"use":true,"opacity":1,"rotationX":0,"delay":10,"originZ":"-50","ease":"power4.inOut"}}},
"FlipAndLetterCycle":{"name":"Letter Flip Cycle","frame_0":{"transform":{"opacity":0,"rotationX":"70deg","y":"0","originZ":"-50"},"chars":{"use":true,"opacity":0,"y":"[-100||100]"}},"frame_1":{"timeline":{"speed":1750,"ease":"power4.inOut"},"transform":{"opacity":1,"originZ":"-50","rotationX":0},"chars":{"use":true,"direction":"middletoedge","opacity":1,"y":0,"delay":10,"ease":"power4.inOut"}}}
"group":"Masked Transitions",
"MaskedZoomOut":{"name":"Masked Zoom Out","frame_0":{"transform":{"opacity":0,"scaleX":2,"scaleY":2},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1000,"ease":"power2.out"},"mask":{"use":true},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}},
"SlideMaskFromBottom":{"name":"Slide From Bottom","frame_0":{"transform":{"opacity":0,"y":"100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200,"ease":"power3.inOut"},"mask":{"use":true,"y":0},"transform":{"opacity":1,"y":0}}},
"SlideMaskFromLeft":{"name":"Slide From Left","frame_0":{"transform":{"opacity":0,"x":"-100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.inOut"},"mask":{"use":true},"transform":{"opacity":1,"x":0}}},
"SlideMaskFromRight":{"name":"Slide From Right","frame_0":{"transform":{"opacity":0,"x":"100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.inOut"},"mask":{"use":true},"transform":{"opacity":1,"x":0}}},
"SlideMaskFromTop":{"name":"Slide From Top","frame_0":{"transform":{"opacity":0,"y":"-100%"},"mask":{"use":true}},"frame_1":{"timeline":{"speed":1200,"ease":"power3.inOut"},"mask":{"use":true},"transform":{"opacity":1,"y":0}}},
"SmoothMaskFromRight":{"name":"Smooth Mask From Right","frame_0":{"transform":{"opacity":1,"x":"-175%"},"mask":{"use":true,"x":"100%"}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.out"},"mask":{"use":true,"x":0},"transform":{"opacity":1,"x":0}}},
"SmoothMaskFromLeft":{"name":"Smooth Mask From Left","frame_0":{"transform":{"opacity":1,"x":"175%"},"mask":{"use":true,"x":"-100%"}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.out"},"mask":{"use":true,"x":0},"transform":{"opacity":1,"x":0}}}
"PopUpBack":{"name":"Pop Up Back","frame_0":{"transform":{"opacity":0,"rotationY":"360deg"}},"frame_1":{"timeline":{"speed":500,"ease":"back.out"},"transform":{"opacity":1,"rotationY":0}}},
"PopUpSmooth":{"name":"Pop Up Smooth","frame_0":{"transform":{"opacity":0,"scaleX":0.9,"scaleY":0.9}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.inOut"},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}},
"SmoothPopUp_One":{"name":"Smooth Pop Up v.1","frame_0":{"transform":{"opacity":0,"scaleX":0.8,"scaleY":0.8}},"frame_1":{"timeline":{"speed":1000,"ease":"power4.out"},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}},
"SmoothPopUp_Two":{"name":"Smooth Pop Up v.2","frame_0":{"transform":{"opacity":0,"scaleX":0.9,"scaleY":0.9}},"frame_1":{"timeline":{"speed":1000,"ease":"power2.inOut"},"transform":{"opacity":1,"scaleX":1,"scaleY":1}}}
"RotateInFromBottom":{"name":"Rotate In From Bottom","frame_0":{"transform":{"opacity":0,"rotationZ":"70deg","y":"bottom","scaleY":2,"scaleX":2}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.inOut"},"transform":{"opacity":1,"y":0,"rotationZ":0,"scaleX":1,"scaleY":1}}},
"RotateInFormZero":{"name":"Rotate In From Bottom v2.","frame_0":{"transform":{"opacity":1,"rotationY":"-20deg","rotationX":"-20deg","y":"200%","scaleY":2,"scaleX":2}},"frame_1":{"timeline":{"speed":1000,"ease":"power3.out"},"transform":{"opacity":1,"y":0,"rotationZ":0,"rotationY":0,"scaleX":1,"scaleY":1}}},
"FlipFromTop":{"name":"Flip From Top","frame_0":{"transform":{"opacity":0,"rotationX":"70deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750,"ease":"power4.inOut"},"transform":{"opacity":1,"originZ":"-50","rotationX":0}}},
"FlipFromBottom":{"name":"Flip From Bottom","frame_0":{"transform":{"opacity":0,"rotationX":"-70deg","y":"0","originZ":"-50"}},"frame_1":{"timeline":{"speed":1750,"ease":"power4.inOut"},"transform":{"opacity":1,"rotationX":0,"originZ":"-50"}}}