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

PHP wp_transition_comment_status函数代码示例

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

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



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

示例1: wp_update_comment

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Make sure that the comment post ID is valid (if specified).
    if (isset($commentarr['comment_post_ID']) && !get_post($commentarr['comment_post_ID'])) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    $data = wp_unslash($commentarr);
    /**
     * Filter the comment content before it is updated in the database.
     *
     * @since 1.5.0
     *
     * @param string $comment_content The comment data.
     */
    $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']);
    $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']);
    if (!isset($data['comment_approved'])) {
        $data['comment_approved'] = 1;
    } elseif ('hold' == $data['comment_approved']) {
        $data['comment_approved'] = 0;
    } elseif ('approve' == $data['comment_approved']) {
        $data['comment_approved'] = 1;
    }
    $comment_ID = $data['comment_ID'];
    $comment_post_ID = $data['comment_post_ID'];
    $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id');
    $data = wp_array_slice_assoc($data, $keys);
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    /**
     * Fires immediately after a comment is updated in the database.
     *
     * The hook also fires immediately before comment status transition hooks are fired.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID The comment ID.
     */
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:69,代码来源:comment-functions.php


示例2: wp_update_comment

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    // Escape data pulled from DB.
    foreach ((array) $comment as $key => $value) {
        $comment[$key] = $wpdb->escape($value);
    }
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    extract(stripslashes_deep($commentarr), EXTR_SKIP);
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    if (!isset($comment_approved)) {
        $comment_approved = 1;
    } else {
        if ('hold' == $comment_approved) {
            $comment_approved = 0;
        } else {
            if ('approve' == $comment_approved) {
                $comment_approved = 1;
            }
        }
    }
    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->comments} SET\n\t\t\tcomment_content      = %s,\n\t\t\tcomment_author       = %s,\n\t\t\tcomment_author_email = %s,\n\t\t\tcomment_approved     = %s,\n\t\t\tcomment_author_url   = %s,\n\t\t\tcomment_date         = %s,\n\t\t\tcomment_date_gmt     = %s\n\t\tWHERE comment_ID = %d", $comment_content, $comment_author, $comment_author_email, $comment_approved, $comment_author_url, $comment_date, $comment_date_gmt, $comment_ID));
    $rval = $wpdb->rows_affected;
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment_approved, $comment->comment_approved, $comment);
    return $rval;
}
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:48,代码来源:comment.php


示例3: wp_update_comment

/**
 * Updates an existing comment in the database.
 *
 * Filters the comment and makes sure certain fields are valid before updating.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param array $commentarr Contains information on the comment.
 * @return int Comment was updated if value is 1, or was not updated if value is 0.
 */
function wp_update_comment($commentarr)
{
    global $wpdb;
    // First, get all of the original fields
    $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
    if (empty($comment)) {
        return 0;
    }
    // Escape data pulled from DB.
    $comment = wp_slash($comment);
    $old_status = $comment['comment_approved'];
    // Merge old and new fields with new fields overwriting old ones.
    $commentarr = array_merge($comment, $commentarr);
    $commentarr = wp_filter_comment($commentarr);
    // Now extract the merged array.
    extract(wp_unslash($commentarr), EXTR_SKIP);
    $comment_content = apply_filters('comment_save_pre', $comment_content);
    $comment_date_gmt = get_gmt_from_date($comment_date);
    if (!isset($comment_approved)) {
        $comment_approved = 1;
    } else {
        if ('hold' == $comment_approved) {
            $comment_approved = 0;
        } else {
            if ('approve' == $comment_approved) {
                $comment_approved = 1;
            }
        }
    }
    $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent');
    $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    clean_comment_cache($comment_ID);
    wp_update_comment_count($comment_post_ID);
    do_action('edit_comment', $comment_ID);
    $comment = get_comment($comment_ID);
    wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
    return $rval;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:50,代码来源:comment.php


示例4: wp_set_comment_status

 /**
  * Hook to wp_set_comment_status action and correctly update the status if necessary
  *
  * @param $comment_id (int) The id of the comment
  */
 public function wp_set_comment_status($comment_id)
 {
     // Make sure we are working with a comment we have data for
     if (!isset($this->current_comment->status) || $this->current_comment->comment_ID != $comment_id) {
         return;
     }
     // END if
     $comment_status = $this->current_comment->status;
     // Set $this->current_comment back to NULL now that we're finished
     $this->current_comment = NULL;
     global $wpdb;
     // Update comment status with the CORRECT value for this comment
     $wpdb->update($wpdb->comments, array('comment_approved' => $comment_status), array('comment_ID' => $comment_id));
     // We've changed stuff so the cache needs to be cleared again
     clean_comment_cache($comment_id);
     // The rest of this is aping default WP behavior to make sure things fire correctly based on the status change
     do_action('wp_set_comment_status', $comment_id, $comment_status);
     $comment = get_comment($comment_id);
     $comment_old = clone get_comment($comment_id);
     wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
     wp_update_comment_count($comment->comment_post_ID);
 }
开发者ID:kgneil,项目名称:bsocial-comments,代码行数:27,代码来源:class-bsocial-comments-register.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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