本文整理汇总了PHP中wp_unspam_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_unspam_comment函数的具体用法?PHP wp_unspam_comment怎么用?PHP wp_unspam_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_unspam_comment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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');
示例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;
}
示例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}");
}
}
示例9: unspam_comment
private function unspam_comment($id)
{
return wp_unspam_comment($id);
}
示例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();
}
示例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);
}
示例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);
//.........这里部分代码省略.........
示例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;
}
示例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;
示例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']);