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
}
[2500] Fix | Delete
}
[2501] Fix | Delete
if ( $cache_compression ) {
[2502] Fix | Delete
$sizes[ 'supercache' ][ 'cached' ] = intval( $sizes[ 'supercache' ][ 'cached' ] / 2 );
[2503] Fix | Delete
$sizes[ 'supercache' ][ 'expired' ] = intval( $sizes[ 'supercache' ][ 'expired' ] / 2 );
[2504] Fix | Delete
}
[2505] Fix | Delete
$cache_stats = array( 'generated' => time(), 'supercache' => $sizes[ 'supercache' ], 'wpcache' => $sizes[ 'wpcache' ] );
[2506] Fix | Delete
update_option( 'supercache_stats', $cache_stats );
[2507] Fix | Delete
return $cache_stats;
[2508] Fix | Delete
}
[2509] Fix | Delete
[2510] Fix | Delete
function wp_cache_files() {
[2511] Fix | Delete
global $cache_path, $file_prefix, $cache_max_time, $valid_nonce, $supercachedir, $super_cache_enabled, $blog_cache_dir, $cache_compression;
[2512] Fix | Delete
global $wp_cache_preload_on;
[2513] Fix | Delete
[2514] Fix | Delete
if ( '/' != substr($cache_path, -1)) {
[2515] Fix | Delete
$cache_path .= '/';
[2516] Fix | Delete
}
[2517] Fix | Delete
[2518] Fix | Delete
if ( $valid_nonce ) {
[2519] Fix | Delete
if(isset($_REQUEST['wp_delete_cache'])) {
[2520] Fix | Delete
wp_cache_clean_cache($file_prefix);
[2521] Fix | Delete
$_GET[ 'action' ] = 'regenerate_cache_stats';
[2522] Fix | Delete
}
[2523] Fix | Delete
if ( isset( $_REQUEST[ 'wp_delete_all_cache' ] ) ) {
[2524] Fix | Delete
wp_cache_clean_cache( $file_prefix, true );
[2525] Fix | Delete
$_GET[ 'action' ] = 'regenerate_cache_stats';
[2526] Fix | Delete
}
[2527] Fix | Delete
if(isset($_REQUEST['wp_delete_expired'])) {
[2528] Fix | Delete
wp_cache_clean_expired($file_prefix);
[2529] Fix | Delete
$_GET[ 'action' ] = 'regenerate_cache_stats';
[2530] Fix | Delete
}
[2531] Fix | Delete
}
[2532] Fix | Delete
echo "<a name='listfiles'></a>";
[2533] Fix | Delete
echo '<div class="wpsc-card">';
[2534] Fix | Delete
echo '<fieldset class="options" id="show-this-fieldset"><h4>' . __( 'Cache Contents', 'wp-super-cache' ) . '</h4>';
[2535] Fix | Delete
[2536] Fix | Delete
$cache_stats = get_option( 'supercache_stats' );
[2537] Fix | Delete
if ( !is_array( $cache_stats ) || ( isset( $_GET[ 'listfiles' ] ) ) || ( $valid_nonce && array_key_exists('action', $_GET) && $_GET[ 'action' ] == 'regenerate_cache_stats' ) ) {
[2538] Fix | Delete
$count = 0;
[2539] Fix | Delete
$expired = 0;
[2540] Fix | Delete
$now = time();
[2541] Fix | Delete
$wp_cache_fsize = 0;
[2542] Fix | Delete
if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
[2543] Fix | Delete
if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletewpcache' ) {
[2544] Fix | Delete
$deleteuri = wpsc_deep_replace( array( '..', '\\', 'index.php' ), preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', base64_decode( $_GET[ 'uri' ] ) ) );
[2545] Fix | Delete
} else {
[2546] Fix | Delete
$deleteuri = '';
[2547] Fix | Delete
}
[2548] Fix | Delete
[2549] Fix | Delete
if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletesupercache' ) {
[2550] Fix | Delete
$supercacheuri = wpsc_deep_replace( array( '..', '\\', 'index.php' ), preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', preg_replace("/(\?.*)?$/", '', base64_decode( $_GET[ 'uri' ] ) ) ) );
[2551] Fix | Delete
$supercacheuri = trailingslashit( realpath( $cache_path . 'supercache/' . $supercacheuri ) );
[2552] Fix | Delete
if ( wp_cache_confirm_delete( $supercacheuri ) ) {
[2553] Fix | Delete
printf( __( "Deleting supercache file: <strong>%s</strong><br />", 'wp-super-cache' ), $supercacheuri );
[2554] Fix | Delete
wpsc_delete_files( $supercacheuri );
[2555] Fix | Delete
prune_super_cache( $supercacheuri . 'page', true );
[2556] Fix | Delete
@rmdir( $supercacheuri );
[2557] Fix | Delete
} else {
[2558] Fix | Delete
wp_die( __( 'Warning! You are not allowed to delete that file', 'wp-super-cache' ) );
[2559] Fix | Delete
}
[2560] Fix | Delete
}
[2561] Fix | Delete
while( false !== ( $file = readdir( $handle ) ) ) {
[2562] Fix | Delete
if ( // phpcs:ignore Generic.WhiteSpace.ScopeIndent.IncorrectExact
[2563] Fix | Delete
str_contains( $file, $file_prefix )
[2564] Fix | Delete
&& substr( $file, -4 ) == '.php' // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
[2565] Fix | Delete
) { // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect
[2566] Fix | Delete
if ( false == file_exists( $blog_cache_dir . 'meta/' . $file ) ) {
[2567] Fix | Delete
@unlink( $blog_cache_dir . $file );
[2568] Fix | Delete
continue; // meta does not exist
[2569] Fix | Delete
}
[2570] Fix | Delete
$mtime = filemtime( $blog_cache_dir . 'meta/' . $file );
[2571] Fix | Delete
$fsize = @filesize( $blog_cache_dir . $file );
[2572] Fix | Delete
if ( $fsize > 0 )
[2573] Fix | Delete
$fsize = $fsize - 15; // die() command takes 15 bytes at the start of the file
[2574] Fix | Delete
[2575] Fix | Delete
$age = $now - $mtime;
[2576] Fix | Delete
if ( $valid_nonce && isset( $_GET[ 'listfiles' ] ) ) {
[2577] Fix | Delete
$meta = json_decode( wp_cache_get_legacy_cache( $blog_cache_dir . 'meta/' . $file ), true );
[2578] Fix | Delete
if ( $deleteuri != '' && $meta[ 'uri' ] == $deleteuri ) {
[2579] Fix | Delete
printf( __( "Deleting wp-cache file: <strong>%s</strong><br />", 'wp-super-cache' ), esc_html( $deleteuri ) );
[2580] Fix | Delete
@unlink( $blog_cache_dir . 'meta/' . $file );
[2581] Fix | Delete
@unlink( $blog_cache_dir . $file );
[2582] Fix | Delete
continue;
[2583] Fix | Delete
}
[2584] Fix | Delete
$meta[ 'age' ] = $age;
[2585] Fix | Delete
foreach( $meta as $key => $val )
[2586] Fix | Delete
$meta[ $key ] = esc_html( $val );
[2587] Fix | Delete
if ( $cache_max_time > 0 && $age > $cache_max_time ) {
[2588] Fix | Delete
$expired_list[ $age ][] = $meta;
[2589] Fix | Delete
} else {
[2590] Fix | Delete
$cached_list[ $age ][] = $meta;
[2591] Fix | Delete
}
[2592] Fix | Delete
}
[2593] Fix | Delete
[2594] Fix | Delete
if ( $cache_max_time > 0 && $age > $cache_max_time ) {
[2595] Fix | Delete
++$expired;
[2596] Fix | Delete
} else {
[2597] Fix | Delete
++$count;
[2598] Fix | Delete
}
[2599] Fix | Delete
$wp_cache_fsize += $fsize;
[2600] Fix | Delete
}
[2601] Fix | Delete
}
[2602] Fix | Delete
closedir($handle);
[2603] Fix | Delete
}
[2604] Fix | Delete
if( $wp_cache_fsize != 0 ) {
[2605] Fix | Delete
$wp_cache_fsize = $wp_cache_fsize/1024;
[2606] Fix | Delete
} else {
[2607] Fix | Delete
$wp_cache_fsize = 0;
[2608] Fix | Delete
}
[2609] Fix | Delete
if( $wp_cache_fsize > 1024 ) {
[2610] Fix | Delete
$wp_cache_fsize = number_format( $wp_cache_fsize / 1024, 2 ) . "MB";
[2611] Fix | Delete
} elseif( $wp_cache_fsize != 0 ) {
[2612] Fix | Delete
$wp_cache_fsize = number_format( $wp_cache_fsize, 2 ) . "KB";
[2613] Fix | Delete
} else {
[2614] Fix | Delete
$wp_cache_fsize = '0KB';
[2615] Fix | Delete
}
[2616] Fix | Delete
$cache_stats = wp_cache_regenerate_cache_file_stats();
[2617] Fix | Delete
} else {
[2618] Fix | Delete
echo "<p>" . __( 'Cache stats are not automatically generated. You must click the link below to regenerate the stats on this page.', 'wp-super-cache' ) . "</p>";
[2619] Fix | Delete
echo "<a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'contents', 'action' => 'regenerate_cache_stats' ) ), 'wp-cache' ) . "'>" . __( 'Regenerate cache stats', 'wp-super-cache' ) . "</a>";
[2620] Fix | Delete
if ( is_array( $cache_stats ) ) {
[2621] Fix | Delete
echo "<p>" . sprintf( __( 'Cache stats last generated: %s minutes ago.', 'wp-super-cache' ), number_format( ( time() - $cache_stats[ 'generated' ] ) / 60 ) ) . "</p>";
[2622] Fix | Delete
}
[2623] Fix | Delete
$cache_stats = get_option( 'supercache_stats' );
[2624] Fix | Delete
}// regerate stats cache
[2625] Fix | Delete
[2626] Fix | Delete
if ( is_array( $cache_stats ) ) {
[2627] Fix | Delete
$fsize = wp_cache_format_fsize( $cache_stats[ 'wpcache' ][ 'fsize' ] / 1024 );
[2628] Fix | Delete
echo "<p><strong>" . __( 'WP-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>";
[2629] Fix | Delete
echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'cached' ] ) . "</li>";
[2630] Fix | Delete
echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $cache_stats[ 'wpcache' ][ 'expired' ] ) . "</li></ul>";
[2631] Fix | Delete
if ( array_key_exists('fsize', (array)$cache_stats[ 'supercache' ]) )
[2632] Fix | Delete
$fsize = $cache_stats[ 'supercache' ][ 'fsize' ] / 1024;
[2633] Fix | Delete
else
[2634] Fix | Delete
$fsize = 0;
[2635] Fix | Delete
$fsize = wp_cache_format_fsize( $fsize );
[2636] Fix | Delete
echo "<p><strong>" . __( 'WP-Super-Cache', 'wp-super-cache' ) . " ({$fsize})</strong></p>";
[2637] Fix | Delete
echo "<ul><li>" . sprintf( __( '%s Cached Pages', 'wp-super-cache' ), $cache_stats[ 'supercache' ][ 'cached' ] ) . "</li>";
[2638] Fix | Delete
if ( isset( $now ) && isset( $cache_stats ) )
[2639] Fix | Delete
$age = intval( ( $now - $cache_stats['generated'] ) / 60 );
[2640] Fix | Delete
else
[2641] Fix | Delete
$age = 0;
[2642] Fix | Delete
echo "<li>" . sprintf( __( '%s Expired Pages', 'wp-super-cache' ), $cache_stats[ 'supercache' ][ 'expired' ] ) . "</li></ul>";
[2643] Fix | Delete
if ( $valid_nonce && array_key_exists('listfiles', $_GET) && isset( $_GET[ 'listfiles' ] ) ) {
[2644] Fix | Delete
echo "<div style='padding: 10px; border: 1px solid #333; height: 400px; width: 90%; overflow: auto'>";
[2645] Fix | Delete
$cache_description = array( 'supercache' => __( 'WP-Super-Cached', 'wp-super-cache' ), 'wpcache' => __( 'WP-Cached', 'wp-super-cache' ) );
[2646] Fix | Delete
foreach( $cache_stats as $type => $details ) {
[2647] Fix | Delete
if ( is_array( $details ) == false )
[2648] Fix | Delete
continue;
[2649] Fix | Delete
foreach( array( 'cached_list' => 'Fresh', 'expired_list' => 'Stale' ) as $list => $description ) {
[2650] Fix | Delete
if ( is_array( $details[ $list ] ) & !empty( $details[ $list ] ) ) {
[2651] Fix | Delete
echo "<h5>" . sprintf( __( '%s %s Files', 'wp-super-cache' ), $description, $cache_description[ $type ] ) . "</h5>";
[2652] Fix | Delete
echo "<table class='widefat'><tr><th>#</th><th>" . __( 'URI', 'wp-super-cache' ) . "</th><th>" . __( 'Files', 'wp-super-cache' ) . "</th><th>" . __( 'Age', 'wp-super-cache' ) . "</th><th>" . __( 'Delete', 'wp-super-cache' ) . "</th></tr>";
[2653] Fix | Delete
$c = 1;
[2654] Fix | Delete
$flip = 1;
[2655] Fix | Delete
[2656] Fix | Delete
ksort( $details[ $list ] );
[2657] Fix | Delete
foreach( $details[ $list ] as $directory => $d ) {
[2658] Fix | Delete
if ( isset( $d[ 'upper_age' ] ) ) {
[2659] Fix | Delete
$age = "{$d[ 'lower_age' ]} - {$d[ 'upper_age' ]}";
[2660] Fix | Delete
} else {
[2661] Fix | Delete
$age = $d[ 'lower_age' ];
[2662] Fix | Delete
}
[2663] Fix | Delete
$bg = $flip ? 'style="background: #EAEAEA;"' : '';
[2664] Fix | Delete
echo "<tr $bg><td>$c</td><td> <a href='http://{$directory}'>{$directory}</a></td><td>{$d[ 'files' ]}</td><td>{$age}</td><td><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $directory ) ) ), 'wp-cache' ) . "#listfiles'>X</a></td></tr>\n";
[2665] Fix | Delete
$flip = !$flip;
[2666] Fix | Delete
++$c;
[2667] Fix | Delete
}
[2668] Fix | Delete
echo "</table>";
[2669] Fix | Delete
}
[2670] Fix | Delete
}
[2671] Fix | Delete
}
[2672] Fix | Delete
echo "</div>";
[2673] Fix | Delete
echo "<p><a href='?page=wpsupercache&tab=contents#top'>" . __( 'Hide file list', 'wp-super-cache' ) . "</a></p>";
[2674] Fix | Delete
} elseif ( $cache_stats[ 'supercache' ][ 'cached' ] > 500 || $cache_stats[ 'supercache' ][ 'expired' ] > 500 || $cache_stats[ 'wpcache' ][ 'cached' ] > 500 || $cache_stats[ 'wpcache' ][ 'expired' ] > 500 ) {
[2675] Fix | Delete
echo "<p><em>" . __( 'Too many cached files, no listing possible.', 'wp-super-cache' ) . "</em></p>";
[2676] Fix | Delete
} else {
[2677] Fix | Delete
echo "<p><a href='" . wp_nonce_url( add_query_arg( array( 'page' => 'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "</a></p>";
[2678] Fix | Delete
}
[2679] Fix | Delete
if ( $cache_max_time > 0 )
[2680] Fix | Delete
echo "<p>" . sprintf( __( 'Expired files are files older than %s seconds. They are still used by the plugin and are deleted periodically.', 'wp-super-cache' ), $cache_max_time ) . "</p>";
[2681] Fix | Delete
if ( $wp_cache_preload_on )
[2682] Fix | Delete
echo "<p>" . __( 'Preload mode is enabled. Supercache files will never be expired.', 'wp-super-cache' ) . "</p>";
[2683] Fix | Delete
} // cache_stats
[2684] Fix | Delete
wp_cache_delete_buttons();
[2685] Fix | Delete
[2686] Fix | Delete
echo '</fieldset>';
[2687] Fix | Delete
echo '</div>';
[2688] Fix | Delete
}
[2689] Fix | Delete
[2690] Fix | Delete
function wp_cache_delete_buttons() {
[2691] Fix | Delete
[2692] Fix | Delete
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
[2693] Fix | Delete
[2694] Fix | Delete
echo '<form name="wp_cache_content_expired" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
[2695] Fix | Delete
echo '<input type="hidden" name="wp_delete_expired" />';
[2696] Fix | Delete
echo '<div class="submit" style="float:left"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . '" /></div>';
[2697] Fix | Delete
wp_nonce_field('wp-cache');
[2698] Fix | Delete
echo "</form>\n";
[2699] Fix | Delete
[2700] Fix | Delete
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
[2701] Fix | Delete
echo '<input type="hidden" name="wp_delete_cache" />';
[2702] Fix | Delete
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . '" /></div>';
[2703] Fix | Delete
wp_nonce_field('wp-cache');
[2704] Fix | Delete
echo "</form>\n";
[2705] Fix | Delete
if ( is_multisite() && wpsupercache_site_admin() ) {
[2706] Fix | Delete
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
[2707] Fix | Delete
echo '<input type="hidden" name="wp_delete_all_cache" />';
[2708] Fix | Delete
echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
[2709] Fix | Delete
wp_nonce_field('wp-cache');
[2710] Fix | Delete
echo "</form>\n";
[2711] Fix | Delete
}
[2712] Fix | Delete
}
[2713] Fix | Delete
[2714] Fix | Delete
function delete_cache_dashboard() {
[2715] Fix | Delete
if ( function_exists( '_deprecated_function' ) ) {
[2716] Fix | Delete
_deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.4' );
[2717] Fix | Delete
}
[2718] Fix | Delete
[2719] Fix | Delete
if ( false == wpsupercache_site_admin() )
[2720] Fix | Delete
return false;
[2721] Fix | Delete
[2722] Fix | Delete
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
[2723] Fix | Delete
return false;
[2724] Fix | Delete
[2725] Fix | Delete
echo "<li><a href='" . wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1', 'wp-cache' ) . "' target='_blank' title='" . __( 'Delete Super Cache cached files (opens in new window)', 'wp-super-cache' ) . "'>" . __( 'Delete Cache', 'wp-super-cache' ) . "</a></li>";
[2726] Fix | Delete
}
[2727] Fix | Delete
//add_action( 'dashmenu', 'delete_cache_dashboard' );
[2728] Fix | Delete
[2729] Fix | Delete
function wpsc_dirsize($directory, $sizes) {
[2730] Fix | Delete
global $cache_max_time, $cache_path, $valid_nonce, $wp_cache_preload_on, $file_prefix;
[2731] Fix | Delete
$now = time();
[2732] Fix | Delete
[2733] Fix | Delete
if (is_dir($directory)) {
[2734] Fix | Delete
if( $dh = opendir( $directory ) ) {
[2735] Fix | Delete
while( ( $entry = readdir( $dh ) ) !== false ) {
[2736] Fix | Delete
if ($entry != '.' && $entry != '..') {
[2737] Fix | Delete
$sizes = wpsc_dirsize( trailingslashit( $directory ) . $entry, $sizes );
[2738] Fix | Delete
}
[2739] Fix | Delete
}
[2740] Fix | Delete
closedir($dh);
[2741] Fix | Delete
}
[2742] Fix | Delete
} elseif ( is_file( $directory ) && strpos( $directory, 'meta-' . $file_prefix ) === false ) {
[2743] Fix | Delete
if ( strpos( $directory, '/' . $file_prefix ) !== false ) {
[2744] Fix | Delete
$cache_type = 'wpcache';
[2745] Fix | Delete
} else {
[2746] Fix | Delete
$cache_type = 'supercache';
[2747] Fix | Delete
}
[2748] Fix | Delete
$keep_fresh = false;
[2749] Fix | Delete
if ( $cache_type === 'supercache' && $wp_cache_preload_on ) {
[2750] Fix | Delete
$keep_fresh = true;
[2751] Fix | Delete
}
[2752] Fix | Delete
$filem = filemtime( $directory );
[2753] Fix | Delete
if ( ! $keep_fresh && $cache_max_time > 0 && $filem + $cache_max_time <= $now ) {
[2754] Fix | Delete
$cache_status = 'expired';
[2755] Fix | Delete
} else {
[2756] Fix | Delete
$cache_status = 'cached';
[2757] Fix | Delete
}
[2758] Fix | Delete
$sizes[ $cache_type ][ $cache_status ] += 1;
[2759] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Presumably the caller should handle it if necessary.
[2760] Fix | Delete
if ( $valid_nonce && isset( $_GET['listfiles'] ) ) {
[2761] Fix | Delete
$dir = str_replace( $cache_path . 'supercache/', '', dirname( $directory ) );
[2762] Fix | Delete
$age = $now - $filem;
[2763] Fix | Delete
if ( ! isset( $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ] ) ) {
[2764] Fix | Delete
$sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['lower_age'] = $age;
[2765] Fix | Delete
$sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['files'] = 1;
[2766] Fix | Delete
} else {
[2767] Fix | Delete
$sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['files'] += 1;
[2768] Fix | Delete
if ( $age <= $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['lower_age'] ) {
[2769] Fix | Delete
[2770] Fix | Delete
if ( $age < $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['lower_age'] && ! isset( $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['upper_age'] ) ) {
[2771] Fix | Delete
$sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['upper_age'] = $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['lower_age'];
[2772] Fix | Delete
}
[2773] Fix | Delete
[2774] Fix | Delete
$sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['lower_age'] = $age;
[2775] Fix | Delete
[2776] Fix | Delete
} elseif ( ! isset( $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['upper_age'] ) || $age > $sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['upper_age'] ) {
[2777] Fix | Delete
[2778] Fix | Delete
$sizes[ $cache_type ][ $cache_status . '_list' ][ $dir ]['upper_age'] = $age;
[2779] Fix | Delete
[2780] Fix | Delete
}
[2781] Fix | Delete
}
[2782] Fix | Delete
}
[2783] Fix | Delete
if ( ! isset( $sizes['fsize'] ) ) {
[2784] Fix | Delete
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[2785] Fix | Delete
$sizes[ $cache_type ]['fsize'] = @filesize( $directory );
[2786] Fix | Delete
} else {
[2787] Fix | Delete
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[2788] Fix | Delete
$sizes[ $cache_type ]['fsize'] += @filesize( $directory );
[2789] Fix | Delete
}
[2790] Fix | Delete
}
[2791] Fix | Delete
return $sizes;
[2792] Fix | Delete
}
[2793] Fix | Delete
[2794] Fix | Delete
function wp_cache_clean_cache( $file_prefix, $all = false ) {
[2795] Fix | Delete
global $cache_path, $supercachedir, $blog_cache_dir;
[2796] Fix | Delete
[2797] Fix | Delete
do_action( 'wp_cache_cleared' );
[2798] Fix | Delete
[2799] Fix | Delete
if ( $all == true && wpsupercache_site_admin() && function_exists( 'prune_super_cache' ) ) {
[2800] Fix | Delete
prune_super_cache( $cache_path, true );
[2801] Fix | Delete
return true;
[2802] Fix | Delete
}
[2803] Fix | Delete
if ( $supercachedir == '' )
[2804] Fix | Delete
$supercachedir = get_supercache_dir();
[2805] Fix | Delete
[2806] Fix | Delete
if (function_exists ('prune_super_cache')) {
[2807] Fix | Delete
if( is_dir( $supercachedir ) ) {
[2808] Fix | Delete
prune_super_cache( $supercachedir, true );
[2809] Fix | Delete
} elseif( is_dir( $supercachedir . '.disabled' ) ) {
[2810] Fix | Delete
prune_super_cache( $supercachedir . '.disabled', true );
[2811] Fix | Delete
}
[2812] Fix | Delete
$_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats;
[2813] Fix | Delete
} else {
[2814] Fix | Delete
wp_cache_debug( 'Warning! prune_super_cache() not found in wp-cache.php', 1 );
[2815] Fix | Delete
}
[2816] Fix | Delete
[2817] Fix | Delete
wp_cache_clean_legacy_files( $blog_cache_dir, $file_prefix );
[2818] Fix | Delete
wp_cache_clean_legacy_files( $cache_path, $file_prefix );
[2819] Fix | Delete
}
[2820] Fix | Delete
[2821] Fix | Delete
function wpsc_delete_post_cache( $id ) {
[2822] Fix | Delete
$post = get_post( $id );
[2823] Fix | Delete
wpsc_delete_url_cache( get_author_posts_url( $post->post_author ) );
[2824] Fix | Delete
$permalink = get_permalink( $id );
[2825] Fix | Delete
if ( $permalink != '' ) {
[2826] Fix | Delete
wpsc_delete_url_cache( $permalink );
[2827] Fix | Delete
return true;
[2828] Fix | Delete
} else {
[2829] Fix | Delete
return false;
[2830] Fix | Delete
}
[2831] Fix | Delete
}
[2832] Fix | Delete
[2833] Fix | Delete
function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
[2834] Fix | Delete
global $wpdb;
[2835] Fix | Delete
[2836] Fix | Delete
$dir = trailingslashit( $dir );
[2837] Fix | Delete
if ( @is_dir( $dir . 'meta' ) == false )
[2838] Fix | Delete
return false;
[2839] Fix | Delete
[2840] Fix | Delete
if ( $handle = @opendir( $dir ) ) {
[2841] Fix | Delete
$curr_blog_id = is_multisite() ? get_current_blog_id() : false;
[2842] Fix | Delete
[2843] Fix | Delete
while ( false !== ( $file = readdir( $handle ) ) ) {
[2844] Fix | Delete
if ( is_file( $dir . $file ) == false || $file == 'index.html' ) {
[2845] Fix | Delete
continue;
[2846] Fix | Delete
}
[2847] Fix | Delete
[2848] Fix | Delete
if ( str_contains( $file, $file_prefix ) ) {
[2849] Fix | Delete
if ( strpos( $file, '.html' ) ) {
[2850] Fix | Delete
// delete old WPCache files immediately
[2851] Fix | Delete
@unlink( $dir . $file);
[2852] Fix | Delete
@unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
[2853] Fix | Delete
} else {
[2854] Fix | Delete
$meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true );
[2855] Fix | Delete
if ( $curr_blog_id && $curr_blog_id !== (int) $meta['blog_id'] ) {
[2856] Fix | Delete
continue;
[2857] Fix | Delete
}
[2858] Fix | Delete
@unlink( $dir . $file);
[2859] Fix | Delete
@unlink( $dir . 'meta/' . $file);
[2860] Fix | Delete
}
[2861] Fix | Delete
}
[2862] Fix | Delete
}
[2863] Fix | Delete
closedir($handle);
[2864] Fix | Delete
}
[2865] Fix | Delete
}
[2866] Fix | Delete
[2867] Fix | Delete
function wp_cache_clean_expired($file_prefix) {
[2868] Fix | Delete
global $cache_max_time, $blog_cache_dir, $wp_cache_preload_on;
[2869] Fix | Delete
[2870] Fix | Delete
if ( $cache_max_time == 0 ) {
[2871] Fix | Delete
return false;
[2872] Fix | Delete
}
[2873] Fix | Delete
[2874] Fix | Delete
// If phase2 was compiled, use its function to avoid race-conditions
[2875] Fix | Delete
if(function_exists('wp_cache_phase2_clean_expired')) {
[2876] Fix | Delete
if ( $wp_cache_preload_on != 1 && function_exists ('prune_super_cache')) {
[2877] Fix | Delete
$dir = get_supercache_dir();
[2878] Fix | Delete
if( is_dir( $dir ) ) {
[2879] Fix | Delete
prune_super_cache( $dir );
[2880] Fix | Delete
} elseif( is_dir( $dir . '.disabled' ) ) {
[2881] Fix | Delete
prune_super_cache( $dir . '.disabled' );
[2882] Fix | Delete
}
[2883] Fix | Delete
$_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats;
[2884] Fix | Delete
}
[2885] Fix | Delete
return wp_cache_phase2_clean_expired($file_prefix);
[2886] Fix | Delete
}
[2887] Fix | Delete
[2888] Fix | Delete
$now = time();
[2889] Fix | Delete
if ( $handle = @opendir( $blog_cache_dir ) ) {
[2890] Fix | Delete
while ( false !== ( $file = readdir( $handle ) ) ) {
[2891] Fix | Delete
if ( str_contains( $file, $file_prefix ) ) {
[2892] Fix | Delete
if ( strpos( $file, '.html' ) ) {
[2893] Fix | Delete
@unlink( $blog_cache_dir . $file);
[2894] Fix | Delete
@unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
[2895] Fix | Delete
} elseif ( ( filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) {
[2896] Fix | Delete
@unlink( $blog_cache_dir . $file );
[2897] Fix | Delete
@unlink( $blog_cache_dir . 'meta/' . $file );
[2898] Fix | Delete
}
[2899] Fix | Delete
}
[2900] Fix | Delete
}
[2901] Fix | Delete
closedir($handle);
[2902] Fix | Delete
}
[2903] Fix | Delete
}
[2904] Fix | Delete
[2905] Fix | Delete
function wpsc_remove_marker( $filename, $marker ) {
[2906] Fix | Delete
if (!file_exists( $filename ) || is_writeable_ACLSafe( $filename ) ) {
[2907] Fix | Delete
if (!file_exists( $filename ) ) {
[2908] Fix | Delete
return '';
[2909] Fix | Delete
} else {
[2910] Fix | Delete
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
[2911] Fix | Delete
}
[2912] Fix | Delete
[2913] Fix | Delete
$f = fopen( $filename, 'w' );
[2914] Fix | Delete
if ( $markerdata ) {
[2915] Fix | Delete
$state = true;
[2916] Fix | Delete
foreach ( $markerdata as $n => $markerline ) {
[2917] Fix | Delete
if (strpos($markerline, '# BEGIN ' . $marker) !== false)
[2918] Fix | Delete
$state = false;
[2919] Fix | Delete
if ( $state ) {
[2920] Fix | Delete
if ( $n + 1 < count( $markerdata ) )
[2921] Fix | Delete
fwrite( $f, "{$markerline}\n" );
[2922] Fix | Delete
else
[2923] Fix | Delete
fwrite( $f, "{$markerline}" );
[2924] Fix | Delete
}
[2925] Fix | Delete
if (strpos($markerline, '# END ' . $marker) !== false) {
[2926] Fix | Delete
$state = true;
[2927] Fix | Delete
}
[2928] Fix | Delete
}
[2929] Fix | Delete
}
[2930] Fix | Delete
return true;
[2931] Fix | Delete
} else {
[2932] Fix | Delete
return false;
[2933] Fix | Delete
}
[2934] Fix | Delete
}
[2935] Fix | Delete
[2936] Fix | Delete
if( get_option( 'gzipcompression' ) )
[2937] Fix | Delete
update_option( 'gzipcompression', 0 );
[2938] Fix | Delete
[2939] Fix | Delete
// Catch 404 requests. Themes that use query_posts() destroy $wp_query->is_404
[2940] Fix | Delete
function wp_cache_catch_404() {
[2941] Fix | Delete
global $wp_cache_404;
[2942] Fix | Delete
if ( function_exists( '_deprecated_function' ) )
[2943] Fix | Delete
_deprecated_function( __FUNCTION__, 'WP Super Cache 1.5.6' );
[2944] Fix | Delete
$wp_cache_404 = false;
[2945] Fix | Delete
if( is_404() )
[2946] Fix | Delete
$wp_cache_404 = true;
[2947] Fix | Delete
}
[2948] Fix | Delete
//More info - https://github.com/Automattic/wp-super-cache/pull/373
[2949] Fix | Delete
//add_action( 'template_redirect', 'wp_cache_catch_404' );
[2950] Fix | Delete
[2951] Fix | Delete
function wp_cache_favorite_action( $actions ) {
[2952] Fix | Delete
if ( function_exists( '_deprecated_function' ) ) {
[2953] Fix | Delete
_deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.4' );
[2954] Fix | Delete
}
[2955] Fix | Delete
[2956] Fix | Delete
if ( false == wpsupercache_site_admin() )
[2957] Fix | Delete
return $actions;
[2958] Fix | Delete
[2959] Fix | Delete
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
[2960] Fix | Delete
return $actions;
[2961] Fix | Delete
[2962] Fix | Delete
$actions[ wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1&tab=contents', 'wp-cache' ) ] = array( __( 'Delete Cache', 'wp-super-cache' ), 'manage_options' );
[2963] Fix | Delete
[2964] Fix | Delete
return $actions;
[2965] Fix | Delete
}
[2966] Fix | Delete
//add_filter( 'favorite_actions', 'wp_cache_favorite_action' );
[2967] Fix | Delete
[2968] Fix | Delete
function wp_cache_plugin_notice( $plugin ) {
[2969] Fix | Delete
global $cache_enabled;
[2970] Fix | Delete
if( $plugin == 'wp-super-cache/wp-cache.php' && !$cache_enabled && function_exists( 'admin_url' ) )
[2971] Fix | Delete
echo '<td colspan="5" class="plugin-update">' . sprintf( __( 'WP Super Cache must be configured. Go to <a href="%s">the admin page</a> to enable and configure the plugin.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</td>';
[2972] Fix | Delete
}
[2973] Fix | Delete
add_action( 'after_plugin_row', 'wp_cache_plugin_notice' );
[2974] Fix | Delete
[2975] Fix | Delete
function wp_cache_plugin_actions( $links, $file ) {
[2976] Fix | Delete
if ( $file === 'wp-super-cache/wp-cache.php' && function_exists( 'admin_url' ) && is_array( $links ) ) {
[2977] Fix | Delete
$settings_link = '<a href="' . admin_url( 'options-general.php?page=wpsupercache' ) . '">' . __( 'Settings', 'wp-super-cache' ) . '</a>';
[2978] Fix | Delete
array_unshift( $links, $settings_link ); // before other links
[2979] Fix | Delete
}
[2980] Fix | Delete
return $links;
[2981] Fix | Delete
}
[2982] Fix | Delete
add_filter( 'plugin_action_links', 'wp_cache_plugin_actions', 10, 2 );
[2983] Fix | Delete
[2984] Fix | Delete
function wp_cache_admin_notice() {
[2985] Fix | Delete
global $cache_enabled, $wp_cache_phase1_loaded;
[2986] Fix | Delete
if( substr( $_SERVER['PHP_SELF'], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( 'admin_url' ) )
[2987] Fix | Delete
echo '<div class="notice notice-info"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
[2988] Fix | Delete
[2989] Fix | Delete
if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
[2990] Fix | Delete
if ( wp_cache_create_advanced_cache() ) {
[2991] Fix | Delete
echo '<div class="notice notice-error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>';
[2992] Fix | Delete
}
[2993] Fix | Delete
}
[2994] Fix | Delete
}
[2995] Fix | Delete
add_action( 'admin_notices', 'wp_cache_admin_notice' );
[2996] Fix | Delete
[2997] Fix | Delete
function wp_cache_check_site() {
[2998] Fix | Delete
global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wpdb;
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function