Created
February 21, 2012 00:55
-
-
Save kurtpayne/1872650 to your computer and use it in GitHub Desktop.
W3TC Autoconfigurator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Activate W3 Total Cache | |
if ( file_exists( WP_PLUGIN_DIR . '/w3-total-cache/w3-total-cache.php' ) ) | |
activate_plugin( WP_PLUGIN_DIR . '/w3-total-cache/w3-total-cache.php' , admin_url() ); | |
// Load host specific W3TC config | |
if ( defined( 'W3TC_CONFIG_PATH' ) ) { | |
// Set the configuration path based on the platform's abilities | |
$config_path = realpath( dirname( __FILE__ ) ) . '/resources/w3-total-cache-config_default.php'; | |
// Copy our config to W3TC's default config path | |
file_put_contents( W3TC_CONFIG_PATH, file_get_contents( $config_path ) ); | |
// Initialize 2 config objects | |
$old_config = new W3_Config(); // Default config | |
$new_config = new W3_Config(); // Our config | |
// Load our config file | |
$new_config->read( W3TC_CONFIG_PATH ); | |
// Overwrite the default config with our values | |
$admin = w3_instance( 'W3_Plugin_TotalCacheAdmin' ); | |
$admin->config_save( $old_config, $new_config ); | |
// Disable W3TC preview mode | |
if ( file_exists( W3TC_CONFIG_PREVIEW_PATH ) ) | |
unlink( W3TC_CONFIG_PREVIEW_PATH ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment