本文整理汇总了PHP中w3tc_objectcache_flush函数的典型用法代码示例。如果您正苦于以下问题:PHP w3tc_objectcache_flush函数的具体用法?PHP w3tc_objectcache_flush怎么用?PHP w3tc_objectcache_flush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3tc_objectcache_flush函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flush
/**
* Clear something from the cache
*
* @param array $args
* @param array $vars
*/
function flush($args = array(), $vars = array())
{
if (function_exists('w3tc_pgcache_flush')) {
$args = array_unique($args);
do {
$cache_type = array_shift($args);
switch ($cache_type) {
case 'db':
case 'database':
if (w3tc_dbcache_flush()) {
WP_CLI::success('The object cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the object cache failed.');
}
break;
case 'minify':
if (w3tc_minify_flush()) {
WP_CLI::success('The object cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the object cache failed.');
}
break;
case 'object':
if (w3tc_objectcache_flush()) {
WP_CLI::success('The object cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the object cache failed.');
}
break;
case 'post':
default:
if (isset($vars['post_id'])) {
if (is_numeric($vars['post_id'])) {
w3tc_pgcache_flush_post($vars['post_id']);
} else {
WP_CLI::error('This is not a valid post id.');
}
w3tc_pgcache_flush_post($vars['post_id']);
} elseif (isset($vars['permalink'])) {
$id = url_to_postid($vars['permalink']);
if (is_numeric($id)) {
w3tc_pgcache_flush_post($id);
} else {
WP_CLI::error('There is no post with this permalink.');
}
} else {
if (isset($flushed_page_cache) && $flushed_page_cache) {
break;
}
$flushed_page_cache = true;
w3tc_pgcache_flush();
}
}
} while (!empty($args));
} else {
WP_CLI::error('The W3 Total Cache could not be found, is it installed?');
}
}
示例2: clear_caches
/**
* Clear caches.
*
* Clears popular WordPress caching mechanisms.
*
* @since 4.0.0
*
* @param bool $page [optional] true to clear page cache
*
* @return void
*/
public static function clear_caches($page = false)
{
//clear APC Cache
if (function_exists('apc_store')) {
apc_clear_cache();
//Let's clear APC (if it exists) when big stuff is saved.
}
//clear w3 total cache or wp super cache
if (function_exists('w3tc_pgcache_flush')) {
if (true == $page) {
w3tc_pgcache_flush();
w3tc_minify_flush();
}
w3tc_dbcache_flush();
w3tc_objectcache_flush();
} else {
if (function_exists('wp_cache_clear_cache') && true == $page) {
wp_cache_clear_cache();
}
}
}
示例3: save_settings
function save_settings()
{
$options = get_option($this->optionname);
if (isset($_REQUEST['reset']) && $_REQUEST['reset'] == "true" && isset($_REQUEST['plugin']) && $_REQUEST['plugin'] == 'google-analytics-for-wordpress') {
$options = $this->set_defaults();
$options['msg'] = "<div class=\"updated\"><p>" . __('Google Analytics settings reset.') . "</p></div>\n";
} elseif (isset($_POST['submit']) && isset($_POST['plugin']) && $_POST['plugin'] == 'google-analytics-for-wordpress') {
if (!current_user_can('manage_options')) {
die(__('You cannot edit the Google Analytics for WordPress options.'));
}
check_admin_referer('analyticspp-config');
foreach (array('uastring', 'dlextensions', 'domainorurl', 'position', 'domain', 'customcode', 'ga_token', 'extraseurl', 'gajsurl', 'gfsubmiteventpv', 'trackprefix', 'ignore_userlevel', 'internallink', 'internallinklabel', 'primarycrossdomain', 'othercrossdomains') as $option_name) {
if (isset($_POST[$option_name])) {
$options[$option_name] = $_POST[$option_name];
} else {
$options[$option_name] = '';
}
}
foreach (array('extrase', 'trackoutbound', 'admintracking', 'trackadsense', 'allowanchor', 'allowlinker', 'allowhash', 'rsslinktagging', 'advancedsettings', 'trackregistration', 'theme_updated', 'cv_loggedin', 'cv_authorname', 'cv_category', 'cv_all_categories', 'cv_tags', 'cv_year', 'cv_post_type', 'outboundpageview', 'downloadspageview', 'trackcrossdomain', 'gajslocalhosting', 'manual_uastring', 'taggfsubmit', 'wpec_tracking', 'shopp_tracking', 'anonymizeip', 'trackcommentform', 'debug', 'firebuglite', 'yoast_tracking') as $option_name) {
if (isset($_POST[$option_name]) && $_POST[$option_name] == 'on') {
$options[$option_name] = true;
} else {
$options[$option_name] = false;
}
}
if (isset($_POST['manual_uastring']) && isset($_POST['uastring_man'])) {
$options['uastring'] = $_POST['uastring_man'];
}
if ($options['trackcrossdomain']) {
if (!$options['allowlinker']) {
$options['allowlinker'] = true;
}
if (empty($options['primarycrossdomain'])) {
$origin = GA_Filter::ga_get_domain($_SERVER["HTTP_HOST"]);
$options['primarycrossdomain'] = $origin["domain"];
}
}
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
}
if (function_exists('w3tc_dbcache_flush')) {
w3tc_dbcache_flush();
}
if (function_exists('w3tc_minify_flush')) {
w3tc_minify_flush();
}
if (function_exists('w3tc_objectcache_flush')) {
w3tc_objectcache_flush();
}
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache();
}
$options['msg'] = "<div id=\"updatemessage\" class=\"updated fade\"><p>Google Analytics <strong>settings updated</strong>.</p></div>\n";
$options['msg'] .= "<script type=\"text/javascript\">setTimeout(function(){jQuery('#updatemessage').hide('slow');}, 3000);</script>";
}
update_option($this->optionname, $options);
}
示例4: flush_w3tc_cache
/**
* Flush W3TC cache after succesfull update/add of taxonomy meta option
*
* @todo [JRF => whomever] check the above and this function to see if they should be combined or really
* do something significantly different
*
* @static
*/
public static function flush_w3tc_cache()
{
if (defined('W3TC_DIR') && function_exists('w3tc_objectcache_flush')) {
w3tc_objectcache_flush();
}
}
示例5: w3tc_flush
public function w3tc_flush($flushAll = false)
{
if ($flushAll) {
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
}
if (function_exists('w3tc_dbcache_flush')) {
w3tc_dbcache_flush();
}
}
if (function_exists('w3tc_objectcache_flush')) {
w3tc_objectcache_flush();
}
}
示例6: w3_config_save
//.........这里部分代码省略.........
}
}
if ($current_config->get_boolean('newrelic.enabled')) {
if ($current_config->get_boolean('pgcache.enabled')) {
if (w3_is_network() && $current_config->get_boolean('common.force_master')) {
$new_config->set('pgcache.late_init', true);
}
}
}
do_action('w3tc_saved_options', $new_config, $new_config_admin);
/**
* Save config
*/
try {
$new_config_admin->save();
$new_config->save();
} catch (Exception $ex) {
// try to fix environment, it potentially can be fixed silently
// dont show error here, it will be called again later
// in admin_notices
try {
$environment = w3_instance('W3_AdminEnvironment');
$environment->fix_in_wpadmin($new_config);
} catch (Exception $ex) {
}
// retry save process and complain now on failure
try {
$new_config_admin->save();
$new_config->save();
} catch (Exception $ex) {
throw new Exception('<strong>Can\'t change configuration</strong>: ' . $ex->getMessage());
}
}
$w3_plugin_cdn = w3_instance('W3_Plugin_CdnAdmin');
/**
* Empty caches on engine change or cache enable/disable
*/
if ($old_config->get_string('pgcache.engine') != $new_config->get_string('pgcache.engine') || $old_config->get_string('pgcache.enabled') != $new_config->get_string('pgcache.enabled')) {
w3tc_pgcache_flush();
}
if ($old_config->get_string('dbcache.engine') != $new_config->get_string('dbcache.engine') || $old_config->get_string('dbcache.enabled') != $new_config->get_string('dbcache.enabled')) {
w3tc_dbcache_flush();
}
if ($old_config->get_string('objectcache.engine') != $new_config->get_string('objectcache.engine') || $old_config->get_string('objectcache.enabled') != $new_config->get_string('objectcache.enabled')) {
w3tc_objectcache_flush();
}
if ($old_config->get_string('minify.engine') != $new_config->get_string('minify.engine') || $old_config->get_string('minify.enabled') != $new_config->get_string('minify.enabled')) {
w3tc_minify_flush();
}
/**
* Update CloudFront CNAMEs
*/
$update_cf_cnames = false;
if ($new_config->get_boolean('cdn.enabled') && in_array($new_config->get_string('cdn.engine'), array('cf', 'cf2'))) {
if ($new_config->get_string('cdn.engine') == 'cf') {
$old_cnames = $old_config->get_array('cdn.cf.cname');
$new_cnames = $new_config->get_array('cdn.cf.cname');
} else {
$old_cnames = $old_config->get_array('cdn.cf2.cname');
$new_cnames = $new_config->get_array('cdn.cf2.cname');
}
if (count($old_cnames) != count($new_cnames) || count(array_diff($old_cnames, $new_cnames))) {
$update_cf_cnames = true;
}
}
/**
* Refresh config
*/
$current_config->load();
/**
* React to config changes
*/
$environment = w3_instance('W3_AdminEnvironment');
$environment->fix_on_event($new_config, 'config_change', $old_config);
/**
* Update support us option
*/
w3_instance('W3_AdminLinks')->link_update($current_config);
/**
* Auto upload minify files to CDN
*/
if ($new_config->get_boolean('minify.enabled') && $new_config->get_boolean('minify.upload') && $new_config->get_boolean('cdn.enabled') && !w3_is_cdn_mirror($new_config->get_string('cdn.engine'))) {
w3_cdn_upload_minify();
}
/**
* Auto upload browsercache files to CDN
*/
if ($new_config->get_boolean('cdn.enabled') && $new_config->get_string('cdn.engine') == 'ftp') {
w3_cdn_delete_browsercache($current_config);
w3_cdn_upload_browsercache($current_config);
}
/**
* Update CloudFront CNAMEs
*/
if ($update_cf_cnames) {
$error = null;
$w3_plugin_cdn->update_cnames($error);
}
return true;
}
示例7: flush_objectcache
/**
* Flush object cache
*
* @return void
*/
function flush_objectcache()
{
_doing_it_wrong('flush_objectcache', 'This function is deprecated. Use w3tc_objectcache_flush() instead.', '0.9.3');
w3tc_objectcache_flush();
}
示例8: clear_cache
public function clear_cache()
{
if (function_exists('wp_cache_clear_cache')) {
$GLOBALS["super_cache_enabled"] = 1;
wp_cache_clear_cache();
} else {
if (function_exists('simple_cache_clear')) {
simple_cache_clear();
} else {
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
}
if (function_exists('w3tc_dbcache_flush')) {
w3tc_dbcache_flush();
}
if (function_exists('w3tc_minify_flush')) {
w3tc_minify_flush();
}
if (function_exists('w3tc_objectcache_flush')) {
w3tc_objectcache_flush();
}
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache();
}
}
}
}
示例9: ini_set
*/
/*
ini_set('display_errors',1);
error_reporting(E_ALL);
*/
/* Define the file path */
if (!defined("WP_CONTENT_URL")) {
define("WP_CONTENT_URL", get_option("siteurl") . "/wp-content");
}
if (!defined("WP_PLUGIN_URL")) {
define("WP_PLUGIN_URL", WP_CONTENT_URL . "/plugins");
}
define('DD_PLUGIN_URL', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)) . '/');
// fix for the W3 Total Cache bug (fixed in Digg Digg 5.1)
if (function_exists('w3tc_objectcache_flush')) {
w3tc_objectcache_flush();
}
require_once 'include/dd-global-variable.php';
require_once 'include/dd-printform.php';
require_once 'include/dd-helper.php';
require_once 'include/dd-manual.php';
require_once 'include/dd-upgrade.php';
//http://codex.wordpress.org/Function_Reference/register_activation_hook
//function to be run when the plugin is activated
register_activation_hook(__FILE__, 'dd_run_when_plugin_activated');
add_action('init', 'dd_enable_required_js_in_wordpress');
add_action('wp_head', 'dd_output_css_to_html');
add_action('wp_head', 'dd_get_thumbnails_for_fb');
add_filter('the_excerpt', 'dd_hook_wp_content');
add_filter('the_content', 'dd_hook_wp_content');
function dd_hook_wp_content($content = '')
示例10: clear_cache
/**
* Clear cache(s) based on HTTP GET parameters. Allows another site to tell this site to clear its cache.
* Will only run if GET params include correct secret key, which is defined in SitePush options
*
* @return mixed result code echoed to screen, or FALSE if command/key not set
*/
private function clear_cache()
{
//check $_GET to see if someone has asked us to clear the cache
//for example a push from another server to this one
$cmd = isset($_GET['sitepush_cmd']) ? $_GET['sitepush_cmd'] : FALSE;
$key = isset($_GET['sitepush_key']) ? $_GET['sitepush_key'] : FALSE;
//no command and/or key so return to normal WP initialisation
if (!$cmd || !$key) {
return FALSE;
}
//do nothing if the secret key isn't correct
$options = get_option('sitepush_options');
$result = '';
if ($key != urlencode($options['cache_key'])) {
status_header('403');
//return an HTTP error so we know cache clear wasn't successful
$result .= "[1] Unrecognized cache key\n";
die(trim($result));
}
switch ($cmd) {
case 'clear_cache':
// Purge the entire w3tc page cache:
if (function_exists('w3tc_pgcache_flush')) {
/** @noinspection PhpUndefinedFunctionInspection */
w3tc_pgcache_flush();
/** @noinspection PhpUndefinedFunctionInspection */
w3tc_dbcache_flush();
/** @noinspection PhpUndefinedFunctionInspection */
w3tc_minify_flush();
/** @noinspection PhpUndefinedFunctionInspection */
w3tc_objectcache_flush();
$result .= "[0] W3TC cache cleared\n";
}
// Purge the entire supercache page cache:
if (function_exists('wp_cache_clear_cache')) {
/** @noinspection PhpUndefinedFunctionInspection */
wp_cache_clear_cache();
$result .= "[0] Supercache cleared\n";
}
break;
default:
$result .= "[2] Unrecognised cache command\n";
status_header('400');
//return an HTTP error so we know cache clear wasn't successful
break;
}
if (!$result) {
$result = "[3] No supported cache present\n";
}
die(trim($result));
}
示例11: top_generate_query
function top_generate_query($can_requery = true)
{
global $wpdb;
$rtrn_msg = "";
$omitCats = get_option('top_opt_omit_cats');
$maxAgeLimit = get_option('top_opt_max_age_limit');
$ageLimit = get_option('top_opt_age_limit');
$exposts = get_option('top_opt_excluded_post');
$exposts = preg_replace('/,,+/', ',', $exposts);
$top_opt_tweeted_posts = array();
$top_opt_tweeted_posts = get_option('top_opt_tweeted_posts');
if (!$top_opt_tweeted_posts) {
$top_opt_tweeted_posts = array();
}
if ($top_opt_tweeted_posts != null) {
$already_tweeted = implode(",", $top_opt_tweeted_posts);
} else {
$already_tweeted = "";
}
if (substr($exposts, 0, 1) == ",") {
$exposts = substr($exposts, 1, strlen($exposts));
}
if (substr($exposts, -1, 1) == ",") {
$exposts = substr($exposts, 0, strlen($exposts) - 1);
}
if (!(isset($ageLimit) && is_numeric($ageLimit))) {
$ageLimit = top_opt_AGE_LIMIT;
}
if (!(isset($maxAgeLimit) && is_numeric($maxAgeLimit))) {
$maxAgeLimit = top_opt_MAX_AGE_LIMIT;
}
if (!isset($omitCats)) {
$omitCats = top_opt_OMIT_CATS;
}
$as_post_type = get_option('as_post_type');
$as_number_tweet = get_option('as_number_tweet');
if ($as_number_tweet <= 0) {
$as_number_tweet = 1;
}
if ($as_number_tweet > 10) {
$as_number_tweet = 10;
}
//trying to fix multiposts
//if($last<1){$as_number_tweet = 0;}
$pt = '';
if ($as_post_type != 'all') {
$pt = "post_type = '{$as_post_type}' AND";
}
$sql = "SELECT ID\n FROM {$wpdb->posts}\n WHERE {$pt} post_status = 'publish' ";
if (is_numeric($ageLimit)) {
if ($ageLimit > 0) {
$sql = $sql . " AND post_date <= curdate( ) - INTERVAL " . $ageLimit . " day";
}
}
if ($maxAgeLimit != 0) {
$sql = $sql . " AND post_date >= curdate( ) - INTERVAL " . $maxAgeLimit . " day";
}
if (isset($exposts)) {
if (trim($exposts) != '') {
$sql = $sql . " AND ID Not IN (" . $exposts . ") ";
}
}
if (isset($already_tweeted)) {
if (trim($already_tweeted) != "") {
$sql = $sql . " AND ID Not IN (" . $already_tweeted . ") ";
}
}
if ($omitCats != '') {
$sql = $sql . " AND NOT (ID IN (SELECT tr.object_id FROM " . $wpdb->prefix . "term_relationships AS tr INNER JOIN " . $wpdb->prefix . "term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN (" . $omitCats . ")))";
}
$sql = $sql . "\n ORDER BY RAND() \n LIMIT {$as_number_tweet} ";
$oldest_post = $wpdb->get_results($sql);
if ($oldest_post == null) {
if ($can_requery) {
$top_opt_tweeted_posts = array();
update_option('top_opt_tweeted_posts', $top_opt_tweeted_posts);
return top_generate_query(false);
} else {
return "No post found to tweet. Please check your settings and try again.--" . $sql;
}
}
if (isset($oldest_post)) {
$ret = '';
foreach ($oldest_post as $k => $odp) {
array_push($top_opt_tweeted_posts, $odp->ID);
$ret .= 'Tweet ' . $k . ' : ' . top_opt_tweet_post($odp->ID) . '<br/>';
}
update_option('top_opt_tweeted_posts', $top_opt_tweeted_posts);
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
w3tc_dbcache_flush();
w3tc_minify_flush();
w3tc_objectcache_flush();
$cache = ' and W3TC Caches cleared';
}
$next_tweet_time = time() + get_option('top_opt_interval') * 60 * 60;
update_option('next_tweet_time', $next_tweet_time);
return $ret;
}
return $rtrn_msg;
//.........这里部分代码省略.........
示例12: cache_flush
protected function cache_flush()
{
// W3 Total Cache
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
}
if (function_exists('w3tc_dbcache_flush')) {
w3tc_dbcache_flush();
}
if (function_exists('w3tc_minify_flush')) {
w3tc_minify_flush();
}
if (function_exists('w3tc_objectcache_flush')) {
w3tc_objectcache_flush();
}
// WP Super Cache
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache();
}
}
示例13: flush
/**
* Clear something from the cache.
*
* @synopsis <cache-type>... [--post_id=<post-id>] [--permalink=<permalink>]
*/
function flush($args = array(), $assoc_args = array())
{
$args = array_unique($args);
do {
$cache_type = array_shift($args);
switch ($cache_type) {
case 'db':
case 'database':
if (w3tc_dbcache_flush()) {
WP_CLI::success('The database cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the database cache failed.');
}
break;
case 'minify':
if (w3tc_minify_flush()) {
WP_CLI::success('The minify cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the minify cache failed.');
}
break;
case 'object':
if (w3tc_objectcache_flush()) {
WP_CLI::success('The object cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the object cache failed.');
}
break;
case 'page':
if (w3tc_pgcache_flush()) {
WP_CLI::success('The page cache is flushed successfully.');
} else {
WP_CLI::error('Flushing the page cache failed.');
}
break;
case 'post':
default:
if (isset($assoc_args['post_id'])) {
if (is_numeric($assoc_args['post_id']) && get_post($assoc_args['post_id'])) {
if (w3tc_pgcache_flush_post($assoc_args['post_id'])) {
WP_CLI::success('Post ' . $assoc_args['post_id'] . ' is flushed successfully.');
} else {
WP_CLI::error('Flushing ' . $assoc_args['post_id'] . ' from cache failed.');
}
} else {
WP_CLI::error('This is not a valid post id.');
}
} elseif (isset($assoc_args['permalink'])) {
$id = url_to_postid($assoc_args['permalink']);
if (is_numeric($id) && $id > 0) {
if (w3tc_pgcache_flush_post($id)) {
WP_CLI::success($id . ' is flushed successfully.');
} else {
WP_CLI::error('Flushing ' . $id . ' from cache failed.');
}
} else {
WP_CLI::error('There is no post with this permalink.');
}
}
}
} while (!empty($args));
}