PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / trunk
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript vtrunk
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
← All changes | inc/thirdparty/plugin/Elementor.php +47 -6 4.0.16trunk View file →
@@ -3,21 +3,62 @@
3 3 if (!defined('ABSPATH')) exit;
4 4
5 5 use BerqWP\BerqWP;
6 6
7 -class berqElementor extends berqIntegrations {
8 -
9 - function __construct() {
7 +class berqElementor extends berqIntegrations
8 +{
9 +
10 + function __construct()
11 + {
10 12 // add_action( 'elementor/editor/after_save', [$this, 'flush_page_cache'] );
13 +
14 + // post update
15 + add_action('updated_post_meta', [$this, 'cdn_purge_static_post'], 10, 4);
16 + add_action('added_post_meta', [$this, 'cdn_purge_static_post'], 10, 4);
17 +
18 + // elementor cache flush
19 + add_action('elementor/core/files/clear_cache', [$this, 'handle_flush_cache']);
11 20 }
12 21
13 - function flush_page_cache($post_id, $editor_data) {
22 + function detect() {
23 + return class_exists( '\Elementor\Plugin' );
24 + }
14 25
15 - $post_url = get_permalink( $post_id );
26 + function flush_page_cache($post_id, $editor_data)
27 + {
28 +
29 + $post_url = get_permalink($post_id);
16 30 berqCache::purge_page($post_url, true);
31 + }
17 32
33 + function handle_flush_cache() {
34 +
35 + if (!$this->detect()) {
36 + return;
37 + }
38 +
39 + berqCache::stale_cloud_assets();
18 40 }
19 41
42 + function cdn_purge_static_post($meta_id, $post_id, $meta_key, $meta_value)
43 + {
20 44
45 + if (!$this->detect()) {
46 + return;
47 + }
48 +
49 + if ('_elementor_css' !== $meta_key) {
50 + return;
51 + }
52 +
53 + if (!berqwp_can_use_cloud()) {
54 + return;
55 + }
56 +
57 + global $berq_log;
58 + $berq_log->info("Elementor regenerating css detected");
59 +
60 + berqCache::stale_cloud_assets();
61 + }
21 62 }
22 63
23 -new berqElementor();
64 +new berqElementor();