wpsc_get_htaccess_info() │ WPSCache 1.0
Хуки из функции
Возвращает
null
. Ничего.
Использование
wpsc_get_htaccess_info();
Код wpsc_get_htaccess_info() wpsc get htaccess info WPSCache 1.8
function wpsc_get_htaccess_info() { global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_disable_utf8; global $htaccess_path; if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) { $document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; $apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; } else { $document_root = $_SERVER[ "DOCUMENT_ROOT" ]; $apache_root = '%{DOCUMENT_ROOT}'; } $content_dir_root = $document_root; if ( strpos( $document_root, '/kunden/homepages/' ) === 0 ) { // https://wordpress.org/support/topic/plugin-wp-super-cache-how-to-get-mod_rewrite-working-on-1and1-shared-hosting?replies=1 // On 1and1, PHP's directory structure starts with '/homepages'. The // Apache directory structure has an extra '/kunden' before it. // Also 1and1 does not support the %{DOCUMENT_ROOT} variable in // .htaccess files. // This prevents the $inst_root from being calculated correctly and // means that the $apache_root is wrong. // // e.g. This is an example of how Apache and PHP see the directory // structure on 1and1: // Apache: /kunden/homepages/xx/dxxxxxxxx/htdocs/site1/index.html // PHP: /homepages/xx/dxxxxxxxx/htdocs/site1/index.html // Here we fix up the paths to make mode_rewrite work on 1and1 shared hosting. $content_dir_root = substr( $content_dir_root, 7 ); $apache_root = $document_root; } $home_path = get_home_path(); $home_root = parse_url(get_bloginfo('url')); $home_root = isset( $home_root[ 'path' ] ) ? trailingslashit( $home_root[ 'path' ] ) : '/'; if ( isset( $htaccess_path ) ) { $home_path = $htaccess_path; } elseif ( $home_root == '/' && $home_path != $_SERVER[ 'DOCUMENT_ROOT' ] ) { $home_path = $_SERVER[ 'DOCUMENT_ROOT' ]; } elseif ( $home_root != '/' && $home_path != str_replace( '//', '/', $_SERVER[ 'DOCUMENT_ROOT' ] . $home_root ) && is_dir( $_SERVER[ 'DOCUMENT_ROOT' ] . $home_root ) ) { $home_path = str_replace( '//', '/', $_SERVER[ 'DOCUMENT_ROOT' ] . $home_root ); } $home_path = trailingslashit( $home_path ); $home_root_lc = str_replace( '//', '/', strtolower( $home_root ) ); $inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $content_dir_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) ); $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) ); $wprules = str_replace( "RewriteEngine On\n", '', $wprules ); $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules ); $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ); if( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$"; $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$"; } $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST"; $condition_rules[] = "RewriteCond %{QUERY_STRING} ^$"; $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . wpsc_get_extra_cookies() . "|wp-postpass_).*$"; $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]"; $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]"; if ( $wp_cache_mobile_enabled ) { if ( isset( $wp_cache_mobile_browsers ) && "" != $wp_cache_mobile_browsers ) $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) . ").* [NC]"; if ( isset( $wp_cache_mobile_prefixes ) && "" != $wp_cache_mobile_prefixes ) $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^(" . addcslashes( str_replace( ', ', '|', $wp_cache_mobile_prefixes ), ' ' ) . ").* [NC]"; } $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules ); $rules = "<IfModule mod_rewrite.c>\n"; $rules .= "RewriteEngine On\n"; $rules .= "RewriteBase $home_root\n"; // props Chris Messina $rules .= "#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible\n"; if ( isset( $wp_cache_disable_utf8 ) == false || $wp_cache_disable_utf8 == 0 ) { $charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset'); $rules .= "AddDefaultCharset {$charset}\n"; } $rules .= "CONDITION_RULES"; $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n"; $rules .= "RewriteCond %{HTTPS} on\n"; $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html.gz -f\n"; $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html.gz\" [L]\n\n"; $rules .= "CONDITION_RULES"; $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n"; $rules .= "RewriteCond %{HTTPS} !on\n"; $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html.gz -f\n"; $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html.gz\" [L]\n\n"; $rules .= "CONDITION_RULES"; $rules .= "RewriteCond %{HTTPS} on\n"; $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html -f\n"; $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html\" [L]\n\n"; $rules .= "CONDITION_RULES"; $rules .= "RewriteCond %{HTTPS} !on\n"; $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html -f\n"; $rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html\" [L]\n"; $rules .= "</IfModule>\n"; $rules = apply_filters( 'supercacherewriterules', $rules ); $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules ); $gziprules = "<IfModule mod_mime.c>\n <FilesMatch \"\\.html\\.gz\$\">\n ForceType text/html\n FileETag None\n </FilesMatch>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n"; $gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n"; $vary_header = $cache_control_header = ''; if ( defined( 'WPSC_VARY_HEADER' ) ) { if ( WPSC_VARY_HEADER != '' ) { $vary_header = WPSC_VARY_HEADER; } } else { $vary_header = 'Accept-Encoding, Cookie'; } if ( defined( 'WPSC_CACHE_CONTROL_HEADER' ) ) { if ( WPSC_CACHE_CONTROL_HEADER != '' ) { $cache_control_header = WPSC_CACHE_CONTROL_HEADER; } } else { $cache_control_header = 'max-age=3, must-revalidate'; } $headers_text = ""; if ( $vary_header != '' ) { $headers_text .= " Header set Vary '$vary_header'\n"; } if ( $cache_control_header != '' ) { $headers_text .= " Header set Cache-Control '$cache_control_header'\n"; } if ( $headers_text != '' ) { $gziprules .= "<IfModule mod_headers.c>\n$headers_text</IfModule>\n"; } $gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A3\n</IfModule>\n"; $gziprules .= "Options -Indexes\n"; return array( "document_root" => $document_root, "apache_root" => $apache_root, "home_path" => $home_path, "home_root" => $home_root, "home_root_lc" => $home_root_lc, "inst_root" => $inst_root, "wprules" => $wprules, "scrules" => $scrules, "condition_rules" => $condition_rules, "rules" => $rules, "gziprules" => $gziprules ); }