本文整理汇总了PHP中wp_untrash_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_untrash_comment函数的具体用法?PHP wp_untrash_comment怎么用?PHP wp_untrash_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_untrash_comment函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_wp_untrash_comment
public function test_wp_untrash_comment()
{
wp_trash_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('trash'));
wp_untrash_comment($this->comment->comment_ID);
$this->client->do_sync();
$this->assertEquals(1, $this->server_replica_storage->comment_count('approve'));
$this->assertEquals(0, $this->server_replica_storage->comment_count('trash'));
}
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:11,代码来源:test_class.jetpack-sync-comments.php
示例2: 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
示例3: 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
示例4: 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
示例5: die
}
if (!current_user_can('edit_post', $comment->comment_post_ID)) {
die('-1');
}
check_ajax_referer("delete-comment_{$id}");
$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');
}
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php
示例6: 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
示例7: 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
示例8: admin_url
else
$redir = admin_url('edit-comments.php');
$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir );
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' :
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:31,代码来源:comment.php
示例9: write_comment
/**
* Handle a few different variations of writing a comment.
*/
public static function write_comment($message, $method)
{
switch ($method) {
case 'delete':
// @todo comment delete
// @todo capability check
self::die_failure('delete_comment_not_supported', __('Deleting comments is not supported yet', 'o2'));
case 'update':
// Update an existing comment
add_filter('map_meta_cap', array('o2_Write_API', 'restrict_comment_editing'), 10, 4);
if (!current_user_can('edit_comment', $message->id)) {
self::die_failure('cannot_edit_comment', __('You are not allowed to edit this comment', 'o2'));
}
remove_filter('map_meta_cap', array('o2_Write_API', 'restrict_comment_editing'), 10, 4);
// Get current comment data
$comment_status = wp_get_comment_status($message->id);
// Assume that if comment_status is false, that the comment has been deleted.
if (false == $comment_status) {
self::die_failure('comment_already_deleted', __('Comment has already been deleted by another session.', 'o2'));
} else {
if ('trash' != $comment_status && $message->isTrashed) {
if (!wp_trash_comment($message->id)) {
self::die_failure('trash_comment_failed', __('Trashing that comment failed.', 'o2'));
}
do_action('o2_writeapi_comment_trashed', $message->id);
} else {
if ('trash' == $comment_status && !$message->isTrashed) {
if (!wp_untrash_comment($message->id)) {
self::die_failure('untrash_comment_failed', __('Untrashing that comment failed.', 'o2'));
}
do_action('o2_writeapi_comment_untrashed', $message->id);
} else {
// Load comment data, merge in new stuff, then save again
$comment = get_comment($message->id);
$comment->comment_content = addslashes($message->contentRaw);
wp_update_comment((array) $comment);
// Modifying trash status is bumped in o2:bump_trashed_comment based on trash actions.
o2_Fragment::bump_comment_modified_time($message->id);
do_action('o2_writeapi_comment_updated', $message->id);
}
}
}
// Reload the full, clean object and output it
$comment = get_comment($message->id);
self::die_success(o2_Fragment::get_fragment($comment));
case 'create':
// Posting a new comment. We use the core-provided file to
// avoid re-implementing a bunch of logic
// Re-map some incoming data to match the expected _POST elements
$remap = array('comment_post_ID' => $message->postID, 'comment' => addslashes($message->contentRaw), 'comment_parent' => $message->parentID);
$_POST = array_merge($_POST, $remap);
// Let the core comment handler take it from here
// Have to suppress warnings from wp-comments-post because ABSPATH gets redefined
global $wpdb, $user_ID;
@(require_once ABSPATH . 'wp-comments-post.php');
// If we get here, it means the core actions weren't fired, so
// something most likely went wrong
self::die_failure('unknown_comment_error', __('Failed to post comment.', 'o2'));
}
}
开发者ID:thecancerus,项目名称:o2,代码行数:63,代码来源:write-api.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_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
示例12: action_restore
public static function action_restore()
{
global $aecomments;
$postID = AECAjax::get_post_id();
$commentID = AECAjax::get_comment_id();
check_ajax_referer("restore_{$commentID}");
wp_untrash_comment($commentID);
$approve_count = get_comment_count($postID);
$comment_count = wp_count_comments();
$response = array('approve_count' => $approve_count['approved'], 'moderation_count' => $comment_count->moderated, 'spam_count' => $comment_count->spam, 'comment_links' => AECCore::build_admin_links($commentID, $postID));
die(json_encode($response));
}
开发者ID:EfncoPlugins,项目名称:ajax-edit-comments,代码行数:12,代码来源:class.ajax.php
示例13: restore_comment
private function restore_comment($id)
{
return wp_untrash_comment($id);
}
开发者ID:AndyA,项目名称:River,代码行数:4,代码来源:manage-comments.php
示例14: test_untrashed_comment_should_invalidate_query_cache
public function test_untrashed_comment_should_invalidate_query_cache()
{
global $wpdb;
$c = self::factory()->comment->create(array('comment_post_ID' => self::$post_id, 'comment_approved' => '1'));
wp_trash_comment($c);
$q = new WP_Comment_Query(array('post_id' => self::$post_id, 'fields' => 'ids'));
wp_untrash_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
示例15: 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
示例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: test_untrash_should_invalidate_comment_cache
public function test_untrash_should_invalidate_comment_cache()
{
global $wpdb;
$c = self::factory()->comment->create();
wp_trash_comment($c);
$comment = get_comment($c);
$this->assertSame('trash', $comment->comment_approved);
wp_untrash_comment($c);
$comment = get_comment($c);
$this->assertSame('1', $comment->comment_approved);
}
开发者ID:aaronjorbin,项目名称:WordPress,代码行数:11,代码来源:comment.php
示例18: admin_url
$redir = admin_url('edit-comments.php?p=' . absint($comment->comment_post_ID));
} else {
$redir = admin_url('edit-comments.php');
}
$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':
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:31,代码来源:comment.php
示例19: 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
示例20: untrash
/**
* Untrash a comment
*
* Example: wp comment untrash 15
*
* @param array $args}
* @param array $assoc_args
*/
public function untrash($args, $assoc_args)
{
$comment_id = WP_CLI::get_numeric_arg($args, 0, "Comment ID");
if (wp_untrash_comment($comment_id)) {
WP_CLI::success("Untrashed comment {$comment_id}.");
} else {
WP_CLI::error("Failed untrashing comment {$comment_id}");
}
}
开发者ID:rpeterson,项目名称:wp-cli,代码行数:17,代码来源:comment.php
注:本文中的wp_untrash_comment函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论