• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_cache_flush函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_cache_flush函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_flush函数的具体用法?PHP wp_cache_flush怎么用?PHP wp_cache_flush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_cache_flush函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wpmuNewBlog

 /**
  * Runs activation function and sets up default WP options for new blog,
  * a.k.a. when a registered user creates a new blog
  *
  * @param int $blog_id
  * @param int $user_id
  *
  * @see add_action( 'wpmu_new_blog', ... )
  */
 function wpmuNewBlog($blog_id, $user_id)
 {
     $this->blog_id = (int) $blog_id;
     $this->user_id = (int) $user_id;
     switch_to_blog($this->blog_id);
     if (!$this->isBookSetup()) {
         $this->wpmuActivate();
         array_walk($this->opts, function ($v, $k) {
             if (empty($v)) {
                 delete_option($k);
             } else {
                 update_option($k, $v);
             }
         });
         wp_cache_flush();
     }
     // Set current metadata version to skip redundant upgrade routines
     update_option('pressbooks_metadata_version', \Pressbooks\Metadata::$currentVersion);
     flush_rewrite_rules(false);
     do_action('pressbooks_new_blog');
     restore_current_blog();
     if (is_user_logged_in()) {
         (new \Pressbooks\Catalog())->deleteCache();
         \Pressbooks\Redirect\location(get_admin_url($this->blog_id));
     }
 }
开发者ID:pressbooks,项目名称:pressbooks,代码行数:35,代码来源:class-pb-activation.php


示例2: execute

 /**
  * {@inheritdoc}
  * @param array $args
  * * zip - file path
  * * dir - where the zip file will be extract
  */
 public function execute(array $args, array $state = array())
 {
     if (!isset($args['zip'])) {
         return new WP_Error('no_zip', __('Zip file not specified', 'fw'));
     } else {
         $args['zip'] = fw_fix_path($args['zip']);
     }
     if (!isset($args['dir'])) {
         return new WP_Error('no_dir', __('Destination dir not specified', 'fw'));
     } else {
         $args['dir'] = fw_fix_path($args['dir']);
     }
     if (empty($state)) {
         if (!fw_ext_backups_is_dir_empty($args['dir'])) {
             return new WP_Error('destination_not_empty', __('Destination dir is not empty', 'fw'));
         }
         $state = array('entry' => '', 'extracted_files' => 0);
     }
     wp_cache_flush();
     FW_Cache::clear();
     if (is_wp_error($extract_result = fw_ext_backups_unzip_partial($args['zip'], $args['dir'], $state['entry']))) {
         return $extract_result;
     } else {
         if ($extract_result['finished']) {
             return true;
         } else {
             $state['entry'] = $extract_result['last_entry'];
             $state['extracted_files'] += $extract_result['extracted_files'];
             return $state;
         }
     }
 }
开发者ID:ThemeFuse,项目名称:Unyson-Backups-Extension,代码行数:38,代码来源:class-fw-ext-backups-task-type-unzip.php


示例3: wc_delete_product_transients

/**
 * Clear all transients cache for product data.
 *
 * @param int $post_id (default: 0)
 */
function wc_delete_product_transients($post_id = 0)
{
    global $wpdb;
    if (wp_using_ext_object_cache()) {
        wp_cache_flush();
        // There isn't a reliable method of looking up the names, so flush the cache.
        return;
    }
    $post_id = absint($post_id);
    // Clear core transients
    $transients_to_clear = array('wc_products_onsale', 'wc_hidden_product_ids', 'wc_hidden_product_ids_search', 'wc_attribute_taxonomies', 'wc_term_counts', 'wc_featured_products');
    // Clear transients for which we don't have the name
    $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE ('_transient_wc_uf_pid_%') OR `option_name` LIKE ('_transient_timeout_wc_uf_pid_%')");
    $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE ('_transient_wc_ln_count_%') OR `option_name` LIKE ('_transient_timeout_wc_ln_count_%')");
    $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE ('_transient_wc_ship_%') OR `option_name` LIKE ('_transient_timeout_wc_ship_%')");
    $wpdb->query("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE ('_transient_wc_products_will_display_%') OR `option_name` LIKE ('_transient_timeout_wc_products_will_display_%')");
    // Clear product specific transients
    $post_transient_names = array('wc_product_children_ids_', 'wc_product_total_stock_', 'wc_average_rating_', 'wc_rating_count_');
    if ($post_id > 0) {
        foreach ($post_transient_names as $transient) {
            $transients_to_clear[] = $transient . $post_id;
        }
    } else {
        foreach ($post_transient_names as $transient) {
            $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE %s OR `option_name` LIKE %s", '_transient_' . $transient . '%', '_transient_timeout_' . $transient . '%'));
        }
    }
    // Delete transients
    foreach ($transients_to_clear as $transient) {
        delete_transient($transient);
    }
    do_action('woocommerce_delete_product_transients', $post_id);
}
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:38,代码来源:wc-product-functions.php


