Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-super...
File: wp-cache.php
[3000] Fix | Delete
if ( !isset( $wp_super_cache_front_page_check ) || ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 0 ) ) {
[3001] Fix | Delete
return false;
[3002] Fix | Delete
}
[3003] Fix | Delete
[3004] Fix | Delete
if ( function_exists( "wp_remote_get" ) == false ) {
[3005] Fix | Delete
return false;
[3006] Fix | Delete
}
[3007] Fix | Delete
$front_page = wp_remote_get( site_url(), array('timeout' => 60, 'blocking' => true ) );
[3008] Fix | Delete
if( is_array( $front_page ) ) {
[3009] Fix | Delete
// Check for gzipped front page
[3010] Fix | Delete
if ( $front_page[ 'headers' ][ 'content-type' ] == 'application/x-gzip' ) {
[3011] Fix | Delete
if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
[3012] Fix | Delete
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Please clear cache!', 'wp-super-cache' ), home_url() ), sprintf( __( "Please visit %s to clear the cache as the front page of your site is now downloading!", 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) );
[3013] Fix | Delete
} else {
[3014] Fix | Delete
wp_cache_clear_cache( $wpdb->blogid );
[3015] Fix | Delete
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Cache Cleared!', 'wp-super-cache' ), home_url() ), sprintf( __( "The cache on your blog has been cleared because the front page of your site is now downloading. Please visit %s to verify the cache has been cleared.", 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) );
[3016] Fix | Delete
}
[3017] Fix | Delete
}
[3018] Fix | Delete
[3019] Fix | Delete
// Check for broken front page
[3020] Fix | Delete
if (
[3021] Fix | Delete
! empty( $wp_super_cache_front_page_text )
[3022] Fix | Delete
&& ! str_contains( $front_page['body'], $wp_super_cache_front_page_text )
[3023] Fix | Delete
) {
[3024] Fix | Delete
if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) {
[3025] Fix | Delete
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Please clear cache!', 'wp-super-cache' ), home_url() ), sprintf( __( 'Please visit %1$s to clear the cache as the front page of your site is not correct and missing the text, "%2$s"!', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ), $wp_super_cache_front_page_text ) );
[3026] Fix | Delete
} else {
[3027] Fix | Delete
wp_cache_clear_cache( $wpdb->blogid );
[3028] Fix | Delete
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Cache Cleared!', 'wp-super-cache' ), home_url() ), sprintf( __( 'The cache on your blog has been cleared because the front page of your site is missing the text "%2$s". Please visit %1$s to verify the cache has been cleared.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ), $wp_super_cache_front_page_text ) );
[3029] Fix | Delete
}
[3030] Fix | Delete
}
[3031] Fix | Delete
}
[3032] Fix | Delete
if ( isset( $wp_super_cache_front_page_notification ) && $wp_super_cache_front_page_notification == 1 ) {
[3033] Fix | Delete
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page check!', 'wp-super-cache' ), home_url() ), sprintf( __( "WP Super Cache has checked the front page of your blog. Please visit %s if you would like to disable this.", 'wp-super-cache' ) . "\n\n", admin_url( 'options-general.php?page=wpsupercache' ) ) );
[3034] Fix | Delete
}
[3035] Fix | Delete
[3036] Fix | Delete
if ( !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
[3037] Fix | Delete
wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
[3038] Fix | Delete
wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
[3039] Fix | Delete
}
[3040] Fix | Delete
}
[3041] Fix | Delete
add_action( 'wp_cache_check_site_hook', 'wp_cache_check_site' );
[3042] Fix | Delete
[3043] Fix | Delete
function update_cached_mobile_ua_list( $mobile_browsers, $mobile_prefixes = 0, $mobile_groups = 0 ) {
[3044] Fix | Delete
global $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_groups;
[3045] Fix | Delete
wp_cache_setting( 'wp_cache_mobile_browsers', $mobile_browsers );
[3046] Fix | Delete
wp_cache_setting( 'wp_cache_mobile_prefixes', $mobile_prefixes );
[3047] Fix | Delete
if ( is_array( $mobile_groups ) ) {
[3048] Fix | Delete
$wp_cache_mobile_groups = $mobile_groups;
[3049] Fix | Delete
wp_cache_replace_line('^ *\$wp_cache_mobile_groups', "\$wp_cache_mobile_groups = '" . implode( ', ', $mobile_groups ) . "';", $wp_cache_config_file);
[3050] Fix | Delete
}
[3051] Fix | Delete
[3052] Fix | Delete
return true;
[3053] Fix | Delete
}
[3054] Fix | Delete
[3055] Fix | Delete
function wpsc_update_htaccess() {
[3056] Fix | Delete
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
[3057] Fix | Delete
wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
[3058] Fix | Delete
if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
[3059] Fix | Delete
return true;
[3060] Fix | Delete
} else {
[3061] Fix | Delete
return false;
[3062] Fix | Delete
}
[3063] Fix | Delete
}
[3064] Fix | Delete
[3065] Fix | Delete
function wpsc_update_htaccess_form( $short_form = true ) {
[3066] Fix | Delete
global $wpmu_version;
[3067] Fix | Delete
[3068] Fix | Delete
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
[3069] Fix | Delete
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
[3070] Fix | Delete
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
[3071] Fix | Delete
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h5>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h5><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
[3072] Fix | Delete
echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p></div>";
[3073] Fix | Delete
} else {
[3074] Fix | Delete
if ( $short_form == false ) {
[3075] Fix | Delete
echo "<p>" . sprintf( __( 'To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>%s.htaccess</code>', 'wp-super-cache' ), $home_path ) . " ";
[3076] Fix | Delete
_e( "You can edit the file yourself. Add the following rules.", 'wp-super-cache' );
[3077] Fix | Delete
echo __( " Make sure they appear before any existing WordPress rules. ", 'wp-super-cache' ) . "</p>";
[3078] Fix | Delete
echo "<div style='overflow: auto; width: 800px; height: 400px; padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>";
[3079] Fix | Delete
echo "<pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p>";
[3080] Fix | Delete
echo "</div>";
[3081] Fix | Delete
echo "<h5>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</h5>";
[3082] Fix | Delete
echo "<div style='overflow: auto; width: 800px; height: 400px; padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>";
[3083] Fix | Delete
echo "<pre># BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache</pre></p>";
[3084] Fix | Delete
echo "</div>";
[3085] Fix | Delete
}
[3086] Fix | Delete
if ( !isset( $wpmu_version ) || $wpmu_version == '' ) {
[3087] Fix | Delete
echo '<form name="updatehtaccess" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#modrewrite' ) . '" method="post">';
[3088] Fix | Delete
echo '<input type="hidden" name="updatehtaccess" value="1" />';
[3089] Fix | Delete
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . '" /></div>';
[3090] Fix | Delete
wp_nonce_field('wp-cache');
[3091] Fix | Delete
echo "</form>\n";
[3092] Fix | Delete
}
[3093] Fix | Delete
}
[3094] Fix | Delete
}
[3095] Fix | Delete
[3096] Fix | Delete
/*
[3097] Fix | Delete
* Return LOGGED_IN_COOKIE if it doesn't begin with wordpress_logged_in
[3098] Fix | Delete
* to avoid having people update their .htaccess file
[3099] Fix | Delete
*/
[3100] Fix | Delete
function wpsc_get_logged_in_cookie() {
[3101] Fix | Delete
$logged_in_cookie = 'wordpress_logged_in';
[3102] Fix | Delete
if ( defined( 'LOGGED_IN_COOKIE' ) && substr( constant( 'LOGGED_IN_COOKIE' ), 0, 19 ) != 'wordpress_logged_in' )
[3103] Fix | Delete
$logged_in_cookie = constant( 'LOGGED_IN_COOKIE' );
[3104] Fix | Delete
return $logged_in_cookie;
[3105] Fix | Delete
}
[3106] Fix | Delete
[3107] Fix | Delete
function wpsc_get_htaccess_info() {
[3108] Fix | Delete
global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_disable_utf8;
[3109] Fix | Delete
global $htaccess_path;
[3110] Fix | Delete
[3111] Fix | Delete
if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) {
[3112] Fix | Delete
$document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
[3113] Fix | Delete
$apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
[3114] Fix | Delete
} else {
[3115] Fix | Delete
$document_root = $_SERVER[ "DOCUMENT_ROOT" ];
[3116] Fix | Delete
$apache_root = '%{DOCUMENT_ROOT}';
[3117] Fix | Delete
}
[3118] Fix | Delete
$content_dir_root = $document_root;
[3119] Fix | Delete
if ( strpos( $document_root, '/kunden/homepages/' ) === 0 ) {
[3120] Fix | Delete
// https://wordpress.org/support/topic/plugin-wp-super-cache-how-to-get-mod_rewrite-working-on-1and1-shared-hosting?replies=1
[3121] Fix | Delete
// On 1and1, PHP's directory structure starts with '/homepages'. The
[3122] Fix | Delete
// Apache directory structure has an extra '/kunden' before it.
[3123] Fix | Delete
// Also 1and1 does not support the %{DOCUMENT_ROOT} variable in
[3124] Fix | Delete
// .htaccess files.
[3125] Fix | Delete
// This prevents the $inst_root from being calculated correctly and
[3126] Fix | Delete
// means that the $apache_root is wrong.
[3127] Fix | Delete
//
[3128] Fix | Delete
// e.g. This is an example of how Apache and PHP see the directory
[3129] Fix | Delete
// structure on 1and1:
[3130] Fix | Delete
// Apache: /kunden/homepages/xx/dxxxxxxxx/htdocs/site1/index.html
[3131] Fix | Delete
// PHP: /homepages/xx/dxxxxxxxx/htdocs/site1/index.html
[3132] Fix | Delete
// Here we fix up the paths to make mode_rewrite work on 1and1 shared hosting.
[3133] Fix | Delete
$content_dir_root = substr( $content_dir_root, 7 );
[3134] Fix | Delete
$apache_root = $document_root;
[3135] Fix | Delete
}
[3136] Fix | Delete
$home_path = get_home_path();
[3137] Fix | Delete
$home_root = parse_url(get_bloginfo('url'));
[3138] Fix | Delete
$home_root = isset( $home_root[ 'path' ] ) ? trailingslashit( $home_root[ 'path' ] ) : '/';
[3139] Fix | Delete
if ( isset( $htaccess_path ) ) {
[3140] Fix | Delete
$home_path = $htaccess_path;
[3141] Fix | Delete
} elseif (
[3142] Fix | Delete
$home_root == '/' &&
[3143] Fix | Delete
$home_path != $_SERVER[ 'DOCUMENT_ROOT' ]
[3144] Fix | Delete
) {
[3145] Fix | Delete
$home_path = $_SERVER[ 'DOCUMENT_ROOT' ];
[3146] Fix | Delete
} elseif (
[3147] Fix | Delete
$home_root != '/' &&
[3148] Fix | Delete
$home_path != str_replace( '//', '/', $_SERVER[ 'DOCUMENT_ROOT' ] . $home_root ) &&
[3149] Fix | Delete
is_dir( $_SERVER[ 'DOCUMENT_ROOT' ] . $home_root )
[3150] Fix | Delete
) {
[3151] Fix | Delete
$home_path = str_replace( '//', '/', $_SERVER[ 'DOCUMENT_ROOT' ] . $home_root );
[3152] Fix | Delete
}
[3153] Fix | Delete
[3154] Fix | Delete
$home_path = trailingslashit( $home_path );
[3155] Fix | Delete
$home_root_lc = str_replace( '//', '/', strtolower( $home_root ) );
[3156] Fix | Delete
$inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $content_dir_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) );
[3157] Fix | Delete
$wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
[3158] Fix | Delete
$wprules = str_replace( "RewriteEngine On\n", '', $wprules );
[3159] Fix | Delete
$wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
[3160] Fix | Delete
$scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
[3161] Fix | Delete
[3162] Fix | Delete
if( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
[3163] Fix | Delete
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$";
[3164] Fix | Delete
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$";
[3165] Fix | Delete
}
[3166] Fix | Delete
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
[3167] Fix | Delete
$condition_rules[] = "RewriteCond %{QUERY_STRING} ^$";
[3168] Fix | Delete
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . wpsc_get_extra_cookies() . "|wp-postpass_).*$";
[3169] Fix | Delete
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
[3170] Fix | Delete
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
[3171] Fix | Delete
if ( $wp_cache_mobile_enabled ) {
[3172] Fix | Delete
if ( isset( $wp_cache_mobile_browsers ) && "" != $wp_cache_mobile_browsers )
[3173] Fix | Delete
$condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) . ").* [NC]";
[3174] Fix | Delete
if ( isset( $wp_cache_mobile_prefixes ) && "" != $wp_cache_mobile_prefixes )
[3175] Fix | Delete
$condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^(" . addcslashes( str_replace( ', ', '|', $wp_cache_mobile_prefixes ), ' ' ) . ").* [NC]";
[3176] Fix | Delete
}
[3177] Fix | Delete
$condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules );
[3178] Fix | Delete
[3179] Fix | Delete
$rules = "<IfModule mod_rewrite.c>\n";
[3180] Fix | Delete
$rules .= "RewriteEngine On\n";
[3181] Fix | Delete
$rules .= "RewriteBase $home_root\n"; // props Chris Messina
[3182] Fix | Delete
$rules .= "#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible\n";
[3183] Fix | Delete
if ( isset( $wp_cache_disable_utf8 ) == false || $wp_cache_disable_utf8 == 0 ) {
[3184] Fix | Delete
$charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset');
[3185] Fix | Delete
$rules .= "AddDefaultCharset {$charset}\n";
[3186] Fix | Delete
}
[3187] Fix | Delete
[3188] Fix | Delete
$rules .= "CONDITION_RULES";
[3189] Fix | Delete
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
[3190] Fix | Delete
$rules .= "RewriteCond %{HTTPS} on\n";
[3191] Fix | Delete
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html.gz -f\n";
[3192] Fix | Delete
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html.gz\" [L]\n\n";
[3193] Fix | Delete
[3194] Fix | Delete
$rules .= "CONDITION_RULES";
[3195] Fix | Delete
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
[3196] Fix | Delete
$rules .= "RewriteCond %{HTTPS} !on\n";
[3197] Fix | Delete
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html.gz -f\n";
[3198] Fix | Delete
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html.gz\" [L]\n\n";
[3199] Fix | Delete
[3200] Fix | Delete
$rules .= "CONDITION_RULES";
[3201] Fix | Delete
$rules .= "RewriteCond %{HTTPS} on\n";
[3202] Fix | Delete
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html -f\n";
[3203] Fix | Delete
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index-https.html\" [L]\n\n";
[3204] Fix | Delete
[3205] Fix | Delete
$rules .= "CONDITION_RULES";
[3206] Fix | Delete
$rules .= "RewriteCond %{HTTPS} !on\n";
[3207] Fix | Delete
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html -f\n";
[3208] Fix | Delete
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{SERVER_NAME}{$home_root_lc}$1/index.html\" [L]\n";
[3209] Fix | Delete
$rules .= "</IfModule>\n";
[3210] Fix | Delete
$rules = apply_filters( 'supercacherewriterules', $rules );
[3211] Fix | Delete
[3212] Fix | Delete
$rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules );
[3213] Fix | Delete
[3214] Fix | Delete
$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";
[3215] Fix | Delete
$gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
[3216] Fix | Delete
[3217] Fix | Delete
// Default headers.
[3218] Fix | Delete
$headers = array(
[3219] Fix | Delete
'Vary' => 'Accept-Encoding, Cookie',
[3220] Fix | Delete
'Cache-Control' => 'max-age=3, must-revalidate',
[3221] Fix | Delete
);
[3222] Fix | Delete
[3223] Fix | Delete
// Allow users to override the Vary header with WPSC_VARY_HEADER.
[3224] Fix | Delete
if ( defined( 'WPSC_VARY_HEADER' ) && ! empty( WPSC_VARY_HEADER ) ) {
[3225] Fix | Delete
$headers['Vary'] = WPSC_VARY_HEADER;
[3226] Fix | Delete
}
[3227] Fix | Delete
[3228] Fix | Delete
// Allow users to override Cache-control header with WPSC_CACHE_CONTROL_HEADER
[3229] Fix | Delete
if ( defined( 'WPSC_CACHE_CONTROL_HEADER' ) && ! empty( WPSC_CACHE_CONTROL_HEADER ) ) {
[3230] Fix | Delete
$headers['Cache-Control'] = WPSC_CACHE_CONTROL_HEADER;
[3231] Fix | Delete
}
[3232] Fix | Delete
[3233] Fix | Delete
// Allow overriding headers with a filter.
[3234] Fix | Delete
$headers = apply_filters( 'wpsc_htaccess_mod_headers', $headers );
[3235] Fix | Delete
[3236] Fix | Delete
// Combine headers into a block of text.
[3237] Fix | Delete
$headers_text = implode(
[3238] Fix | Delete
"\n",
[3239] Fix | Delete
array_map(
[3240] Fix | Delete
function ( $key, $value ) {
[3241] Fix | Delete
return " Header set $key '" . addcslashes( $value, "'" ) . "'";
[3242] Fix | Delete
},
[3243] Fix | Delete
array_keys( $headers ),
[3244] Fix | Delete
array_values( $headers )
[3245] Fix | Delete
)
[3246] Fix | Delete
);
[3247] Fix | Delete
[3248] Fix | Delete
// Pack headers into gziprules (for historic reasons) - TODO refactor the values
[3249] Fix | Delete
// returned to better reflect the blocks being written.
[3250] Fix | Delete
if ( $headers_text != '' ) {
[3251] Fix | Delete
$gziprules .= "<IfModule mod_headers.c>\n$headers_text\n</IfModule>\n";
[3252] Fix | Delete
}
[3253] Fix | Delete
[3254] Fix | Delete
// Deafult mod_expires rules.
[3255] Fix | Delete
$expires_rules = array(
[3256] Fix | Delete
'ExpiresActive On',
[3257] Fix | Delete
'ExpiresByType text/html A3',
[3258] Fix | Delete
);
[3259] Fix | Delete
[3260] Fix | Delete
// Allow overriding mod_expires rules with a filter.
[3261] Fix | Delete
$expires_rules = apply_filters( 'wpsc_htaccess_mod_expires', $expires_rules );
[3262] Fix | Delete
[3263] Fix | Delete
$gziprules .= "<IfModule mod_expires.c>\n";
[3264] Fix | Delete
$gziprules .= implode(
[3265] Fix | Delete
"\n",
[3266] Fix | Delete
array_map(
[3267] Fix | Delete
function ( $line ) {
[3268] Fix | Delete
return " $line";
[3269] Fix | Delete
},
[3270] Fix | Delete
$expires_rules
[3271] Fix | Delete
)
[3272] Fix | Delete
);
[3273] Fix | Delete
$gziprules .= "\n</IfModule>\n";
[3274] Fix | Delete
[3275] Fix | Delete
$gziprules .= "Options -Indexes\n";
[3276] Fix | Delete
[3277] Fix | Delete
return array(
[3278] Fix | Delete
'document_root' => $document_root,
[3279] Fix | Delete
'apache_root' => $apache_root,
[3280] Fix | Delete
'home_path' => $home_path,
[3281] Fix | Delete
'home_root' => $home_root,
[3282] Fix | Delete
'home_root_lc' => $home_root_lc,
[3283] Fix | Delete
'inst_root' => $inst_root,
[3284] Fix | Delete
'wprules' => $wprules,
[3285] Fix | Delete
'scrules' => $scrules,
[3286] Fix | Delete
'condition_rules' => $condition_rules,
[3287] Fix | Delete
'rules' => $rules,
[3288] Fix | Delete
'gziprules' => $gziprules,
[3289] Fix | Delete
);
[3290] Fix | Delete
}
[3291] Fix | Delete
[3292] Fix | Delete
function clear_post_supercache( $post_id ) {
[3293] Fix | Delete
$dir = get_current_url_supercache_dir( $post_id );
[3294] Fix | Delete
if ( false == @is_dir( $dir ) )
[3295] Fix | Delete
return false;
[3296] Fix | Delete
[3297] Fix | Delete
if ( get_supercache_dir() == $dir ) {
[3298] Fix | Delete
wp_cache_debug( "clear_post_supercache: not deleting post_id $post_id as it points at homepage: $dir" );
[3299] Fix | Delete
return false;
[3300] Fix | Delete
}
[3301] Fix | Delete
[3302] Fix | Delete
wp_cache_debug( "clear_post_supercache: post_id: $post_id. deleting files in $dir" );
[3303] Fix | Delete
if ( get_post_type( $post_id ) != 'page') { // don't delete child pages if they exist
[3304] Fix | Delete
prune_super_cache( $dir, true );
[3305] Fix | Delete
} else {
[3306] Fix | Delete
wpsc_delete_files( $dir );
[3307] Fix | Delete
}
[3308] Fix | Delete
}
[3309] Fix | Delete
[3310] Fix | Delete
/**
[3311] Fix | Delete
* Serves an AJAX endpoint to return the current state of the preload process.
[3312] Fix | Delete
*/
[3313] Fix | Delete
function wpsc_ajax_get_preload_status() {
[3314] Fix | Delete
$preload_status = wpsc_get_preload_status( true );
[3315] Fix | Delete
wp_send_json_success( $preload_status );
[3316] Fix | Delete
}
[3317] Fix | Delete
add_action( 'wp_ajax_wpsc_get_preload_status', 'wpsc_ajax_get_preload_status' );
[3318] Fix | Delete
[3319] Fix | Delete
/**
[3320] Fix | Delete
* Returns the location of the preload status file.
[3321] Fix | Delete
*/
[3322] Fix | Delete
function wpsc_get_preload_status_file_path() {
[3323] Fix | Delete
global $cache_path;
[3324] Fix | Delete
return $cache_path . 'preload_permalink.txt';
[3325] Fix | Delete
}
[3326] Fix | Delete
[3327] Fix | Delete
/**
[3328] Fix | Delete
* Get the timestamp of the next preload.
[3329] Fix | Delete
*/
[3330] Fix | Delete
function wpsc_get_next_preload_time() {
[3331] Fix | Delete
$next = wp_next_scheduled( 'wp_cache_preload_hook' );
[3332] Fix | Delete
if ( ! $next ) {
[3333] Fix | Delete
$next = wp_next_scheduled( 'wp_cache_full_preload_hook' );
[3334] Fix | Delete
}
[3335] Fix | Delete
[3336] Fix | Delete
return $next;
[3337] Fix | Delete
}
[3338] Fix | Delete
[3339] Fix | Delete
/**
[3340] Fix | Delete
* Read the preload status. Caches the result in a static variable.
[3341] Fix | Delete
*/
[3342] Fix | Delete
function wpsc_get_preload_status( $include_next = false ) {
[3343] Fix | Delete
$status = array(
[3344] Fix | Delete
'running' => false,
[3345] Fix | Delete
'history' => array(),
[3346] Fix | Delete
'next' => false,
[3347] Fix | Delete
'previous' => null,
[3348] Fix | Delete
);
[3349] Fix | Delete
[3350] Fix | Delete
$filename = wpsc_get_preload_status_file_path();
[3351] Fix | Delete
if ( file_exists( $filename ) ) {
[3352] Fix | Delete
$data = wp_json_file_decode( $filename, array( 'associative' => true ) );
[3353] Fix | Delete
if ( is_array( $data ) ) {
[3354] Fix | Delete
$status = $data;
[3355] Fix | Delete
}
[3356] Fix | Delete
}
[3357] Fix | Delete
[3358] Fix | Delete
if ( $include_next ) {
[3359] Fix | Delete
$status['next'] = wpsc_get_next_preload_time();
[3360] Fix | Delete
}
[3361] Fix | Delete
[3362] Fix | Delete
return $status;
[3363] Fix | Delete
}
[3364] Fix | Delete
[3365] Fix | Delete
/**
[3366] Fix | Delete
* Update the preload status file during a preload.
[3367] Fix | Delete
*/
[3368] Fix | Delete
function wpsc_update_active_preload( $group = null, $progress = null, $url = null ) {
[3369] Fix | Delete
$preload_status = wpsc_get_preload_status();
[3370] Fix | Delete
[3371] Fix | Delete
$preload_status['running'] = true;
[3372] Fix | Delete
[3373] Fix | Delete
// Add the new entry to the history.
[3374] Fix | Delete
array_unshift(
[3375] Fix | Delete
$preload_status['history'],
[3376] Fix | Delete
array(
[3377] Fix | Delete
'group' => $group,
[3378] Fix | Delete
'progress' => $progress,
[3379] Fix | Delete
'url' => $url,
[3380] Fix | Delete
)
[3381] Fix | Delete
);
[3382] Fix | Delete
[3383] Fix | Delete
// Limit to 5 in the history.
[3384] Fix | Delete
$preload_status['history'] = array_slice( $preload_status['history'], 0, 5 );
[3385] Fix | Delete
[3386] Fix | Delete
$filename = wpsc_get_preload_status_file_path();
[3387] Fix | Delete
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
[3388] Fix | Delete
if ( false === file_put_contents( $filename, wp_json_encode( $preload_status ) ) ) {
[3389] Fix | Delete
wp_cache_debug( "wpsc_update_active_preload: failed to write to $filename" );
[3390] Fix | Delete
}
[3391] Fix | Delete
}
[3392] Fix | Delete
[3393] Fix | Delete
/**
[3394] Fix | Delete
* Update the preload status to indicate it is idle. If a finish time is specified, store it.
[3395] Fix | Delete
*/
[3396] Fix | Delete
function wpsc_update_idle_preload( $finish_time = null ) {
[3397] Fix | Delete
$preload_status = wpsc_get_preload_status();
[3398] Fix | Delete
[3399] Fix | Delete
$preload_status['running'] = false;
[3400] Fix | Delete
$preload_status['history'] = array();
[3401] Fix | Delete
[3402] Fix | Delete
if ( ! empty( $finish_time ) ) {
[3403] Fix | Delete
$preload_status['previous'] = $finish_time;
[3404] Fix | Delete
}
[3405] Fix | Delete
[3406] Fix | Delete
$filename = wpsc_get_preload_status_file_path();
[3407] Fix | Delete
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
[3408] Fix | Delete
if ( false === file_put_contents( $filename, wp_json_encode( $preload_status ) ) ) {
[3409] Fix | Delete
wp_cache_debug( "wpsc_update_idle_preload: failed to write to $filename" );
[3410] Fix | Delete
}
[3411] Fix | Delete
}
[3412] Fix | Delete
[3413] Fix | Delete
function wp_cron_preload_cache() {
[3414] Fix | Delete
global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path, $wp_cache_preload_taxonomies;
[3415] Fix | Delete
[3416] Fix | Delete
// check if stop_preload.txt exists and preload should be stopped.
[3417] Fix | Delete
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[3418] Fix | Delete
if ( @file_exists( $cache_path . 'stop_preload.txt' ) ) {
[3419] Fix | Delete
wp_cache_debug( 'wp_cron_preload_cache: preload cancelled. Aborting preload.' );
[3420] Fix | Delete
wpsc_reset_preload_settings();
[3421] Fix | Delete
return true;
[3422] Fix | Delete
}
[3423] Fix | Delete
[3424] Fix | Delete
/*
[3425] Fix | Delete
* The mutex file is used to prevent multiple preload processes from running at the same time.
[3426] Fix | Delete
* If the mutex file is found, the preload process will wait 3-8 seconds and then check again.
[3427] Fix | Delete
* If the mutex file is still found, the preload process will abort.
[3428] Fix | Delete
* If the mutex file is not found, the preload process will create the mutex file and continue.
[3429] Fix | Delete
* The mutex file is deleted at the end of the preload process.
[3430] Fix | Delete
* The mutex file is deleted if it is more than 10 minutes old.
[3431] Fix | Delete
* The mutex file should only be deleted by the preload process that created it.
[3432] Fix | Delete
* If the mutex file is deleted by another process, another preload process may start.
[3433] Fix | Delete
*/
[3434] Fix | Delete
$mutex = $cache_path . "preload_mutex.tmp";
[3435] Fix | Delete
if ( @file_exists( $mutex ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[3436] Fix | Delete
sleep( 3 + wp_rand( 1, 5 ) );
[3437] Fix | Delete
// check again just in case another preload process is still running.
[3438] Fix | Delete
if ( @file_exists( $mutex ) && @filemtime( $mutex ) > ( time() - 600 ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[3439] Fix | Delete
wp_cache_debug( 'wp_cron_preload_cache: preload mutex found and less than 600 seconds old. Aborting preload.', 1 );
[3440] Fix | Delete
return true;
[3441] Fix | Delete
} else {
[3442] Fix | Delete
wp_cache_debug( 'wp_cron_preload_cache: old preload mutex found and deleted. Preload continues.', 1 );
[3443] Fix | Delete
@unlink( $mutex );
[3444] Fix | Delete
}
[3445] Fix | Delete
}
[3446] Fix | Delete
$fp = @fopen( $mutex, 'w' );
[3447] Fix | Delete
@fclose( $fp );
[3448] Fix | Delete
[3449] Fix | Delete
$counter = get_option( 'preload_cache_counter' );
[3450] Fix | Delete
$c = $counter[ 'c' ];
[3451] Fix | Delete
[3452] Fix | Delete
if ( $wp_cache_preload_email_volume == 'none' && $wp_cache_preload_email_me == 1 ) {
[3453] Fix | Delete
$wp_cache_preload_email_me = 0;
[3454] Fix | Delete
wp_cache_setting( 'wp_cache_preload_email_me', 0 );
[3455] Fix | Delete
}
[3456] Fix | Delete
[3457] Fix | Delete
$just_started_preloading = false;
[3458] Fix | Delete
[3459] Fix | Delete
/*
[3460] Fix | Delete
* Preload taxonomies first.
[3461] Fix | Delete
*
[3462] Fix | Delete
*/
[3463] Fix | Delete
if ( isset( $wp_cache_preload_taxonomies ) && $wp_cache_preload_taxonomies ) {
[3464] Fix | Delete
wp_cache_debug( 'wp_cron_preload_cache: doing taxonomy preload.', 5 );
[3465] Fix | Delete
$taxonomies = apply_filters(
[3466] Fix | Delete
'wp_cache_preload_taxonomies',
[3467] Fix | Delete
array(
[3468] Fix | Delete
'post_tag' => 'tag',
[3469] Fix | Delete
'category' => 'category',
[3470] Fix | Delete
)
[3471] Fix | Delete
);
[3472] Fix | Delete
[3473] Fix | Delete
$preload_more_taxonomies = false;
[3474] Fix | Delete
[3475] Fix | Delete
foreach ( $taxonomies as $taxonomy => $path ) {
[3476] Fix | Delete
$taxonomy_filename = $cache_path . 'taxonomy_' . $taxonomy . '.txt';
[3477] Fix | Delete
[3478] Fix | Delete
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[3479] Fix | Delete
if ( false === @file_exists( $taxonomy_filename ) ) {
[3480] Fix | Delete
[3481] Fix | Delete
if ( ! $just_started_preloading && $wp_cache_preload_email_me ) {
[3482] Fix | Delete
// translators: 1: site url
[3483] Fix | Delete
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Started', 'wp-super-cache' ), home_url(), '' ), ' ' );
[3484] Fix | Delete
}
[3485] Fix | Delete
[3486] Fix | Delete
$just_started_preloading = true;
[3487] Fix | Delete
$out = '';
[3488] Fix | Delete
$records = get_terms( $taxonomy );
[3489] Fix | Delete
foreach ( $records as $term ) {
[3490] Fix | Delete
$out .= get_term_link( $term ) . "\n";
[3491] Fix | Delete
}
[3492] Fix | Delete
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
[3493] Fix | Delete
$fp = fopen( $taxonomy_filename, 'w' );
[3494] Fix | Delete
if ( $fp ) {
[3495] Fix | Delete
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fwrite
[3496] Fix | Delete
fwrite( $fp, $out );
[3497] Fix | Delete
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose
[3498] Fix | Delete
fclose( $fp );
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function