本文整理汇总了PHP中wp_cache_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_delete函数的具体用法?PHP wp_cache_delete怎么用?PHP wp_cache_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_cache_delete函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
}
}
开发者ID:Didox,项目名称:beminfinito,代码行数:41,代码来源:class-sitemaps-admin.php
示例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;
}
开发者ID:briancompton,项目名称:knightsplaza,代码行数:25,代码来源:class-ai1ec-updater.php
示例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;
}
开发者ID:bluedanbob,项目名称:wordpress,代码行数:25,代码来源:meta.php
示例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;
}
开发者ID:robertoperata,项目名称:bbqverona.com,代码行数:31,代码来源:vafpress_shortcode_whitelist.php
示例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);
}
开发者ID:humanmade,项目名称:protected-embeds,代码行数:14,代码来源:class-embed.php
示例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));
}
开发者ID:billyprice1,项目名称:bdApi,代码行数:7,代码来源:user.php
示例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'));
}
开发者ID:kucrut,项目名称:wordpress,代码行数:10,代码来源:registration.php
示例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');
}
}
开发者ID:Ashkas,项目名称:CAT,代码行数:7,代码来源:cache.php
示例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;
}
开发者ID:navinweb,项目名称:wordpress-starter-pack,代码行数:27,代码来源:widget-instagram.php
示例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);
}
开发者ID:solsticehc,项目名称:solsticehc,代码行数:11,代码来源:class-groups-user.php
示例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;
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:30,代码来源:meta.functions.php
示例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);
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:29,代码来源:cache.php
示例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());
}
开发者ID:voodoologic,项目名称:reboot,代码行数:7,代码来源:TPStorage.php
示例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}");
}
开发者ID:Jaace,项目名称:wp-cli,代码行数:30,代码来源:site.php
示例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);
}
开发者ID:WeFoster,项目名称:wefoster,代码行数:60,代码来源:widget-setter.php
示例16: flush_jl_cat_posts_widget
function flush_jl_cat_posts_widget($post_id)
{
$categories = wp_get_post_categories($post_id);
foreach ($categories as $cat_id) {
wp_cache_delete('jl_cat_posts_widget-' . $cat_id, 'widget');
}
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:7,代码来源:cat-posts.php
示例17: ap_opt
/**
* To retrive AnsPress option
* @param string $key Name of option to retrive,
* Keep it blank to get all options of AnsPress
* @param string $value Enter value to update existing option
* @return string
* @since 0.1
*/
function ap_opt($key = false, $value = null)
{
$settings = wp_cache_get('ap_opt', 'options');
if ($settings === false) {
$settings = get_option('anspress_opt');
if (!$settings) {
$settings = array();
}
$settings = $settings + ap_default_options();
wp_cache_set('ap_opt', $settings, 'options');
}
if (!is_null($value)) {
$settings[$key] = $value;
update_option('anspress_opt', $settings);
// clear cache if option updated
wp_cache_delete('ap_opt', 'options');
return;
}
if (false === $key) {
return $settings;
}
if (isset($settings[$key])) {
return $settings[$key];
} else {
return NULL;
}
return false;
}
开发者ID:BRoz,项目名称:anspress,代码行数:36,代码来源:options.php
示例18: save
/**
* Save meta box data
*/
public static function save($post_id, $post)
{
if ('shop_subscription' == $post->post_type && !empty($_POST['woocommerce_meta_nonce']) && wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
if (isset($_POST['_billing_interval'])) {
update_post_meta($post_id, '_billing_interval', $_POST['_billing_interval']);
}
if (!empty($_POST['_billing_period'])) {
update_post_meta($post_id, '_billing_period', $_POST['_billing_period']);
}
$subscription = wcs_get_subscription($post_id);
$dates = array();
foreach (wcs_get_subscription_date_types() as $date_key => $date_label) {
if ('last_payment' == $date_key) {
continue;
}
$utc_timestamp_key = $date_key . '_timestamp_utc';
// A subscription needs a start date, even if it wasn't set
if (isset($_POST[$utc_timestamp_key])) {
$datetime = $_POST[$utc_timestamp_key];
} elseif ('start' === $date_key) {
$datetime = current_time('timestamp', true);
} else {
// No date to set
continue;
}
$dates[$date_key] = date('Y-m-d H:i:s', $datetime);
}
try {
$subscription->update_dates($dates, 'gmt');
wp_cache_delete($post_id, 'posts');
} catch (Exception $e) {
wcs_add_admin_notice($e->getMessage(), 'error');
}
}
}
开发者ID:slavic18,项目名称:cats,代码行数:38,代码来源:class-wcs-meta-box-subscription-schedule.php
示例19: update
/**
* @method update
*/
public function update($settings)
{
global $wp_widget_factory;
// Make sure we have a widget.
if (!isset($settings->widget) || !isset($wp_widget_factory->widgets[$settings->widget])) {
return $settings;
}
// Get the widget instance.
$factory = $wp_widget_factory->widgets[$settings->widget];
$class = get_class($factory);
$instance = new $class($factory->id_base, $factory->name, $factory->widget_options);
// Get the widget settings.
$settings_key = 'widget-' . $instance->id_base;
$widget_settings = array();
if (isset($settings->{$settings_key})) {
$widget_settings = (array) $settings->{$settings_key};
}
// Run the widget update method.
$widget_settings = $instance->update($widget_settings, array());
// Save the widget settings as an object.
if (is_array($widget_settings)) {
$settings->{$settings_key} = (object) $widget_settings;
}
// Delete the WordPress cache for this widget.
wp_cache_delete($settings->widget, 'widget');
// Return the settings.
return $settings;
}
开发者ID:meftasadat,项目名称:DSL_SITE,代码行数:31,代码来源:widget.php
示例20: wp_insert_user
function wp_insert_user($userdata)
{
global $wpdb;
extract($userdata);
// Are we updating or creating?
if (!empty($ID)) {
$update = true;
} else {
$update = false;
// Password is not hashed when creating new user.
$user_pass = md5($user_pass);
}
if (empty($user_nicename)) {
$user_nicename = sanitize_title($user_login);
}
if (empty($display_name)) {
$display_name = $user_login;
}
if (empty($nickname)) {
$nickname = $user_login;
}
if (empty($user_registered)) {
$user_registered = gmdate('Y-m-d H:i:s');
}
if ($update) {
$query = "UPDATE {$wpdb->users} SET user_pass='{$user_pass}', user_email='{$user_email}', user_url='{$user_url}', user_nicename = '{$user_nicename}', display_name = '{$display_name}' WHERE ID = '{$ID}'";
$query = apply_filters('update_user_query', $query);
$wpdb->query($query);
$user_id = $ID;
} else {
$query = "INSERT INTO {$wpdb->users} \n\t\t(user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name)\n\tVALUES \n\t\t('{$user_login}', '{$user_pass}', '{$user_email}', '{$user_url}', '{$user_registered}', '{$user_nicename}', '{$display_name}')";
$query = apply_filters('create_user_query', $query);
$wpdb->query($query);
$user_id = $wpdb->insert_id;
}
update_usermeta($user_id, 'first_name', $first_name);
update_usermeta($user_id, 'last_name', $last_name);
update_usermeta($user_id, 'nickname', $nickname);
update_usermeta($user_id, 'description', $description);
update_usermeta($user_id, 'jabber', $jabber);
update_usermeta($user_id, 'aim', $aim);
update_usermeta($user_id, 'yim', $yim);
if ($update && !empty($role)) {
$user = new WP_User($user_id);
$user->set_role($role);
}
if (!$update) {
$user = new WP_User($user_id);
$user->set_role(get_settings('default_role'));
}
wp_cache_delete($user_id, 'users');
wp_cache_delete($user_login, 'userlogins');
if ($update) {
do_action('profile_update', $user_id);
} else {
do_action('user_register', $user_id);
}
return $user_id;
}
开发者ID:robertlange81,项目名称:Website,代码行数:59,代码来源:registration-functions.php
注:本文中的wp_cache_delete函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论