get_current_url_supercache_dir()
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
get_current_url_supercache_dir( $post_id );
- $post_id **
- -
Код get_current_url_supercache_dir() get current url supercache dir WPSCache 1.12.4
function get_current_url_supercache_dir( $post_id = 0 ) { global $cached_direct_pages, $cache_path, $wp_cache_request_uri, $WPSC_HTTP_HOST, $wp_cache_home_path; static $saved_supercache_dir = array(); if ( isset( $saved_supercache_dir[ $post_id ] ) ) { return $saved_supercache_dir[ $post_id ]; } $DONOTREMEMBER = 0; if ( $post_id != 0 ) { $site_url = site_url(); $permalink = get_permalink( $post_id ); if ( ! str_contains( $permalink, $site_url ) ) { /* * Sometimes site_url doesn't return the siteurl. See https://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made */ $DONOTREMEMBER = 1; wp_cache_debug( "get_current_url_supercache_dir: WARNING! site_url ($site_url) not found in permalink ($permalink).", 1 ); if ( preg_match( '`^(https?:)?//([^/]+)(/.*)?$`i', $permalink, $matches ) ) { if ( $WPSC_HTTP_HOST != $matches[2] ) { wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink).", 1 ); } wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$matches[2]}) from permalink ($permalink). Is the url right?", 1 ); $uri = isset( $matches[3] ) ? $matches[3] : ''; } elseif ( preg_match( '`^/([^/]+)(/.*)?$`i', $permalink, $matches ) ) { wp_cache_debug( "get_current_url_supercache_dir: WARNING! Permalink ($permalink) looks as absolute path. Is the url right?", 1 ); $uri = $permalink; } else { wp_cache_debug( "get_current_url_supercache_dir: WARNING! Permalink ($permalink) could not be understood by parsing url. Using front page.", 1 ); $uri = ''; } } else { $uri = str_replace( $site_url, '', $permalink ); if ( ! str_starts_with( $uri, $wp_cache_home_path ) ) { $uri = rtrim( $wp_cache_home_path, '/' ) . $uri; } } } else { $uri = strtolower( $wp_cache_request_uri ); $uri = preg_replace_callback( '/%[a-f0-9]{2}/', function ( $matches ) { return strtoupper( $matches[0] ); }, $uri ); } $uri = wpsc_deep_replace( array( '..', '\\', 'index.php' ), preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', preg_replace( '/(\?.*)?(#.*)?$/', '', $uri ) ) ); $hostname = $WPSC_HTTP_HOST; // Get hostname from wp options for wp-cron, wp-cli and similar requests. if ( empty( $hostname ) && function_exists( 'get_option' ) ) { $hostname = (string) parse_url( get_option( 'home' ), PHP_URL_HOST ); } $dir = preg_replace( '/:.*$/', '', $hostname ) . $uri; // To avoid XSS attacks if ( function_exists( 'apply_filters' ) ) { $dir = apply_filters( 'supercache_dir', $dir ); } else { $dir = do_cacheaction( 'supercache_dir', $dir ); } $dir = $cache_path . 'supercache/' . $dir . '/'; if ( is_array( $cached_direct_pages ) && in_array( $_SERVER['REQUEST_URI'], $cached_direct_pages ) ) { $dir = ABSPATH . $uri . '/'; } $dir = str_replace( '..', '', str_replace( '//', '/', $dir ) ); wp_cache_debug( "supercache dir: $dir", 5 ); if ( $DONOTREMEMBER == 0 ) { $saved_supercache_dir[ $post_id ] = $dir; } return $dir; }