当前位置: 首页>>代码示例>>PHP>>正文


PHP clean_post_cache函数代码示例

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


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

示例1: upsert_post

 public function upsert_post($post, $silent = false)
 {
     global $wpdb;
     // reject the post if it's not a WP_Post
     if (!$post instanceof WP_Post) {
         return;
     }
     $post = $post->to_array();
     // reject posts without an ID
     if (!isset($post['ID'])) {
         return;
     }
     $now = current_time('mysql');
     $now_gmt = get_gmt_from_date($now);
     $defaults = array('ID' => 0, 'post_author' => '0', 'post_content' => '', 'post_content_filtered' => '', 'post_title' => '', 'post_name' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => 'closed', 'comment_count' => '0', 'ping_status' => '', 'post_password' => '', 'to_ping' => '', 'pinged' => '', 'post_parent' => 0, 'menu_order' => 0, 'guid' => '', 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_modified' => $now, 'post_modified_gmt' => $now_gmt);
     $post = array_intersect_key($post, $defaults);
     $post = sanitize_post($post, 'db');
     unset($post['filter']);
     $exists = $wpdb->get_var($wpdb->prepare("SELECT EXISTS( SELECT 1 FROM {$wpdb->posts} WHERE ID = %d )", $post['ID']));
     if ($exists) {
         $wpdb->update($wpdb->posts, $post, array('ID' => $post['ID']));
     } else {
         $wpdb->insert($wpdb->posts, $post);
     }
     clean_post_cache($post['ID']);
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:26,代码来源:class.jetpack-sync-wp-replicastore.php

示例2: __invoke

 /**
  * Reset the post_date field on your posts.
  * A sadly necessary step after you change your timezone in WordPress
  * 
  * @synopsis --post_type=<post-type>
  */
 public function __invoke($args, $assoc_args)
 {
     global $wpdb;
     $query_args = array('post_type' => $assoc_args['post_type'], 'posts_per_page' => -1, 'post_status' => 'publish');
     $query = new WP_Query($query_args);
     if (empty($query->posts)) {
         WP_CLI::error("No posts found");
     }
     WP_CLI::line(sprintf("Updating post_date on %d posts.", count($query->posts)));
     foreach ($query->posts as $key => $post) {
         if (empty($post->post_date_gmt) || "0000-00-00 00:00:00" == $post->post_date_gmt) {
             WP_CLI::line(sprintf("Error: Post %d is missing a publish date.", $post->ID));
             continue;
         }
         $original = $post->post_date;
         $new = get_date_from_gmt($post->post_date_gmt);
         if ($new == $original) {
             WP_CLI::line(sprintf("No Change: Post %d has the correct post_date of %s", $post->ID, $original));
             continue;
         }
         $wpdb->update($wpdb->posts, array('post_date' => $new), array('ID' => $post->ID));
         clean_post_cache($post->ID);
         WP_CLI::line(sprintf("Updated: Post %d changed from %s to %s", $post->ID, $original, $new));
         if ($key && $key % 10 == 0) {
             sleep(1);
         }
     }
     WP_CLI::success("Posts were updated with the correct post_date.");
 }
开发者ID:danielbachhuber,项目名称:wp-cli-reset-post-date-command,代码行数:35,代码来源:wp-cli-reset-post-date-command.php

示例3: process_bulk_action

 /**
  * Handle Bulk Action's request
  *
  */
 public function process_bulk_action()
 {
     global $wpdb;
     try {
         switch ($this->current_action()) {
             case 'unassign':
                 if (empty($_REQUEST['post_ids']) || !is_array($_REQUEST['post_ids'])) {
                     throw new \Exception(sprintf(__('Invalid request: no %s IDs provided.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                 }
                 $post_ids = $_REQUEST['post_ids'];
                 foreach ($post_ids as $post_id) {
                     $post_id = (int) $post_id;
                     if (!$post_id) {
                         throw new \Exception(sprintf(__('Invalid request: incorrect %s IDs provided.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                     }
                     $wpdb->query($wpdb->prepare("\n                  UPDATE {$wpdb->posts}\n                  SET post_parent = '0'\n                  WHERE ID = %d\n                ", $post_id));
                     clean_post_cache($post_id);
                 }
                 $label = count($post_ids) > 1 ? __('Children', ud_get_wp_property('domain')) : __('Child', ud_get_wp_property('domain'));
                 $this->message = sprintf(__('Selected %s have been successfully un-assigned from current %s.', ud_get_wp_property('domain')), $label, \WPP_F::property_label());
                 break;
             default:
                 //** Any custom action can be processed using action hook */
                 do_action('wpp::children_list_table::process_bulk_action', $this->current_action());
                 break;
         }
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
     }
 }
开发者ID:ksan5835,项目名称:rankproperties,代码行数:34,代码来源:class-children-list-table.php

示例4: _appthemes_update_comment_count

/**
 * Updates the comment count for the post.
 * Recalculates comment count by excluding specified comment types, eg. report, review.
 *
 * @param int $post_id Post ID
 * @param int $new New comment count
 * @param int $old Previous comment count
 *
 * @return void
 */
function _appthemes_update_comment_count($post_id, $new, $old)
{
    global $wpdb;
    if (!current_theme_supports('app-comment-counts')) {
        return;
    }
    $args_sets = get_theme_support('app-comment-counts');
    $options = array('exclude_type' => array());
    if (!is_array($args_sets)) {
        $args_sets = array();
    }
    foreach ($args_sets as $args_set) {
        foreach ($args_set as $key => $arg) {
            if (!isset($options[$key])) {
                $options[$key] = $arg;
            } elseif (is_array($arg)) {
                $options[$key] = array_merge_recursive((array) $options[$key], $arg);
            }
        }
    }
    $exclude_types = apply_filters('appthemes_ctypes_count_exclude', $options['exclude_type']);
    if (empty($exclude_types) || !is_array($exclude_types)) {
        return;
    }
    $post = get_post($post_id);
    $exclude_types = esc_sql($exclude_types);
    $count = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved = '1' AND comment_type NOT IN ( '" . implode("', '", $exclude_types) . "' )", $post_id));
    $wpdb->update($wpdb->posts, array('comment_count' => $count), array('ID' => $post_id));
    clean_post_cache($post);
}
开发者ID:kalushta,项目名称:darom,代码行数:40,代码来源:comment-counts.php

示例5: update

 public function update(array $post_data_array, $direct_db_update = false)
 {
     if ($direct_db_update) {
         $this->wpdb->update($this->wpdb->posts, $post_data_array, array('ID' => $this->post_id));
         clean_post_cache($this->post_id);
     } else {
         $post_data_array['ID'] = $this->post_id;
         wp_update_post($post_data_array);
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:10,代码来源:class-wpml-wp-post.php

示例6: removeMenuItems

 private function removeMenuItems($postid)
 {
     global $wpdb;
     $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d and post_name like %s", $postid, "gwpm_matrimony_%"));
     if (!empty($post_ids)) {
         foreach ($post_ids as $post_id) {
             wp_delete_post($post_id, true);
             clean_post_cache($post_id);
         }
     }
 }
开发者ID:ITechGenie,项目名称:genie-wp-matrimony,代码行数:11,代码来源:GwpmSetupModel.php

示例7: register_post_type

 /**
  * Register a private post type to store cron events
  */
 public function register_post_type()
 {
     register_post_type(self::POST_TYPE, array('label' => 'Cron Events', 'public' => false, 'rewrite' => false, 'export' => false, 'exclude_from_search' => true));
     // Clear caches for any manually-inserted posts, lest stale caches be used
     if (!empty($this->posts_to_clean)) {
         foreach ($this->posts_to_clean as $index => $post_to_clean) {
             clean_post_cache($post_to_clean);
             unset($this->posts_to_clean[$index]);
         }
     }
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:14,代码来源:class-cron-options-cpt.php

示例8: setUp

 function setUp()
 {
     parent::setUp();
     /* Create and setup a loop for testing */
     $post_ids = $this->factory->post->create_many(10);
     foreach ($post_ids as $post_id) {
         clean_post_cache($post_id);
     }
     $query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 3));
     $GLOBALS['wp_query'] = $query;
 }
开发者ID:scottnix,项目名称:Thematic,代码行数:11,代码来源:test-content-extensions.php

示例9: transition_post_status

 function transition_post_status($new, $old, $the_post)
 {
     if ('publish' == $old && 'publish' != $new) {
         // A published post was trashed or something else
         $this->delete_post($the_post->ID);
         return;
     }
     clean_post_cache($the_post->ID);
     // Publish a new post
     if ('publish' != $old && $this->post_is_public($the_post->ID) && ('post' == $the_post->post_type || 'page' == $the_post->post_type)) {
         $this->jetpack->sync->post($the_post->ID);
     }
 }
开发者ID:JeffreyBue,项目名称:jb,代码行数:13,代码来源:subscriptions.php

示例10: test_publish_missing_post

 public function test_publish_missing_post()
 {
     $post = $this->factory->post->create_and_get(['post_author' => 1, 'post_date' => '2017-01-01 00:00:00']);
     $this->assertSame('future', $post->post_status);
     global $wpdb;
     $wpdb->update($wpdb->posts, ['post_date' => '2000-01-01 10:10:10', 'post_date_gmt' => '2000-01-01 10:10:10', 'post_status' => 'future'], ['ID' => $post->ID]);
     clean_post_cache($post->ID);
     $this->class->wp_missing_schedule_posts();
     $updated_post = get_post($post->ID);
     $this->assertSame('publish', $updated_post->post_status);
     $flag = get_post_meta($updated_post->ID, $this->class->get_plugin_slug(), true);
     $date_published = DateTime::createFromFormat('U', $flag);
     $this->assertInstanceOf('DateTime', $date_published);
 }
开发者ID:timeincoss,项目名称:wp-missing-schedule,代码行数:14,代码来源:test-wp-missing-schedule.php

示例11: test_post_flushing_cache

 public function test_post_flushing_cache()
 {
     $this->factory->post->create_many(10);
     $first_run = $this->query->query([]);
     $this->assertSame($this->obj->all_post_ids, false);
     $post_id = $this->factory->post->create();
     clean_post_cache($post_id);
     $second_run = $this->query->query([]);
     $this->assertSame($this->obj->all_post_ids, false);
     $this->assertNotEquals($first_run, $second_run);
     $third_run = $this->query->query(['p' => $post_id]);
     $this->assertSame($this->obj->all_post_ids, false);
     $this->assertNotEquals($second_run, $third_run);
 }
开发者ID:timeincoss,项目名称:enhanced-post-cache,代码行数:14,代码来源:test-cache.php

示例12: setUp

 /**
  * Set it Up
  */
 public function setUp()
 {
     parent::setUp();
     $payment_id = Give_Helper_Payment::create_simple_payment();
     $this->_payment_key = give_get_payment_key($payment_id);
     $this->_payment_id = $payment_id;
     $this->_key = $this->_payment_key;
     $this->_transaction_id = 'FIR3SID3';
     give_set_payment_transaction_id($payment_id, $this->_transaction_id);
     give_insert_payment_note($payment_id, sprintf(esc_html__('PayPal Transaction ID: %s', 'give'), $this->_transaction_id));
     // Make sure we're working off a clean object caching in WP Core.
     // Prevents some payment_meta from not being present.
     clean_post_cache($payment_id);
     update_postmeta_cache(array($payment_id));
 }
开发者ID:wordimpress,项目名称:give,代码行数:18,代码来源:tests-payment-class.php

示例13: setUp

 function setUp()
 {
     /* Load the legacy files before anything else - needed for childtheme_overrides* to work */
     include_legacy_xhtml_files();
     /* Load the thematic files */
     parent::setUp();
     /* Create and setup a loop for testing */
     $post_ids = $this->factory->post->create_many(10);
     foreach ($post_ids as $post_id) {
         clean_post_cache($post_id);
     }
     $query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 5));
     $GLOBALS['wp_query'] = $query;
     thematic_replace_loops();
 }
开发者ID:scottnix,项目名称:Thematic,代码行数:15,代码来源:test-legacy-xhtml.php

示例14: checkConversion

 /**
  * Check POST date for convert object on an another custom type.
  *
  * @return void
  * @author Amaury Balmer
  */
 function checkConversion()
 {
     if (isset($_POST['custom-type-convert']) && $_POST['custom-type-convert'] == '1') {
         check_admin_referer('convert-post_type');
         foreach ((array) $_POST['objects'] as $object_id => $new_post_type) {
             // Change the post type
             $object = get_post_to_edit($object_id);
             $object->post_type = $new_post_type;
             wp_update_post((array) $object);
             // Clean object cache
             clean_post_cache($object_id);
         }
         return true;
     }
     return false;
 }
开发者ID:newinsites,项目名称:Wordpress-Starter,代码行数:22,代码来源:class.admin.conversion.php

示例15: save

 /**
  * Save post data
  *
  * @param mixed $value
  * @param \WP_Post $post
  */
 protected function save($value, \WP_Post $post = null)
 {
     switch ($this->field) {
         case 'post_meta':
             update_post_meta($post->ID, $this->name, $value);
             break;
         default:
             $post_id = intval($value);
             // TODO: Reconsider updating post row logic
             /** @var \wpdb $wpdb */
             global $wpdb;
             $wpdb->update($wpdb->posts, ['post_parent' => $post_id], ['ID' => $post->ID], ['%d'], ['%d']);
             clean_post_cache($post);
             break;
     }
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:22,代码来源:TokenInputPost.php


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