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

PHP wp_set_comment_status函数代码示例

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

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



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

示例1: set_status

 private function set_status($args, $status, $success)
 {
     list($comment_id) = $args;
     $r = wp_set_comment_status($comment_id, 'approve', true);
     if (is_wp_error($r)) {
         WP_CLI::error($r);
     } else {
         WP_CLI::success("{$success} comment {$comment_id}");
     }
 }
开发者ID:netcon-source,项目名称:wp-cli,代码行数:10,代码来源:comment.php


示例2: set_comment_status

 function set_comment_status($comment_id, $comment_status)
 {
     if ($comment_status == '1') {
         wp_set_comment_status($comment_id, 'approve');
     } elseif ($comment_status == '0') {
         wp_set_comment_status($comment_id, 'hold');
     } else {
         wp_set_comment_status($comment_id, 'spam');
     }
 }
开发者ID:dss-web,项目名称:erklaringmothatytringer-wp-advance-comment,代码行数:10,代码来源:saved-comment-edit.php


示例3: sent_comment_to_spam

 function sent_comment_to_spam($comment_id)
 {
     $wpad_flaging_threshold = get_option('wpad_flaging_threshold');
     if (empty($wpad_flaging_threshold)) {
         return;
     }
     $no_of_flags = get_comment_meta($comment_id, 'no_of_flags', true);
     if ($no_of_flags >= $wpad_flaging_threshold) {
         wp_set_comment_status($comment_id, 'hold');
     }
 }
开发者ID:dss-web,项目名称:erklaringmothatytringer-wp-advance-comment,代码行数:11,代码来源:frontend-save-data.php


