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

PHP wp_spam_comment函数代码示例

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

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



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

示例1: spam_comment

 function spam_comment($comment_id, $remote_addr, $reason)
 {
     wp_spam_comment($comment_id);
     $blacklist = get_option("blacklist_keys");
     update_option("blacklist_keys", $blacklist . "\n" . $remote_addr);
     mail(get_option("admin_email"), "spam " . home_url(), $reason . "\n" . $_POST['email'] . "\n" . $_POST['url'] . "\n" . $_POST['comment']);
     wp_die($reason);
 }
开发者ID:pgogy,项目名称:WordPress-greenmidget,代码行数:8,代码来源:greenmidget.php


示例2: spec_comment_spam_comment

function spec_comment_spam_comment($comment_id)
{
    wp_spam_comment($comment_id);
}
开发者ID:gagelafleur,项目名称:thebluemuse,代码行数:4,代码来源:functions.php


示例3: cron_recheck

 public static function cron_recheck()
 {
     global $wpdb;
     $api_key = self::get_api_key();
     $status = self::verify_key($api_key);
     if (get_option('akismet_alert_code') || $status == 'invalid') {
         // since there is currently a problem with the key, reschedule a check for 6 hours hence
         wp_schedule_single_event(time() + 21600, 'akismet_schedule_cron_recheck');
         do_action('akismet_scheduled_recheck', 'key-problem-' . get_option('akismet_alert_code') . '-' . $status);
         return false;
     }
     delete_option('akismet_available_servers');
     $comment_errors = $wpdb->get_col("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'\tLIMIT 100");
     load_plugin_textdomain('akismet');
     foreach ((array) $comment_errors as $comment_id) {
         // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
         $comment = get_comment($comment_id);
         if (!$comment || strtotime($comment->comment_date_gmt) < strtotime("-15 days")) {
             delete_comment_meta($comment_id, 'akismet_error');
             delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
             continue;
         }
         add_comment_meta($comment_id, 'akismet_rechecking', true);
         $status = self::check_db_comment($comment_id, 'retry');
         $event = '';
         if ($status == 'true') {
             $event = 'cron-retry-spam';
         } elseif ($status == 'false') {
             $event = 'cron-retry-ham';
         }
         // If we got back a legit response then update the comment history
         // other wise just bail now and try again later.  No point in
         // re-trying all the comments once we hit one failure.
         if (!empty($event)) {
             delete_comment_meta($comment_id, 'akismet_error');
             self::update_comment_history($comment_id, '', $event);
             update_comment_meta($comment_id, 'akismet_result', $status);
             // make sure the comment status is still pending.  if it isn't, that means the user has already moved it elsewhere.
             $comment = get_comment($comment_id);
             if ($comment && 'unapproved' == wp_get_comment_status($comment_id)) {
                 if ($status == 'true') {
                     wp_spam_comment($comment_id);
                 } elseif ($status == 'false') {
                     // comment is good, but it's still in the pending queue.  depending on the moderation settings
                     // we may need to change it to approved.
                     if (check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type)) {
                         wp_set_comment_status($comment_id, 1);
                     } else {
                         if (get_comment_meta($comment_id, 'akismet_delayed_moderation_email', true)) {
                             wp_notify_moderator($comment_id);
                         }
                     }
                 }
             }
             delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
         } else {
             // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
             // send a moderation email now.
             if (intval(gmdate('U')) - strtotime($comment->comment_date_gmt) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL) {
                 delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
                 wp_notify_moderator($comment_id);
             }
             delete_comment_meta($comment_id, 'akismet_rechecking');
             wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
             do_action('akismet_scheduled_recheck', 'check-db-comment-' . $status);
             return;
         }
         delete_comment_meta($comment_id, 'akismet_rechecking');
     }
     $remaining = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'");
     if ($remaining && !wp_next_scheduled('akismet_schedule_cron_recheck')) {
         wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
         do_action('akismet_scheduled_recheck', 'remaining');
     }
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:75,代码来源:class.akismet.php


