本文整理汇总了PHP中wp_cache_add_non_persistent_groups函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_add_non_persistent_groups函数的具体用法?PHP wp_cache_add_non_persistent_groups怎么用?PHP wp_cache_add_non_persistent_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_cache_add_non_persistent_groups函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadAllOptions
public static function loadAllOptions()
{
global $wpdb;
$options = wp_cache_get('alloptions', 'wordfence');
if (!$options) {
$table = self::table();
self::updateTableExists();
$suppress = $wpdb->suppress_errors();
if (!($rawOptions = $wpdb->get_results("SELECT name, val FROM {$table} WHERE autoload = 'yes'"))) {
$rawOptions = $wpdb->get_results("SELECT name, val FROM {$table}");
}
$wpdb->suppress_errors($suppress);
$options = array();
foreach ((array) $rawOptions as $o) {
if (in_array($o->name, self::$serializedOptions)) {
$val = maybe_unserialize($o->val);
if ($val) {
$options[$o->name] = $val;
}
} else {
$options[$o->name] = $o->val;
}
}
wp_cache_add_non_persistent_groups('wordfence');
wp_cache_add('alloptions', $options, 'wordfence');
}
return $options;
}
示例2: __construct
/**
* PHP 5 constructor
*
* @since 1.0-beta
*/
function __construct()
{
// Define post type and taxonomy names for use in the register functions
$this->post_type_name = apply_filters('bp_docs_post_type_name', 'bp_doc');
$this->associated_item_tax_name = apply_filters('bp_docs_associated_item_tax_name', 'bp_docs_associated_item');
$this->access_tax_name = apply_filters('bp_docs_access_tax_name', 'bp_docs_access');
// :'(
wp_cache_add_non_persistent_groups(array('bp_docs_nonpersistent'));
// Let plugins know that BP Docs has started loading
add_action('plugins_loaded', array($this, 'load_hook'), 20);
// Load predefined constants first thing
add_action('bp_docs_load', array($this, 'load_constants'), 2);
// Includes necessary files
add_action('bp_docs_load', array($this, 'includes'), 4);
// Load the BP Component extension
add_action('bp_docs_load', array($this, 'do_integration'), 6);
// Load textdomain
add_action('bp_docs_load', array($this, 'load_plugin_textdomain'));
// Let other plugins know that BP Docs has finished initializing
add_action('bp_init', array($this, 'init_hook'));
// Hooks into the 'init' action to register our WP custom post type and tax
add_action('bp_docs_init', array($this, 'register_post_type'), 2);
add_action('bp_docs_init', array(&$this, 'add_rewrite_tags'), 4);
// Set up doc taxonomy, etc
add_action('bp_docs_init', array($this, 'load_doc_extras'), 8);
// Add rewrite rules
add_action('generate_rewrite_rules', array(&$this, 'generate_rewrite_rules'));
// parse_query
add_action('parse_query', array($this, 'parse_query'));
// Protect doc access
add_action('template_redirect', array($this, 'protect_doc_access'));
add_action('admin_init', array($this, 'flush_rewrite_rules'));
}
示例3: __construct
function __construct()
{
// vars
$this->cache = array();
$this->reference = array();
// prevent ACF from persistent cache
wp_cache_add_non_persistent_groups('acf');
}
示例4: add_non_persistent_groups
/**
* Adds a non-persistent group to the list.
*
* @uses wp_cache_add_non_persistent_groups
*
* @param array $args Function arguments.
* @param array $assoc_args Function arguments with parameter key.
* @return void
*/
public function add_non_persistent_groups($args, $assoc_args)
{
if (empty($args)) {
WP_CLI::line('usage: wp cache add_non_persistent_groups <group>');
exit;
}
$group = $args[0];
wp_cache_add_non_persistent_groups($group);
}
示例5: init
function init()
{
//Add non-persistent cache group
wp_cache_add_non_persistent_groups(self::SLUG);
//Registers GET listener to toggle setting
$this->register_endpoints();
//Message if WPML installed
if ($this->wpml_installed()) {
add_action('admin_notices', array($this, 'admin_notices'));
}
}
示例6: __construct
/**
* Constructor.
*
* @since 1.9
*/
public function __construct()
{
if (!bp_docs_enable_folders()) {
return;
}
$this->register_post_type();
$this->register_taxonomies();
// It is my hope and dream that this will one day be persistent.
wp_cache_add_non_persistent_groups(array('bp_docs_folders'));
add_action('bp_docs_enqueue_scripts', array($this, 'enqueue_assets'));
$this->setup_hooks();
}
示例7: flush_cache
function flush_cache() {
global $wp_object_cache;
$wp_object_cache->group_ops = array();
$wp_object_cache->stats = array();
$wp_object_cache->memcache_debug = array();
$wp_object_cache->cache = array();
if ( method_exists( $wp_object_cache, '__remoteset' ) ) {
$wp_object_cache->__remoteset();
}
wp_cache_flush();
wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) );
wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
}
示例8: init
public function init()
{
wp_cache_add_non_persistent_groups('my-wp-backup');
add_action('admin_post_MyWPBackup_settings', array($this, 'post_settings'));
add_action('admin_post_MyWPBackup_import', array($this, 'post_import'));
add_action(is_multisite() ? 'network_admin_notices' : 'admin_notices', array($this, 'admin_notice'));
global $current_user;
$user_id = $current_user->ID;
if (is_multisite() && is_network_admin() || !is_multisite() && current_user_can('manage_options')) {
if ('1' === filter_input(INPUT_GET, 'mwpb_notice_close', FILTER_SANITIZE_NUMBER_INT)) {
add_user_meta($user_id, 'mwpb-notice-1', 'true', true);
}
}
Job::get_instance();
Backup::get_instance();
}
示例9: add_cache_groups
public function add_cache_groups()
{
if (function_exists('wp_cache_add_non_persistent_groups')) {
wp_cache_add_non_persistent_groups(array('bu-navigation'));
}
}
示例10: cacsp_add_non_persistent_cache_group
/**
* Add our non-persistent cache group.
*
* BuddyPress does not have decent (any) cache support for groups-of-member queries. Adding a
* non-persistent group here so that we don't have to worry about invalidation. At least this
* will help with single pages.
*/
function cacsp_add_non_persistent_cache_group()
{
wp_cache_add_non_persistent_groups(array('cacsp_groups_of_user'));
}
示例11: wp_start_object_cache
/**
* Starts the WordPress object cache.
*
* If an object-cache.php file exists in the wp-content directory,
* it uses that drop-in as an external object cache.
*
* @access private
* @since 3.0.0
*/
function wp_start_object_cache()
{
$first_init = false;
if (!function_exists('wp_cache_init')) {
global $_wp_using_ext_object_cache;
if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
require_once WP_CONTENT_DIR . '/object-cache.php';
$_wp_using_ext_object_cache = true;
} else {
require_once ABSPATH . WPINC . '/cache.php';
$_wp_using_ext_object_cache = false;
}
$first_init = true;
}
// If cache supports reset, reset instead of init if already initialized.
// Reset signals to the cache that global IDs have changed and it may need to update keys
// and cleanup caches.
if (!$first_init && function_exists('wp_cache_reset')) {
wp_cache_reset();
} else {
wp_cache_init();
}
if (function_exists('wp_cache_add_global_groups')) {
wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts'));
wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
}
}
示例12: wp_start_object_cache
/**
* Start the WordPress object cache.
*
* If an object-cache.php file exists in the wp-content directory,
* it uses that drop-in as an external object cache.
*
* @since 3.0.0
* @access private
*
* @global int $blog_id Blog ID.
*/
function wp_start_object_cache()
{
global $blog_id;
$first_init = false;
if (!function_exists('wp_cache_init')) {
if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
require_once WP_CONTENT_DIR . '/object-cache.php';
if (function_exists('wp_cache_init')) {
wp_using_ext_object_cache(true);
}
}
$first_init = true;
} elseif (!wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
/*
* Sometimes advanced-cache.php can load object-cache.php before
* it is loaded here. This breaks the function_exists check above
* and can result in `$_wp_using_ext_object_cache` being set
* incorrectly. Double check if an external cache exists.
*/
wp_using_ext_object_cache(true);
}
if (!wp_using_ext_object_cache()) {
require_once ABSPATH . WPINC . '/cache.php';
}
/*
* If cache supports reset, reset instead of init if already
* initialized. Reset signals to the cache that global IDs
* have changed and it may need to update keys and cleanup caches.
*/
if (!$first_init && function_exists('wp_cache_switch_to_blog')) {
wp_cache_switch_to_blog($blog_id);
} elseif (function_exists('wp_cache_init')) {
wp_cache_init();
}
if (function_exists('wp_cache_add_global_groups')) {
wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache'));
wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
}
}
示例13: wp_start_object_cache
/**
* Starts the WordPress object cache.
*
* If an object-cache.php file exists in the wp-content directory,
* it uses that drop-in as an external object cache.
*
* @access private
* @since 3.0.0
*/
function wp_start_object_cache()
{
global $_wp_using_ext_object_cache;
$first_init = false;
if (!function_exists('wp_cache_init')) {
if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
require_once WP_CONTENT_DIR . '/object-cache.php';
$_wp_using_ext_object_cache = true;
} else {
require_once ABSPATH . WPINC . '/cache.php';
$_wp_using_ext_object_cache = false;
}
$first_init = true;
} else {
if (!$_wp_using_ext_object_cache && file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
// Sometimes advanced-cache.php can load object-cache.php before it is loaded here.
// This breaks the function_exists check above and can result in $_wp_using_ext_object_cache
// being set incorrectly. Double check if an external cache exists.
$_wp_using_ext_object_cache = true;
}
}
// If cache supports reset, reset instead of init if already initialized.
// Reset signals to the cache that global IDs have changed and it may need to update keys
// and cleanup caches.
if (!$first_init && function_exists('wp_cache_reset')) {
wp_cache_reset();
} else {
wp_cache_init();
}
if (function_exists('wp_cache_add_global_groups')) {
wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts'));
wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
}
}
示例14: restore_current_blog
function restore_current_blog()
{
global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
if (!$switched) {
return false;
}
if (!is_array($switched_stack)) {
return false;
}
$blog = array_pop($switched_stack);
if ($blog_id == $blog) {
do_action('switch_blog', $blog, $blog);
/* If we still have items in the switched stack, consider ourselves still 'switched' */
$switched = is_array($switched_stack) && count($switched_stack) > 0;
return true;
}
$wpdb->set_blog_id($blog);
$prev_blog_id = $blog_id;
$blog_id = $blog;
$table_prefix = $wpdb->prefix;
if (is_object($wp_roles)) {
$wpdb->suppress_errors();
if (method_exists($wp_roles, '_init')) {
$wp_roles->_init();
} elseif (method_exists($wp_roles, '__construct')) {
$wp_roles->__construct();
}
$wpdb->suppress_errors(false);
}
if (did_action('init')) {
$current_user = wp_get_current_user();
if (is_object($current_user)) {
$current_user->for_blog($blog_id);
}
}
if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) {
$global_groups = $wp_object_cache->global_groups;
} else {
$global_groups = false;
}
wp_cache_init();
if (function_exists('wp_cache_add_global_groups')) {
if (is_array($global_groups)) {
wp_cache_add_global_groups($global_groups);
} else {
wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts'));
}
wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
}
do_action('switch_blog', $blog_id, $prev_blog_id);
/* If we still have items in the switched stack, consider ourselves still 'switched' */
$switched = is_array($switched_stack) && count($switched_stack) > 0;
return true;
}
示例15: wp_cache_add_non_persistent_groups
<?php
/**
* Turn off persistent caching for users.
*
* We use memcached for GlotPress because query calculations are very heavy and slow.
*
* However some issues were noticed with persistent user caching (very likely due to the WP.org setup)
* so this turns it off. User queries in GlotPress are comparatively very light.
*
* We should test this and remove this plugin at a later date.
*
* @author Nacin
*/
wp_cache_add_non_persistent_groups(array('users', 'userlogins', 'usermeta', 'usermail', 'usernicename'));