PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.2
Elementor Website Builder – more than just a page builder v3.0.2
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
← All changes | core/files/css/post.php +7 -83 4.2.23.0.2 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2 namespace Elementor\Core\Files\CSS;
3 3
4 +use Elementor\Base_Data_Control;
5 +use Elementor\Control_Repeater;
4 6 use Elementor\Controls_Stack;
5 -use Elementor\Core\DynamicTags\Dynamic_CSS;
6 -use Elementor\Core\Kits\Manager;
7 7 use Elementor\Element_Base;
8 8 use Elementor\Plugin;
9 9
10 10 if ( ! defined( 'ABSPATH' ) ) {
@@ -191,11 +191,9 @@
191 191 * @since 1.2.2
192 192 * @access public
193 193 */
194 194 public function enqueue() {
195 - $document = Plugin::$instance->documents->get( $this->post_id );
196 -
197 - if ( ! $document || ! $document->is_built_with_elementor() ) {
195 + if ( ! Plugin::$instance->db->is_built_with_elementor( $this->post_id ) ) {
198 196 return;
199 197 }
200 198
201 199 parent::enqueue();
@@ -217,9 +215,9 @@
217 215 * @param array $placeholders Placeholders.
218 216 * @param array $replacements Replacements.
219 217 * @param array $all_controls All controls.
220 218 */
221 - public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, ?array $all_controls = null ) {
219 + public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) {
222 220 parent::add_controls_stack_style_rules( $controls_stack, $controls, $values, $placeholders, $replacements, $all_controls );
223 221
224 222 if ( $controls_stack instanceof Element_Base ) {
225 223 foreach ( $controls_stack->get_children() as $child_element ) {
@@ -292,11 +290,12 @@
292 290 * @param Element_Base $element The element.
293 291 */
294 292 do_action( 'elementor/element/before_parse_css', $this, $element );
295 293
296 - $this->render_element_global_styles( $element );
297 - $this->render_element_styles( $element );
294 + $element_settings = $element->get_settings();
298 295
296 + $this->add_controls_stack_style_rules( $element, $this->get_style_controls( $element, null, $element->get_parsed_dynamic_settings() ), $element_settings, [ '{{ID}}', '{{WRAPPER}}' ], [ $element->get_id(), $this->get_element_unique_selector( $element ) ] );
297 +
299 298 /**
300 299 * After element parse CSS.
301 300 *
302 301 * Fires after the CSS of the element is parsed.
@@ -306,81 +305,6 @@
306 305 * @param Post $this The post CSS file.
307 306 * @param Element_Base $element The element.
308 307 */
309 308 do_action( 'elementor/element/parse_css', $this, $element );
310 - }
311 -
312 - private function render_element_styles( Element_Base $element ) {
313 - $this->add_controls_stack_style_rules(
314 - $element,
315 - $this->get_style_controls( $element, null, $element->get_parsed_dynamic_settings() ),
316 - $element->get_settings(),
317 - [ '{{ID}}', '{{WRAPPER}}' ],
318 - [ $element->get_id(), $this->get_element_unique_selector( $element ) ]
319 - );
320 - }
321 -
322 - private function render_element_global_styles( Element_Base $element ) {
323 - if ( $this instanceof Dynamic_CSS ) {
324 - return;
325 - }
326 -
327 - /** @var Manager $module */
328 - $kits_manager = Plugin::$instance->kits_manager;
329 - $custom_colors_enabled = $kits_manager->is_custom_colors_enabled();
330 - $custom_typography_enabled = $kits_manager->is_custom_typography_enabled();
331 -
332 - $controls = $element->get_controls();
333 - $global_controls = [];
334 - $global_values['__globals__'] = [];
335 -
336 - foreach ( $controls as $control ) {
337 - $this->build_global_controls_and_values(
338 - $control,
339 - $controls,
340 - $global_controls,
341 - $global_values,
342 - $custom_colors_enabled,
343 - $custom_typography_enabled
344 - );
345 - }
346 -
347 - foreach ( $global_controls as $control ) {
348 - $this->add_control_rules(
349 - $control,
350 - $controls,
351 - function( $control ) {},
352 - [ '{{WRAPPER}}' ],
353 - [ '.elementor-widget-' . $element->get_name() ],
354 - $global_values
355 - );
356 - }
357 - }
358 -
359 - private function build_global_controls_and_values( $control, $controls, &$global_controls, &$global_values, $custom_colors_enabled, $custom_typography_enabled ) {
360 - $is_color_control = 'color' === $control['type'];
361 - $is_typography_control = isset( $control['groupType'] ) && 'typography' === $control['groupType'];
362 -
363 - // If it is a color/typography control and default colors/typography are disabled,
364 - // don't add the default CSS.
365 - if ( ( $is_color_control && ! $custom_colors_enabled ) || ( $is_typography_control && ! $custom_typography_enabled ) ) {
366 - return;
367 - }
368 -
369 - $global_control = $control;
370 -
371 - // Handle group controls that don't have a default global property.
372 - if ( ! empty( $control['groupType'] ) ) {
373 - $global_control = $controls[ $control['groupPrefix'] . $control['groupType'] ];
374 - }
375 -
376 - // If the control has a default global defined, add it to the globals array
377 - // that is used in add_control_rules.
378 - if ( ! empty( $control['global']['default'] ) ) {
379 - $global_values['__globals__'][ $control['name'] ] = $global_control['global']['default'];
380 - }
381 -
382 - if ( ! empty( $global_control['global']['default'] ) ) {
383 - $global_controls[] = $control;
384 - }
385 309 }
386 310 }