示例4: add_query_arg

	switch ( $action ) {
		case 'deletecomment' :
			wp_delete_comment( $comment_id );
			$redir = add_query_arg( array('deleted' => '1'), $redir );
			break;
		case 'trashcomment' :
			wp_trash_comment($comment_id);
			$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
			break;
		case 'untrashcomment' :
			wp_untrash_comment($comment_id);
			$redir = add_query_arg( array('untrashed' => '1'), $redir );
			break;
		case 'spamcomment' :
			wp_spam_comment($comment_id);
			$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
			break;
		case 'unspamcomment' :
			wp_unspam_comment($comment_id);
			$redir = add_query_arg( array('unspammed' => '1'), $redir );
			break;
		case 'approvecomment' :
			wp_set_comment_status( $comment_id, 'approve' );
			$redir = add_query_arg( array( 'approved' => 1 ), $redir );
			break;
		case 'unapprovecomment' :
			wp_set_comment_status( $comment_id, 'hold' );
			$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
			break;
	}
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:30,代码来源:comment.php


示例5: test_wp_spam_comment

 public function test_wp_spam_comment()
 {
     wp_spam_comment($this->comment->comment_ID);
     $this->client->do_sync();
     $this->assertEquals(0, $this->server_replica_storage->comment_count('approve'));
     $this->assertEquals(1, $this->server_replica_storage->comment_count('spam'));
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:7,代码来源:test_class.jetpack-sync-comments.php


示例6: update_comment

 function update_comment($path, $blog_id, $comment_id)
 {
     $comment = get_comment($comment_id);
     if (!$comment || is_wp_error($comment)) {
         return new WP_Error('unknown_comment', 'Unknown comment', 404);
     }
     if (!current_user_can('edit_comment', $comment->comment_ID)) {
         return new WP_Error('unauthorized', 'User cannot edit comment', 403);
     }
     $args = $this->query_args();
     $input = $this->input(false);
     if (!is_array($input) || !$input) {
         return new WP_Error('invalid_input', 'Invalid request input', 400);
     }
     $update = array();
     foreach ($input as $key => $value) {
         $update["comment_{$key}"] = $value;
     }
     $comment_status = wp_get_comment_status($comment->comment_ID);
     if ($comment_status !== $update['status'] && !current_user_can('moderate_comments')) {
         return new WP_Error('unauthorized', 'User cannot moderate comments', 403);
     }
     if (isset($update['comment_status'])) {
         switch ($update['comment_status']) {
             case 'approved':
                 if ('approve' !== $comment_status) {
                     wp_set_comment_status($comment->comment_ID, 'approve');
                 }
                 break;
             case 'unapproved':
                 if ('hold' !== $comment_status) {
                     wp_set_comment_status($comment->comment_ID, 'hold');
                 }
                 break;
             case 'spam':
                 if ('spam' !== $comment_status) {
                     wp_spam_comment($comment->comment_ID);
                 }
                 break;
             case 'unspam':
                 if ('spam' === $comment_status) {
                     wp_unspam_comment($comment->comment_ID);
                 }
                 break;
             case 'trash':
                 if (!EMPTY_TRASH_DAYS) {
                     return new WP_Error('trash_disabled', 'Cannot trash comment', 403);
                 }
                 if ('trash' !== $comment_status) {
                     wp_trash_comment($comment_id);
                 }
                 break;
             case 'untrash':
                 if ('trash' === $comment_status) {
                     wp_untrash_comment($comment->comment_ID);
                 }
                 break;
             default:
                 $update['comment_approved'] = 1;
                 break;
         }
         unset($update['comment_status']);
     }
     if (!empty($update)) {
         $update['comment_ID'] = $comment->comment_ID;
         wp_update_comment(add_magic_quotes($update));
     }
     $return = $this->get_comment($comment->comment_ID, $args['context']);
     if (!$return || is_wp_error($return)) {
         return $return;
     }
     do_action('wpcom_json_api_objects', 'comments');
     return $return;
 }
开发者ID:vsalx,项目名称:rattieinfo,代码行数:74,代码来源:class.json-api-endpoints.php


示例7: wp_get_comment_status

 $status = wp_get_comment_status($comment->comment_ID);
 if (isset($_POST['trash']) && 1 == $_POST['trash']) {
     if ('trash' == $status) {
         die((string) time());
     }
     $r = wp_trash_comment($comment->comment_ID);
 } elseif (isset($_POST['untrash']) && 1 == $_POST['untrash']) {
     if ('trash' != $status) {
         die((string) time());
     }
     $r = wp_untrash_comment($comment->comment_ID);
 } elseif (isset($_POST['spam']) && 1 == $_POST['spam']) {
     if ('spam' == $status) {
         die((string) time());
     }
     $r = wp_spam_comment($comment->comment_ID);
 } elseif (isset($_POST['unspam']) && 1 == $_POST['unspam']) {
     if ('spam' != $status) {
         die((string) time());
     }
     $r = wp_unspam_comment($comment->comment_ID);
 } elseif (isset($_POST['delete']) && 1 == $_POST['delete']) {
     $r = wp_delete_comment($comment->comment_ID);
 } else {
     die('-1');
 }
 if ($r) {
     // Decide if we need to send back '1' or a more complicated response including page links and comment counts
     _wp_ajax_delete_comment_response($comment->comment_ID);
 }
 die('0');
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php


示例8: remove_query_arg

 $redir = remove_query_arg(array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir);
 switch ($action) {
     case 'deletecomment':
         wp_delete_comment($comment);
         $redir = add_query_arg(array('deleted' => '1'), $redir);
         break;
     case 'trashcomment':
         wp_trash_comment($comment);
         $redir = add_query_arg(array('trashed' => '1', 'ids' => $comment_id), $redir);
         break;
     case 'untrashcomment':
         wp_untrash_comment($comment);
         $redir = add_query_arg(array('untrashed' => '1'), $redir);
         break;
     case 'spamcomment':
         wp_spam_comment($comment);
         $redir = add_query_arg(array('spammed' => '1', 'ids' => $comment_id), $redir);
         break;
     case 'unspamcomment':
         wp_unspam_comment($comment);
         $redir = add_query_arg(array('unspammed' => '1'), $redir);
         break;
     case 'approvecomment':
         wp_set_comment_status($comment, 'approve');
         $redir = add_query_arg(array('approved' => 1), $redir);
         break;
     case 'unapprovecomment':
         wp_set_comment_status($comment, 'hold');
         $redir = add_query_arg(array('unapproved' => 1), $redir);
         break;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:31,代码来源:comment.php


示例9: group_actions

 /**
  * Handles group's moderating actions about ideas
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @uses bp_is_group() to check a group is displayed
  * @uses bp_is_current_action() to check the group's current action
  * @uses wp_idea_stream_root_slug() to get the IdeaStream root slug
  * @uses wp_idea_stream_action_get_slug() to get the IdeaStream's action slug
  * @uses bp_action_variable() to get a specific action variable
  * @uses groups_get_current_group() to get the current group's object
  * @uses WP_Idea_Stream_Group->group_ideas_archive_url() to get the group's IdeaStream archive page
  * @uses check_admin_referer() to check the request was made on the site
  * @uses wp_idea_stream_user_can() to check user's capability
  * @uses WP_Idea_Stream_Group->remove_from_group() to remove one or more ideas from a group
  * @uses wp_get_referer() to get the url the user came from
  * @uses wp_spam_comment() to spam a comment made on an idea
  * @uses wp_trash_comment() to trash a comment made on an idea
  * @uses wp_idea_stream_add_message() to add a feedback to display to the user once redirected
  * @uses bp_core_redirect() to safely redirect the user
  */
 public function group_actions()
 {
     if (!bp_is_group()) {
         return;
     }
     $group = groups_get_current_group();
     // This part is to catch the group status before it might be updated
     if ('group-settings' == bp_get_group_current_admin_tab() && bp_is_item_admin()) {
         $this->group_update_ideas_stati = $group;
         if (!empty($_POST['group-status']) && in_array($_POST['group-status'], array('public', 'private', 'hidden'))) {
             $this->group_update_ideas_stati->new_status = $_POST['group-status'];
         }
     }
     // This part is for ideastream moderation actions.
     if (!(bp_is_current_action(wp_idea_stream_root_slug()) && wp_idea_stream_action_get_slug() == bp_action_variable(0) && bp_action_variable(1))) {
         return;
     }
     $feedback = array();
     // Default to group's home
     $redirect = $this->group_ideas_archive_url($group, true);
     switch (bp_action_variable(1)) {
         case 'remove-idea':
             check_admin_referer('group-remove-idea');
             if (!bp_action_variable(2)) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Removing the idea failed.', 'wp-idea-stream');
                 break;
             }
             $idea_id = absint(bp_action_variable(2));
             if (!wp_idea_stream_user_can('remove_group_ideas')) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Removing the idea failed. You do not have the capability to remove ideas.', 'wp-idea-stream');
                 break;
             }
             if (false === $this->remove_from_group($idea_id, $group->id)) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Removing the idea failed.', 'wp-idea-stream');
                 $redirect = wp_get_referer();
             } else {
                 $feedback['type'] = 'success';
                 $feedback['content'] = __('The idea was successfully removed.', 'wp-idea-stream');
             }
             break;
         case 'spam-comment':
             check_admin_referer('group-spam-comment');
             $redirect = wp_get_referer();
             if (!bp_action_variable(2)) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Spamming the comment failed.', 'wp-idea-stream');
                 break;
             }
             $comment_id = absint(bp_action_variable(2));
             if (!wp_idea_stream_user_can('spam_group_idea_comments')) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Spamming the comment failed. You do not have the capability to spam comments.', 'wp-idea-stream');
                 break;
             }
             if (false === wp_spam_comment($comment_id)) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Spamming the comment failed.', 'wp-idea-stream');
             } else {
                 $feedback['type'] = 'success';
                 $feedback['content'] = __('The comment was successfully marked as spam.', 'wp-idea-stream');
             }
             break;
         case 'trash-comment':
             check_admin_referer('group-trash-comment');
             $redirect = wp_get_referer();
             if (!bp_action_variable(2)) {
                 $feedback['type'] = 'error';
                 $feedback['content'] = __('Deleting the comment failed.', 'wp-idea-stream');
                 break;
             }
             $comment_id = absint(bp_action_variable(2));
             if (!wp_idea_stream_user_can('trash_group_idea_comments')) {
                 $feedback['type'] = 'error';
//.........这里部分代码省略.........
开发者ID:mrjarbenne,项目名称:wp-idea-stream,代码行数:101,代码来源:groups.php


示例10: spam_comment

 private function spam_comment($id)
 {
     return wp_spam_comment($id);
 }
开发者ID:AndyA,项目名称:River,代码行数:4,代码来源:manage-comments.php


示例11: test_unspammed_comment_should_invalidate_query_cache

 public function test_unspammed_comment_should_invalidate_query_cache()
 {
     global $wpdb;
     $c = self::factory()->comment->create(array('comment_post_ID' => self::$post_id, 'comment_approved' => '1'));
     wp_spam_comment($c);
     $q = new WP_Comment_Query(array('post_id' => self::$post_id, 'fields' => 'ids'));
     wp_unspam_comment($c);
     $num_queries = $wpdb->num_queries;
     $q = new WP_Comment_Query(array('post_id' => self::$post_id, 'fields' => 'ids'));
     $num_queries++;
     $this->assertSame($num_queries, $wpdb->num_queries);
     $this->assertEqualSets(array($c), $q->comments);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:13,代码来源:query.php


示例12: bulk_comments

 private function bulk_comments($doaction, $comment_ids)
 {
     global $wpdb;
     $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
     foreach ((array) $comment_ids as $comment_id) {
         // Check the permissions on each
         $_post_id = (int) $wpdb->get_var($wpdb->prepare("SELECT comment_post_ID FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id));
         if (!current_user_can('edit_post', $_post_id)) {
             continue;
         }
         switch ($doaction) {
             case 'approve':
                 wp_set_comment_status($comment_id, 'approve');
                 $approved++;
                 break;
             case 'unapprove':
                 wp_set_comment_status($comment_id, 'hold');
                 $unapproved++;
                 break;
             case 'spam':
             case 'markspam':
                 if (function_exists('wp_spam_coment')) {
                     wp_spam_comment($comment_id);
                 } else {
                     wp_set_comment_status($comment_id, 'spam');
                 }
                 $spammed++;
                 break;
             case 'unspam':
                 if (function_exists('wp_unspam_comment')) {
                     wp_unspam_comment($comment_id);
                     $unspammed++;
                 }
                 break;
             case 'trash':
                 if (function_exists('wp_trash_comment')) {
                     wp_trash_comment($comment_id);
                     $trashed++;
                 }
                 break;
             case 'untrash':
                 if (function_exists('wp_untrash_comment')) {
                     wp_untrash_comment($comment_id);
                     $untrashed++;
                 }
                 break;
             case 'delete':
                 if (function_exists('wp_delete_comment')) {
                     wp_delete_comment($comment_id);
                 } else {
                     wp_set_comment_status($comment_id, 'delete');
                 }
                 $deleted++;
                 break;
         }
     }
     $redirect_to = $this->referer;
     if (false === strpos($redirect_to, 'edit-comments.php')) {
         $redirect_to = 'edit-comments.php';
     }
     if ($approved) {
         $redirect_to = add_query_arg('approved', $approved, $redirect_to);
     }
     if ($unapproved) {
         $redirect_to = add_query_arg('unapproved', $unapproved, $redirect_to);
     }
     if ($spammed) {
         $redirect_to = add_query_arg('spammed', $spammed, $redirect_to);
     }
     if ($unspammed) {
         $redirect_to = add_query_arg('unspammed', $unspammed, $redirect_to);
     }
     if ($trashed) {
         $redirect_to = add_query_arg('trashed', $trashed, $redirect_to);
     }
     if ($untrashed) {
         $redirect_to = add_query_arg('untrashed', $untrashed, $redirect_to);
     }
     if ($deleted) {
         $redirect_to = add_query_arg('deleted', $deleted, $redirect_to);
     }
     if ($trashed || $spammed) {
         $redirect_to = add_query_arg('ids', join(',', $comment_ids), $redirect_to);
     }
     if ($this->post_id > 0) {
         $redirect_to = add_query_arg('p', $this->post_id, $redirect_to);
     }
     if (isset($_REQUEST['apage'])) {
         $redirect_to = add_query_arg('apage', abs(intval($_REQUEST['apage'])), $redirect_to);
     }
     if (!empty($_REQUEST['mode'])) {
         $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to);
     }
     if (!empty($_REQUEST['comment_status'])) {
         $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to);
     }
     if (!empty($_REQUEST['s'])) {
         $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
     }
     $this->admin->redirect($redirect_to);
//.........这里部分代码省略.........
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:101,代码来源:edit-comments.php


示例13: geodir_reviewrating_comment_action

/**
 * Review Rating comment ajax actions.
 *
 * @since 1.0.0
 * @package GeoDirectory_Review_Rating_Manager
 *
 * @param $request
 * @return bool
 */
function geodir_reviewrating_comment_action($request)
{
    global $wpdb;
    $comment_ids = array();
    if (isset($request['comment_ids']) && $request['comment_ids'] != '') {
        $comment_ids = explode(',', $request['comment_ids']);
    }
    if (!empty($comment_ids) && $request['comment_ids'] != '') {
        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_review_action_nonce')) {
            return false;
        }
        foreach ($comment_ids as $comment_id) {
            if ($comment_id != '') {
                switch ($request['comment_action']) {
                    case 'deletecomment':
                        wp_delete_comment($comment_id);
                        break;
                    case 'trashcomment':
                        wp_trash_comment($comment_id);
                        break;
                    case 'untrashcomment':
                        wp_untrash_comment($comment_id);
                        break;
                    case 'spamcomment':
                        wp_spam_comment($comment_id);
                        break;
                    case 'unspamcomment':
                        wp_unspam_comment($comment_id);
                        break;
                    case 'approvecomment':
                        wp_set_comment_status($comment_id, 'approve');
                        break;
                    case 'unapprovecomment':
                        wp_set_comment_status($comment_id, 'hold');
                        break;
                }
            }
        }
        if (isset($request['geodir_comment_search'])) {
            $geodir_commentsearch = $request['geodir_comment_search'];
        }
        if (isset($request['geodir_comment_posttype'])) {
            $post_type = $request['geodir_comment_posttype'];
        }
        $status = $request['subtab'];
        $orderby = 'comment_date_gmt';
        $order = 'DESC';
        if (isset($request['geodir_comment_sort'])) {
            if ($request['geodir_comment_sort'] == 'oldest') {
                $orderby = 'comment_date_gmt';
                $order = 'ASC';
            }
        }
        if (isset($request['paged']) && $request['paged'] != '') {
            $paged = $request['paged'];
        } else {
            $paged = 1;
        }
        $show_post = $request['show_post'];
        $defaults = array('paged' => $paged, 'show_post' => $show_post, 'orderby' => $orderby, 'order' => $order, 'post_type' => $post_type, 'comment_approved' => $status, 'user_id' => '', 'search' => $geodir_commentsearch);
        $comments = geodir_reviewrating_get_comments($defaults);
        geodir_reviewrating_show_comments($comments['comments']);
    }
    if (isset($request['gd_tab_head'])) {
        geodir_reviewrating_show_tab_head($request['gd_tab_head']);
    }
    exit;
}
开发者ID:poweronio,项目名称:mbsite,代码行数:77,代码来源:geodir_reviewrating_functions.php


示例14: test_cache_should_be_invalidated_when_comment_is_spammed

 /**
  * @ticket 11334
  */
 public function test_cache_should_be_invalidated_when_comment_is_spammed()
 {
     $p = self::factory()->post->create();
     $c = self::factory()->comment->create(array('comment_post_ID' => $p));
     // Prime cache.
     $page_1 = get_page_of_comment($c, array('per_page' => 3));
     // Spam comment.
     wp_spam_comment($c);
     $this->assertFalse(wp_cache_get($c, 'comment_pages'));
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:13,代码来源:getPageOfComment.php


示例15: bp_blogs_sync_activity_edit_to_post_comment

/**
 * Updates the blog comment when the associated activity comment is edited.
 *
 * @since 2.0.0
 *
 * @param BP_Activity_Activity $activity The activity object.
 */
function bp_blogs_sync_activity_edit_to_post_comment(BP_Activity_Activity $activity)
{
    // This is a new entry, so stop!
    // We only want edits!
    if (empty($activity->id) || bp_disable_blogforum_comments()) {
        return;
    }
    // fetch parent activity item
    $parent_activity = new BP_Activity_Activity($activity->item_id);
    // if parent activity isn't a post type having the buddypress-activity support for comments, stop now!
    if (!bp_activity_type_supports($parent_activity->type, 'post-type-comment-tracking')) {
        return;
    }
    $post_type = bp_activity_post_type_get_tracking_arg($parent_activity->type, 'post_type');
    // No associated post type for this activity comment, stop.
    if (!$post_type) {
        return;
    }
    // Try to see if a corresponding blog comment exists.
    $post_comment_id = bp_activity_get_meta($activity->id, "bp_blogs_{$post_type}_comment_id");
    if (empty($post_comment_id)) {
        return;
    }
    // Handle multisite.
    switch_to_blog($parent_activity->item_id);
    // Get the comment status
    $post_comment_status = wp_get_comment_status($post_comment_id);
    $old_comment_status = $post_comment_status;
    // No need to edit the activity, as it's the activity who's updating the comment
    remove_action('transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10, 3);
    remove_action('bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10, 4);
    if (1 === (int) $activity->is_spam && 'spam' !== $post_comment_status) {
        wp_spam_comment($post_comment_id);
    } elseif (!$activity->is_spam) {
        if ('spam' === $post_comment_status) {
            wp_unspam_comment($post_comment_id);
        } elseif ('trash' === $post_comment_status) {
            wp_untrash_comment($post_comment_id);
        } else {
            // Update the blog post comment.
            wp_update_comment(array('comment_ID' => $post_comment_id, 'comment_content' => $activity->content));
        }
    }
    // Restore actions
    add_action('transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10, 3);
    add_action('bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10, 4);
    restore_current_blog();
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:55,代码来源:bp-blogs-activity.php


示例16: ajax_comment_status

 /**
  * approve/unapprove/spam/unspam a comment via an admin-ajax.php endpoint
  */
 public function ajax_comment_status()
 {
     $comment_id = absint($_GET['comment_id']);
     $direction = $_GET['direction'];
     if (!current_user_can('edit_comment', $comment_id)) {
         return wp_send_json_error();
     }
     // END if
     if (!check_ajax_referer('bsocial-comment-status', 'bsocial-nonce')) {
         return wp_send_json_error();
     }
     // END if
     $allowed_directions = array('approve', 'unapprove', 'spam', 'unspam', 'trash', 'untrash');
     if (!in_array($direction, $allowed_directions)) {
         return wp_send_json_error();
     }
     // END if
     if (!($comment = get_comment($comment_id))) {
         return wp_send_json_error();
     }
     //end if
     $data = array();
     switch ($direction) {
         case 'approve':
             $data = array('success' => wp_set_comment_status($comment->comment_ID, 'approve'), 'link' => $this->get_status_link($comment->comment_ID, 'approve'), 'state' => 'approved');
             break;
         case 'unapprove':
             $data = array('success' => wp_set_comment_status($comment->comment_ID, 'hold'), 'link' => $this->get_status_link($comment->comment_ID, 'approve'), 'state' => 'unapproved');
             break;
         case 'spam':
             $data = array('success' => wp_spam_comment($comment->comment_ID), 'link' => $this->get_status_link($comment->comment_ID, 'spam'), 'state' => 'spammed');
             break;
         case 'unspam':
             $data = array('success' => wp_unspam_comment($comment->comment_ID), 'link' => $this->get_status_link($comment->comment_ID, 'spam'), 'state' => 'unspammed');
             break;
         case 'trash':
             $data = array('success' => wp_trash_comment($comment->comment_ID), 'link' => $this->get_status_link($comment->comment_ID, 'trash'), 'state' => 'trashed');
             break;
         case 'untrash':
             $data = array('success' => wp_untrash_comment($comment->comment_ID), 'link' => $this->get_status_link($comment->comment_ID, 'trash'), 'state' => 'untrashed');
             break;
     }
     // END switch
     wp_send_json($data);
     die;
 }
开发者ID:kgneil,项目名称:bsocial-comments,代码行数:49,代码来源:class-bsocial-comments.php


示例17: wdhb_honeypot_check_field

/**
 * Check if the honeypot field has been filled
 */
function wdhb_honeypot_check_field($comment_id, $comment_approved)
{
    if (isset($_POST['wdhb_honeypot']) && $_POST['wdhb_honeypot'] !== "") {
        wp_spam_comment($comment_id);
    }
}
开发者ID:webdesignhandbook,项目名称:wp-honeypot,代码行数:9,代码来源:wdhb-honeypot.php


示例18: handle_status_param

 /**
  * Set the comment_status of a given comment object when creating or updating a comment.
  *
  * @param string|int $new_status
  * @param object     $comment
  * @return boolean   $changed
  */
 protected function handle_status_param($new_status, $comment)
 {
     $old_status = wp_get_comment_status($comment->comment_ID);
     if ($new_status === $old_status) {
         return false;
     }
     switch ($new_status) {
         case 'approved':
         case 'approve':
         case '1':
             $changed = wp_set_comment_status($comment->comment_ID, 'approve');
             break;
         case 'hold':
         case '0':
             $changed = wp_set_comment_status($comment->comment_ID, 'hold');
             break;
         case 'spam':
             $changed = wp_spam_comment($comment->comment_ID);
             break;
         case 'unspam':
             $changed = wp_unspam_comment($comment->comment_ID);
             break;
         case 'trash':
             $changed = wp_trash_comment($comment->comment_ID);
             break;
         case 'untrash':
             $changed = wp_untrash_comment($comment->comment_ID);
             break;
         default:
             $changed = false;
             break;
     }
     return $changed;
 }
开发者ID:alexandrinos,项目名称:wp-api-rest,代码行数:41,代码来源:class-wp-rest-comments-controller.php


示例19: test_wp_count_comments_cache

 public function test_wp_count_comments_cache()
 {
     $post_id = self::factory()->post->create(array('post_status' => 'publish'));
     $comment_id = self::factory()->comment->create(array('comment_approved' => '1', 'comment_post_ID' => $post_id));
     $count1 = wp_count_comments($post_id);
     $this->assertEquals(1, $count1->approved);
     $this->assertEquals(0, $count1->moderated);
     $this->assertEquals(0, $count1->spam);
     $this->assertEquals(0, $count1->trash);
     $this->assertEquals(0, $count1->{'post-trashed'});
     $this->assertEquals(1, $count1->total_comments);
     $this->assertEquals(1, $count1->all);
     $all_count1 = wp_count_comments();
     $this->assertEquals(1, $all_count1->approved);
     $this->assertEquals(0, $all_count1->moderated);
     $this->assertEquals(0, $all_count1->spam);
     $this->assertEquals(0, $all_count1->trash);
     $this->assertEquals(0, $all_count1->{'post-trashed'});
     $this->assertEquals(1, $all_count1->total_comments);
     $this->assertEquals(1, $all_count1->all);
     wp_spam_comment($comment_id);
     $count2 = wp_count_comments($post_id);
     $this->assertEquals(0, $count2->approved);
     $this->assertEquals(0, $count2->moderated);
     $this->assertEquals(1, $count2->spam);
     $this->assertEquals(0, $count2->trash);
     $this->assertEquals(0, $count2->{'post-trashed'});
     $this->assertEquals(1, $count2->total_comments);
     $this->assertEquals(0, $count2->all);
     $all_count2 = wp_count_comments();
     $this->assertEquals(0, $all_count2->approved);
     $this->assertEquals(0, $all_count2->moderated);
     $this->assertEquals(1, $all_count2->spam);
     $this->assertEquals(0, $all_count2->trash);
     $this->assertEquals(0, $all_count2->{'post-trashed'});
     $this->assertEquals(1, $all_count2->total_comments);
     $this->assertEquals(0, $all_count2->all);
     wp_trash_comment($comment_id);
     $count3 = wp_count_comments($post_id);
     $this->assertEquals(0, $count3->approved);
     $this->assertEquals(0, $count3->moderated);
     $this->assertEquals(0, $count3->spam);
     $this->assertEquals(1, $count3->trash);
     $this->assertEquals(0, $count3->{'post-trashed'});
     $this->assertEquals(0, $count3->total_comments);
     $this->assertEquals(0, $count3->all);
     $all_count3 = wp_count_comments();
     $this->assertEquals(0, $all_count3->approved);
     $this->assertEquals(0, $all_count3->moderated);
     $this->assertEquals(0, $all_count3->spam);
     $this->assertEquals(1, $all_count3->trash);
     $this->assertEquals(0, $all_count3->{'post-trashed'});
     $this->assertEquals(0, $all_count3->total_comments);
     $this->assertEquals(0, $all_count3->all);
     wp_untrash_comment($comment_id);
     $count4 = wp_count_comments($post_id);
     $this->assertEquals(0, $count4->approved);
     $this->assertEquals(0, $count4->moderated);
     $this->assertEquals(1, $count4->spam);
     $this->assertEquals(0, $count4->trash);
     $this->assertEquals(0, $count4->{'post-trashed'});
     $this->assertEquals(1, $count4->total_comments);
     $this->assertEquals(0, $count4->all);
     $all_count4 = wp_count_comments();
     $this->assertEquals(0, $all_count4->approved);
     $this->assertEquals(0, $all_count4->moderated);
     $this->assertEquals(1, $all_count4->spam);
     $this->assertEquals(0, $all_count4->trash);
     $this->assertEquals(0, $all_count4->{'post-trashed'});
     $this->assertEquals(1, $all_count4->total_comments);
     $this->assertEquals(0, $all_count4->all);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:72,代码来源:wpCountComments.php


示例20: delete_comment

 private function delete_comment($action)
 {
     $comment_id = intval($_REQUEST['c']);
     check_admin_referer('delete-comment_' . $comment_id);
     $noredir = isset($_REQUEST['noredir']);
     if (!($comment = get_comment($comment_id))) {
         $this->base->ks_die(__('Oops, no comment with this ID.') . sprintf(' <a href="%s">' . __('Go back') . '</a>!', 'edit-comments.php'), '', false);
         //exit;
     }
     if (!current_user_can('edit_post', $comment->comment_post_ID)) {
         $this->base->ks_die(__('You are not allowed to edit comments on this post.'));
     }
     $redir = $this->referer;
     if (empty($redir) || $noredir || false !== strpos($redir, 'comment.php')) {
         $redir = 'edit-comments.php';
     }
     switch ($action) {
         case 'deletecomment':
             wp_delete_comment($comment_id);
             $redir = add_query_arg(array('deleted' => 1), $redir);
             break;
         case 'trashcomment':
             if (function_exists('wp_trash_comment')) {
                 wp_trash_comment($comment_id);
                 $redir = add_query_arg(array('trashed' => '1', 'ids' => $comment_id), $redir);
             }
       

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_specialchars函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_spaces_regexp函数代码示例发布时间: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