purge_url( $url ); } add_action( 'after_rocket_clean_home', 'rocket_clean_nginx_cache_home', 10, 2 ); /** * Clears NGINX cache for a specific URL when using "Purge this URL" from the admin bar on the front end * * @since 3.3.0.1 * @author Remy Perona * * @param string $url URL to purge. * @return void */ function rocket_clean_nginx_cache_url( $url ) { global $nginx_purger; if ( ! isset( $nginx_purger ) ) { return; } if ( ! isset( $_GET['type'], $_GET['_wpnonce'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } if ( false !== strpos( $url, 'index.html' ) ) { return; } if ( 'page' === substr( $url, -4 ) ) { return; } $url = str_replace( '*', '', $url ); $nginx_purger->purge_url( $url ); } add_action( 'after_rocket_clean_file', 'rocket_clean_nginx_cache_url' ); /** * Clean the NGINX cache using Nginx Helper after WP Rocket's cache is purged. * * @since 3.3.0.1 */ function rocket_clean_nginx_helper_cache() { if ( isset( $_GET['nginx_helper_action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } do_action( 'rt_nginx_helper_purge_all' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals } add_action( 'after_rocket_clean_domain', 'rocket_clean_nginx_helper_cache' ); /** * Clean the NGINX cache after the Used CSS has been generated. * * @since 3.12.3 */ add_action( 'rocket_rucss_after_clearing_usedcss', 'rocket_clean_nginx_cache_url' ); add_action( 'rocket_rucss_complete_job_status', 'rocket_clean_nginx_helper_cache' ); endif;