@@ -822,7 +822,7 @@ function get_supercache_dir( $blog_id = 0 ) {
822822 return trailingslashit ( apply_filters ( 'wp_super_cache_supercachedir ' , $ cache_path . 'supercache/ ' . trailingslashit ( strtolower ( preg_replace ( '/:.*$/ ' , '' , str_replace ( 'http:// ' , '' , str_replace ( 'https:// ' , '' , $ home ) ) ) ) ) ) );
823823}
824824function get_current_url_supercache_dir ( $ post_id = 0 ) {
825- global $ cached_direct_pages , $ cache_path , $ wp_cache_request_uri , $ WPSC_HTTP_HOST , $ wp_cache_home_path ;
825+ global $ cached_direct_pages , $ cache_path , $ wp_cache_request_uri , $ WPSC_HTTP_HOST ;
826826 static $ saved_supercache_dir = array ();
827827
828828 if ( isset ( $ saved_supercache_dir [ $ post_id ] ) ) {
@@ -831,14 +831,14 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
831831
832832 $ DONOTREMEMBER = 0 ;
833833 if ( $ post_id != 0 ) {
834- $ site_url = site_url ();
834+ $ home_url = home_url ();
835835 $ permalink = get_permalink ( $ post_id );
836- if ( ! str_contains ( $ permalink , $ site_url ) ) {
836+ if ( ! str_contains ( $ permalink , $ home_url ) ) {
837837 /*
838- * Sometimes site_url doesn't return the siteurl . See https://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made
838+ * Sometimes home_url doesn't return the home url . See https://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made
839839 */
840840 $ DONOTREMEMBER = 1 ;
841- wp_cache_debug ( "get_current_url_supercache_dir: WARNING! site_url ( $ site_url ) not found in permalink ( $ permalink). " , 1 );
841+ wp_cache_debug ( "get_current_url_supercache_dir: WARNING! home_url ( $ home_url ) not found in permalink ( $ permalink). " , 1 );
842842 if ( preg_match ( '`^(https?:)?//([^/]+)(/.*)?$`i ' , $ permalink , $ matches ) ) {
843843 if ( $ WPSC_HTTP_HOST != $ matches [2 ] ) {
844844 wp_cache_debug ( "get_current_url_supercache_dir: WARNING! SERVER_NAME ( {$ WPSC_HTTP_HOST }) not found in permalink ( $ permalink). " , 1 );
@@ -853,10 +853,9 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
853853 $ uri = '' ;
854854 }
855855 } else {
856- $ uri = str_replace ( $ site_url , '' , $ permalink );
857- $ home_path = $ wp_cache_home_path ?? '' ;
858- if ( $ home_path !== '' && ! str_starts_with ( $ uri , $ home_path ) ) {
859- $ uri = rtrim ( $ home_path , '/ ' ) . $ uri ;
856+ $ uri = wp_parse_url ( $ permalink , PHP_URL_PATH );
857+ if ( ! is_string ( $ uri ) ) {
858+ $ uri = '' ;
860859 }
861860 }
862861 } else {
@@ -882,7 +881,7 @@ function ( $matches ) {
882881 $ dir = do_cacheaction ( 'supercache_dir ' , $ dir );
883882 }
884883 $ dir = $ cache_path . 'supercache/ ' . $ dir . '/ ' ;
885- if ( is_array ( $ cached_direct_pages ) && in_array ( $ _SERVER ['REQUEST_URI ' ], $ cached_direct_pages ) ) {
884+ if ( is_array ( $ cached_direct_pages ) && in_array ( $ _SERVER ['REQUEST_URI ' ], $ cached_direct_pages, true ) ) {
886885 $ dir = ABSPATH . $ uri . '/ ' ;
887886 }
888887 $ dir = str_replace ( '.. ' , '' , str_replace ( '// ' , '/ ' , $ dir ) );
0 commit comments