WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

wpcache_do_rebuild() WPSCache 1.0

Хуков нет.

Возвращает

null. Ничего.

Использование

wpcache_do_rebuild( $dir );
$dir (обязательный)
-

Код wpcache_do_rebuild() WPSCache 1.7.4

<?php
function wpcache_do_rebuild( $dir ) {
	global $do_rebuild_list, $cache_path, $wpsc_file_mtimes;
	wp_cache_debug( "wpcache_do_rebuild: doing rebuild for $dir" );

	if ( !is_dir( $dir ) ) {
		wp_cache_debug( "wpcache_do_rebuild: exiting as directory is not a directory: $dir" );
		return false;
	}

	$dir = wpsc_get_realpath( $dir );
	if ( ! $dir ) {
		wp_cache_debug( 'wpcache_do_rebuild: exiting as directory does not exist.' );
		return false;
	}

	if ( isset( $do_rebuild_list[ $dir ] ) ) {
		wp_cache_debug( "wpcache_do_rebuild: directory already rebuilt: $dir" );
		return false;
	}

	$protected = wpsc_get_protected_directories();
	foreach( $protected as $id => $directory ) {
		$protected[ $id ] = wpsc_get_realpath( $directory );
	}

	if ( ! wpsc_is_in_cache_directory( $dir ) ) {
		wp_cache_debug( "wpcache_do_rebuild: exiting as directory not in cache_path: $dir" );
		return false;
	}

	if ( in_array( $dir, $protected ) ) {
		wp_cache_debug( "wpcache_do_rebuild: exiting as directory is protected: $dir" );
		return false;
	}

	if ( !is_dir( $dir ) ) {
		wp_cache_debug( "wpcache_do_rebuild: exiting as directory is not a directory: $dir" );
		return false;
	}

	$dh = @opendir( $dir );
	if ( false == $dh ) {
		wp_cache_debug( "wpcache_do_rebuild: exiting as could not open directory for reading: $dir" );
		return false;
	}

	$dir = trailingslashit( $dir );
	$wpsc_file_mtimes = array();
	while ( ( $file = readdir( $dh ) ) !== false ) {
		if ( $file == '.' || $file == '..' || false == is_file( $dir . $file ) ) {
			continue;
		}

		$cache_file = $dir . $file;
		// if the file is index.html.needs-rebuild and index.html doesn't exist and
		// if the rebuild file is less than 10 seconds old then remove the ".needs-rebuild"
		// extension so index.html can be served to other visitors temporarily
		// until index.html is generated again at the end of this page.

		if ( substr( $cache_file, -14 ) != '.needs-rebuild' ) {
			wp_cache_debug( "wpcache_do_rebuild: base file found: $cache_file" );
			continue;
		}

		wp_cache_debug( "wpcache_do_rebuild: found rebuild file: $cache_file" );

		if ( @file_exists( substr( $cache_file, 0, -14 ) ) ) {
			wp_cache_debug( "wpcache_do_rebuild: rebuild file deleted because base file found: $cache_file" );
			@unlink( $cache_file ); // delete the rebuild file because index.html already exists
			continue;
		}

		$mtime = @filemtime( $cache_file );
		if ( $mtime && ( time() - $mtime ) < 10 ) {
			wp_cache_debug( "wpcache_do_rebuild: rebuild file is new: $cache_file" );
			$base_file = substr( $cache_file, 0, -14 );
			if ( false == @rename( $cache_file, $base_file ) ) { // rename the rebuild file
				@unlink( $cache_file );
				wp_cache_debug( "wpcache_do_rebuild: rebuild file rename failed. Deleted rebuild file: $cache_file" );
			} else {
				$do_rebuild_list[ $dir ] = 1;
				$wpsc_file_mtimes[ $base_file ] = $mtime;
				wp_cache_debug( "wpcache_do_rebuild: rebuild file renamed: $base_file" );
			}
		} else {
			wp_cache_debug( "wpcache_do_rebuild: rebuild file deleted because it's too old: $cache_file" );
			@unlink( $cache_file ); // delete the rebuild file because index.html already exists
		}
	}
}