wp_cache_delete example

// Upgrade DB with separate request.     /** This filter is documented in wp-admin/includes/update-core.php */
    apply_filters( 'update_feedback', __( 'Upgrading database…' ) );

    $db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
    wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) );

    // Clear the cache to prevent an update_option() from saving a stale db_version to the cache.     wp_cache_flush();
    // Not all cache back ends listen to 'flush'.     wp_cache_delete( 'alloptions', 'options' );

    // Remove working directory.     $wp_filesystem->delete( $from, true );

    // Force refresh of update information.     if ( function_exists( 'delete_site_transient' ) ) {
        delete_site_transient( 'update_core' );
    } else {
        delete_option( 'update_core' );
    }

    
// If WP_DEFAULT_THEME doesn't exist, also include the latest core default theme.     if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) {
        $core_default = WP_Theme::get_core_default_theme();
        if ( $core_default ) {
            $allowed_themes[ $core_default->get_stylesheet() ] = true;
        }
    }

    if ( function_exists( 'clean_network_cache' ) ) {
        clean_network_cache( $network_id );
    } else {
        wp_cache_delete( $network_id, 'networks' );
    }

    if ( ! is_multisite() ) {
        $site_admins = array( $site_user->user_login );
        $users       = get_users(
            array(
                'fields' => array( 'user_login' ),
                'role'   => 'administrator',
            )
        );
        if ( $users ) {
            
$theme_has_support[ $stylesheet ] = file_exists( $path );

    return $theme_has_support[ $stylesheet ];
}

/** * Cleans the caches under the theme_json group. * * @since 6.2.0 */
function wp_clean_theme_json_cache() {
    wp_cache_delete( 'wp_get_global_stylesheet', 'theme_json' );
    wp_cache_delete( 'wp_get_global_styles_svg_filters', 'theme_json' );
    wp_cache_delete( 'wp_get_global_settings_custom', 'theme_json' );
    wp_cache_delete( 'wp_get_global_settings_theme', 'theme_json' );
    wp_cache_delete( 'wp_get_global_styles_custom_css', 'theme_json' );
    WP_Theme_JSON_Resolver::clean_cached_data();
}

/** * Returns the current theme's wanted patterns (slugs) to be * registered from Pattern Directory. * * @since 6.3.0 * * @return string[] */

    do_action( 'add_user_to_blog', $user_id$role$blog_id );

    clean_user_cache( $user_id );
    wp_cache_delete( $blog_id . '_user_count', 'blog-details' );

    restore_current_blog();

    return true;
}

/** * Removes a user from a blog. * * Use the {@see 'remove_user_from_blog'} action to fire an event when * users are removed from a blog. * * Accepts an optional `$reassign` parameter, if you want to * reassign the user's blog posts to another user upon removal. * * @since MU (3.0.0) * * @global wpdb $wpdb WordPress database abstraction object. * * @param int $user_id ID of the user being removed. * @param int $blog_id Optional. ID of the blog the user is being removed from. Default 0. * @param int $reassign Optional. ID of the user to whom to reassign posts. Default 0. * @return true|WP_Error True on success or a WP_Error object if the user doesn't exist. */
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
        return;
    }

    $post = get_post( $post );

    if ( ! $post ) {
        return;
    }

    wp_cache_delete( $post->ID, 'posts' );
    wp_cache_delete( $post->ID, 'post_meta' );

    clean_object_term_cache( $post->ID, $post->post_type );

    wp_cache_delete( 'wp_get_archives', 'general' );

    /** * Fires immediately after the given post's cache is cleaned. * * @since 2.5.0 * * @param int $post_id Post ID. * @param WP_Post $post Post object. */
private function cache_get( $key ) {
        return wp_cache_get( $key . '-' . $this->cache_hash, 'themes' );
    }

    /** * Clears the cache for the theme. * * @since 3.4.0 */
    public function cache_delete() {
        foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) {
            wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
        }
        $this->template          = null;
        $this->textdomain_loaded = null;
        $this->theme_root_uri    = null;
        $this->parent            = null;
        $this->errors            = null;
        $this->headers_sanitized = null;
        $this->name_translated   = null;
        $this->block_theme       = null;
        $this->headers           = array();
        $this->__construct( $this->stylesheet, $this->theme_root );
    }
$blog_id = (int) $blog_id;

    $all     = $get_all ? '' : 'short';
    $details = wp_cache_get( $blog_id . $all, 'blog-details' );

    if ( $details ) {
        if ( ! is_object( $details ) ) {
            if ( -1 == $details ) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.                 wp_cache_delete( $blog_id . $all, 'blog-details' );
                unset( $details );
            }
        } else {
            return $details;
        }
    }

    // Try the other cache.     if ( $get_all ) {
        $details = wp_cache_get( $blog_id . 'short', 'blog-details' );
    } else {
        
return $value;
}

