/var/www/html/wp-content/plugins/elementor/core/settings/base/css-manager.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php

namespace Elementor\Core\Settings\Base;

use 
Elementor\Core\Files\CSS\Base as CSS_File;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly
}

abstract class 
CSS_Manager extends Manager {

    
/**
     * Get CSS file name.
     *
     * Retrieve CSS file name for the settings base css manager.
     *
     * @since 2.8.0
     * @access protected
     * @abstract
     *
     * @return string CSS file name
     */
    
abstract protected function get_css_file_name();

    
/**
     * Get model for CSS file.
     *
     * Retrieve the model for the CSS file.
     *
     * @since 2.8.0
     * @access protected
     * @abstract
     *
     * @param CSS_File $css_file The requested CSS file.
     *
     * @return CSS_Model
     *
     */
    
abstract protected function get_model_for_css_fileCSS_File $css_file );

    
/**
     * Get CSS file for update.
     *
     * Retrieve the CSS file before updating it.
     *
     * @since 2.8.0
     * @access protected
     * @abstract
     *
     * @param int $id Post ID.
     *
     * @return CSS_File
     *
     */
    
abstract protected function get_css_file_for_update$id );

    
/**
     * Settings base manager constructor.
     *
     * Initializing Elementor settings base css manager.
     *
     * @since 2.8.0
     * @access public
     */
    
public function __construct() {
        
parent::__construct();

        
$name $this->get_css_file_name();

        
add_action"elementor/css-file/{$name}/parse", [ $this'add_settings_css_rules' ] );
    }

    
/**
     * Save settings.
     *
     * Save settings to the database and update the CSS file.
     *
     * @since 2.8.0
     * @access public
     *
     * @param array $settings Settings.
     * @param int   $id       Optional. Post ID. Default is `0`.
     */
    
public function save_settings( array $settings$id ) {
        
parent::save_settings$settings$id );

        
$css_file $this->get_css_file_for_update$id );

        if ( 
$css_file ) {
            
$css_file->update();
        }
    }

    
/**
     * Add settings CSS rules.
     *
     * Add new CSS rules to the settings manager.
     *
     * Fired by `elementor/css-file/{$name}/parse` action.
     *
     * @since 2.8.0
     * @access public
     *
     * @param CSS_File $css_file The requested CSS file.
     *
     */
    
public function add_settings_css_rulesCSS_File $css_file ) {
        
$model $this->get_model_for_css_file$css_file );

        
$css_file->add_controls_stack_style_rules(
            
$model,
            
$css_file->get_style_controls$modelnull$model->get_settings() ),
            
$model->get_settings(),
            [ 
'{{WRAPPER}}' ],
            [ 
$model->get_css_wrapper_selector() ]
        );
    }
}