示例4: isTriggered

 public function isTriggered()
 {
     $flusher =& $_REQUEST['bf-flusher'];
     $nonce =& $_REQUEST['_wpnonce'];
     // Don't do anything if we don't see a flush request or the user is not an administrator
     if (!isset($flusher) || !current_user_can('administrator')) {
         return;
     }
     // Verify the nonce security token. If not valid die with permission denied
     if (!isset($nonce) || !wp_verify_nonce($nonce, 'flush_' . $flusher)) {
         wp_die(esc_html__('Permission Denied', 'bfflusher'));
     }
     // Which flush action are we to perform?
     switch ($flusher) {
         case 'permalinks':
             flush_rewrite_rules();
             break;
         case 'object-cache':
             function_exists('wp_cache_flush_site') ? wp_cache_flush_site() : wp_cache_flush();
             break;
     }
     // Safe redirect to the page that the user originally came from.
     wp_safe_redirect($_SERVER['HTTP_REFERER']);
     die;
 }
开发者ID:alex-windett,项目名称:Wordpress-Setup,代码行数:25,代码来源:flusher.php


示例5: import

 /**
  * Import settings via WP-CFM
  */
 public function import()
 {
     $app = Bootstrap::getApplication();
     $helpers = $app['helpers'];
     $baseUrl = get_option('siteurl');
     $src = WPBOOT_BASEPATH . '/bootstrap/config/wpbootstrap.json';
     $trg = $app['path'] . '/wp-content/config/wpbootstrap.json';
     if (file_exists($src)) {
         @mkdir(dirname($trg), 0777, true);
         copy($src, $trg);
         // deneutralize
         $settings = json_decode(file_get_contents($trg));
         $helpers->fieldSearchReplace($settings, Bootstrap::NEUTRALURL, $baseUrl);
         file_put_contents($trg, $helpers->prettyPrint(json_encode($settings)));
         if (function_exists('WPCFM')) {
             WPCFM()->readwrite->pull_bundle('wpbootstrap');
         } else {
             $cli = $app['cli'];
             $cli->warning('Plugin WP-CFM does not seem to be installed. No options imported.');
             $cli->warning('Add the WP-CFM plugin directly to this install using:');
             $cli->warning('$ wp plugin install wp-cfm --activate');
             $cli->warning('');
             $cli->warning('...or to your appsettings using:');
             $cli->warning('$ wp bootstrap add plugin wp-cfm');
             $cli->warning('$ wp bootstrap setup');
             return;
         }
         // Flush options to make sure no other code overwrites based
         // on old settings stored in cache
         wp_cache_flush();
     }
 }
开发者ID:eriktorsner,项目名称:wp-bootstrap,代码行数:35,代码来源:ImportOptions.php


示例6: wp_dlm_clear_cached_stuff

function wp_dlm_clear_cached_stuff()
{
    delete_transient('dlm_categories');
    delete_transient('dlm_tags');
    delete_transient('dlm_used_tags');
    wp_cache_flush();
}
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:7,代码来源:functions.inc.php