/** * Deletes the bookmark cache. * * @since 2.7.0 * * @param int $bookmark_id Bookmark ID. */
function clean_bookmark_cache( $bookmark_id ) {
    wp_cache_delete( $bookmark_id, 'bookmark' );
    wp_cache_delete( 'get_bookmarks', 'bookmark' );
    clean_object_term_cache( $bookmark_id, 'link' );
}
(object) array(
                'blog_id' => $blog_id,
                'domain'  => null,
                'path'    => null,
            )
        );
    }

    $blog_id         = $blog->blog_id;
    $domain_path_key = md5( $blog->domain . $blog->path );

    wp_cache_delete( $blog_id, 'sites' );
    wp_cache_delete( $blog_id, 'site-details' );
    wp_cache_delete( $blog_id, 'blog-details' );
    wp_cache_delete( $blog_id . 'short', 'blog-details' );
    wp_cache_delete( $domain_path_key, 'blog-lookup' );
    wp_cache_delete( $domain_path_key, 'blog-id-cache' );
    wp_cache_delete( $blog_id, 'blog_meta' );

    /** * Fires immediately after a site has been removed from the object cache. * * @since 4.6.0 * * @param string $id Site ID as a numeric string. * @param WP_Site $blog Site object. * @param string $domain_path_key md5 hash of domain and path. */

    function wp_cache_delete_multiple( array $keys$group = '' ) {
        $values = array();

        foreach ( $keys as $key ) {
            $values[ $key ] = wp_cache_delete( $key$group );
        }

        return $values;
    }
endif;

if ( ! function_exists( 'wp_cache_flush_runtime' ) ) :
    /** * Removes all cache items from the in-memory runtime cache. * * Compat function to mimic wp_cache_flush_runtime(). * * @ignore * @since 6.0.0 * * @see wp_cache_flush_runtime() * * @return bool True on success, false on failure. */
$result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) );

    if ( ! wp_installing() ) {
        if ( 'yes' === $row->autoload ) {
            $alloptions = wp_load_alloptions( true );
            if ( is_array( $alloptions ) && isset( $alloptions[ $option ] ) ) {
                unset( $alloptions[ $option ] );
                wp_cache_set( 'alloptions', $alloptions, 'options' );
            }
        } else {
            wp_cache_delete( $option, 'options' );
        }
    }

    if ( $result ) {

        /** * Fires after a specific option has been deleted. * * The dynamic portion of the hook name, `$option`, refers to the option name. * * @since 3.0.0 * * @param string $option Name of the deleted option. */
$values[] = $wpdb->prepare( '(%d, %d, %d)', $object_id$tt_id, ++$term_order );
            }
        }

        if ( $values ) {
            if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . implode( ',', $values ) . ' ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)' ) ) {
                return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database.' )$wpdb->last_error );
            }
        }
    }

    wp_cache_delete( $object_id$taxonomy . '_relationships' );
    wp_cache_set_terms_last_changed();

    /** * Fires after an object's terms have been set. * * @since 2.8.0 * * @param int $object_id Object ID. * @param array $terms An array of object term IDs or slugs. * @param array $tt_ids An array of term taxonomy IDs. * @param string $taxonomy Taxonomy slug. * @param bool $append Whether to append new terms to the old terms. * @param array $old_tt_ids Old array of term taxonomy IDs. */
$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id$meta_key) );

    if ( $cur && $cur->umeta_id )
        do_action( 'delete_usermeta', $cur->umeta_id, $user_id$meta_key$meta_value );

    if ( ! empty($meta_value) )
        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id$meta_key$meta_value) );
    else
        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id$meta_key) );

    clean_user_cache( $user_id );
    wp_cache_delete( $user_id, 'user_meta' );

    if ( $cur && $cur->umeta_id )
        do_action( 'deleted_usermeta', $cur->umeta_id, $user_id$meta_key$meta_value );

    return true;
}

/** * Retrieve user metadata. * * If $user_id is not a number, then the function will fail over with a 'false' * boolean return value. Other returned values depend on whether there is only * one item to be returned, which be that single item type. If there is more * than one metadata value, then it will be list of metadata values. * * @since 2.0.0 * @deprecated 3.0.0 Use get_user_meta() * @see get_user_meta() * * @param int $user_id User ID * @param string $meta_key Optional. Metadata key. Default empty. * @return mixed */

function clean_user_cache( $user ) {
    if ( is_numeric( $user ) ) {
        $user = new WP_User( $user );
    }

    if ( ! $user->exists() ) {
        return;
    }

    wp_cache_delete( $user->ID, 'users' );
    wp_cache_delete( $user->user_login, 'userlogins' );
    wp_cache_delete( $user->user_nicename, 'userslugs' );

    if ( ! empty( $user->user_email ) ) {
        wp_cache_delete( $user->user_email, 'useremail' );
    }

    wp_cache_delete( $user->ID, 'user_meta' );
    wp_cache_set_users_last_changed();

    /** * Fires immediately after the given user's cache is cleaned. * * @since 4.4.0 * * @param int $user_id User ID. * @param WP_User $user User object. */
/** * Clears the plugins cache used by get_plugins() and by default, the plugin updates cache. * * @since 3.7.0 * * @param bool $clear_update_cache Whether to clear the plugin updates cache. Default true. */
function wp_clean_plugins_cache( $clear_update_cache = true ) {
    if ( $clear_update_cache ) {
        delete_site_transient( 'update_plugins' );
    }
    wp_cache_delete( 'plugins', 'plugins' );
}

/** * Loads a given plugin attempt to generate errors. * * @since 3.0.0 * @since 4.4.0 Function was moved into the `wp-admin/includes/plugin.php` file. * * @param string $plugin Path to the plugin file relative to the plugins directory. */
function plugin_sandbox_scrape( $plugin ) {
    
Home | Imprint | This part of the site doesn't use cookies.