Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
17.31% |
9 / 52 |
|
44.44% |
8 / 18 |
CRAP | |
0.00% |
0 / 1 |
| Super_Cache_Config_Compatibility | |
17.31% |
9 / 52 |
|
44.44% |
8 / 18 |
811.10 | |
0.00% |
0 / 1 |
| is_compatible | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
306 | |||
| include_supercache_config | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_mobile_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_late_init_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_rejected_cookies_configured | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_cache_restrictions_configured | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| is_preload_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_no_cache_for_get_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_save_headers_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_make_known_anon_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_dynamic_cache_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_clear_on_post_edit_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_front_page_checks_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_extra_pages_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| is_extra_acceptable_files_enabled | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| is_extra_rejected_uris_enabled | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| is_extra_rejected_user_agents_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_array_value_changed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\Jetpack_Boost\Lib; |
| 4 | |
| 5 | class Super_Cache_Config_Compatibility { |
| 6 | public static function is_compatible() { |
| 7 | if ( ! self::include_supercache_config() ) { |
| 8 | return true; |
| 9 | } |
| 10 | |
| 11 | if ( self::is_mobile_enabled() ) { |
| 12 | return false; |
| 13 | } |
| 14 | |
| 15 | if ( self::is_late_init_enabled() ) { |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | if ( self::is_rejected_cookies_configured() ) { |
| 20 | return false; |
| 21 | } |
| 22 | |
| 23 | if ( self::is_cache_restrictions_configured() ) { |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | if ( self::is_preload_enabled() ) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | if ( self::is_no_cache_for_get_enabled() ) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | if ( self::is_save_headers_enabled() ) { |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | if ( self::is_make_known_anon_enabled() ) { |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | if ( self::is_dynamic_cache_enabled() ) { |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | if ( self::is_clear_on_post_edit_enabled() ) { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | if ( self::is_front_page_checks_enabled() ) { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | if ( self::is_extra_pages_enabled() ) { |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | if ( self::is_extra_acceptable_files_enabled() ) { |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | if ( self::is_extra_rejected_uris_enabled() ) { |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | if ( self::is_extra_rejected_user_agents_enabled() ) { |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | private static function include_supercache_config() { |
| 75 | return include WPCACHECONFIGPATH . '/wp-cache-config.php'; |
| 76 | } |
| 77 | |
| 78 | private static function is_mobile_enabled() { |
| 79 | return ! empty( $GLOBALS['wp_cache_mobile_enabled'] ); |
| 80 | } |
| 81 | |
| 82 | private static function is_late_init_enabled() { |
| 83 | return ! empty( $GLOBALS['wp_super_cache_late_init'] ); |
| 84 | } |
| 85 | |
| 86 | private static function is_rejected_cookies_configured() { |
| 87 | return ! empty( $GLOBALS['wpsc_rejected_cookies'] ); |
| 88 | } |
| 89 | |
| 90 | private static function is_cache_restrictions_configured() { |
| 91 | return isset( $GLOBALS['wp_cache_not_logged_in'] ) && $GLOBALS['wp_cache_not_logged_in'] !== 2; |
| 92 | } |
| 93 | |
| 94 | private static function is_preload_enabled() { |
| 95 | return ! empty( $GLOBALS['wp_cache_preload_on'] ); |
| 96 | } |
| 97 | |
| 98 | private static function is_no_cache_for_get_enabled() { |
| 99 | return ! empty( $GLOBALS['wp_cache_no_cache_for_get'] ); |
| 100 | } |
| 101 | |
| 102 | private static function is_save_headers_enabled() { |
| 103 | return ! empty( $GLOBALS['wpsc_save_headers'] ); |
| 104 | } |
| 105 | |
| 106 | private static function is_make_known_anon_enabled() { |
| 107 | return ! empty( $GLOBALS['wp_cache_make_known_anon'] ); |
| 108 | } |
| 109 | |
| 110 | private static function is_dynamic_cache_enabled() { |
| 111 | return ! empty( $GLOBALS['wp_cache_mfunc_enabled'] ); |
| 112 | } |
| 113 | |
| 114 | private static function is_clear_on_post_edit_enabled() { |
| 115 | return ! empty( $GLOBALS['wp_cache_clear_on_post_edit'] ); |
| 116 | } |
| 117 | |
| 118 | private static function is_front_page_checks_enabled() { |
| 119 | return ! empty( $GLOBALS['wp_cache_front_page_checks'] ); |
| 120 | } |
| 121 | |
| 122 | private static function is_extra_pages_enabled() { |
| 123 | return is_array( $GLOBALS['wp_cache_pages'] ) && array_sum( $GLOBALS['wp_cache_pages'] ); |
| 124 | } |
| 125 | |
| 126 | private static function is_extra_acceptable_files_enabled() { |
| 127 | $default_cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' ); |
| 128 | return self::is_array_value_changed( $default_cache_acceptable_files, $GLOBALS['cache_acceptable_files'] ); |
| 129 | } |
| 130 | |
| 131 | private static function is_extra_rejected_uris_enabled() { |
| 132 | $default_cache_rejected_uri = array( 'wp-.*\\.php', 'index\\.php' ); |
| 133 | return self::is_array_value_changed( $default_cache_rejected_uri, $GLOBALS['cache_rejected_uri'] ); |
| 134 | } |
| 135 | |
| 136 | private static function is_extra_rejected_user_agents_enabled() { |
| 137 | return self::is_array_value_changed( array( '' ), $GLOBALS['cache_rejected_user_agent'] ); |
| 138 | } |
| 139 | |
| 140 | private static function is_array_value_changed( $default, $current ) { |
| 141 | return is_array( $current ) && array_diff( $current, $default ); |
| 142 | } |
| 143 | } |