wp_cache_create_advanced_cache()WPSCache 1.0

Hooks from the function

Return

null. Nothing (null).

Usage

wp_cache_create_advanced_cache();

wp_cache_create_advanced_cache() code WPSCache 1.12.0

function wp_cache_create_advanced_cache() {
	global $wpsc_advanced_cache_filename, $wpsc_advanced_cache_dist_filename;
	if ( file_exists( ABSPATH . 'wp-config.php') ) {
		$global_config_file = ABSPATH . 'wp-config.php';
	} elseif ( file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
		$global_config_file = dirname( ABSPATH ) . '/wp-config.php';
	} elseif ( defined( 'DEBIAN_FILE' ) && file_exists( DEBIAN_FILE ) ) {
		$global_config_file = DEBIAN_FILE;
	} else {
		die('Cannot locate wp-config.php');
	}

	$line = 'define( \'WPCACHEHOME\', \'' . __DIR__ . '/\' );';

	if ( ! apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
		echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! " . sprintf( __( 'Not allowed to edit %s per configuration.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
		return false;
	}

	if (
		! strpos( file_get_contents( $global_config_file ), "WPCACHEHOME" ) ||
		(
			defined( 'WPCACHEHOME' ) &&
			(
				constant( 'WPCACHEHOME' ) == '' ||
				(
					constant( 'WPCACHEHOME' ) != '' &&
					! file_exists( constant( 'WPCACHEHOME' ) . '/wp-cache.php' )
				)
			)
		)
	) {
		if (
			! is_writeable_ACLSafe( $global_config_file ) ||
			! wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', $line, $global_config_file )
		) {
			echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
			return false;
		}
	}
	$ret = true;

	if ( file_exists( $wpsc_advanced_cache_filename ) ) {
		$file = file_get_contents( $wpsc_advanced_cache_filename );
		if (
			! strpos( $file, "WP SUPER CACHE 0.8.9.1" ) &&
			! strpos( $file, "WP SUPER CACHE 1.2" )
		) {
			return false;
		}
	}

	$file = file_get_contents( $wpsc_advanced_cache_dist_filename );
	$fp = @fopen( $wpsc_advanced_cache_filename, 'w' );
	if( $fp ) {
		// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fwrite
		fwrite( $fp, $file );
		fclose( $fp );
	} else {
		$ret = false;
	}
	return $ret;
}