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

PHP wp_unspam_comment函数代码示例

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

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



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

示例1: comment_bulk_action

 function comment_bulk_action()
 {
     //Read form data
     $action = $_POST['action'];
     $commentIds = explode(',', $_POST['ids']);
     $information['success'] = 0;
     foreach ($commentIds as $commentId) {
         if ($commentId) {
             $information['success']++;
             if ('approve' === $action) {
                 wp_set_comment_status($commentId, 'approve');
             } else {
                 if ('unapprove' === $action) {
                     wp_set_comment_status($commentId, 'hold');
                 } else {
                     if ('spam' === $action) {
                         wp_spam_comment($commentId);
                     } else {
                         if ('unspam' === $action) {
                             wp_unspam_comment($commentId);
                         } else {
                             if ('trash' === $action) {
                                 wp_trash_comment($commentId);
                             } else {
                                 if ('restore' === $action) {
                                     wp_untrash_comment($commentId);
                                 } else {
                                     if ('delete' === $action) {
                                         wp_delete_comment($commentId, true);
                                     } else {
                                         $information['success']--;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     MainWP_Helper::write($information);
 }
开发者ID:jexmex,项目名称:mainwp-child,代码行数:42,代码来源:class-mainwp-child.php


示例2: test_unspam_should_invalidate_comment_cache

 public function test_unspam_should_invalidate_comment_cache()
 {
     global $wpdb;
     $c = self::factory()->comment->create();
     wp_spam_comment($c);
     $comment = get_comment($c);
     $this->assertSame('spam', $comment->comment_approved);
     wp_unspam_comment($c);
     $comment = get_comment($c);
     $this->assertSame('1', $comment->comment_approved);
 }
开发者ID:aaronjorbin,项目名称:WordPress,代码行数:11,代码来源:comment.php


示例3: 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);
             }
             break;
         case 'untrashcomment':
             if (function_exists('wp_untrash_comment')) {
                 wp_untrash_comment($comment_id);
                 $redir = add_query_arg(array('untrashed' => '1'), $redir);
             }
             break;
         case 'spamcomment':
             if (function_exists('wp_spam_comment')) {
                 wp_spam_comment($comment_id);
             } else {
                 wp_set_comment_status($comment_id, 'spam');
             }
             $redir = add_query_arg(array('spammed' => '1', 'ids' => $comment_id), $redir);
             break;
         case 'unspamcomment':
             if (function_exists('wp_spam_comment')) {
                 wp_unspam_comment($comment_id);
                 $redir = add_query_arg(array('unspammed' => '1'), $redir);
             }
             break;
     }
     $this->admin->redirect($redir);
     exit;
 }
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:51,代码来源:comment.php


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


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


示例6: wp_trash_comment

         $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');
     break;
 case 'delete-cat':
     check_ajax_referer("delete-category_{$id}");
     if (!current_user_can('manage_categories')) {
         die('-1');
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php


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


示例8: unspam

 /**
  * Unspam a comment
  *
  * Example: wp comment unspam 15
  *
  * @param array $args}
  * @param array $assoc_args
  */
 public function unspam($args, $assoc_args)
 {
     $comment_id = WP_CLI::get_numeric_arg($args, 0, "Comment ID");
     if (wp_unspam_comment($comment_id)) {
         WP_CLI::success("Unspammed comment {$comment_id}.");
     } else {
         WP_CLI::error("Failed unspamming comment {$comment_id}");
     }
 }
开发者ID:rpeterson,项目名称:wp-cli,代码行数:17,代码来源:comment.php


示例9: unspam_comment

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


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


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

			$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;
	}

	wp_redirect( $redir );
	die;
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:30,代码来源:comment.php


示例15: add_query_arg

             $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;
     }
     wp_redirect($redir);
     die;
 case 'editedcomment':
     $comment_id = absint($_POST['comment_ID']);
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:31,代码来源:comment.php


示例16: wp_ajax_delete_comment

/**
 * Ajax handler for deleting a comment.
 *
 * @since 3.1.0
 */
function wp_ajax_delete_comment()
{
    $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
    if (!($comment = get_comment($id))) {
        wp_die(time());
    }
    if (!current_user_can('edit_comment', $comment->comment_ID)) {
        wp_die(-1);
    }
    check_ajax_referer("delete-comment_{$id}");
    $status = wp_get_comment_status($comment);
    $delta = -1;
    if (isset($_POST['trash']) && 1 == $_POST['trash']) {
        if ('trash' == $status) {
            wp_die(time());
        }
        $r = wp_trash_comment($comment);
    } elseif (isset($_POST['untrash']) && 1 == $_POST['untrash']) {
        if ('trash' != $status) {
            wp_die(time());
        }
        $r = wp_untrash_comment($comment);
        if (!isset($_POST['comment_status']) || $_POST['comment_status'] != 'trash') {
            // undo trash, not in trash
            $delta = 1;
        }
    } elseif (isset($_POST['spam']) && 1 == $_POST['spam']) {
        if ('spam' == $status) {
            wp_die(time());
        }
        $r = wp_spam_comment($comment);
    } elseif (isset($_POST['unspam']) && 1 == $_POST['unspam']) {
        if ('spam' != $status) {
            wp_die(time());
        }
        $r = wp_unspam_comment($comment);
        if (!isset($_POST['comment_status']) || $_POST['comment_status'] != 'spam') {
            // undo spam, not in spam
            $delta = 1;
        }
    } elseif (isset($_POST['delete']) && 1 == $_POST['delete']) {
        $r = wp_delete_comment($comment);
    } else {
        wp_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, $delta);
    }
    wp_die(0);
}
开发者ID:hughnet,项目名称:WordPress,代码行数:56,代码来源:ajax-actions.php


示例17: test_bp_blogs_sync_activity_edit_to_post_comment_spam_activity_comment_unspam_post_comment

 /**
  * @group bp_blogs_sync_activity_edit_to_post_comment
  * @group post_type_comment_activities
  */
 public function test_bp_blogs_sync_activity_edit_to_post_comment_spam_activity_comment_unspam_post_comment()
 {
     $old_user = get_current_user_id();
     $u = $this->factory->user->create();
     $this->set_current_user($u);
     $userdata = get_userdata($u);
     // let's use activity comments instead of single "new_blog_comment" activity items
     add_filter('bp_disable_blogforum_comments', '__return_false');
     // create the blog post
     $post_id = $this->factory->post->create(array('post_status' => 'publish', 'post_type' => 'post', 'post_title' => 'Test activity comment to post comment'));
     // grab the activity ID for the activity comment
     $a1 = bp_activity_get_activity_id(array('type' => 'new_blog_post', 'component' => buddypress()->blogs->id, 'filter' => array('item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id)));
     $a2 = bp_activity_new_comment(array('content' => 'the generated comment should be spamed/unspamed once the activity comment is spamed/unspamed', 'user_id' => $u, 'activity_id' => $a1));
     $c = bp_activity_get_meta($a2, 'bp_blogs_post_comment_id');
     $activity = new BP_Activity_Activity($a2);
     bp_activity_mark_as_spam($activity);
     $activity->save();
     wp_unspam_comment($c);
     $post_comments = get_comments(array('post_id' => $post_id, 'status' => 'approve'));
     $comment = reset($post_comments);
     $this->assertTrue((int) $comment->comment_ID === (int) bp_activity_get_meta($a2, 'bp_blogs_post_comment_id'), 'The comment ID should be in the activity meta');
     $this->assertTrue((int) $a2 === (int) get_comment_meta($comment->comment_ID, 'bp_activity_comment_id', true), 'The activity ID should be in the comment meta');
     // reset
     remove_filter('bp_disable_blogforum_comments', '__return_false');
     $this->set_current_user($old_user);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:activity.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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