^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数edit_comment()用法示例

edit_comment()

Update a comment with values provided in $_POST.


描述


源代码

File: wp-admin/includes/comment.php

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

function edit_comment() {
	if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) )
		wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) );

	if ( isset( $_POST['newcomment_author'] ) )
		$_POST['comment_author'] = $_POST['newcomment_author'];
	if ( isset( $_POST['newcomment_author_email'] ) )
		$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
	if ( isset( $_POST['newcomment_author_url'] ) )
		$_POST['comment_author_url'] = $_POST['newcomment_author_url'];
	if ( isset( $_POST['comment_status'] ) )
		$_POST['comment_approved'] = $_POST['comment_status'];
	if ( isset( $_POST['content'] ) )
		$_POST['comment_content'] = $_POST['content'];
	if ( isset( $_POST['comment_ID'] ) )
		$_POST['comment_ID'] = (int) $_POST['comment_ID'];

	foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
		if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
			$_POST['edit_date'] = '1';
			break;
		}
	}

	if ( !empty ( $_POST['edit_date'] ) ) {
		$aa = $_POST['aa'];
		$mm = $_POST['mm'];
		$jj = $_POST['jj'];
		$hh = $_POST['hh'];
		$mn = $_POST['mn'];
		$ss = $_POST['ss'];
		$jj = ($jj > 31 ) ? 31 : $jj;
		$hh = ($hh > 23 ) ? $hh -24 : $hh;
		$mn = ($mn > 59 ) ? $mn -60 : $mn;
		$ss = ($ss > 59 ) ? $ss -60 : $ss;
		$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
	}

	wp_update_comment( $_POST );
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/l10n.php:
    __()
  • wp-includes/functions.php:
    wp_die()
  • wp-includes/comment.php:
    wp_update_comment()

Used By

  • wp-admin/includes/ajax-actions.php:
    wp_ajax_edit_comment()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