Example #1
0
 /**
  * Returns onject instance. Called by WP engine
  *
  * @return W3_Db
  */
 static function instance()
 {
     static $instances = array();
     if (!isset($instances[0])) {
         $processors = array();
         $call_default_constructor = true;
         // no caching during activation
         $is_installing = defined('WP_INSTALLING') && WP_INSTALLING;
         $config = w3_instance('W3_Config');
         if (!$is_installing && $config->get_boolean('dbcache.enabled')) {
             $processors[] = w3_instance('W3_DbCache');
         }
         if (w3_is_dbcluster()) {
             $processors[] = w3_instance('W3_Enterprise_DbCluster');
         }
         $processors[] = new W3_DbProcessor();
         $class = __CLASS__;
         $o = new $class($processors);
         $underlying_manager = new W3_DbCallUnderlying($o);
         foreach ($processors as $processor) {
             $processor->manager = $o;
             $processor->underlying_manager = $underlying_manager;
         }
         // initialize after processors configured
         $o->initialize();
         @($instances[0] = $o);
     }
     return $instances[0];
 }
Example #2
0
 /**
  * Database cluster config editor
  *
  * @return void
  */
 function dbcluster_config()
 {
     $this->_page = 'w3tc_dbcluster_config';
     if (w3_is_dbcluster()) {
         $content = @file_get_contents(W3TC_FILE_DB_CLUSTER_CONFIG);
     } else {
         $content = @file_get_contents(W3TC_DIR . '/ini/dbcluster-config-sample.php');
     }
     include W3TC_INC_OPTIONS_DIR . '/enterprise/dbcluster-config.php';
 }
Example #3
0
 /**
  * Check if we can do modify contents
  *
  * @return boolean
  */
 function can_ob()
 {
     global $w3_late_init;
     $enabled = w3_is_preview_mode();
     $enabled = $enabled || $this->_config->get_boolean('pgcache.enabled');
     $enabled = $enabled || $this->_config->get_boolean('dbcache.enabled');
     $enabled = $enabled || $this->_config->get_boolean('objectcache.enabled');
     $enabled = $enabled || $this->_config->get_boolean('browsercache.enabled');
     $enabled = $enabled || $this->_config->get_boolean('minify.enabled');
     $enabled = $enabled || $this->_config->get_boolean('cdn.enabled');
     $enabled = $enabled || $this->_config->get_boolean('fragmentcache.enabled');
     $enabled = $enabled || w3_is_dbcluster();
     $enabled = $enabled && !$w3_late_init;
     /**
      * Check if plugin enabled
      */
     if (!$enabled) {
         return false;
     }
     /**
      * Skip if admin
      */
     if (defined('WP_ADMIN')) {
         return false;
     }
     /**
      * Skip if doing AJAX
      */
     if (defined('DOING_AJAX')) {
         return false;
     }
     /**
      * Skip if doing cron
      */
     if (defined('DOING_CRON')) {
         return false;
     }
     /**
      * Skip if APP request
      */
     if (defined('APP_REQUEST')) {
         return false;
     }
     /**
      * Skip if XMLRPC request
      */
     if (defined('XMLRPC_REQUEST')) {
         return false;
     }
     /**
      * Check for WPMU's and WP's 3.0 short init
      */
     if (defined('SHORTINIT') && SHORTINIT) {
         return false;
     }
     /**
      * Check User Agent
      */
     if (isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], W3TC_POWERED_BY) !== false) {
         return false;
     }
     return true;
 }
Example #4
0
    define('W3TC_DIR', WP_CONTENT_DIR . '/plugins/w3-total-cache');
}
/**
 * Abort W3TC loading if WordPress is upgrading
 */
if (!@is_dir(W3TC_DIR) || !file_exists(W3TC_DIR . '/inc/define.php')) {
    if (!defined('WP_ADMIN')) {
        // lets don't show error on front end
        require_once ABSPATH . WPINC . '/wp-db.php';
    } else {
        @header('HTTP/1.1 503 Service Unavailable');
        die(sprintf('<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.', __FILE__));
    }
} else {
    require_once W3TC_DIR . '/inc/define.php';
    // no caching during activation
    $is_installing = defined('WP_INSTALLING') && WP_INSTALLING;
    $config = w3_instance('W3_Config');
    if (!$is_installing && $config->get_boolean('dbcache.enabled') || w3_is_dbcluster()) {
        if (defined('DB_TYPE')) {
            $db_driver_path = sprintf('%s/Db/%s.php', W3TC_LIB_W3_DIR, DB_TYPE);
            if (file_exists($db_driver_path)) {
                require_once $db_driver_path;
            } else {
                die(sprintf('<strong>W3 Total Cache Error:</strong> database driver doesn\'t exist: %s.', $db_driver_path));
            }
        }
        w3_require_once(W3TC_LIB_W3_DIR . '/Db.php');
        $GLOBALS['wpdb'] = W3_Db::instance();
    }
}
<tr>
    <th><label for="w3tc_dbcluster_config">Database cluster:</th>
    <td>
        <input type="submit" id="w3tc_dbcluster_config" name="w3tc_dbcluster_config" class="button"
               value="<?php 
echo w3_is_dbcluster() ? 'Edit Database Cluster Configuration' : 'Enable database cluster';
?>
" /><br />
        <span class="description">Create db-cluster-config.php file with your database cluster configuration to enable it.</span>
    </td>
</tr>