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


PHP clean_comment_cache函数代码示例

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


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

示例1: test_editor_can_edit_orphan_comments

 /**
  * @ticket 33154
  */
 function test_editor_can_edit_orphan_comments()
 {
     global $wpdb;
     // Become an editor
     $this->_setRole('editor');
     // Get a comment
     $comments = get_comments(array('post_id' => $this->_comment_post->ID));
     $comment = array_pop($comments);
     // Manually update the comment_post_ID, because wp_update_comment() will prevent it.
     $wpdb->query("UPDATE {$wpdb->comments} SET comment_post_ID=0 WHERE comment_ID={$comment->comment_ID}");
     clean_comment_cache($comment->comment_ID);
     // Set up a default request
     $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce('replyto-comment');
     $_POST['comment_ID'] = $comment->comment_ID;
     $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
     // Make the request
     try {
         $this->_handleAjax('edit-comment');
     } catch (WPAjaxDieContinueException $e) {
         unset($e);
     }
     // Get the response
     $xml = simplexml_load_string($this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA);
     // Check the meta data
     $this->assertEquals(-1, (string) $xml->response[0]->edit_comment['position']);
     $this->assertEquals($comment->comment_ID, (string) $xml->response[0]->edit_comment['id']);
     $this->assertEquals('edit-comment_' . $comment->comment_ID, (string) $xml->response['action']);
     // Check the payload
     $this->assertNotEmpty((string) $xml->response[0]->edit_comment[0]->response_data);
     // And supplemental is empty
     $this->assertEmpty((string) $xml->response[0]->edit_comment[0]->supplemental);
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:35,代码来源:EditComment.php

示例2: wpSetUpBeforeClass

 public static function wpSetUpBeforeClass($factory)
 {
     global $wpdb;
     // Ensure that there is a comment with ID 1.
     $comment_1 = WP_Comment::get_instance(1);
     if (!$comment_1) {
         $wpdb->insert($wpdb->comments, array('comment_ID' => 1));
         clean_comment_cache(1);
     }
     self::$comment_id = self::factory()->comment->create();
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:11,代码来源:wpComment.php

示例3: comment_edited

 public static function comment_edited($commentID = 0, $postID = 0)
 {
     //Clear the comment cache
     if (function_exists('clean_comment_cache')) {
         clean_comment_cache($commentID);
     }
     //For WP Cache and WP Super Cache
     if (function_exists('wp_cache_post_change')) {
         @wp_cache_post_change($postID);
     }
     //Get out if user is admin or post owner
     if (AECCore::is_comment_owner($postID)) {
         return;
     }
     //Increment the number of edited comments
     AECCore::increment_edit_count();
 }
开发者ID:EfncoPlugins,项目名称:ajax-edit-comments,代码行数:17,代码来源:class.actions.php

示例4: test_update_comment_meta_cache_true

 /**
  * @ticket 16894
  */
 public function test_update_comment_meta_cache_true()
 {
     global $wpdb;
     $p = $this->factory->post->create(array('post_status' => 'publish'));
     $comment_ids = $this->factory->comment->create_post_comments($p, 3);
     foreach ($comment_ids as $cid) {
         update_comment_meta($cid, 'foo', 'bar');
     }
     // Clear comment cache, just in case.
     clean_comment_cache($comment_ids);
     $q = new WP_Comment_Query(array('post_ID' => $p, 'update_comment_meta_cache' => true));
     $num_queries = $wpdb->num_queries;
     foreach ($comment_ids as $cid) {
         get_comment_meta($cid, 'foo', 'bar');
     }
     $this->assertSame($num_queries, $wpdb->num_queries);
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:20,代码来源:metaCache.php

示例5: akismet_delete_old

function akismet_delete_old()
{
    global $wpdb;
    $now_gmt = current_time('mysql', 1);
    $comment_ids = $wpdb->get_col("SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB('{$now_gmt}', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
    if (empty($comment_ids)) {
        return;
    }
    $comma_comment_ids = implode(', ', array_map('intval', $comment_ids));
    do_action('delete_comment', $comment_ids);
    $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( {$comma_comment_ids} )");
    $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( {$comma_comment_ids} )");
    clean_comment_cache($comment_ids);
    $n = mt_rand(1, 5000);
    if (apply_filters('akismet_optimize_table', $n == 11)) {
        // lucky number
        $wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
    }
}
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:19,代码来源:akismet.php

示例6: download_comment_bodies

 function download_comment_bodies()
 {
     global $wpdb;
     $cookie = $this->get_session();
     if (is_wp_error($cookie)) {
         return $cookie;
     }
     // Load previous state (if any)
     $this->usermap = (array) get_option('ljapi_usermap');
     $maxid = get_option('ljapi_maxid') ? (int) get_option('ljapi_maxid') : 1;
     $highest_id = (int) get_option('ljapi_highest_comment_id');
     $loop = 0;
     while ($maxid > $highest_id && $loop < 5) {
         // We do 5 loops per call to avoid memory limits
         $loop++;
         // Get a batch of comments, using the highest_id we've already got as a starting point
         $results = wp_remote_get($this->comments_url . '?get=comment_body&startid=' . ($highest_id + 1), array('cookies' => array($cookie), 'timeout' => 20));
         if (is_wp_error($results)) {
             return new WP_Error('comment_bodies', __('Failed to retrieve comment bodies from LiveJournal. Please try again soon.'));
         }
         $results = wp_remote_retrieve_body($results);
         // Parse out each comment and insert directly
         preg_match_all('|<comment id=\'(\\d+)\'.*</comment>|iUs', $results, $matches);
         for ($c = 0; $c < count($matches[0]); $c++) {
             // Keep track of highest id seen
             if ($matches[1][$c] > $highest_id) {
                 $highest_id = $matches[1][$c];
                 update_option('ljapi_highest_comment_id', $highest_id);
             }
             $comment = $matches[0][$c];
             // Filter out any captured, deleted comments (nothing useful to import)
             $comment = preg_replace('|<comment id=\'\\d+\' jitemid=\'\\d+\' posterid=\'\\d+\' state=\'D\'[^/]*/>|is', '', $comment);
             // Parse this comment into an array and insert
             $comment = $this->parse_comment($comment);
             $comment = wp_filter_comment($comment);
             $id = wp_insert_comment($comment);
             // Clear cache
             clean_comment_cache($id);
         }
         // Clear cache to preseve memory
         wp_cache_flush();
     }
     // endwhile - all comments downloaded and ready for bulk processing
     // Counter just used to show progress to user
     update_option('ljapi_comment_batch', (int) get_option('ljapi_comment_batch') + 1);
     return true;
 }
开发者ID:beaucollins,项目名称:wp,代码行数:47,代码来源:livejournal.php

示例7: duplicate_comments

 private function duplicate_comments($master_post_id, $translated_id)
 {
     global $sitepress;
     remove_filter('comments_clauses', array($sitepress, 'comments_clauses'), 10);
     $comments_on_master = get_comments(array('post_id' => $master_post_id));
     $comments_on_translation = get_comments(array('post_id' => $translated_id, 'status' => 'any'));
     add_filter('comments_clauses', array($sitepress, 'comments_clauses'), 10, 2);
     foreach ($comments_on_translation as $comment) {
         wp_delete_comment($comment->comment_ID, true);
         clean_comment_cache($comment->comment_ID);
     }
     $iclTranslationManagement = wpml_load_core_tm();
     foreach ($comments_on_master as $comment) {
         $iclTranslationManagement->duplication_insert_comment($comment->comment_ID);
         clean_comment_cache($comment->comment_ID);
     }
     wp_update_comment_count_now($master_post_id);
     wp_update_comment_count_now($translated_id);
 }
开发者ID:nhainam,项目名称:wordpress4,代码行数:19,代码来源:wpml-post-duplication.class.php

示例8: delete_old_comments

 public static function delete_old_comments()
 {
     global $wpdb;
     while ($comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", defined('AKISMET_DELETE_LIMIT') ? AKISMET_DELETE_LIMIT : 10000))) {
         if (empty($comment_ids)) {
             return;
         }
         $wpdb->queries = array();
         do_action('delete_comment', $comment_ids);
         $comma_comment_ids = implode(', ', array_map('intval', $comment_ids));
         $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( {$comma_comment_ids} )");
         $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( {$comma_comment_ids} )");
         clean_comment_cache($comment_ids);
     }
     if (apply_filters('akismet_optimize_table', mt_rand(1, 5000) == 11, $wpdb->comments)) {
         // lucky number
         $wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
     }
 }
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:19,代码来源:class.akismet.php

示例9: test_comment_objects_should_be_filled_from_cache

 /**
  * @ticket 34138
  */
 public function test_comment_objects_should_be_filled_from_cache()
 {
     global $wpdb;
     $comments = self::factory()->comment->create_many(3, array('comment_post_ID' => self::$post_id));
     clean_comment_cache($comments);
     $num_queries = $wpdb->num_queries;
     $q = new WP_Comment_Query(array('post_id' => self::$post_id, 'no_found_rows' => true, 'update_comment_post_cache' => false, 'update_comment_meta_cache' => false));
     // 2 queries should have been fired: one for IDs, one to prime comment caches.
     $num_queries += 2;
     $found = wp_list_pluck($q->comments, 'comment_ID');
     $this->assertEqualSets($comments, $found);
     $this->assertSame($num_queries, $wpdb->num_queries);
 }
开发者ID:dd32,项目名称:wordpress.develop,代码行数:16,代码来源:query.php

示例10: apply_cleanout

 /**
  * Ask not for whom the bell tolls, 
  * it tolls for thee, Spam... 
  * This routine is intended to be called by the scheduled event.
  *
  * @author Brian Layman <plugins@thecodecave.com>
  * @since 1.4
  */
 public function apply_cleanout()
 {
     // error_log( "Apply Cleanout Executing" );
     // This routine is originally lifted from Akismet. Adjusted to limit the initial deletes.
     global $wpdb;
     $now_gmt = current_time('mysql', 1);
     $sql = "SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB('{$now_gmt}', INTERVAL " . $this->spam_days . " DAY) > comment_date_gmt AND comment_approved = 'spam' limit 0," . $this->spam_delete_limit;
     // error_log( $sql );
     $comment_ids = $wpdb->get_col($sql);
     if (empty($comment_ids)) {
         return;
     }
     $comma_comment_ids = implode(', ', array_map('intval', $comment_ids));
     do_action('delete_comment', $comment_ids);
     // error_log( "Deleted comments: " . count( $comment_ids ) );
     if (count($comment_ids) >= $this->spam_delete_limit) {
         $this->schedule_single_deletion_event();
     }
     $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( {$comma_comment_ids} )");
     // Note these have passed throught intval
     $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( {$comma_comment_ids} )");
     // Note these have passed throught intval
     clean_comment_cache($comment_ids);
 }
开发者ID:satishux,项目名称:fitnesshack,代码行数:32,代码来源:index.php

示例11: wp_untrash_post_comments

/**
 * Restore comments for a post from the trash.
 *
 * @since 2.9.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
 * @return true|void
 */
function wp_untrash_post_comments($post = null)
{
    global $wpdb;
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    $post_id = $post->ID;
    $statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
    if (empty($statuses)) {
        return true;
    }
    /**
     * Fires before comments are restored for a post from the trash.
     *
     * @since 2.9.0
     *
     * @param int $post_id Post ID.
     */
    do_action('untrash_post_comments', $post_id);
    // Restore each comment to its original status.
    $group_by_status = array();
    foreach ($statuses as $comment_id => $comment_status) {
        $group_by_status[$comment_status][] = $comment_id;
    }
    foreach ($group_by_status as $status => $comments) {
        // Sanity check. This shouldn't happen.
        if ('post-trashed' == $status) {
            $status = '0';
        }
        $comments_in = implode(', ', array_map('intval', $comments));
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->comments} SET comment_approved = %s WHERE comment_ID IN ({$comments_in})", $status));
    }
    clean_comment_cache(array_keys($statuses));
    delete_post_meta($post_id, '_wp_trash_meta_comments_status');
    /**
     * Fires after comments are restored for a post from the trash.
     *
     * @since 2.9.0
     *
     * @param int $post_id Post ID.
     */
    do_action('untrashed_post_comments', $post_id);
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:54,代码来源:post.php

示例12: wp_update_comment

/**
 * wp_update_comment() - Parses and updates an existing comment in the database
 *
 * {@internal Missing Long Description}}
 *
 * @since 2.0.0
 * @uses $wpdb
 *
 * @param array $commentarr Contains information on the comment
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    // Escape data pulled from DB.
    foreach ((array) $comment as $key => $value) {
        $comment[$key] = $wpdb->escape($value);
    }
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    extract($commentarr, EXTR_SKIP);
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    $wpdb->query("UPDATE {$wpdb->comments} SET\n\t\t\tcomment_content      = '{$comment_content}',\n\t\t\tcomment_author       = '{$comment_author}',\n\t\t\tcomment_author_email = '{$comment_author_email}',\n\t\t\tcomment_approved     = '{$comment_approved}',\n\t\t\tcomment_author_url   = '{$comment_author_url}',\n\t\t\tcomment_date         = '{$comment_date}',\n\t\t\tcomment_date_gmt     = '{$comment_date_gmt}'\n\t\tWHERE comment_ID = {$comment_ID}");
    $rval = $wpdb->rows_affected;
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    do_action('edit_comment', $comment_ID);
    return $rval;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:34,代码来源:comment.php

示例13: wp_set_comment_status

 /**
  * Hook to wp_set_comment_status action and correctly update the status if necessary
  *
  * @param $comment_id (int) The id of the comment
  */
 public function wp_set_comment_status($comment_id)
 {
     // Make sure we are working with a comment we have data for
     if (!isset($this->current_comment->status) || $this->current_comment->comment_ID != $comment_id) {
         return;
     }
     // END if
     $comment_status = $this->current_comment->status;
     // Set $this->current_comment back to NULL now that we're finished
     $this->current_comment = NULL;
     global $wpdb;
     // Update comment status with the CORRECT value for this comment
     $wpdb->update($wpdb->comments, array('comment_approved' => $comment_status), array('comment_ID' => $comment_id));
     // We've changed stuff so the cache needs to be cleared again
     clean_comment_cache($comment_id);
     // The rest of this is aping default WP behavior to make sure things fire correctly based on the status change
     do_action('wp_set_comment_status', $comment_id, $comment_status);
     $comment = get_comment($comment_id);
     $comment_old = clone get_comment($comment_id);
     wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
     wp_update_comment_count($comment->comment_post_ID);
 }
开发者ID:kgneil,项目名称:bsocial-comments,代码行数:27,代码来源:class-bsocial-comments-register.php

示例14: delete_comment_override

 /**
  * Create a new comment with message "This comment has been permanently deleted."
  * and put it in place of deleted comment.
  *
  * @param $comment_ID
  */
 public function delete_comment_override($comment_ID)
 {
     $children = get_comments(array('status' => 'approve', 'parent' => $comment_ID));
     if (!empty($children)) {
         $old_comment = get_comment($comment_ID);
         $comment_to_add = $old_comment;
         unset($comment_to_add->comment_ID);
         $comment_to_add->comment_approved = 1;
         $comment_to_add->comment_content = __('This comment was deleted.', 'o2');
         $new_comment_id = wp_insert_comment((array) $comment_to_add);
         $comment_created = get_comment_meta($comment_ID, 'o2_comment_created', true);
         if (empty($comment_created)) {
             $comment = get_comment($comment_ID);
             $comment_created = strtotime($comment->comment_date_gmt);
         }
         update_comment_meta($new_comment_id, 'o2_comment_created', $comment_created);
         o2_Fragment::bump_comment_modified_time($new_comment_id);
         update_comment_meta($new_comment_id, 'o2_comment_prev_deleted', $comment_ID);
         $clean_comment_ids = array();
         foreach ($children as $child) {
             $clean_comment_ids[] = $child->comment_ID;
             $child->comment_parent = $new_comment_id;
             wp_update_comment((array) $child);
         }
         $clean_comment_ids[] = $new_comment_id;
         clean_comment_cache($clean_comment_ids);
     }
 }
开发者ID:thecancerus,项目名称:o2,代码行数:34,代码来源:o2.php

示例15: delete_old_comments

 public static function delete_old_comments()
 {
     global $wpdb;
     /**
      * Determines how many comments will be deleted in each batch.
      *
      * @param int The default, as defined by AKISMET_DELETE_LIMIT.
      */
     $delete_limit = apply_filters('akismet_delete_comment_limit', defined('AKISMET_DELETE_LIMIT') ? AKISMET_DELETE_LIMIT : 10000);
     $delete_limit = max(1, intval($delete_limit));
     /**
      * Determines how many days a comment will be left in the Spam queue before being deleted.
      *
      * @param int The default number of days.
      */
     $delete_interval = apply_filters('akismet_delete_comment_interval', 15);
     $delete_interval = max(1, intval($delete_interval));
     while ($comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_id FROM {$wpdb->comments} WHERE DATE_SUB(NOW(), INTERVAL %d DAY) > comment_date_gmt AND comment_approved = 'spam' LIMIT %d", $delete_interval, $delete_limit))) {
         if (empty($comment_ids)) {
             return;
         }
         $wpdb->queries = array();
         foreach ($comment_ids as $comment_id) {
             do_action('delete_comment', $comment_id);
         }
         $comma_comment_ids = implode(', ', array_map('intval', $comment_ids));
         $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_id IN ( {$comma_comment_ids} )");
         $wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( {$comma_comment_ids} )");
         clean_comment_cache($comment_ids);
     }
     if (apply_filters('akismet_optimize_table', mt_rand(1, 5000) == 11, $wpdb->comments)) {
         // lucky number
         $wpdb->query("OPTIMIZE TABLE {$wpdb->comments}");
     }
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:35,代码来源:class.akismet.php


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