示例7: testItForwardsWPPostFields

 public function testItForwardsWPPostFields()
 {
     // Given I have a random post
     $posts = get_posts();
     $this->assertNotNull($posts);
     $this->assertNotEmpty($posts);
     $this->assertNotInstanceOf('\\WP_Error', $posts);
     /** @var \WP_Post $post */
     $post = current($posts);
     $this->assertNotNull($post);
     $this->assertNotEquals(0, $post->ID);
     $this->assertInstanceOf('\\WP_Post', $post);
     // And I turn it into a comfort post
     $comfort_post = new Simple_Post($post->ID);
     // And the meta key has no value
     $meta_key = uniqid('some_meta_');
     $this->assertEmpty($post->{$meta_key});
     $this->assertEmpty($comfort_post->{$meta_key});
     // And I fill the meta entity
     $meta_value = uniqid('some_value_');
     update_post_meta($post->ID, $meta_key, $meta_value);
     // When I fetch the meta value via WP_Post
     wp_cache_flush();
     $this->assertEquals($meta_value, $post->{$meta_key});
     // Then It should equal the comfort post meta value
     wp_cache_flush();
     $this->assertEquals($meta_value, $comfort_post->{$meta_key});
 }
开发者ID:sourcerer-mike,项目名称:wp-comfort,代码行数:28,代码来源:test-abstract-post.php


示例8: 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


示例9: wp_install

