本文整理汇总了PHP中wp_cache_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_delete函数的具体用法?PHP wp_cache_delete怎么用?PHP wp_cache_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_cache_delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: status_transition
/**
* Hooked into transition_post_status. Will initiate search engine pings
* if the post is being published, is a post type that a sitemap is built for
* and is a post that is included in sitemaps.
*
* @param string $new_status New post status.
* @param string $old_status Old post status.
* @param \WP_Post $post Post object.
*/
function status_transition($new_status, $old_status, $post)
{
if ($new_status != 'publish') {
return;
}
wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
// #17455.
$options = WPSEO_Options::get_options(array('wpseo_xml', 'wpseo_titles'));
if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true || $post->post_type === 'nav_menu_item') {
return;
}
if (WP_CACHE) {
wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index');
}
/**
* Filter: 'wpseo_allow_xml_sitemap_ping' - Check if pinging is not allowed (allowed by default)
*
* @api boolean $allow_ping The boolean that is set to true by default.
*/
if (apply_filters('wpseo_allow_xml_sitemap_ping', true) === false) {
return;
}
// Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
$excluded_posts = explode(',', $options['excluded-posts']);
if (!in_array($post->ID, $excluded_posts)) {
if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) {
wpseo_ping_search_engines();
} else {
wp_schedule_single_event(time() + 300, 'wpseo_ping_search_engines');
}
}
}
示例2: upgrade
public function upgrade($plugin, $url)
{
$this->init();
$this->upgrade_strings();
add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
// inject our certificate, in case we are on machine w/o CA
add_action('http_api_curl', array(Ai1ec_Http_Utility::instance(), 'curl_inject_certificate'));
$this->run(array('package' => $url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin)));
// Cleanup our hooks, in case something else does an upgrade on
// this connection.
remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
if (!$this->result || is_wp_error($this->result)) {
return $this->result;
}
// Force refresh of plugin update information
delete_site_transient('update_plugins');
wp_cache_delete('plugins', 'plugins');
// activate the plugin
activate_plugin($plugin);
echo '<p>Plugin activated.</p>';
echo '<a href="' . admin_url('index.php') . '">Continue Here</a>';
return true;
}
示例3: delete_metadata
function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '')
{
if (!$meta_type || !$meta_key) {
return false;
}
if (!($table = _get_meta_table($meta_type))) {
return false;
}
global $wpdb;
$column = esc_sql($meta_type . '_id');
// expected_slashed ($meta_key)
$meta_key = stripslashes($meta_key);
$meta_value = maybe_serialize(stripslashes_deep($meta_value));
$query = $wpdb->prepare("DELETE FROM {$table} WHERE meta_key = %s", $meta_key);
if ($meta_value) {
$query .= $wpdb->prepare("AND meta_value = %s", $meta_value);
}
$count = $wpdb->query($query);
if (!$count) {
return false;
}
wp_cache_delete($object_id, $meta_type . '_meta');
do_action("deleted_{$meta_type}_meta", $object_id, $meta_key, $meta_value);
return true;
}
示例4: wpurp_shortcode_generator_user_menu_authors
function wpurp_shortcode_generator_user_menu_authors()
{
$menu_authors = array();
$menu_author_ids = array();
// Get all menus one by one
$limit = 100;
$offset = 0;
while (true) {
$args = array('post_type' => 'menu', 'post_status' => array('publish', 'private'), 'posts_per_page' => $limit, 'offset' => $offset);
$query = new WP_Query($args);
if (!$query->have_posts()) {
break;
}
$posts = $query->posts;
foreach ($posts as $post) {
$id = $post->ID;
$author = $post->post_author;
if (!in_array($author, $menu_author_ids)) {
$menu_author_ids[] = $author;
$user = get_userdata($author);
$name = $user ? $user->display_name : __('n/a', 'wp-ultimate-recipe');
$menu_authors[] = array('value' => $author, 'label' => $name);
}
wp_cache_delete($id, 'posts');
wp_cache_delete($id, 'post_meta');
}
$offset += $limit;
wp_cache_flush();
}
return $menu_authors;
}
示例5: update
/**
* Update the embed code on an Embed
*
* @param int $id
* @param string $html
* @return Embed
*/
public static function update($id, $html = '')
{
global $wpdb;
$update = $wpdb->update("{$wpdb->base_prefix}protected_embeds", array('html' => $html), array('embed_id' => $id));
wp_cache_delete($id, 'protected-embeds');
return static::get($id);
}
示例6: xfac_user_deleteRecord
function xfac_user_deleteRecord($record)
{
global $wpdb;
$tblAuth = xfac_getTableAuth();
wp_cache_delete($record->user_id, XFAC_CACHE_RECORDS_BY_USER_ID);
return $wpdb->delete($tblAuth, array('id' => $record->id));
}
示例7: test_add_option_with_no_options_cache
/**
* @ticket 38930
*/
public function test_add_option_with_no_options_cache()
{
register_setting('test_group', 'test_default', array('default' => 'My Default :)'));
wp_cache_delete('notoptions', 'options');
$this->assertTrue(add_option('test_default', 'hello'));
$this->assertEquals('hello', get_option('test_default'));
}
示例8: skattle_clear_page_caches
function skattle_clear_page_caches()
{
if ($_POST[post_type] == 'page') {
$key = 'child-pages-' . $post->ID;
wp_cache_delete($key, 'page');
}
}
示例9: update
function update($new_instance, $old_instance)
{
$instance = $old_instance;
if (isset($new_instance['dologout']) && $new_instance['dologout'] == 1) {
$instance['access_token'] = null;
$instance['login'] = null;
wp_cache_delete($this->id, $this->cache_key);
}
if (isset($new_instance['login'], $new_instance['pass']) && trim($new_instance['login']) != "" && trim($new_instance['pass']) != "") {
wp_cache_delete($this->id, 'wpinstagram_cache');
$auth = $this->instagram_login($new_instance['login'], $new_instance['pass']);
$instance['access_token'] = $auth->access_token;
$instance['login'] = $auth->user->username;
}
if ($new_instance['count'] != $old_instance['count'] || $new_instance['hashtag'] != $instance['hashtag']) {
wp_cache_delete($this->id, $this->cache_key);
}
if (preg_match("/[a-zA-Z0-9_\\-]+/i", $new_instance['hashtag'])) {
$instance['hashtag'] = $new_instance['hashtag'];
} else {
unset($instance['hashtag']);
}
$instance['title'] = strip_tags($new_instance['title']);
$instance['count'] = strip_tags($new_instance['count']);
$instance['count'] = intval($instance['count']) ? $instance['count'] : 9;
return $instance;
}
示例10: clear_cache
/**
* Clear cache objects for the user.
* @param int $user_id
*/
public static function clear_cache($user_id)
{
// be lazy, clear the entries so they are rebuilt when requested
wp_cache_delete(self::CAPABILITIES . $user_id, self::CACHE_GROUP);
wp_cache_delete(self::CAPABILITY_IDS . $user_id, self::CACHE_GROUP);
wp_cache_delete(self::GROUP_IDS . $user_id, self::CACHE_GROUP);
}
示例11: wpsc_delete_meta
/**
* Deletes meta data from the database
*
* @internal
*/
function wpsc_delete_meta($object_id = 0, $meta_key, $meta_value, $type, $global = false)
{
global $wpdb;
if (!is_numeric($object_id) || empty($object_id) && !$global) {
return false;
}
$cache_object_id = $object_id = (int) $object_id;
$object_type = $type;
$meta_key = wpsc_sanitize_meta_key($meta_key);
$meta_tuple = compact('object_type', 'object_id', 'meta_key', 'meta_value', 'type');
$meta_tuple = apply_filters('wpsc_delete_meta', $meta_tuple);
extract($meta_tuple, EXTR_OVERWRITE);
$meta_value = maybe_serialize($meta_value);
if (empty($meta_value)) {
$meta_sql = $wpdb->prepare("SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key);
} else {
$meta_sql = $wpdb->prepare("SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s AND `meta_value` = %s", $object_type, $object_id, $meta_key, $meta_value);
}
if (!($meta_id = $wpdb->get_var($meta_sql))) {
return false;
}
$wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_META . "` WHERE `meta_id` = %d", $meta_id));
wp_cache_delete($cache_object_id, $object_type);
return true;
}
示例12: test_bp_messages_update_meta_cache
/**
* @group bp_messages_update_meta_cache
*/
public function test_bp_messages_update_meta_cache()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
// create the thread
$t1 = $this->factory->message->create(array('sender_id' => $u1, 'recipients' => array($u2), 'subject' => 'This is a knive'));
// create a reply
$this->factory->message->create(array('thread_id' => $t1, 'sender_id' => $u2, 'recipients' => array($u1), 'content' => "That's a spoon"));
// grab the message ids as individual variables
list($m1, $m2) = $this->get_message_ids($t1);
// add cache for each message
bp_messages_update_meta($m1, 'utensil', 'knive');
bp_messages_update_meta($m1, 'is_knive', 'yes');
bp_messages_update_meta($m2, 'utensil', 'spoon');
bp_messages_update_meta($m2, 'is_knive', 'no');
bp_messages_update_meta($m2, 'is_spoon', 'yes');
// prime cache
bp_messages_get_meta($m1, 'utensil');
// Ensure an empty cache for second message
wp_cache_delete($m2, 'message_meta');
// update message meta cache
bp_messages_update_meta_cache(array($m1, $m2));
$expected = array($m1 => array('utensil' => array('knive'), 'is_knive' => array('yes')), $m2 => array('utensil' => array('spoon'), 'is_knive' => array('no'), 'is_spoon' => array('yes')));
$found = array($m1 => wp_cache_get($m1, 'message_meta'), $m2 => wp_cache_get($m2, 'message_meta'));
$this->assertEquals($expected, $found);
}
示例13: savePaywallSettings
function savePaywallSettings(TPSiteSettings $ss, TPPaySettings $pw)
{
$ss->addPaywall($pw);
$this->saveSiteSettings($ss);
wp_cache_delete("tinypass_" . $pw->getResourceId());
update_option("tinypass_" . $pw->getResourceId(), $pw->toArray());
}
示例14: _empty_taxonomies
/**
* Delete terms, taxonomies, and tax relationships.
*/
private function _empty_taxonomies()
{
global $wpdb;
// Empty taxonomies and terms
$terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy}");
$ids = array();
$taxonomies = array();
foreach ((array) $terms as $term) {
$taxonomies[] = $term->taxonomy;
$ids[] = $term->term_id;
wp_cache_delete($term->term_id, $term->taxonomy);
}
$taxonomies = array_unique($taxonomies);
$cleaned = array();
foreach ($taxonomies as $taxonomy) {
if (isset($cleaned[$taxonomy])) {
continue;
}
$cleaned[$taxonomy] = true;
wp_cache_delete('all_ids', $taxonomy);
wp_cache_delete('get', $taxonomy);
delete_option("{$taxonomy}_children");
}
$wpdb->query("TRUNCATE {$wpdb->terms}");
$wpdb->query("TRUNCATE {$wpdb->term_taxonomy}");
$wpdb->query("TRUNCATE {$wpdb->term_relationships}");
}
示例15: set_widget
public static function set_widget($args)
{
$r = wp_parse_args($args, array('id_base' => '', 'sidebar_id' => '', 'settings' => array()));
$id_base = $r['id_base'];
$sidebar_id = $r['sidebar_id'];
$settings = (array) $r['settings'];
// Don't try to set a widget if it hasn't been registered
if (!self::widget_exists($id_base)) {
return new WP_Error('widget_does_not_exist', 'Widget does not exist');
}
global $wp_registered_sidebars;
if (!isset($wp_registered_sidebars[$sidebar_id])) {
return new WP_Error('sidebar_does_not_exist', 'Sidebar does not exist');
}
$sidebars = wp_get_sidebars_widgets();
$sidebar = (array) $sidebars[$sidebar_id];
// Multi-widgets can only be detected by looking at their settings
$option_name = 'widget_' . $id_base;
// Don't let it get pulled from the cache
wp_cache_delete($option_name, 'options');
$all_settings = get_option($option_name);
if (is_array($all_settings)) {
$skeys = array_keys($all_settings);
// Find the highest numeric key
rsort($skeys);
foreach ($skeys as $k) {
if (is_numeric($k)) {
$multi_number = $k + 1;
break;
}
}
if (!isset($multi_number)) {
$multi_number = 1;
}
$all_settings[$multi_number] = $settings;
//$all_settings = array( $multi_number => $settings );
} else {
$multi_number = 1;
$all_settings = array($multi_number => $settings);
}
$widget_id = $id_base . '-' . $multi_number;
$sidebar[] = $widget_id;
// Because of the way WP_Widget::update_callback() works, gotta fake the $_POST
$_POST['widget-' . $id_base] = $all_settings;
global $wp_registered_widget_updates, $wp_registered_widget_controls;
foreach ((array) $wp_registered_widget_updates as $name => $control) {
if ($name == $id_base) {
if (!is_callable($control['callback'])) {
continue;
}
ob_start();
call_user_func_array($control['callback'], $control['params']);
ob_end_clean();
break;
}
}
$sidebars[$sidebar_id] = $sidebar;
wp_set_sidebars_widgets($sidebars);
update_option($option_name, $all_settings);
}