PageRenderTime 30ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/themeforest-8497776-eco-nature-environment-ecology-wordpress-theme/Update/theme plugins/revslider/includes/framework/cssparser.class.php

https://gitlab.com/hop23typhu/list-theme
PHP | 648 lines | 591 code | 34 blank | 23 comment | 47 complexity | edd46a93a0db4f9cf9c428021f597c41 MD5 | raw file
  1. <?php
  2. /**
  3. * @author ThemePunch <info@themepunch.com>
  4. * @link http://www.themepunch.com/
  5. * @copyright 2015 ThemePunch
  6. */
  7. if( !defined( 'ABSPATH') ) exit();
  8. class RevSliderCssParser{
  9. private $cssContent;
  10. public function __construct(){
  11. }
  12. /**
  13. *
  14. * init the parser, set css content
  15. */
  16. public function initContent($cssContent){
  17. $this->cssContent = $cssContent;
  18. }
  19. /**
  20. *
  21. * get array of slide classes, between two sections.
  22. */
  23. public function getArrClasses($startText = "",$endText="",$explodeonspace=false){
  24. $content = $this->cssContent;
  25. //trim from top
  26. if(!empty($startText)){
  27. $posStart = strpos($content, $startText);
  28. if($posStart !== false)
  29. $content = substr($content, $posStart,strlen($content)-$posStart);
  30. }
  31. //trim from bottom
  32. if(!empty($endText)){
  33. $posEnd = strpos($content, $endText);
  34. if($posEnd !== false)
  35. $content = substr($content,0,$posEnd);
  36. }
  37. //get styles
  38. $lines = explode("\n",$content);
  39. $arrClasses = array();
  40. foreach($lines as $key=>$line){
  41. $line = trim($line);
  42. if(strpos($line, "{") === false)
  43. continue;
  44. //skip unnessasary links
  45. if(strpos($line, ".caption a") !== false)
  46. continue;
  47. if(strpos($line, ".tp-caption a") !== false)
  48. continue;
  49. //get style out of the line
  50. $class = str_replace("{", "", $line);
  51. $class = trim($class);
  52. //skip captions like this: .tp-caption.imageclass img
  53. if(strpos($class," ") !== false){
  54. if(!$explodeonspace){
  55. continue;
  56. }else{
  57. $class = explode(',', $class);
  58. $class = $class[0];
  59. }
  60. }
  61. //skip captions like this: .tp-caption.imageclass:hover, :before, :after
  62. if(strpos($class,":") !== false)
  63. continue;
  64. $class = str_replace(".caption.", ".", $class);
  65. $class = str_replace(".tp-caption.", ".", $class);
  66. $class = str_replace(".", "", $class);
  67. $class = trim($class);
  68. $arrWords = explode(" ", $class);
  69. $class = $arrWords[count($arrWords)-1];
  70. $class = trim($class);
  71. $arrClasses[] = $class;
  72. }
  73. sort($arrClasses);
  74. return($arrClasses);
  75. }
  76. public static function parseCssToArray($css){
  77. while(strpos($css, '/*') !== false){
  78. if(strpos($css, '*/') === false) return false;
  79. $start = strpos($css, '/*');
  80. $end = strpos($css, '*/') + 2;
  81. $css = str_replace(substr($css, $start, $end - $start), '', $css);
  82. }
  83. //preg_match_all( '/(?ims)([a-z0-9\s\.\:#_\-@]+)\{([^\}]*)\}/', $css, $arr);
  84. preg_match_all( '/(?ims)([a-z0-9\,\s\.\:#_\-@]+)\{([^\}]*)\}/', $css, $arr);
  85. $result = array();
  86. foreach ($arr[0] as $i => $x){
  87. $selector = trim($arr[1][$i]);
  88. if(strpos($selector, '{') !== false || strpos($selector, '}') !== false) return false;
  89. $rules = explode(';', trim($arr[2][$i]));
  90. $result[$selector] = array();
  91. foreach ($rules as $strRule){
  92. if (!empty($strRule)){
  93. $rule = explode(":", $strRule);
  94. if(strpos($rule[0], '{') !== false || strpos($rule[0], '}') !== false || strpos($rule[1], '{') !== false || strpos($rule[1], '}') !== false) return false;
  95. //put back everything but not $rule[0];
  96. $key = trim($rule[0]);
  97. unset($rule[0]);
  98. $values = implode(':', $rule);
  99. $result[$selector][trim($key)] = trim(str_replace("'", '"', $values));
  100. }
  101. }
  102. }
  103. return($result);
  104. }
  105. public static function parseDbArrayToCss($cssArray, $nl = "\n\r"){
  106. $css = '';
  107. $deformations = self::get_deformation_css_tags();
  108. $transparency = array(
  109. 'color' => 'color-transparency',
  110. 'background-color' => 'background-transparency',
  111. 'border-color' => 'border-transparency'
  112. );
  113. $check_parameters = array(
  114. 'border-width' => 'px',
  115. 'border-radius' => 'px',
  116. 'padding' => 'px',
  117. 'font-size' => 'px',
  118. 'line-height' => 'px'
  119. );
  120. foreach($cssArray as $id => $attr){
  121. $stripped = '';
  122. if(strpos($attr['handle'], '.tp-caption') !== false){
  123. $stripped = trim(str_replace('.tp-caption', '', $attr['handle']));
  124. }
  125. $attr['advanced'] = json_decode($attr['advanced'], true);
  126. $styles = json_decode(str_replace("'", '"', $attr['params']), true);
  127. $styles_adv = $attr['advanced']['idle'];
  128. $css.= $attr['handle'];
  129. if(!empty($stripped)) $css.= ', '.$stripped;
  130. $css.= " {".$nl;
  131. if(is_array($styles) || is_array($styles_adv)){
  132. if(is_array($styles)){
  133. foreach($styles as $name => $style){
  134. if(in_array($name, $deformations) && $name !== 'css_cursor') continue;
  135. if(!is_array($name) && isset($transparency[$name])){ //the style can have transparency!
  136. if(isset($styles[$transparency[$name]]) && $style !== 'transparent'){
  137. $style = RevSliderFunctions::hex2rgba($style, $styles[$transparency[$name]] * 100);
  138. }
  139. }
  140. if(!is_array($name) && isset($check_parameters[$name])){
  141. $style = RevSliderFunctions::add_missing_val($style, $check_parameters[$name]);
  142. }
  143. if(is_array($style)) $style = implode(' ', $style);
  144. $ret = self::check_for_modifications($name, $style);
  145. if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
  146. $css.= $ret['name'].':'.$ret['style'].";".$nl;
  147. }
  148. }
  149. if(is_array($styles_adv)){
  150. foreach($styles_adv as $name => $style){
  151. if(in_array($name, $deformations) && $name !== 'css_cursor') continue;
  152. if(is_array($style)) $style = implode(' ', $style);
  153. $ret = self::check_for_modifications($name, $style);
  154. if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
  155. $css.= $ret['name'].':'.$ret['style'].";".$nl;
  156. }
  157. }
  158. }
  159. $css.= "}".$nl.$nl;
  160. //add hover
  161. $setting = json_decode($attr['settings'], true);
  162. if(isset($setting['hover']) && $setting['hover'] == 'true'){
  163. $hover = json_decode(str_replace("'", '"', $attr['hover']), true);
  164. $hover_adv = $attr['advanced']['hover'];
  165. if(is_array($hover) || is_array($hover_adv)){
  166. $css.= $attr['handle'].":hover";
  167. if(!empty($stripped)) $css.= ', '.$stripped.':hover';
  168. $css.= " {".$nl;
  169. if(is_array($hover)){
  170. foreach($hover as $name => $style){
  171. if(in_array($name, $deformations) && $name !== 'css_cursor') continue;
  172. if(!is_array($name) && isset($transparency[$name])){ //the style can have transparency!
  173. if(isset($hover[$transparency[$name]]) && $style !== 'transparent'){
  174. $style = RevSliderFunctions::hex2rgba($style, $hover[$transparency[$name]] * 100);
  175. }
  176. }
  177. if(!is_array($name) && isset($check_parameters[$name])){
  178. $style = RevSliderFunctions::add_missing_val($style, $check_parameters[$name]);
  179. }
  180. if(is_array($style)) $style = implode(' ', $style);
  181. $ret = self::check_for_modifications($name, $style);
  182. if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
  183. $css.= $ret['name'].':'.$ret['style'].";".$nl;
  184. }
  185. }
  186. if(is_array($hover_adv)){
  187. foreach($hover_adv as $name => $style){
  188. if(in_array($name, $deformations) && $name !== 'css_cursor') continue;
  189. if(is_array($style)) $style = implode(' ', $style);
  190. $ret = self::check_for_modifications($name, $style);
  191. if($ret['name'] == 'cursor' && $ret['style'] == 'auto') continue;
  192. $css.= $ret['name'].':'.$ret['style'].";".$nl;
  193. }
  194. }
  195. $css.= "}".$nl.$nl;
  196. }
  197. }
  198. }
  199. return $css;
  200. }
  201. /**
  202. * Check for Modifications like with css_cursor
  203. * @since: 5.1.3
  204. **/
  205. public static function check_for_modifications($name, $style){
  206. if($name == 'css_cursor'){
  207. if($style == 'zoom-in') $style = 'zoom-in; -webkit-zoom-in; cursor: -moz-zoom-in';
  208. if($style == 'zoom-out') $style = 'zoom-out; -webkit-zoom-out; cursor: -moz-zoom-out';
  209. $name = 'cursor';
  210. }
  211. return array('name' => $name, 'style' => $style);
  212. }
  213. public static function parseArrayToCss($cssArray, $nl = "\n\r", $adv = false){
  214. $css = '';
  215. foreach($cssArray as $id => $attr){
  216. $setting = (array)$attr['settings'];
  217. $advanced = (array)$attr['advanced'];
  218. $stripped = '';
  219. if(strpos($attr['handle'], '.tp-caption') !== false){
  220. $stripped = trim(str_replace('.tp-caption', '', $attr['handle']));
  221. }
  222. $styles = (array)$attr['params'];
  223. $css.= $attr['handle'];
  224. if(!empty($stripped)) $css.= ', '.$stripped;
  225. $css.= " {".$nl;
  226. if($adv && isset($advanced['idle'])){
  227. $styles = array_merge($styles, (array)$advanced['idle']);
  228. if(isset($setting['type'])){
  229. $styles['type'] = $setting['type'];
  230. }
  231. }
  232. if(is_array($styles) && !empty($styles)){
  233. foreach($styles as $name => $style){
  234. if($name == 'background-color' && strpos($style, 'rgba') !== false){ //rgb && rgba
  235. $rgb = explode(',', str_replace('rgba', 'rgb', $style));
  236. unset($rgb[count($rgb)-1]);
  237. $rgb = implode(',', $rgb).')';
  238. $css.= $name.':'.$rgb.";".$nl;
  239. }
  240. $style = (is_array($style)) ? implode(' ', $style) : $style;
  241. $css.= $name.':'.$style.";".$nl;
  242. }
  243. }
  244. $css.= "}".$nl.$nl;
  245. //add hover
  246. if(isset($setting['hover']) && $setting['hover'] == 'true'){
  247. $hover = (array)$attr['hover'];
  248. if($adv && isset($advanced['hover'])){
  249. $styles = array_merge($styles, (array)$advanced['hover']);
  250. }
  251. if(is_array($hover)){
  252. $css.= $attr['handle'].":hover";
  253. if(!empty($stripped)) $css.= ', '.$stripped.":hover";
  254. $css.= " {".$nl;
  255. foreach($hover as $name => $style){
  256. if($name == 'background-color' && strpos($style, 'rgba') !== false){ //rgb && rgba
  257. $rgb = explode(',', str_replace('rgba', 'rgb', $style));
  258. unset($rgb[count($rgb)-1]);
  259. $rgb = implode(',', $rgb).')';
  260. $css.= $name.':'.$rgb.";".$nl;
  261. }
  262. $style = (is_array($style)) ? implode(' ', $style) : $style;
  263. $css.= $name.':'.$style.";".$nl;
  264. }
  265. $css.= "}".$nl.$nl;
  266. }
  267. }
  268. }
  269. return $css;
  270. }
  271. public static function parseStaticArrayToCss($cssArray, $nl = "\n"){
  272. $css = '';
  273. foreach($cssArray as $class => $styles){
  274. $css.= $class." {".$nl;
  275. if(is_array($styles) && !empty($styles)){
  276. foreach($styles as $name => $style){
  277. $style = (is_array($style)) ? implode(' ', $style) : $style;
  278. $css.= $name.':'.$style.";".$nl;
  279. }
  280. }
  281. $css.= "}".$nl.$nl;
  282. }
  283. return $css;
  284. }
  285. public static function parseDbArrayToArray($cssArray, $handle = false){
  286. if(!is_array($cssArray) || empty($cssArray)) return false;
  287. foreach($cssArray as $key => $css){
  288. if($handle != false){
  289. if($cssArray[$key]['handle'] == '.tp-caption.'.$handle){
  290. $cssArray[$key]['params'] = json_decode(str_replace("'", '"', $css['params']));
  291. $cssArray[$key]['hover'] = json_decode(str_replace("'", '"', $css['hover']));
  292. $cssArray[$key]['advanced'] = json_decode(str_replace("'", '"', $css['advanced']));
  293. $cssArray[$key]['settings'] = json_decode(str_replace("'", '"', $css['settings']));
  294. return $cssArray[$key];
  295. }else{
  296. unset($cssArray[$key]);
  297. }
  298. }else{
  299. $cssArray[$key]['params'] = json_decode(str_replace("'", '"', $css['params']));
  300. $cssArray[$key]['hover'] = json_decode(str_replace("'", '"', $css['hover']));
  301. $cssArray[$key]['advanced'] = json_decode(str_replace("'", '"', $css['advanced']));
  302. $cssArray[$key]['settings'] = json_decode(str_replace("'", '"', $css['settings']));
  303. }
  304. }
  305. return $cssArray;
  306. }
  307. public static function compress_css($buffer){
  308. /* remove comments */
  309. $buffer = preg_replace("!/\*[^*]*\*+([^/][^*]*\*+)*/!", "", $buffer) ;
  310. /* remove tabs, spaces, newlines, etc. */
  311. $arr = array("\r\n", "\r", "\n", "\t", " ", " ", " ");
  312. $rep = array("", "", "", "", " ", " ", " ");
  313. $buffer = str_replace($arr, $rep, $buffer);
  314. /* remove whitespaces around {}:, */
  315. $buffer = preg_replace("/\s*([\{\}:,])\s*/", "$1", $buffer);
  316. /* remove last ; */
  317. $buffer = str_replace(';}', "}", $buffer);
  318. return $buffer;
  319. }
  320. /**
  321. * Defines the default CSS Classes, can be given a version number to order them accordingly
  322. * @since: 5.0
  323. **/
  324. public static function default_css_classes(){
  325. $default = array(
  326. '.tp-caption.medium_grey' => '4',
  327. '.tp-caption.small_text' => '4',
  328. '.tp-caption.medium_text' => '4',
  329. '.tp-caption.large_text' => '4',
  330. '.tp-caption.very_large_text' => '4',
  331. '.tp-caption.very_big_white' => '4',
  332. '.tp-caption.very_big_black' => '4',
  333. '.tp-caption.modern_medium_fat' => '4',
  334. '.tp-caption.modern_medium_fat_white' => '4',
  335. '.tp-caption.modern_medium_light' => '4',
  336. '.tp-caption.modern_big_bluebg' => '4',
  337. '.tp-caption.modern_big_redbg' => '4',
  338. '.tp-caption.modern_small_text_dark' => '4',
  339. '.tp-caption.boxshadow' => '4',
  340. '.tp-caption.black' => '4',
  341. '.tp-caption.noshadow' => '4',
  342. '.tp-caption.thinheadline_dark' => '4',
  343. '.tp-caption.thintext_dark' => '4',
  344. '.tp-caption.largeblackbg' => '4',
  345. '.tp-caption.largepinkbg' => '4',
  346. '.tp-caption.largewhitebg' => '4',
  347. '.tp-caption.largegreenbg' => '4',
  348. '.tp-caption.excerpt' => '4',
  349. '.tp-caption.large_bold_grey' => '4',
  350. '.tp-caption.medium_thin_grey' => '4',
  351. '.tp-caption.small_thin_grey' => '4',
  352. '.tp-caption.lightgrey_divider' => '4',
  353. '.tp-caption.large_bold_darkblue' => '4',
  354. '.tp-caption.medium_bg_darkblue' => '4',
  355. '.tp-caption.medium_bold_red' => '4',
  356. '.tp-caption.medium_light_red' => '4',
  357. '.tp-caption.medium_bg_red' => '4',
  358. '.tp-caption.medium_bold_orange' => '4',
  359. '.tp-caption.medium_bg_orange' => '4',
  360. '.tp-caption.grassfloor' => '4',
  361. '.tp-caption.large_bold_white' => '4',
  362. '.tp-caption.medium_light_white' => '4',
  363. '.tp-caption.mediumlarge_light_white' => '4',
  364. '.tp-caption.mediumlarge_light_white_center' => '4',
  365. '.tp-caption.medium_bg_asbestos' => '4',
  366. '.tp-caption.medium_light_black' => '4',
  367. '.tp-caption.large_bold_black' => '4',
  368. '.tp-caption.mediumlarge_light_darkblue' => '4',
  369. '.tp-caption.small_light_white' => '4',
  370. '.tp-caption.roundedimage' => '4',
  371. '.tp-caption.large_bg_black' => '4',
  372. '.tp-caption.mediumwhitebg' => '4',
  373. '.tp-caption.MarkerDisplay' => '5.0',
  374. '.tp-caption.Restaurant-Display' => '5.0',
  375. '.tp-caption.Restaurant-Cursive' => '5.0',
  376. '.tp-caption.Restaurant-ScrollDownText' => '5.0',
  377. '.tp-caption.Restaurant-Description' => '5.0',
  378. '.tp-caption.Restaurant-Price' => '5.0',
  379. '.tp-caption.Restaurant-Menuitem' => '5.0',
  380. '.tp-caption.Furniture-LogoText' => '5.0',
  381. '.tp-caption.Furniture-Plus' => '5.0',
  382. '.tp-caption.Furniture-Title' => '5.0',
  383. '.tp-caption.Furniture-Subtitle' => '5.0',
  384. '.tp-caption.Gym-Display' => '5.0',
  385. '.tp-caption.Gym-Subline' => '5.0',
  386. '.tp-caption.Gym-SmallText' => '5.0',
  387. '.tp-caption.Fashion-SmallText' => '5.0',
  388. '.tp-caption.Fashion-BigDisplay' => '5.0',
  389. '.tp-caption.Fashion-TextBlock' => '5.0',
  390. '.tp-caption.Sports-Display' => '5.0',
  391. '.tp-caption.Sports-DisplayFat' => '5.0',
  392. '.tp-caption.Sports-Subline' => '5.0',
  393. '.tp-caption.Instagram-Caption' => '5.0',
  394. '.tp-caption.News-Title' => '5.0',
  395. '.tp-caption.News-Subtitle' => '5.0',
  396. '.tp-caption.Photography-Display' => '5.0',
  397. '.tp-caption.Photography-Subline' => '5.0',
  398. '.tp-caption.Photography-ImageHover' => '5.0',
  399. '.tp-caption.Photography-Menuitem' => '5.0',
  400. '.tp-caption.Photography-Textblock' => '5.0',
  401. '.tp-caption.Photography-Subline-2' => '5.0',
  402. '.tp-caption.Photography-ImageHover2' => '5.0',
  403. '.tp-caption.WebProduct-Title' => '5.0',
  404. '.tp-caption.WebProduct-SubTitle' => '5.0',
  405. '.tp-caption.WebProduct-Content' => '5.0',
  406. '.tp-caption.WebProduct-Menuitem' => '5.0',
  407. '.tp-caption.WebProduct-Title-Light' => '5.0',
  408. '.tp-caption.WebProduct-SubTitle-Light' => '5.0',
  409. '.tp-caption.WebProduct-Content-Light' => '5.0',
  410. '.tp-caption.FatRounded' => '5.0',
  411. '.tp-caption.NotGeneric-Title' => '5.0',
  412. '.tp-caption.NotGeneric-SubTitle' => '5.0',
  413. '.tp-caption.NotGeneric-CallToAction' => '5.0',
  414. '.tp-caption.NotGeneric-Icon' => '5.0',
  415. '.tp-caption.NotGeneric-Menuitem' => '5.0',
  416. '.tp-caption.MarkerStyle' => '5.0',
  417. '.tp-caption.Gym-Menuitem' => '5.0',
  418. '.tp-caption.Newspaper-Button' => '5.0',
  419. '.tp-caption.Newspaper-Subtitle' => '5.0',
  420. '.tp-caption.Newspaper-Title' => '5.0',
  421. '.tp-caption.Newspaper-Title-Centered' => '5.0',
  422. '.tp-caption.Hero-Button' => '5.0',
  423. '.tp-caption.Video-Title' => '5.0',
  424. '.tp-caption.Video-SubTitle' => '5.0',
  425. '.tp-caption.NotGeneric-Button' => '5.0',
  426. '.tp-caption.NotGeneric-BigButton' => '5.0',
  427. '.tp-caption.WebProduct-Button' => '5.0',
  428. '.tp-caption.Restaurant-Button' => '5.0',
  429. '.tp-caption.Gym-Button' => '5.0',
  430. '.tp-caption.Gym-Button-Light' => '5.0',
  431. '.tp-caption.Sports-Button-Light' => '5.0',
  432. '.tp-caption.Sports-Button-Red' => '5.0',
  433. '.tp-caption.Photography-Button' => '5.0',
  434. '.tp-caption.Newspaper-Button-2' => '5.0'
  435. );
  436. $default = apply_filters('revslider_mod_default_css_handles', $default);
  437. return $default;
  438. }
  439. /**
  440. * Defines the deformation CSS which is not directly usable as pure CSS
  441. * @since: 5.0
  442. **/
  443. public static function get_deformation_css_tags(){
  444. return array(
  445. 'x' => 'x',
  446. 'y' => 'y',
  447. 'z' => 'z',
  448. 'skewx' => 'skewx',
  449. 'skewy' => 'skewy',
  450. 'scalex' => 'scalex',
  451. 'scaley' => 'scaley',
  452. 'opacity' => 'opacity',
  453. 'xrotate' => 'xrotate',
  454. 'yrotate' => 'yrotate',
  455. '2d_rotation' => '2d_rotation',
  456. 'layer_2d_origin_x' => 'layer_2d_origin_x',
  457. 'layer_2d_origin_y' => 'layer_2d_origin_y',
  458. '2d_origin_x' => '2d_origin_x',
  459. '2d_origin_y' => '2d_origin_y',
  460. 'pers' => 'pers',
  461. 'color-transparency' => 'color-transparency',
  462. 'background-transparency' => 'background-transparency',
  463. 'border-transparency' => 'border-transparency',
  464. 'css_cursor' => 'css_cursor',
  465. 'speed' => 'speed',
  466. 'easing' => 'easing',
  467. 'corner_left' => 'corner_left',
  468. 'corner_right' => 'corner_right',
  469. 'parallax' => 'parallax',
  470. 'type' => 'type'/*,
  471. 'text-align' => 'text-align'*/
  472. );
  473. }
  474. public static function get_captions_sorted(){
  475. $db = new RevSliderDB();
  476. $styles = $db->fetch(RevSliderGlobals::$table_css, '', 'handle ASC');
  477. $arr = array('5.0' => array(), 'Custom' => array(), '4' => array());
  478. foreach($styles as $style){
  479. $setting = json_decode($style['settings'], true);
  480. if(!isset($setting['type'])) $setting['type'] = 'text';
  481. 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']);
  482. }
  483. $sorted = array();
  484. foreach($arr as $version => $class){
  485. foreach($class as $name){
  486. $sorted[] = array('label' => $name['label'], 'version' => $version, 'type' => $name['type']);
  487. }
  488. }
  489. return $sorted;
  490. }
  491. /**
  492. * Handles media queries
  493. * @since: 5.2.0
  494. **/
  495. public static function parse_media_blocks($css){
  496. $mediaBlocks = array();
  497. $start = 0;
  498. while(($start = strpos($css, '@media', $start)) !== false){
  499. $s = array();
  500. $i = strpos($css, '{', $start);
  501. if ($i !== false){
  502. $block = trim(substr($css, $start, $i - $start));
  503. array_push($s, $css[$i]);
  504. $i++;
  505. while(!empty($s)){
  506. if ($css[$i] == '{'){
  507. array_push($s, '{');
  508. }elseif ($css[$i] == '}'){
  509. array_pop($s);
  510. }else{
  511. //broken css?
  512. }
  513. $i++;
  514. }
  515. $mediaBlocks[$block] = substr($css, $start, ($i + 1) - $start);
  516. $start = $i;
  517. }
  518. }
  519. return $mediaBlocks;
  520. }
  521. /**
  522. * removes @media { ... } queries from CSS
  523. * @since: 5.2.0
  524. **/
  525. public static function clear_media_block($css){
  526. $start = 0;
  527. if($start = strpos($css, '@media', $start) !== false){
  528. $i = strpos($css, '{', $start) + 1;
  529. //remove @media ... first {
  530. $remove = substr($css, $start - 1, $i - $start + 1);
  531. $css = str_replace($remove, '', $css);
  532. //remove last }
  533. $css = preg_replace('/}$/', '', $css);
  534. }
  535. return $css;
  536. }
  537. }
  538. /**
  539. * old classname extends new one (old classnames will be obsolete soon)
  540. * @since: 5.0
  541. **/
  542. class UniteCssParserRev extends RevSliderCssParser {}
  543. ?>