-
Notifications
You must be signed in to change notification settings - Fork 210
/
avada.php
82 lines (71 loc) · 2.41 KB
/
avada.php
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
$current_theme = wp_get_theme();
if ( 'Avada' === $current_theme->get( 'Name' ) ) {
// When Avada theme purge its own cache.
add_action( 'avada_clear_dynamic_css_cache', 'rocket_clean_domain' );
/**
* Conflict with Avada theme and WP Rocket CDN
*
* @since 2.6.1
*
* @param array $vars An array of variables.
* @param string $handle Name of the avada resource.
* @return array updated array of variables
*/
function rocket_fix_cdn_for_avada_theme( $vars, $handle ) {
if ( 'avada-dynamic' === $handle && get_rocket_option( 'cdn' ) ) {
$src = get_rocket_cdn_url( get_template_directory_uri() . '/assets/less/theme/dynamic.less' );
$vars['template-directory'] = sprintf( '~"%s"', dirname( dirname( dirname( dirname( $src ) ) ) ) );
$vars['lessurl'] = sprintf( '~"%s"', dirname( $src ) );
}
return $vars;
}
add_filter( 'less_vars', 'rocket_fix_cdn_for_avada_theme', 11, 2 );
/**
* Exclude fusion styles from cache busting to prevent cache dir issues
*
* @author Remy Perona
*
* @param array $excluded_files An array of excluded files.
* @return array
*/
function rocket_exclude_avada_dynamic_css( $excluded_files ) {
$upload_dir = wp_upload_dir();
$excluded_files[] = rocket_clean_exclude_file( $upload_dir['baseurl'] . '/fusion-styles/(.*)' );
return $excluded_files;
}
add_filter( 'rocket_exclude_cache_busting', 'rocket_exclude_avada_dynamic_css' );
/**
* Deactivate WP Rocket lazyload if Avada lazyload is enabled
*
* @since 3.3.4
* @author Remy Perona
*
* @param string $old_value Previous Avada option value.
* @param string $value New Avada option value.
* @return void
*/
function rocket_avada_maybe_deactivate_lazyload( $old_value, $value ) {
if ( empty( $old_value['lazy_load'] ) && ! empty( $value['lazy_load'] ) ) {
update_rocket_option( 'lazyload', 0 );
}
}
add_action( 'update_option_avada_theme_options', 'rocket_avada_maybe_deactivate_lazyload', 10, 2 );
}
/**
* Disable WP Rocket lazyload field if Avada lazyload is enabled
*
* @since 3.3.4
* @author Remy Perona
*
* @return bool
*/
function rocket_avada_maybe_disable_lazyload() {
$avada_options = get_option( 'avada_theme_options' );
$current_theme = wp_get_theme();
if ( 'Avada' === $current_theme->get( 'Name' ) && ! empty( $avada_options['lazy_load'] ) ) {
return true;
}
return false;
}