示例4: remove_comment

 /**
  * Remove a single comment from the anth_library_item
  *
  * For technical reasons having to do with the markup created in the project organizer JS,
  * this function takes the *original comment ID* as a parameter, NOT the ID of the copied
  * comment on the anth_library_item. This function then deletes ALL instances of comments
  * on the anth_library_item that correspond to the original comment.
  *
  * @package Anthologize
  * @since 0.6
  *
  * @uses apply_filters() Filter anthologize_remove_comment_status to change the default
  *   behavior from trashing to true deletion
  * @param int $comment_id The ID of the *original* comment corresponding to the comments
  *   you want to delete
  */
 public function remove_comment($comment_id)
 {
     // Just to be safe, we remove all instances of comments on the library item that
     // correspond to the original comment in question
     $comments_to_remove = array_keys($this->included_comments, $comment_id);
     foreach ((array) $comments_to_remove as $ctr) {
         // We'll trash the comment instead of deleting it
         wp_set_comment_status($ctr, apply_filters('anthologize_remove_comment_status', 'trash'));
         unset($this->included_comments[$ctr]);
     }
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:27,代码来源:class-comments.php


示例5: test_sends_highlander_comment_meta_with_comment

 public function test_sends_highlander_comment_meta_with_comment()
 {
     $wpcom_user_id = 101;
     $sig = 'abcd1234';
     $comment_ID = $this->comment->comment_ID;
     add_comment_meta($comment_ID, 'hc_post_as', 'wordpress', true);
     add_comment_meta($comment_ID, 'hc_wpcom_id_sig', $sig, true);
     add_comment_meta($comment_ID, 'hc_foreign_user_id', $wpcom_user_id, true);
     // re-save the comment
     wp_set_comment_status($comment_ID, 'hold');
     $this->client->do_sync();
     $this->client->do_sync();
     $event = $this->server_event_storage->get_most_recent_event();
     $synced_comment = $event->args[1];
     $this->assertObjectHasAttribute('meta', $synced_comment);
     $this->assertEquals('wordpress', $synced_comment->meta['hc_post_as']);
     $this->assertEquals('abcd1234', $synced_comment->meta['hc_wpcom_id_sig']);
     $this->assertEquals(101, $synced_comment->meta['hc_foreign_user_id']);
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:19,代码来源:test_class.jetpack-sync-comments.php


示例6: test_custom_pagination_should_allow_ones_own_unapproved_comments

 /**
  * @ticket 37048
  */
 public function test_custom_pagination_should_allow_ones_own_unapproved_comments()
 {
     $p = self::factory()->post->create();
     $u = self::factory()->user->create();
     $comments = array();
     $now = time();
     for ($i = 0; $i <= 5; $i++) {
         $comments[] = self::factory()->comment->create(array('comment_post_ID' => $p, 'comment_date_gmt' => date('Y-m-d H:i:s', $now - $i), 'comment_author' => 'Commenter ' . $i, 'user_id' => $u));
     }
     // Only 2 and 5 are approved.
     wp_set_comment_status($comments[0], '0');
     wp_set_comment_status($comments[1], '0');
     wp_set_comment_status($comments[3], '0');
     wp_set_comment_status($comments[4], '0');
     update_option('page_comments', true);
     update_option('comments_per_page', 2);
     wp_set_current_user($u);
     $this->go_to(get_permalink($p));
     // comments_template() populates $wp_query->comments
     get_echo('comments_template');
     $found = wp_list_comments(array('echo' => false, 'per_page' => 1, 'page' => 2));
     preg_match_all('|id="comment\\-([0-9]+)"|', $found, $matches);
     $this->assertSame(array($comments[4]), array_map('intval', $matches[1]));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:27,代码来源:wpListComments.php


示例7: akismet_cron_recheck

function akismet_cron_recheck()
{
    global $wpdb;
    $status = akismet_verify_key(akismet_get_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');
        return false;
    }
    delete_option('akismet_available_servers');
    $comment_errors = $wpdb->get_col("\n\t\tSELECT comment_id\n\t\tFROM {$wpdb->prefix}commentmeta\n\t\tWHERE meta_key = 'akismet_error'\n\t\tLIMIT 100\n\t");
    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');
            continue;
        }
        add_comment_meta($comment_id, 'akismet_rechecking', true);
        $status = akismet_check_db_comment($comment_id, 'retry');
        $msg = '';
        if ($status == 'true') {
            $msg = __('Akismet caught this comment as spam during an automatic retry.');
        } elseif ($status == 'false') {
            $msg = __('Akismet cleared this comment during an automatic retry.');
        }
        // 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($msg)) {
            delete_comment_meta($comment_id, 'akismet_error');
            akismet_update_comment_history($comment_id, $msg, 'cron-retry');
            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 {
            delete_comment_meta($comment_id, 'akismet_rechecking');
            wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
            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');
    }
}
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:58,代码来源:akismet.php


示例8: duplication_status_comment

 function duplication_status_comment($comment_id, $comment_status)
 {
     global $wpdb;
     static $_avoid_8_loop;
     if (isset($_avoid_8_loop)) {
         return;
     }
     $_avoid_8_loop = true;
     $original_comment = get_comment_meta($comment_id, '_icl_duplicate_of', true);
     if ($original_comment) {
         $duplicates = $wpdb->get_col($wpdb->prepare("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key='_icl_duplicate_of' AND meta_value=%d", $original_comment));
         $duplicates = array($original_comment) + array_diff($duplicates, array($comment_id));
     } else {
         $duplicates = $wpdb->get_col($wpdb->prepare("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key='_icl_duplicate_of' AND meta_value=%d", $comment_id));
     }
     if (!empty($duplicates)) {
         foreach ($duplicates as $duplicate) {
             wp_set_comment_status($duplicate, $comment_status);
         }
     }
     unset($_avoid_8_loop);
 }
开发者ID:gencagushi,项目名称:tema,代码行数:22,代码来源:translation-management.class.php


示例9: WP_Ajax_Response

     if (!($comment = get_comment($id))) {
         $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id))));
         $x->send();
     }
     if (!current_user_can('edit_post', $comment->comment_post_ID) && !current_user_can('moderate_comments')) {
         die('-1');
     }
     $current = wp_get_comment_status($comment->comment_ID);
     if ($_POST['new'] == $current) {
         die((string) time());
     }
     check_ajax_referer("approve-comment_{$id}");
     if (in_array($current, array('unapproved', 'spam'))) {
         $result = wp_set_comment_status($comment->comment_ID, 'approve', true);
     } else {
         $result = wp_set_comment_status($comment->comment_ID, 'hold', true);
     }
     if (is_wp_error($result)) {
         $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $result));
         $x->send();
     }
     // 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 'add-category':
     // On the Fly
     check_ajax_referer($action);
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php


