PluginProbe
Elementor Website Builder – more than just a page builder / 3.5.3
Elementor Website Builder – more than just a page builder v3.5.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / settings / base / css-manager.php

css-manager.php in Elementor Website Builder – more than just a page builder 3.5.3, at core/settings/base/css-manager.php

120 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Settings\Base;
4
5 use Elementor\Core\Files\CSS\Base as CSS_File;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly
9 }
10
11 abstract class CSS_Manager extends Manager {
12
13 /**
14 * Get CSS file name.
15 *
16 * Retrieve CSS file name for the settings base css manager.
17 *
18 * @since 2.8.0
19 * @access protected
20 * @abstract
21 *
22 * @return string CSS file name
23 */
24 abstract protected function get_css_file_name();
25
26 /**
27 * Get model for CSS file.
28 *
29 * Retrieve the model for the CSS file.
30 *
31 * @since 2.8.0
32 * @access protected
33 * @abstract
34 *
35 * @param CSS_File $css_file The requested CSS file.
36 *
37 * @return CSS_Model
38 *
39 */
40 abstract protected function get_model_for_css_file( CSS_File $css_file );
41
42 /**
43 * Get CSS file for update.
44 *
45 * Retrieve the CSS file before updating it.
46 *
47 * @since 2.8.0
48 * @access protected
49 * @abstract
50 *
51 * @param int $id Post ID.
52 *
53 * @return CSS_File
54 *
55 */
56 abstract protected function get_css_file_for_update( $id );
57
58 /**
59 * Settings base manager constructor.
60 *
61 * Initializing Elementor settings base css manager.
62 *
63 * @since 2.8.0
64 * @access public
65 */
66 public function __construct() {
67 parent::__construct();
68
69 $name = $this->get_css_file_name();
70
71 add_action( "elementor/css-file/{$name}/parse", [ $this, 'add_settings_css_rules' ] );
72 }
73
74 /**
75 * Save settings.
76 *
77 * Save settings to the database and update the CSS file.
78 *
79 * @since 2.8.0
80 * @access public
81 *
82 * @param array $settings Settings.
83 * @param int $id Optional. Post ID. Default is `0`.
84 */
85 public function save_settings( array $settings, $id = 0 ) {
86 parent::save_settings( $settings, $id );
87
88 $css_file = $this->get_css_file_for_update( $id );
89
90 if ( $css_file ) {
91 $css_file->update();
92 }
93 }
94
95 /**
96 * Add settings CSS rules.
97 *
98 * Add new CSS rules to the settings manager.
99 *
100 * Fired by `elementor/css-file/{$name}/parse` action.
101 *
102 * @since 2.8.0
103 * @access public
104 *
105 * @param CSS_File $css_file The requested CSS file.
106 *
107 */
108 public function add_settings_css_rules( CSS_File $css_file ) {
109 $model = $this->get_model_for_css_file( $css_file );
110
111 $css_file->add_controls_stack_style_rules(
112 $model,
113 $css_file->get_style_controls( $model, null, $model->get_settings() ),
114 $model->get_settings(),
115 [ '{{WRAPPER}}' ],
116 [ $model->get_css_wrapper_selector() ]
117 );
118 }
119 }
120