/** * Get folder paths to preserve languages when purging a domain * This function is required when the domains of languages (other than the default) are managed by subfolders * By default, when you clear the cache of the french website with the domain example.com, all subdirectory like /en/ and /de/ are deleted. * But, if you have a domain for your english and german websites with example.com/en/ and example.com/de/, you want to keep the /en/ and /de/ directory when the french domain is cleared. * * @since 2.0 * @deprecated 2.2 * @deprecated Use get_rocket_i18n_to_preserve() * */ function get_rocket_langs_to_preserve($current_lang) { _deprecated_function(__FUNCTION__, '2.2', 'get_rocket_i18n_to_preserve()'); return get_rocket_i18n_to_preserve($current_lang); }
/** * Remove all cache files of the domain * * @since 2.0 Delete domain cache files for all users * @since 1.0 * * @param string $lang (default: '') The language code * @return void */ function rocket_clean_domain($lang = '') { $urls = !$lang ? get_rocket_i18n_uri() : get_rocket_i18n_home_url($lang); $urls = (array) $urls; /** * Filter URLs to delete all caching files from a domain * * @since 2.6.4 * @param array URLs that will be returned * @param string The language code */ $urls = apply_filters('rocket_clean_domain_urls', $urls, $lang); $urls = array_filter($urls); foreach ($urls as $url) { list($host, $path) = get_rocket_parse_url($url); /** This filter is documented in inc/front/htaccess.php */ if (apply_filters('rocket_url_no_dots', false)) { $host = str_replace('.', '_', $host); } $root = WP_ROCKET_CACHE_PATH . $host . '*' . $path; /** * Fires before all cache files are deleted * * @since 1.0 * * @param string $root The path of home cache file * @param string $lang The current lang to purge */ do_action('before_rocket_clean_domain', $root, $lang); // Delete cache domain files if ($dirs = glob($root . '*', GLOB_NOSORT)) { foreach ($dirs as $dir) { rocket_rrmdir($dir, get_rocket_i18n_to_preserve($lang)); } } /** * Fires after all cache files was deleted * * @since 1.0 * * @param string $root The path of home cache file * @param string $lang The current lang to purge */ do_action('after_rocket_clean_domain', $root, $lang); } }