示例10: set_status

 private function set_status($args, $status, $success)
 {
     $comment = $this->fetcher->get_check($args);
     $r = wp_set_comment_status($comment->comment_ID, $status, true);
     if (is_wp_error($r)) {
         WP_CLI::error($r);
     } else {
         WP_CLI::success("{$success} comment {$comment->comment_ID}.");
     }
 }
开发者ID:voldemortensen,项目名称:wp-cli,代码行数:10,代码来源:comment.php


示例11: akismet_recheck_queue

function akismet_recheck_queue()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
        return;
    }
    $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'", ARRAY_A);
    foreach ((array) $moderation as $c) {
        $c['user_ip'] = $c['comment_author_IP'];
        $c['user_agent'] = $c['comment_agent'];
        $c['referrer'] = '';
        $c['blog'] = get_option('home');
        $c['blog_lang'] = get_locale();
        $c['blog_charset'] = get_option('blog_charset');
        $c['permalink'] = get_permalink($c['comment_post_ID']);
        $c['user_role'] = '';
        if (isset($c['user_ID'])) {
            $c['user_role'] = akismet_get_user_roles($c['user_ID']);
        }
        $id = (int) $c['comment_ID'];
        $query_string = '';
        foreach ($c as $key => $data) {
            $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
        }
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
        if ('true' == $response[1]) {
            if (function_exists('wp_set_comment_status')) {
                wp_set_comment_status($id, 'spam');
            } else {
                $wpdb->query("UPDATE {$wpdb->comments} SET comment_approved = 'spam' WHERE comment_ID = {$id}");
            }
        }
    }
    wp_redirect($_SERVER['HTTP_REFERER']);
    exit;
}
开发者ID:hoonio,项目名称:wordpress,代码行数:36,代码来源:akismet.php


示例12: recheck_queue

 public static function recheck_queue()
 {
     global $wpdb;
     Akismet::fix_scheduled_recheck();
     if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
         return;
     }
     $paginate = '';
     if (isset($_POST['limit']) && isset($_POST['offset'])) {
         $paginate = $wpdb->prepare(" LIMIT %d OFFSET %d", array($_POST['limit'], $_POST['offset']));
     }
     $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A);
     foreach ((array) $moderation as $c) {
         $c['user_ip'] = $c['comment_author_IP'];
         $c['user_agent'] = $c['comment_agent'];
         $c['referrer'] = '';
         $c['blog'] = get_bloginfo('url');
         $c['blog_lang'] = get_locale();
         $c['blog_charset'] = get_option('blog_charset');
         $c['permalink'] = get_permalink($c['comment_post_ID']);
         $c['user_role'] = '';
         if (isset($c['user_ID'])) {
             $c['user_role'] = Akismet::get_user_roles($c['user_ID']);
         }
         if (Akismet::is_test_mode()) {
             $c['is_test'] = 'true';
         }
         add_comment_meta($c['comment_ID'], 'akismet_rechecking', true);
         $response = Akismet::http_post(http_build_query($c), 'comment-check');
         if ('true' == $response[1]) {
             wp_set_comment_status($c['comment_ID'], 'spam');
             update_comment_meta($c['comment_ID'], 'akismet_result', 'true');
             delete_comment_meta($c['comment_ID'], 'akismet_error');
             delete_comment_meta($c['comment_ID'], 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam', 'akismet'), 'check-spam');
         } elseif ('false' == $response[1]) {
             update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
             delete_comment_meta($c['comment_ID'], 'akismet_error');
             delete_comment_meta($c['comment_ID'], 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment', 'akismet'), 'check-ham');
             // abnormal result: error
         } else {
             update_comment_meta($c['comment_ID'], 'akismet_result', 'error');
             Akismet::update_comment_history($c['comment_ID'], sprintf(__('Akismet was unable to re-check this comment (response: %s)', 'akismet'), substr($response[1], 0, 50)), 'check-error');
         }
         delete_comment_meta($c['comment_ID'], 'akismet_rechecking');
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         wp_send_json(array('processed' => count((array) $moderation)));
     } else {
         $redirect_to = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : admin_url('edit-comments.php');
         wp_safe_redirect($redirect_to);
         exit;
     }
 }
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:55,代码来源:class.akismet-admin.php


示例13: wp_unspam_comment

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('unspam_comment', $comment->comment_ID);
    $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment, $status)) {
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         *
         * @param int $comment_id The comment ID.
         */
        do_action('unspammed_comment', $comment->comment_ID);
        return true;
    }
    return false;
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:41,代码来源:comment-functions.php


