-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregenerate Elementor CSS
More file actions
42 lines (40 loc) · 1.25 KB
/
regenerate Elementor CSS
File metadata and controls
42 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function regenerate_elementor_css_button() {
global $wp_admin_bar;
$args = array(
'id' => 'regenerate_elementor_css',
'title' => 'Regenerate Elementor CSS',
'href' => '#',
'meta' => array(
'class' => 'regenerate-elementor-css',
),
);
$wp_admin_bar->add_node( $args );
}
add_action( 'admin_bar_menu', 'regenerate_elementor_css_button', 999 );
function regenerate_elementor_css_script() {
if ( is_admin() ) {
?>
<script>
jQuery(document).ready(function($) {
$('#wp-admin-bar-regenerate_elementor_css a').click(function() {
$.post(
ajaxurl,
{
action: 'elementor_css_regenerate'
},
function() {
alert('Elementor CSS regenerated successfully.');
}
);
});
});
</script>
<?php
}
}
add_action( 'admin_footer', 'regenerate_elementor_css_script' );
function regenerate_elementor_css_action() {
\Elementor\Plugin::$instance->files_manager->clear_cache();
wp_die();
}
add_action( 'wp_ajax_elementor_css_regenerate', 'regenerate_elementor_css_action' );