| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
add_action( 'admin_notices', 'powered_cache_flash_messages' ); |
| 8 |
|
| 9 |
/** |
| 10 |
* Display flash messages |
| 11 |
* |
| 12 |
* @since 1.0 |
| 13 |
*/ |
| 14 |
function powered_cache_flash_messages() { |
| 15 |
Powered_Cache_Admin_Helper::get_flash_message(); |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
add_action( 'admin_notices', 'powered_cache_plugin_compatability_notices' ); |
| 20 |
|
| 21 |
/** |
| 22 |
* Display incompatible plugins |
| 23 |
* |
| 24 |
* @since 1.0 |
| 25 |
*/ |
| 26 |
function powered_cache_plugin_compatability_notices() { |
| 27 |
|
| 28 |
$plugins = array( |
| 29 |
'w3-total-cache' => 'w3-total-cache/w3-total-cache.php', |
| 30 |
'wp-super-cache' => 'wp-super-cache/wp-cache.php', |
| 31 |
'quick-cache' => 'quick-cache/quick-cache.php', |
| 32 |
'hyper-cache' => 'hyper-cache/plugin.php', |
| 33 |
'hyper-cache-extended' => 'hyper-cache-extended/plugin.php', |
| 34 |
'wp-fast-cache' => 'wp-fast-cache/wp-fast-cache.php', |
| 35 |
'flexicache' => 'flexicache/wp-plugin.php', |
| 36 |
'wp-fastest-cache' => 'wp-fastest-cache/wpFastestCache.php', |
| 37 |
'lite-cache' => 'lite-cache/plugin.php', |
| 38 |
'gator-cache' => 'gator-cache/gator-cache.php', |
| 39 |
'wp-http-compression' => 'wp-http-compression/wp-http-compression.php', |
| 40 |
'wordpress-gzip-compression' => 'wordpress-gzip-compression/ezgz.php', |
| 41 |
'gzip-ninja-speed-compression' => 'gzip-ninja-speed-compression/gzip-ninja-speed.php', |
| 42 |
'speed-booster-pack' => 'speed-booster-pack/speed-booster-pack.php', |
| 43 |
'wp-performance-score-booster' => 'wp-performance-score-booster/wp-performance-score-booster.php', |
| 44 |
'remove-query-strings-from-static-resources' => 'remove-query-strings-from-static-resources/remove-query-strings.php', |
| 45 |
'query-strings-remover' => 'query-strings-remover/query-strings-remover.php', |
| 46 |
'wp-ffpc' => 'wp-ffpc/wp-ffpc.php', |
| 47 |
'far-future-expiry-header' => 'far-future-expiry-header/far-future-expiration.php', |
| 48 |
'combine-css' => 'combine-css/combine-css.php', |
| 49 |
'super-static-cache' => 'super-static-cache/super-static-cache.php', |
| 50 |
'wpcompressor' => 'wpcompressor/wpcompressor.php', |
| 51 |
'check-and-enable-gzip-compression' => 'check-and-enable-gzip-compression/richards-toolbox.php', |
| 52 |
'leverage-browser-caching-ninjas' => 'leverage-browser-caching-ninjas/leverage-browser-caching-ninja.php', |
| 53 |
'force-gzip' => 'force-gzip/force-gzip.php' |
| 54 |
); |
| 55 |
|
| 56 |
|
| 57 |
$plugins = array_filter( $plugins, 'is_plugin_active' ); |
| 58 |
|
| 59 |
if ( count( $plugins ) > 0 && current_user_can( apply_filters( 'powered_cache_cap', 'manage_options' ) ) ) { ?> |
| 60 |
<div class="error"> |
| 61 |
<h2><?php _e( 'Powered Cache', 'powered-cache' ); ?></h2> |
| 62 |
|
| 63 |
<p><?php printf( __( 'The following plugins are not compatible with <b>%s</b> and will cause unintended results:', 'powered-cache' ), __( 'Powered Cache', 'powered-cache' ) ); ?></p> |
| 64 |
<ul class="incompatible-plugin-list"> |
| 65 |
<?php |
| 66 |
foreach ( $plugins as $plugin ) { |
| 67 |
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin ); |
| 68 |
echo '<li>' . $plugin_data['Name'] . '</span> <a href="' . wp_nonce_url( admin_url( 'admin-post.php?action=deactivate_plugin&plugin=' . urlencode( $plugin ) ), 'deactivate_plugin' ) . '" class="button-secondary">' . __( 'Deactivate', 'powered-cache' ) . '</a></li>'; |
| 69 |
} |
| 70 |
?> |
| 71 |
</ul> |
| 72 |
</div> |
| 73 |
<?php |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
add_action( 'admin_notices', 'powered_cache_advanced_cache_notices' ); |
| 78 |
|
| 79 |
/** |
| 80 |
* Show notices about page cache |
| 81 |
* |
| 82 |
* @since 1.0 |
| 83 |
*/ |
| 84 |
function powered_cache_advanced_cache_notices() { |
| 85 |
|
| 86 |
if ( powered_cache_is_saving_options() ) { |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
if ( true !== powered_cache_get_option( 'enable_page_caching' ) ) { |
| 91 |
return; |
| 92 |
} |
| 93 |
|
| 94 |
$err = array(); |
| 95 |
|
| 96 |
if ( ! defined( 'WP_CACHE' ) || true !== WP_CACHE ) { |
| 97 |
$err['wp_cache'] = sprintf( __( '<code>%s</code> is not in wp-config.php.', 'powered-cache' ), 'define("WP_CACHE", true);' ); |
| 98 |
} |
| 99 |
|
| 100 |
if ( ! defined( 'POWERED_CACHE_PAGE_CACHING' ) || true !== POWERED_CACHE_PAGE_CACHING ) { |
| 101 |
$err['powered_cache_page_cache'] = sprintf( __( '<code>%s</code> file was edited or deleted. You can re-create correct configuration files by saving settings.', 'powered-cache' ), basename( WP_CONTENT_DIR ) . '/advanced-cache.php' ); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
if ( defined( 'POWERED_CACHE_PAGE_CACHING_HAS_PROBLEM' ) && true === POWERED_CACHE_PAGE_CACHING_HAS_PROBLEM ) { |
| 106 |
$err['powered_cache_page_cache_has_problem'] = sprintf( __( 'Powered Cache could not access dropin. Please check <code>%s</code> exist and accessible on your server.', 'powered-cache' ), POWERED_CACHE_DROPIN_DIR . 'page-cache.php' ); |
| 107 |
} |
| 108 |
|
| 109 |
// everything ok |
| 110 |
if ( empty( $err ) ) { |
| 111 |
return; |
| 112 |
} |
| 113 |
|
| 114 |
?> |
| 115 |
<div class="error"> |
| 116 |
<h2><?php _e( 'Powered Cache', 'powered-cache' ); ?></h2> |
| 117 |
<strong><?php echo __( 'Page Caching feature could not work because:', 'powered-cache' ); ?></strong> |
| 118 |
|
| 119 |
<?php foreach ( $err as $error_msg ): ?> |
| 120 |
<p><?php echo $error_msg; ?></p> |
| 121 |
<?php endforeach; ?> |
| 122 |
</div> |
| 123 |
<?php |
| 124 |
|
| 125 |
|
| 126 |
} |
| 127 |
|
| 128 |
add_action( 'admin_notices', 'powered_cache_object_cache_notices' ); |
| 129 |
|
| 130 |
/** |
| 131 |
* Display object cache broken msg |
| 132 |
* |
| 133 |
* @since 1.0 |
| 134 |
*/ |
| 135 |
function powered_cache_object_cache_notices() { |
| 136 |
if ( defined( 'POWERED_OBJECT_CACHE_HAS_PROBLEM' ) && true === POWERED_OBJECT_CACHE_HAS_PROBLEM ) { |
| 137 |
$object_caches = Powered_Cache_Admin_Helper::object_cache_dropins(); |
| 138 |
$broken_file = untrailingslashit( WP_CONTENT_DIR ) . '/object-cache.php'; |
| 139 |
if ( isset( $object_caches[ powered_cache_get_option( 'object_cache' ) ] ) ) { |
| 140 |
$broken_file = $object_caches[ powered_cache_get_option( 'object_cache' ) ]; |
| 141 |
} |
| 142 |
|
| 143 |
$message = sprintf( __( 'Powered Cache could not access object cache backend. Please check <code>%s</code> exist and accessible on your server.', 'powered-cache' ), $broken_file ); |
| 144 |
?> |
| 145 |
<div class="error"> |
| 146 |
<p><strong><?php echo __( 'Powered Cache:', 'powered-cache' ); ?></strong> |
| 147 |
<?php echo $message; ?> |
| 148 |
</p> |
| 149 |
</div> |
| 150 |
<?php |
| 151 |
} |
| 152 |
} |
| 153 |
|