示例14: elseif

	foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each
		$comment = (int) $comment;
		$post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment) );
		if ( !current_user_can('edit_post', $post_id) )
			continue;
		if ( !empty( $_REQUEST['spamit'] ) ) {
			wp_set_comment_status($comment, 'spam');
			$comments_spammed++;
		} elseif ( !empty( $_REQUEST['deleteit'] ) ) {
			wp_set_comment_status($comment, 'delete');
			$comments_deleted++;
		} elseif ( !empty( $_REQUEST['approveit'] ) ) {
			wp_set_comment_status($comment, 'approve');
			$comments_approved++;
		} elseif ( !empty( $_REQUEST['unapproveit'] ) ) {
			wp_set_comment_status($comment, 'hold');
			$comments_unapproved++;
		}
	endforeach;
	$redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved;
	if ( isset($_REQUEST['apage']) )
		$redirect_to = add_query_arg( 'apage', absint($_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);
	wp_redirect( $redirect_to );
} elseif ( !empty($_GET['_wp_http_referer']) ) {
	 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:edit-comments.php


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


示例16: comment_form

 public function comment_form()
 {
     if (empty($_POST['comment'])) {
         $this->result = ap_ajax_responce('comment_content_empty');
         return;
     }
     if (!isset($_REQUEST['comment_ID'])) {
         // Do security check
         if (!ap_user_can_comment() || !isset($_POST['__nonce']) || !wp_verify_nonce($_POST['__nonce'], 'comment_' . (int) $_POST['comment_post_ID'])) {
             $this->result = ap_ajax_responce('no_permission');
             return;
         }
     } else {
         if (!ap_user_can_edit_comment((int) $_REQUEST['comment_ID']) || !wp_verify_nonce($_REQUEST['__nonce'], 'comment_' . (int) $_REQUEST['comment_ID'])) {
             $this->result = ap_ajax_responce('no_permission');
             return;
         }
     }
     $comment_post_ID = (int) $_POST['comment_post_ID'];
     $post = get_post($comment_post_ID);
     if (!$post || empty($post->post_status)) {
         return;
     }
     if (in_array($post->post_status, array('draft', 'pending', 'trash'))) {
         $this->result = ap_ajax_responce('draft_comment_not_allowed');
         return;
     }
     if (isset($_POST['comment_ID'])) {
         $comment_id = (int) $_POST['comment_ID'];
         $updated = wp_update_comment(array('comment_ID' => $comment_id, 'comment_content' => trim($_POST['comment'])));
         if ($updated) {
             $comment = get_comment($comment_id);
             ob_start();
             comment_text($comment_id);
             $html = ob_get_clean();
             $this->result = ap_ajax_responce(array('action' => 'edit_comment', 'comment_ID' => $comment->comment_ID, 'comment_post_ID' => $comment->comment_post_ID, 'comment_content' => $comment->comment_content, 'html' => $html, 'message' => 'comment_edit_success'));
         }
         return;
     } else {
         $user = wp_get_current_user();
         if ($user->exists()) {
             $user_ID = $user->ID;
             $comment_author = wp_slash($user->display_name);
             $comment_author_email = wp_slash($user->user_email);
             $comment_author_url = wp_slash($user->user_url);
             $comment_content = trim($_POST['comment']);
             $comment_type = 'anspress';
         } else {
             $this->result = ap_ajax_responce('no_permission');
             return;
         }
         $comment_parent = 0;
         if (isset($_POST['comment_ID'])) {
             $comment_parent = absint($_POST['comment_ID']);
         }
         $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
         // Automatically approve parent comment.
         if (!empty($_POST['approve_parent'])) {
             $parent = get_comment($comment_parent);
             if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) {
                 if (wp_set_comment_status($parent->comment_ID, 'approve')) {
                     $comment_auto_approved = true;
                 }
             }
         }
         $comment_id = wp_new_comment($commentdata);
         if ($comment_id > 0) {
             $comment = get_comment($comment_id);
             do_action('ap_after_new_comment', $comment);
             ob_start();
             ap_comment($comment);
             $html = ob_get_clean();
             $count = get_comment_count($comment->comment_post_ID);
             $this->result = ap_ajax_responce(array('action' => 'new_comment', 'status' => true, 'comment_ID' => $comment->comment_ID, 'comment_post_ID' => $comment->comment_post_ID, 'comment_content' => $comment->comment_content, 'html' => $html, 'message' => 'comment_success', 'view' => array('comments_count_' . $comment->comment_post_ID => '(' . $count['approved'] . ')', 'comment_count_label_' . $comment->comment_post_ID => sprintf(_n('One comment', '%d comments', $count['approved'], 'ap'), $count['approved']))));
         } else {
             $this->result = ap_ajax_responce('something_wrong');
         }
     }
 }
