view = $view; $this->cache_path = $cache_path; } /** * Get our htaccess config template, with the dynamic values replaced. * * @throws FileNotFoundException If we can't find the view file. * @throws RuntimeException If we can't find the document root. * * @return string */ public function get(): string { $page_cache_dir = $this->cache_path->get_page_cache_dir(); // Get the RewriteBase. $home_root = parse_url( home_url() ); $base = trailingslashit( $home_root['path'] ?? '/' ); $root = swpsp_get_document_root(); // e.g. "wp-content/cache/solid-performance/page". $cache_path = str_replace( $root, '', $page_cache_dir ); $args = [ 'base' => $base, 'cache_path' => $cache_path, 'site_cache_path' => $this->cache_path->get_site_cache_dir(), 'extensions_regex' => sprintf( '%s|%s', Html::EXT, Gzip::EXT ), ]; return $this->view->render_to_string( self::VIEW, $args ); } }