PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.0-dev4
Elementor Website Builder – more than just a page builder v3.29.0-dev4
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 / modules / global-classes / global-classes-css.php

global-classes-css.php in Elementor Website Builder – more than just a page builder 3.29.0-dev4, at modules/global-classes/global-classes-css.php

66 lines 1.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\Modules\GlobalClasses;
4
5 use Elementor\Plugin;
6
7 class Global_Classes_CSS {
8 public function register_hooks() {
9 add_action(
10 'elementor/frontend/after_enqueue_styles',
11 fn() => $this->enqueue_styles()
12 );
13
14 add_action(
15 'elementor/global_classes/update',
16 fn( $context ) => $this->clear_css_cache( $context )
17 );
18
19 add_action(
20 'elementor/core/files/clear_cache',
21 fn() => $this->clear_css_cache( Global_Classes_Repository::CONTEXT_FRONTEND )
22 );
23
24 add_action(
25 'deleted_post',
26 fn( $post_id ) => $this->on_post_delete( $post_id )
27 );
28
29 add_action(
30 'elementor/core/files/after_generate_css',
31 fn() => $this->generate_styles()
32 );
33 }
34
35 private function enqueue_styles() {
36 $css_file = is_preview()
37 ? new Global_Classes_CSS_Preview()
38 : new Global_Classes_CSS_File();
39
40 $css_file->enqueue();
41 }
42
43 private function generate_styles() {
44 ( new Global_Classes_CSS_File() )->update();
45 }
46
47 private function on_post_delete( $post_id ) {
48 if ( ! Plugin::$instance->kits_manager->is_kit( $post_id ) ) {
49 return;
50 }
51
52 $this->clear_css_cache(
53 Global_Classes_Repository::CONTEXT_FRONTEND,
54 $post_id
55 );
56 }
57
58 private function clear_css_cache( string $context, $kit_id = null ): void {
59 ( new Global_Classes_CSS_Preview( $kit_id ) )->delete();
60
61 if ( Global_Classes_Repository::CONTEXT_FRONTEND === $context ) {
62 ( new Global_Classes_CSS_File( $kit_id ) )->delete();
63 }
64 }
65 }
66