开发者ID:Byrlyne,项目名称:anspress,代码行数:79,代码来源:process-form.php


示例17: approve_comment

 private function approve_comment($action)
 {
     $comment_id = intval($_GET['c']);
     check_admin_referer('approve-comment_' . $comment_id);
     $noredir = isset($_GET['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);
     }
     if (!current_user_can('edit_post', $comment->comment_post_ID)) {
         if ('approvecomment' == $action) {
             $this->base->ks_die(__('You are not allowed to edit comments on this post, so you cannot approve this comment.'));
         } else {
             $this->base->ks_die(__('You are not allowed to edit comments on this post, so you cannot disapprove this comment.'));
         }
         // exit;
     }
     $redir = $this->referer;
     if (empty($redir) || $noredir) {
         $redir = 'edit-comments.php?p=' . intval($comment->comment_post_ID);
     }
     if ('approvecomment' == $action) {
         wp_set_comment_status($comment_id, 'approve');
         $redir = add_query_arg(array('approved' => 1), $redir);
     } else {
         wp_set_comment_status($comment_id, 'hold');
         $redir = add_query_arg(array('unapproved' => 1), $redir);
     }
     if (get_option('comments_notify')) {
         wp_notify_postauthor($comment->comment_ID);
     }
     $this->admin->redirect($redir);
     exit;
 }
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:33,代码来源:comment.php


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


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


示例20: wp_unspam_comment

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 * @uses do_action() on 'unspam_comment' before unspamming
 * @uses do_action() on 'unspammed_comment' after unspamming
 *
 * @param int $comment_id Comment ID.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    if (!(int) $comment_id) {
        return false;
    }
    do_action('unspam_comment', $comment_id);
    $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment_id, $status)) {
        delete_comment_meta($comment_id, '_wp_trash_meta_status');
        do_action('unspammed_comment', $comment_id);
        return true;
    }
    return false;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:27,代码来源:comment.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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