| @@ -102,22 +102,8 @@ | ||
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * CSS file constructor. | |
| 107 | - * | |
| 108 | - * Initializing Elementor CSS file. | |
| 109 | - * | |
| 110 | - * @since 1.2.0 | |
| 111 | - * @access public | |
| 112 | - */ | |
| 113 | - public function __construct( $file_name ) { | |
| 114 | - parent::__construct( $file_name ); | |
| 115 | - | |
| 116 | - $this->init_stylesheet(); | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | 106 | * Use external file. |
| 121 | 107 | * |
| 122 | 108 | * Whether to use external CSS file of not. When there are new schemes or settings |
| 123 | 109 | * updates. |
| @@ -328,8 +314,10 @@ | ||
| 328 | 314 | return; |
| 329 | 315 | } |
| 330 | 316 | } |
| 331 | 317 | |
| 318 | + $stylesheet = $this->get_stylesheet(); | |
| 319 | + | |
| 332 | 320 | foreach ( $control['selectors'] as $selector => $css_property ) { |
| 333 | 321 | $output_css_property = ''; |
| 334 | 322 | |
| 335 | 323 | if ( $global_key ) { |
| @@ -421,9 +409,9 @@ | ||
| 421 | 409 | unset( $query['max'] ); |
| 422 | 410 | } |
| 423 | 411 | } |
| 424 | 412 | |
| 425 | - $this->stylesheet_obj->add_rules( $parsed_selector, $output_css_property, $query ); | |
| 413 | + $stylesheet->add_rules( $parsed_selector, $output_css_property, $query ); | |
| 426 | 414 | } |
| 427 | 415 | } |
| 428 | 416 | |
| 429 | 417 | /** |
| @@ -477,8 +465,12 @@ | ||
| 477 | 465 | * |
| 478 | 466 | * @return Stylesheet The stylesheet object. |
| 479 | 467 | */ |
| 480 | 468 | public function get_stylesheet() { |
| 469 | + if ( ! $this->stylesheet_obj ) { | |
| 470 | + $this->init_stylesheet(); | |
| 471 | + } | |
| 472 | + | |
| 481 | 473 | return $this->stylesheet_obj; |
| 482 | 474 | } |
| 483 | 475 | |
| 484 | 476 | /** |
| @@ -638,9 +630,9 @@ | ||
| 638 | 630 | * @param Base $this The current CSS file. |
| 639 | 631 | */ |
| 640 | 632 | do_action( "elementor/css-file/{$name}/parse", $this ); |
| 641 | 633 | |
| 642 | - return $this->stylesheet_obj->__toString(); | |
| 634 | + return $this->get_stylesheet()->__toString(); | |
| 643 | 635 | } |
| 644 | 636 | |
| 645 | 637 | /** |
| 646 | 638 | * Add control style rules. |