/**
 * Register a fragment group for whole network in MS install
 *
 * @param unknown $group
 * @param unknown $actions
 * @param integer $expiration in seconds
 * @return mixed
 */
function w3tc_register_fragment_global_group($group, $actions, $expiration)
{
    if (!is_int($expiration)) {
        $expiration = (int) $expiration;
        trigger_error(__FUNCTION__ . ' needs expiration parameter to be an int.', E_USER_WARNING);
    }
    $o = \W3TC\Dispatcher::component('Extension_FragmentCache_Core');
    return $o->register_global_group($group, $actions, $expiration);
}
Ejemplo n.º 2
0
function w3_instance($class)
{
    $modified_class = null;
    if ($class == 'W3_Redirect') {
        $modified_class = 'Mobile_Redirect';
    } else {
        if ($class == 'W3_Config') {
            $modified_class = 'Config';
        } else {
            if ($class == 'W3_PgCache') {
                $modified_class = 'PgCache_ContentGrabber';
            } else {
                if ($class == 'W3_PgCache') {
                    $modified_class = 'PgCache_ContentGrabber';
                } else {
                    if ($class == 'W3_ObjectCacheBridge') {
                        $modified_class = 'ObjectCache_WpObjectCache';
                    }
                }
            }
        }
    }
    return \W3TC\Dispatcher::component($modified_class);
}
Ejemplo n.º 3
0
        if (isset($w3tc_message_object->host) && !is_null($w3tc_message_object->host)) {
            $_SERVER['HTTP_HOST'] = $w3tc_message_object->host;
        }
    } else {
        if ($message_object->Type != 'SubscriptionConfirmation') {
            echo 'Unsupported message type';
            exit;
        }
    }
}
/**
 * W3 Total Cache SNS module
 */
define('W3TC_WP_LOADING', true);
if (!defined('ABSPATH')) {
    if (file_exists(dirname(__FILE__) . '/../../../../wp-load.php')) {
        require_once dirname(__FILE__) . '/../../../../wp-load.php';
    } else {
        require_once dirname(__FILE__) . '/../../w3tc-wp-loader.php';
    }
}
if (!defined('W3TC_DIR')) {
    define('W3TC_DIR', realpath(dirname(__FILE__) . '/..'));
}
if (!@is_dir(W3TC_DIR) || !file_exists(W3TC_DIR . '/w3-total-cache-api.php')) {
    @header('X-Robots-Tag: noarchive, noodp, nosnippet');
    echo 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>. <br />', dirname(__FILE__));
}
require_once W3TC_DIR . '/w3-total-cache-api.php';
$server = \W3TC\Dispatcher::component('Enterprise_SnsServer');
$server->process_message();
/**
 * deprecated
 * Reloads files.
 *
 * @param string[] $files list of files supports, fullpath, from root, wp-content
 * @param bool    $http  if delete request should be made over http to current site. Default false.
 * @return mixed
 */
function w3tc_opcache_flush_file($file, $http = false)
{
    if (!$http) {
        $o = \W3TC\Dispatcher::component('CacheFlush');
        return $o->opcache_flush_file($file);
    } else {
        $url = WP_PLUGIN_URL . '/' . dirname(W3TC_FILE) . '/pub/opcache.php';
        $path = parse_url($url, PHP_URL_PATH);
        $post = array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'body' => array('nonce' => wp_hash($path), 'command' => 'flush_file', 'file' => $file));
        $result = wp_remote_post($url, $post);
        if (is_wp_error($result)) {
            return $result;
        } elseif ($result['response']['code'] != '200') {
            return $result['response']['code'];
        }
        return true;
    }
}
Ejemplo n.º 5
0
/**
Deprecated. Retained for 3rd parties that use it. see w3tc_config()
*/
function w3_instance($class)
{
    $legacy_class_name = null;
    if ($class == 'W3_Config') {
        $legacy_class_name = 'Config';
    } elseif ($class == 'W3_ObjectCacheBridge') {
        $legacy_class_name = 'ObjectCache_WpObjectCache';
    } elseif ($class == 'W3_PgCache') {
        $legacy_class_name = 'PgCache_ContentGrabber';
    } elseif ($class == 'W3_Redirect') {
        $legacy_class_name = 'Mobile_Redirect';
    } else {
        return null;
    }
    return \W3TC\Dispatcher::component($legacy_class_name);
}
Ejemplo n.º 6
0
 /**
  * Init cache
  *
  * @return void
  */
 function wp_cache_init()
 {
     $GLOBALS['wp_object_cache'] = \W3TC\Dispatcher::component('ObjectCache_WpObjectCache');
 }
Ejemplo n.º 7
0
if (!defined('ABSPATH')) {
    die;
}
global $w3tc_start_microtime;
$w3tc_start_microtime = microtime(true);
/**
 * Abort W3TC loading if WordPress is upgrading
 */
if (defined('WP_INSTALLING') && WP_INSTALLING) {
    return;
}
if (!defined('W3TC_IN_MINIFY')) {
    if (!defined('W3TC_DIR')) {
        define('W3TC_DIR', (defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins') . '/w3-total-cache');
    }
    if (!@is_dir(W3TC_DIR) || !file_exists(W3TC_DIR . '/w3-total-cache-api.php')) {
        if (defined('WP_ADMIN')) {
            // lets don't show error on front end
            echo 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>. <br />', __FILE__);
        }
    } else {
        require_once W3TC_DIR . '/w3-total-cache-api.php';
        $w3tc_redirect = \W3TC\Dispatcher::component('Mobile_Redirect');
        $w3tc_redirect->process();
        $w3tc_config = \W3TC\Dispatcher::config();
        if ($w3tc_config->get_boolean('pgcache.enabled')) {
            $o = \W3TC\Dispatcher::component('PgCache_ContentGrabber');
            $o->process();
        }
    }
}
Ejemplo n.º 8
0
    define('W3TC_DIR', WP_PLUGIN_DIR . '/w3-total-cache');
}
if (!@is_dir(W3TC_DIR) || !file_exists(W3TC_DIR . '/w3-total-cache-api.php')) {
    @header('X-Robots-Tag: noarchive, noodp, nosnippet');
    echo 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>.<br />', dirname(__FILE__));
}
$command = \W3TC\Util_Request::get_string('command');
$nonce = \W3TC\Util_Request::get_string('nonce');
$uri = $_SERVER['REQUEST_URI'];
if (hash_equals(wp_hash($uri), $nonce)) {
    /**
     *
     *
     * @var $w3_cache W3_CacheFlush
     */
    $w3_cache = \W3TC\Dispatcher::component('CacheFlush');
    $result = false;
    switch ($command) {
        case 'flush':
            $result = $w3_cache->opcache_flush();
            break;
        case 'flush_file':
            $file = \W3TC\Util_Request::get_string('file');
            $result = $w3_cache->opcache_flush_file($file);
            break;
    }
    if ($result) {
        header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
        die('Success');
    } else {
        header($_SERVER["SERVER_PROTOCOL"] . " 500 OK");