$c.'.NotGeneric-Menuitem' => '5.0',
$c.'.MarkerStyle' => '5.0',
$c.'.Gym-Menuitem' => '5.0',
$c.'.Newspaper-Button' => '5.0',
$c.'.Newspaper-Subtitle' => '5.0',
$c.'.Newspaper-Title' => '5.0',
$c.'.Newspaper-Title-Centered' => '5.0',
$c.'.Hero-Button' => '5.0',
$c.'.Video-Title' => '5.0',
$c.'.Video-SubTitle' => '5.0',
$c.'.NotGeneric-Button' => '5.0',
$c.'.NotGeneric-BigButton' => '5.0',
$c.'.WebProduct-Button' => '5.0',
$c.'.Restaurant-Button' => '5.0',
$c.'.Gym-Button' => '5.0',
$c.'.Gym-Button-Light' => '5.0',
$c.'.Sports-Button-Light' => '5.0',
$c.'.Sports-Button-Red' => '5.0',
$c.'.Photography-Button' => '5.0',
$c.'.Newspaper-Button-2' => '5.0'
return apply_filters('revslider_mod_default_css_handles', $default);
* Defines the deformation CSS which is not directly usable as pure CSS
public function get_deformation_css_tags(){
'2d_rotation' => '2d_rotation',
'layer_2d_origin_x' => 'layer_2d_origin_x',
'layer_2d_origin_y' => 'layer_2d_origin_y',
'2d_origin_x' => '2d_origin_x',
'2d_origin_y' => '2d_origin_y',
'color-transparency' => 'color-transparency',
'background-transparency' => 'background-transparency',
'border-transparency'=> 'border-transparency',
'corner_left' => 'corner_left',
'corner_right' => 'corner_right',
'parallax' => 'parallax',
'text-align' => 'text-align'
* return the captions sorted by handle name
public function get_captions_sorted(){
$styles = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix . RevSliderFront::TABLE_CSS . " ORDER BY handle ASC", ARRAY_A);
$arr = array('5.0' => array(), 'Custom' => array(), '4' => array());
foreach($styles as $style){
$setting = json_decode($this->get_val($style, 'settings'), true);
if(!isset($setting['type'])) $setting['type'] = 'text';
if(array_key_exists('version', $setting) && isset($setting['version'])) $arr[ucfirst($setting['version'])][] = array('label' => trim(str_replace('.tp-caption.', '', $style['handle'])), 'type' => $setting['type']);
foreach($arr as $version => $class){
foreach($class as $name){
$sorted[] = array('label' => $this->get_val($name, 'label'), 'version' => $version, 'type' => $this->get_val($name, 'type'));
public function parse_media_blocks($css){
while(($start = strpos($css, '@media', $start)) !== false){
$i = strpos($css, '{', $start);
$block = trim(substr($css, $start, $i - $start));
array_push($s, $css[$i]);
}elseif($css[$i] == '}'){
$blocks[$block] = substr($css, $start, ($i + 1) - $start);
* removes @media { ... } queries from CSS
public function clear_media_block($css){
if(empty($css)) return $css;
if(strpos($css, '@media', $start) !== false){
$start = strpos($css, '@media', 0);
$i = strpos($css, '{', $start);
if($i === false) return $css;
$remove = substr($css, $start - 1, $i - $start + 1); //remove @media ... first {
$css = str_replace($remove, '', $css);
$css = preg_replace('/}$/', '', $css); //remove last }
* import contents of the css file
* @before: RevSliderOperations::importCaptionsCssContentArray()
public function import_css_captions(){
$css = $this->get_base_css_captions();
if(is_array($css) && $css !== false && count($css) > 0){
foreach($css as $class => $styles){
//check if static style or dynamic style
if((strpos($class, ':hover') === false && strpos($class, ':') !== false) || //before, after
strpos($class, ' ') !== false || // .tp-caption.imageclass img or .tp-caption .imageclass or .tp-caption.imageclass .img
strpos($class, '.tp-caption') === false || // everything that is not tp-caption
(strpos($class, '.') === false || strpos($class, '#') !== false) || // no class -> #ID or img
strpos($class, '>') !== false){ //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img
$static[$class] = $styles;
if(strpos($class, ':hover') !== false){
$class = trim(str_replace(':hover', '', $class));
'hover' => json_encode($styles),
'settings' => json_encode(array('hover' => 'true'))
'params' => json_encode($styles)
$result = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix . RevSliderFront::TABLE_CSS." WHERE handle = %s", $class), ARRAY_A);
if(!empty($result)){ //update
$wpdb->update($wpdb->prefix . RevSliderFront::TABLE_CSS, $add, array('handle' => $class));
$wpdb->insert($wpdb->prefix . RevSliderFront::TABLE_CSS, $add);
if(!empty($static)){ //save static into static-captions.css
$css = $this->get_static_css()."\n".$this->static_to_css($static); //get the open sans line!
$this->update_static_css($css);
* get contents of the css file
* @before: RevSliderOperations::getCaptionsCssContentArray();
public function get_base_css_captions(){
include(RS_PLUGIN_PATH . 'includes/basic-css.php');
return $this->css_to_array($css);
* get the css raw from the database
public function get_raw_css(){
$result = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix . RevSliderFront::TABLE_CSS, ARRAY_A);
* get the css from the database and set it into an object structure
public function get_database_classes($adv = false){
$css = $this->get_raw_css();
foreach($css as $k => $v){
$css[$v['handle']]['hover'] = json_decode($this->get_val($v, 'hover', ''), true);
$css[$v['handle']]['params'] = json_decode($this->get_val($v, 'params', ''), true);
$css[$v['handle']]['settings'] = json_decode($this->get_val($v, 'settings', ''), true);
unset($css[$v['handle']]['hover']);
unset($css[$v['handle']]['params']);
unset($css[$v['handle']]['settings']);
$css[$v['handle']]['advanced'] = json_decode($this->get_val($v, 'advanced', ''), true);
* add missing px/% to value, do also for object and array
public function add_missing_val($obj, $set_to = 'px'){
foreach($obj as $key => $value){
if(strpos($value, $set_to) === false){
$obj[$key] = $value.$set_to;
}elseif(is_object($obj)){
foreach($obj as $key => $value){
if(strpos($value->v, $set_to) === false){
$obj->$key->v = $value->v.$set_to;
if(strpos($value, $set_to) === false){
$obj->$key = $value.$set_to;
if(strpos($obj, $set_to) === false){
public function hex2rgba($hex, $transparency = false, $raw = false, $do_rgb = false){
if($transparency !== false){
$transparency = ($transparency > 0) ? number_format(($transparency / 100), 2, '.', '') : 0;
$hex = str_replace('#', '', $hex);
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}elseif($this->is_rgb($hex)){
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
$ret = ($do_rgb) ? $r.', '.$g.', '.$b : $r.', '.$g.', '.$b.', '.$transparency;
return ($raw) ? $ret : 'rgba('.$ret.')';