function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
    global $wpdb;
    $base = '/';
    $domain = JQUERY_STAGING_PREFIX . 'jquery.com';
    wp_check_mysql_version();
    wp_cache_flush();
    make_db_current_silent();
    populate_options();
    populate_roles();
    $user_id = wp_create_user($user_name, trim($user_password), $user_email);
    $user = new WP_User($user_id);
    $user->set_role('administrator');
    $guess_url = wp_guess_url();
    foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) {
        $wpdb->{$table} = $prefixed_table;
    }
    install_network();
    populate_network(1, $domain, $user_email, 'jQuery Network', $base, false);
    update_site_option('site_admins', array($user->user_login));
    update_site_option('allowedthemes', array());
    $wpdb->insert($wpdb->blogs, array('site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time('mysql')));
    $blog_id = $wpdb->insert_id;
    update_user_meta($user_id, 'source_domain', $domain);
    update_user_meta($user_id, 'primary_blog', $blog_id);
    if (!($upload_path = get_option('upload_path'))) {
        $upload_path = substr(WP_CONTENT_DIR, strlen(ABSPATH)) . '/uploads';
        update_option('upload_path', $upload_path);
    }
    update_option('fileupload_url', get_option('siteurl') . '/' . $upload_path);
    jquery_install_remaining_sites($user);
    wp_new_blog_notification($blog_title, $guess_url, $user_id, $message = __('The password you chose during the install.'));
    wp_cache_flush();
    return array('url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
开发者ID:ravasthi,项目名称:web-base-template,代码行数:35,代码来源:install.php


示例10: writeItem

 /**
  * {@inheritdoc}
  */
 public function writeItem(array $item)
 {
     // Try to locate an existing post
     $post = $this->findExisting($item);
     if ($post && !$this->replace) {
         // If it exists and the overwrite flag is off, skip processing
         return $this;
     } elseif (!$post && $this->addNew) {
         // Otherwise, if the add-new flag is set, initialize a new post object
         $post = new \WP_Post((object) ['post_title' => '(Untitled)', 'post_type' => $this->getPostType(), 'post_status' => 'publish']);
     }
     if (!$post instanceof \WP_Post) {
         // If we don't have a post object by now, skip the row
         return $this;
     }
     // Clear meta field and term queues
     $this->metaFields = [];
     $this->terms = [];
     // Build the post and queue meta fields and terms
     $this->buildPost($post, $item)->buildMetaFields($post, $item)->buildTerms($post, $item);
     // Save the post
     $ID = $this->savePost($post);
     $post = get_post($ID);
     if (!$post) {
         $this->throwException('Post could not be saved.');
     }
     // Save meta fields and terms
     $this->saveMetaFields($post)->saveTerms($post);
     // Flush the cache
     wp_cache_flush();
     return $this;
 }
开发者ID:asmbs,项目名称:wp-schedule-builder,代码行数:35,代码来源:AbstractPostWriter.php


示例11: db

 public function db($command = '', $args = '')
 {
     if (count($command) == 1 && reset($command) == 'help') {
         return $this->db_help();
     }
     $defaults = array('host' => defined('IMPORT_DB_HOST') ? IMPORT_DB_HOST : DB_HOST, 'user' => defined('IMPORT_DB_USER') ? IMPORT_DB_USER : DB_USER, 'password' => defined('IMPORT_DB_PASSWORD') ? IMPORT_DB_PASSWORD : '', 'name' => defined('IMPORT_DB_NAME') ? IMPORT_DB_NAME : '', 'port' => '3306', 'ssh_host' => defined('IMPORT_DB_SSH_HOST') ? IMPORT_DB_SSH_HOST : '', 'ssh_user' => defined('IMPORT_DB_SSH_USER') ? IMPORT_DB_SSH_USER : '', 'table' => '');
     $args = wp_parse_args($args, $defaults);
     $start_time = time();
     if ($args['ssh_host']) {
         shell_exec(sprintf("ssh -f -L 3308:%s:%s %s@%s sleep 600 >> logfile", $args['host'], $args['port'], $args['ssh_user'], $args['ssh_host']));
         $args['host'] = '127.0.0.1';
         $args['port'] = '3308';
     }
     WP_CLI::line('Importing database from ' . $args['host'] . '...' . ($args['ssh_host'] ? ' via ssh tunnel: ' . $args['ssh_host'] : ''));
     $password = $args['password'] ? '--password=' . escapeshellarg($args['password']) : '';
     // TODO pipe through sed or interconnectIT's search replace script
     if (defined('IMPORT_DB_REMOTE_ABSPATH')) {
         $sed = " | sed s," . trailingslashit(IMPORT_DB_REMOTE_ABSPATH) . "," . ABSPATH . ",g";
     } else {
         $sed = '';
     }
     if ($args['site']) {
         $args['table'] = "wp_{$args['site']}_commentmeta wp_{$args['site']}_comments wp_{$args['site']}_links wp_{$args['site']}_options wp_{$args['site']}_postmeta wp_{$args['site']}_posts wp_{$args['site']}_term_relationships wp_{$args['site']}_term_taxonomy wp_{$args['site']}_terms";
     }
     $exec = sprintf('mysqldump --verbose --host=%s --user=%s %s -P %s %s %s %s | mysql --host=%s --user=%s --password=%s %s', $args['host'], $args['user'], $password, $args['port'], $args['name'], $args['table'], $sed, DB_HOST, DB_USER, escapeshellarg(DB_PASSWORD), DB_NAME);
     WP_CLI::line('Running: ' . $exec);
     WP_CLI::launch($exec);
     WP_CLI::success(sprintf('Finished. Took %d seconds', time() - $start_time));
     wp_cache_flush();
 }
开发者ID:humanmade,项目名称:hm-dev,代码行数:30,代码来源:hm-dev.wp-cli.import.php


示例12: ThemeToolkit

 function ThemeToolkit($theme, $array, $file)
 {
     global $wp_version;
     // is it WP 2.0+ and do we have plugins like "../themes/foo/functions.php" running ?
     if ($wp_version >= 2 and count(@preg_grep('#^\\.\\./themes/[^/]+/functions.php$#', get_settings('active_plugins'))) > 0) {
         wp_cache_flush();
         $this->upgrade_toolkit();
     }
     $this->infos['path'] = '../themes/' . basename(dirname($file));
     /* Create some vars needed if an admin menu is to be printed */
     if ($array['debug']) {
         if (basename($file) == $_GET['page']) {
             $this->infos['debug'] = 1;
         }
         unset($array['debug']);
     }
     if (basename($file) == $_GET['page']) {
         $this->infos['menu_options'] = $array;
         $this->infos['classname'] = $theme;
     }
     $this->option = array();
     /* Check this file is registered as a plugin, do it if needed */
     $this->pluginification();
     /* Get infos about the theme and particularly its 'shortname'
      * which is used to name the entry in wp_options where data are stored */
     $this->do_init();
     /* Read data from options table */
     $this->read_options();
     /* Are we in the admin area ? Add a menu then ! */
     $this->file = $file;
     add_action('admin_menu', array(&$this, 'add_menu'));
 }
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:32,代码来源:themetoolkit.php


示例13: clear_session_transients

 public function clear_session_transients()
 {
     global $wpdb;
     $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_twccr_" . session_id() . "%'");
     $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_twccr_" . session_id() . "%'");
     wp_cache_flush();
 }
开发者ID:skristi,项目名称:urbantac,代码行数:7,代码来源:woocommerce-catalog-restrictions.php


示例14: import

 public function import($fp)
 {
     list($table, $view) = $this->db->query_schema();
     array_map(array($this->db, 'drop_table'), $table);
     array_map(array($this->db, 'drop_view'), $view);
     $this->db->foreach_statement($fp, array($this->db, 'query'));
     wp_cache_flush();
 }
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:8,代码来源:class-fw-backup-ie-database.php


示例15: merge_duplicates

 /**
  * Merge all duplicate event-related posts
  *
  * @return void
  */
 public function merge_duplicates()
 {
     $this->merge_identical_organizers();
     $this->merge_identical_venues();
     $events = TribeEvents::instance();
     $events->setOption('organizer_venue_amalgamation', 1);
     wp_cache_flush();
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:13,代码来源:tribe-amalgamator.php


示例16: flush

 /**
  * Flush the object cache.
  */
 public function flush($args, $assoc_args)
 {
     $value = wp_cache_flush();
     if (false === $value) {
         WP_CLI::error('The object cache could not be flushed.');
     }
     WP_CLI::success('The cache was flushed.');
 }
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:11,代码来源:cache.php


示例17: supernova_page

    function supernova_page()
    {
        global $supernova_options;
        ?>
        			        
        		<div class="supernova_wrap wrap">
<!--        	<div id="icon-options-general" class="supernova32 icon32"></div>
            	<h2 class="supernova_heading">Supernova <?php 
        _e('Theme Options', 'Supernova');
        ?>
</h2>-->
                    <div id="supernovaoptions">
                        <form action="options.php" method="post" enctype="multipart/form-data" id="supernova_admin_form">
                            <?php 
        settings_fields('supernova_group');
        supernova_writer();
        ?>

                            <?php 
        include SUPERNOVA_ADMIN . 'admin-int.php';
        ?>

                             <div class="submit_sticky">
   		   <p class="supernova-botton-primary">
                       <input type="submit" name="supernova-save" class="button-primary new-button-primary" value="<?php 
        _e('Save Settings', 'Supernova');
        ?>
">
                   </p>
                            </div>
                        </form>
                    </div>
        		</div><!--wrap -->

	<?php 
        if (isset($_POST['truncate'])) {
            global $wpdb;
            delete_option('supernova_settings');
            supernova_writer();
            wp_cache_flush();
            ?>
 
                        <script> //to make sure all fields appear empty to the user on reset </script>
	<?php 
        }
        ?>


    <form action="" method="post">
        <p class="tooltip3 tooltip2">
            <input type="submit" name="truncate" class="button-primary reset_button" value="<?php 
        _e('Reset All', 'Supernova');
        ?>
"  />
       	</p>
    </form>
                        <?php 
    }
开发者ID:plusinterativa,项目名称:clientes,代码行数:58,代码来源:admin-setup.php


示例18: vp_flush_regenerable_options

function vp_flush_regenerable_options()
{
    wp_cache_flush();
    $taxonomies = get_taxonomies();
    foreach ($taxonomies as $taxonomy) {
        delete_option("{$taxonomy}_children");
        // Regenerate {$taxonomy}_children
        _get_term_hierarchy($taxonomy);
    }
}
开发者ID:versionpress,项目名称:versionpress,代码行数:10,代码来源:internal-functions.php


示例19: flush

 public static function flush() {
   if (self::$filesystem) {
     $files = glob(ABSPATH.'wp-content/cache/fragment-cache/*'); // get all file names
     foreach ($files as $file) { // iterate files
       if (is_file($file)) unlink($file); // delete file
     }      
   } else {
     wp_cache_flush();
   }
 }
开发者ID:buraksahin59,项目名称:WordPress-FragmentCache,代码行数:10,代码来源:fragment_cache.php


示例20: test_update_adds_falsey_value

 function test_update_adds_falsey_value()
 {
     $key = rand_str();
     $value = 0;
     delete_site_option($key);
     $this->assertTrue(update_site_option($key, $value));
     wp_cache_flush();
     // ensure we're getting the value from the DB
     $this->assertEquals($value, get_site_option($key));
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:10,代码来源:siteOption.php



注:本文中的wp_cache_flush函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_cache_get函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_cache_delete函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap