PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev4
Elementor Website Builder – more than just a page builder v3.35.0-dev4
4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 455 releases
← All changes | modules/atomic-widgets/styles/atomic-widget-styles.php +2 -65 4.3.1 → 3.35.0-dev4 View file →
@@ -4,9 +4,8 @@
4 4
5 5 use Elementor\Core\Base\Document;
6 6 use Elementor\Modules\AtomicWidgets\Utils\Utils;
7 7 use Elementor\Modules\GlobalClasses\Utils\Atomic_Elements_Utils;
8 -use Elementor\Utils as ElementorUtils;
9 8 use Elementor\Plugin;
10 9
11 10 class Atomic_Widget_Styles {
12 11 const STYLES_KEY = 'local';
@@ -31,46 +30,12 @@
31 30 add_action(
32 31 'deleted_post',
33 32 fn( $post_id ) => $this->invalidate_cache( [ $post_id ] )
34 33 );
35 -
36 - add_action(
37 - 'update_option__elementor_pro_license_v2_data',
38 - fn( $old_value, $new_value ) => $this->on_license_data_update( $old_value, $new_value ),
39 - 10,
40 - 2
41 - );
42 -
43 - add_action( 'delete_option__elementor_pro_license_v2_data', fn() => Plugin::$instance->files_manager->clear_cache() );
44 34 }
45 35
46 - /**
47 - * Pro stores the license under a transient-style wrapper whose `timeout` is recomputed on
48 - * every write, so a routine re-validation reports a changed option even when the license
49 - * itself is identical. Purging the whole CSS directory on those refreshes deletes files that
50 - * in-flight requests have already enqueued, so only act on a real license change.
51 - */
52 - private function on_license_data_update( $old_value, $new_value ): void {
53 - $old_payload = $this->get_license_payload( $old_value );
54 -
55 - // Anything we can't positively read as an unchanged license falls through to a purge.
56 - if ( null !== $old_payload && $old_payload === $this->get_license_payload( $new_value ) ) {
57 - return;
58 - }
59 -
60 - Plugin::$instance->files_manager->clear_cache();
61 - }
62 -
63 - private function get_license_payload( $option_value ): ?string {
64 - if ( ! is_array( $option_value ) || ! isset( $option_value['value'] ) || ! is_string( $option_value['value'] ) ) {
65 - return null;
66 - }
67 -
68 - return $option_value['value'];
69 - }
70 -
71 36 private function register_styles( Atomic_Styles_Manager $styles_manager, array $post_ids ) {
72 - $context = $this->get_context( Plugin::$instance->preview->is_editor_or_preview() );
37 + $context = $this->get_context( is_preview() );
73 38
74 39 foreach ( $post_ids as $post_id ) {
75 40 $get_styles = fn() => $this->parse_post_styles( $post_id );
76 41
@@ -84,9 +49,9 @@
84 49 Utils::traverse_post_elements( $post_id, function( $element_data ) use ( &$post_styles ) {
85 50 $post_styles = array_merge( $post_styles, $this->parse_element_style( $element_data ) );
86 51 } );
87 52
88 - return self::get_license_based_filtered_styles( $post_styles );
53 + return $post_styles;
89 54 }
90 55
91 56 private function parse_element_style( array $element_data ) {
92 57 $element_type = Atomic_Elements_Utils::get_element_type( $element_data );
@@ -119,34 +84,6 @@
119 84 }
120 85
121 86 private function get_context( bool $is_preview ) {
122 87 return $is_preview ? self::CONTEXT_PREVIEW : self::CONTEXT_FRONTEND;
123 - }
124 -
125 - public static function get_license_based_filtered_styles( $styles ) {
126 - if ( ElementorUtils::has_pro() && version_compare( ELEMENTOR_PRO_VERSION, '3.35', '<' ) ) {
127 - return $styles;
128 - }
129 -
130 - return apply_filters(
131 - 'elementor/atomic_widgets/editor_data/element_styles',
132 - self::remove_custom_css_from_styles( $styles ),
133 - $styles
134 - );
135 - }
136 -
137 - public static function remove_custom_css_from_styles( array $styles ) {
138 - if ( empty( $styles ) ) {
139 - return $styles;
140 - }
141 -
142 - foreach ( $styles as $style_id => $style ) {
143 - if ( isset( $style['variants'] ) && is_array( $style['variants'] ) ) {
144 - foreach ( $style['variants'] as $variant_index => $variant ) {
145 - unset( $styles[ $style_id ]['variants'][ $variant_index ]['custom_css'] );
146 - }
147 - }
148 - }
149 -
150 - return $styles;
151 88 }
152 89 }