← All changes
|
modules/atomic-widgets/styles/atomic-widget-styles.php
+2
-34
4.2.1
→
3.35.0-dev2
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,15 +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( 'update_option__elementor_pro_license_v2_data', fn() => Plugin::$instance->files_manager->clear_cache() ); | |
| 37 | - add_action( 'delete_option__elementor_pro_license_v2_data', fn() => Plugin::$instance->files_manager->clear_cache() ); | |
| 38 | 34 | } |
| 39 | 35 | |
| 40 | 36 | private function register_styles( Atomic_Styles_Manager $styles_manager, array $post_ids ) { |
| 41 | - $context = $this->get_context( Plugin::$instance->preview->is_editor_or_preview() ); | |
| 37 | + $context = $this->get_context( is_preview() ); | |
| 42 | 38 | |
| 43 | 39 | foreach ( $post_ids as $post_id ) { |
| 44 | 40 | $get_styles = fn() => $this->parse_post_styles( $post_id ); |
| 45 | 41 | |
| @@ -53,9 +49,9 @@ | ||
| 53 | 49 | Utils::traverse_post_elements( $post_id, function( $element_data ) use ( &$post_styles ) { |
| 54 | 50 | $post_styles = array_merge( $post_styles, $this->parse_element_style( $element_data ) ); |
| 55 | 51 | } ); |
| 56 | 52 | |
| 57 | - return self::get_license_based_filtered_styles( $post_styles ); | |
| 53 | + return $post_styles; | |
| 58 | 54 | } |
| 59 | 55 | |
| 60 | 56 | private function parse_element_style( array $element_data ) { |
| 61 | 57 | $element_type = Atomic_Elements_Utils::get_element_type( $element_data ); |
| @@ -88,34 +84,6 @@ | ||
| 88 | 84 | } |
| 89 | 85 | |
| 90 | 86 | private function get_context( bool $is_preview ) { |
| 91 | 87 | return $is_preview ? self::CONTEXT_PREVIEW : self::CONTEXT_FRONTEND; |
| 92 | - } | |
| 93 | - | |
| 94 | - public static function get_license_based_filtered_styles( $styles ) { | |
| 95 | - if ( ElementorUtils::has_pro() && version_compare( ELEMENTOR_PRO_VERSION, '3.35', '<' ) ) { | |
| 96 | - return $styles; | |
| 97 | - } | |
| 98 | - | |
| 99 | - return apply_filters( | |
| 100 | - 'elementor/atomic_widgets/editor_data/element_styles', | |
| 101 | - self::remove_custom_css_from_styles( $styles ), | |
| 102 | - $styles | |
| 103 | - ); | |
| 104 | - } | |
| 105 | - | |
| 106 | - public static function remove_custom_css_from_styles( array $styles ) { | |
| 107 | - if ( empty( $styles ) ) { | |
| 108 | - return $styles; | |
| 109 | - } | |
| 110 | - | |
| 111 | - foreach ( $styles as $style_id => $style ) { | |
| 112 | - if ( isset( $style['variants'] ) && is_array( $style['variants'] ) ) { | |
| 113 | - foreach ( $style['variants'] as $variant_index => $variant ) { | |
| 114 | - unset( $styles[ $style_id ]['variants'][ $variant_index ]['custom_css'] ); | |
| 115 | - } | |
| 116 | - } | |
| 117 | - } | |
| 118 | - | |
| 119 | - return $styles; | |
| 120 | 88 | } |
| 121 | 89 | } |