purgeAllCaches(); } /** * Returns the path of URLs. * * @param array|string $urls Urls we want to get paths. * @return array the path. */ private function get_paths( $urls ) { if ( ! is_array( $urls ) ) { $urls = (array) $urls; } $paths = []; foreach ( $urls as $url ) { $parsed_url = get_rocket_parse_url( $url ); $paths[] = $parsed_url['path']; } return $paths; } /** * Purge the cache of Pressidium from paths. * * @param array $paths Paths of pages we are going to purge cache. * * @return void */ private function purge_cache( $paths ) { NinukisCaching::get_instance()->purge_cache( $paths ); } /** * Purge the cache for the given URL. * * @param string|array $url URL we want to purge. * * @return void */ public function purge_url( $url ) { $paths = $this->get_paths( $url ); $this->purge_cache( $paths ); } /** * Clean cache of post. * * @param WP_Post $post Post that need to be cleaned. * @param array $purge_urls URLs that need to be purged. * * @return void */ public function clean_post( $post, $purge_urls ) { // Purge related urls. $paths = $this->get_paths( $purge_urls ); $this->purge_cache( $paths ); } }