lt; } else { return []; } } public static function getEscapeJson(array $data) { return htmlspecialchars(json_encode($data), ENT_QUOTES, 'UTF-8'); } /** * Replace url for multisite * * @param $string * * @return string */ public static function replaceMsUrl($string) { if( is_multisite() && BLOG_ID_CURRENT_SITE != get_current_blog_id() ) { return str_replace(get_site_url(BLOG_ID_CURRENT_SITE), get_site_url(get_current_blog_id()), $string); } return $string; } /* * Flushes as many page cache plugin's caches as possible. * * @return void */ public static function flushPageCache() { if( function_exists('wp_cache_clear_cache') ) { if( is_multisite() ) { $blog_id = get_current_blog_id(); wp_cache_clear_cache($blog_id); } else { wp_cache_clear_cache(); } } else if( has_action('cachify_flush_cache') ) { do_action('cachify_flush_cache'); } else if( function_exists('w3tc_pgcache_flush') ) { w3tc_pgcache_flush(); } else if( function_exists('wp_fast_cache_bulk_delete_all') ) { wp_fast_cache_bulk_delete_all(); } else if( class_exists('\WpFastestCache') ) { $wpfc = new \WpFastestCache(); $wpfc->deleteCache(); } else if( class_exists('c_ws_plugin__qcache_purging_routines') ) { \c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache } else if( class_exists('zencache') ) { \zencache::clear(); } else if( class_exists('comet_cache') ) { \comet_cache::clear(); } else if( class_exists('\WCL_Cache_Helpers') ) { \WCL_Cache_Helpers::deleteCache(); } else if( class_exists('\WpeCommon') ) { // WPEngine cache purge/flush methods to call by default $wpe_methods = [ 'purge_varnish_cache', ]; // More agressive clear/flush/purge behind a filter if( apply_filters('wbcr/factory/flush_wpengine_aggressive', false) ) { $wpe_methods = array_merge($wpe_methods, ['purge_memcached', 'clear_maxcdn_cache']); } // Filtering the entire list of WpeCommon methods to be called (for advanced usage + easier testing) $wpe_methods = apply_filters('wbcr/factory/wpengine_methods', $wpe_methods); foreach($wpe_methods as $wpe_method) { if( method_exists('WpeCommon', $wpe_method) ) { \WpeCommon::$wpe_method(); } } } else if( function_exists('sg_cachepress_purge_cache') ) { sg_cachepress_purge_cache(); } else if( file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache') ) { // fallback for WP-Super-Cache global $cache_path; if( is_multisite() ) { $blog_id = get_current_blog_id(); prune_super_cache(get_supercache_dir($blog_id), true); prune_super_cache($cache_path . 'blogs/', true); } else { prune_super_cache($cache_path . 'supercache/', true); prune_super_cache($cache_path, true); } } } }