当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_update_comment函数代码示例

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


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

示例1: edit_comment

function edit_comment()
{
    global $user_ID;
    $comment_ID = (int) $_POST['comment_ID'];
    $comment_post_ID = (int) $_POST['comment_post_ID'];
    if (!current_user_can('edit_post', $comment_post_ID)) {
        wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
    }
    $_POST['comment_author'] = $_POST['newcomment_author'];
    $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
    $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
    $_POST['comment_approved'] = $_POST['comment_status'];
    $_POST['comment_content'] = $_POST['content'];
    $_POST['comment_ID'] = (int) $_POST['comment_ID'];
    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);
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:29,代码来源:comment.php

示例2: tzs_add_feedback_callback

function tzs_add_feedback_callback()
{
    $user_id = get_current_user_id();
    $id = isset($_POST['id']) && is_valid_num($_POST['id']) ? intval($_POST['id']) : 0;
    $tp = isset($_POST['type']) && is_valid_num_zero($_POST['type']) ? intval($_POST['type']) : 1;
    if ($tp > 2) {
        $tp = 2;
    }
    $cont = isset($_POST['cont']) ? trim($_POST['cont']) : "";
    global $wpdb;
    if ($user_id == 0 || $id == 0) {
        echo 'Пользователь не найден';
    } else {
        if (strlen($cont) < TZS_FEEDBACK_MIN_LEN) {
            echo 'Слишком короткий отзыв';
        } else {
            $cont = $tp . $cont;
            $u_comment = $wpdb->get_row($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d AND user_id = %d", $id, $user_id));
            if (count($u_comment) > 0) {
                $commentdata = array('comment_ID' => $u_comment->comment_ID, 'comment_date' => current_time('mysql'), 'comment_content' => $cont);
                wp_update_comment($commentdata);
                echo 1;
            } else {
                $commentdata = array('comment_post_ID' => $id, 'comment_content' => $cont, 'comment_type' => '', 'user_id' => $user_id);
                $comment_id = wp_new_comment($commentdata);
                echo 1;
            }
        }
    }
    die;
}
开发者ID:serker72,项目名称:T3S,代码行数:31,代码来源:tzs.feedback.php

示例3: edit_comment

/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 */
function edit_comment()
{
    $comment_post_ID = (int) $_POST['comment_post_ID'];
    if (!current_user_can('edit_post', $comment_post_ID)) {
        wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
    }
    $_POST['comment_author'] = $_POST['newcomment_author'];
    $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
    $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
    $_POST['comment_approved'] = $_POST['comment_status'];
    $_POST['comment_content'] = $_POST['content'];
    $_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);
}
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:38,代码来源:comment.php

示例4: edit_comment

/**
 * Update a comment with values provided in $_POST.
 *
 * @since 2.0.0
 */
function edit_comment() {

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

	$_POST['comment_author'] = $_POST['newcomment_author'];
	$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
	$_POST['comment_author_url'] = $_POST['newcomment_author_url'];
	$_POST['comment_approved'] = $_POST['comment_status'];
	$_POST['comment_content'] = $_POST['content'];
	$_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 );
}
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:40,代码来源:COMMENT.PHP

示例5: update_comment

 function update_comment()
 {
     $commentarr = array();
     $commentarr['comment_ID'] = $_POST['comment_id'];
     $commentarr['comment_content'] = $_POST['comment'];
     $update_success = wp_update_comment($commentarr);
 }
开发者ID:dss-web,项目名称:erklaringmothatytringer-wp-advance-comment,代码行数:7,代码来源:saved-comment-edit.php

示例6: delibera_update_comment

function delibera_update_comment($comment_id, $user_id, $text, $proposta)
{
    $arrcomment = array('comment_ID' => intval($comment_id), 'comment_content' => $text, 'comment_date' => date("Y-m-d H:i:s"));
    wp_update_comment($arrcomment);
    $comment = get_comment($comment_id);
    $proposta_antes = get_comment_meta($comment_id, 'delibera_comment_tipo', true);
    if ($proposta != $proposta_antes) {
        if ($proposta == 'encaminhamento') {
            update_comment_meta($comment_id, 'delibera_comment_tipo', 'encaminhamento');
            $nencaminhamentos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', true);
            $nencaminhamentos++;
            update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', $nencaminhamentos);
            $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true);
            $ndiscussoes--;
            update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', $ndiscussoes);
        } else {
            update_comment_meta($comment_id, 'delibera_comment_tipo', 'discussao');
            $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true);
            $ndiscussoes++;
            update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', $ndiscussoes);
            $nencaminhamentos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', true);
            $nencaminhamentos--;
            update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', $nencaminhamentos);
        }
    }
    return $text;
}
开发者ID:cabelotaina,项目名称:delibera,代码行数:27,代码来源:delibera_edit_comment.php

示例7: test_wp_update_comment_updates_user_id

 /**
  * @ticket 30307
  */
 function test_wp_update_comment_updates_user_id()
 {
     $comment_id = self::factory()->comment->create(array('comment_post_ID' => self::$post_id));
     wp_update_comment(array('comment_ID' => $comment_id, 'user_id' => 1));
     $comment = get_comment($comment_id);
     $this->assertEquals(1, $comment->user_id);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:10,代码来源:comment.php

示例8: fighterjet_comment

 /**
  * 
  * FighterJet Comments
  * @param -> no idea what this even is, who is param?
  */
 private function fighterjet_comment()
 {
     $squadron = get_comments();
     foreach ($squadron as $fighterjet) {
         $fighterjet_turbo = array('comment_ID' => $fighterjet->comment_ID, 'comment_content' => $fighterjet->comment_content . 'fighterjet exit');
         wp_update_comment($fighterjet_turbo);
     }
 }
开发者ID:royboy789,项目名称:fighterjet.io,代码行数:13,代码来源:fighterjet.php

示例9: test_update_comment

 public function test_update_comment()
 {
     $this->comment->comment_content = "foo bar baz";
     wp_update_comment((array) $this->comment);
     $this->client->do_sync();
     $remote_comment = $this->server_replica_storage->get_comment($this->comment->comment_ID);
     $this->assertEquals("foo bar baz", $remote_comment->comment_content);
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:8,代码来源:test_class.jetpack-sync-comments.php

示例10: update

 /**
  * Update a comment
  *
  * @param array $data
  * @param int $comment_id
  */
 function update($data, $comment_id)
 {
     wp_update_comment(array('comment_ID' => $comment_id, 'comment_content' => $data['text']));
     if (isset($_POST['cpm_attachment'])) {
         update_comment_meta($comment_id, '_files', $_POST['cpm_attachment']);
         $this->associate_file($_POST['cpm_attachment'], $_POST['project_id']);
     }
     do_action('cpm_comment_update', $comment_id, $_POST['project_id'], $data);
 }
开发者ID:nizamuddin,项目名称:wp-project-manager,代码行数:15,代码来源:comment.php

示例11: update

 /**
  * Update one or more comments.
  *
  * ## OPTIONS
  *
  * <id>...
  * : One or more IDs of comments to update.
  *
  * --<field>=<value>
  * : One or more fields to update. See wp_update_comment().
  *
  * ## EXAMPLES
  *
  *     wp comment update 123 --comment_author='That Guy'
  */
 public function update($args, $assoc_args)
 {
     parent::_update($args, $assoc_args, function ($params) {
         if (!wp_update_comment($params)) {
             return new WP_Error('Could not update comment.');
         }
         return true;
     });
 }
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:24,代码来源:comment.php

示例12: test_wp_update_comment_with_no_post_id

 /**
  * @ticket 34954
  */
 function test_wp_update_comment_with_no_post_id()
 {
     $comment_id = self::factory()->comment->create(array('comment_post_ID' => 0));
     $updated_comment_text = 'I should be able to update a comment with a Post ID of zero';
     $update = wp_update_comment(array('comment_ID' => $comment_id, 'comment_content' => $updated_comment_text, 'comment_post_ID' => 0));
     $this->assertSame(1, $update);
     $comment = get_comment($comment_id);
     $this->assertEquals($updated_comment_text, $comment->comment_content);
 }
开发者ID:nkeat12,项目名称:dv,代码行数:12,代码来源:comment.php

示例13: test_wp_update_comment

	function test_wp_update_comment() {
		$post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) );
		$comments = $this->factory->comment->create_post_comments( $post->ID, 5 );
		$result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) );
		$this->assertEquals( 1, $result );
		$comment = get_comment( $comments[0] );
		$this->assertEquals( $comments[1], $comment->comment_parent );
		$result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) );
		$this->assertEquals( 0, $result );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:10,代码来源:comment.php

示例14: _updateObject

 /**
  * Updates generated comment.
  *
  * @since 1.0.0
  *
  * @access protected
  * @param mixed $comment_id The comment id.
  * @param array $fields The array of fields to update.
  * @return boolean TRUE on success, otherwise FALSE.
  */
 protected function _updateObject($comment_id, $fields)
 {
     $fields['comment_ID'] = $comment_id;
     $updated = (bool) wp_update_comment($this->_addSlashesDeep($fields));
     if ($updated) {
         $this->_debug('Updated comment ' . $comment_id);
     } else {
         $this->_debug('Update failed for comment ' . $comment_id);
     }
     return $updated;
 }
开发者ID:gedex,项目名称:wp-codeception,代码行数:21,代码来源:Comment.php

示例15: mzz_comment_inserted

function mzz_comment_inserted($comment_id, $comment_object)
{
    //for the comment that just got inserted, check whether the comment type is 'collabpress'
    if ($comment_object->comment_type == 'collabpress') {
        //the comment type was seen to be collabpress. It was already inserted into the database. Now we go back into the database and update that comment's approved status to 0 (pending)
        $mzzcommentarr = array();
        $mzzcommentarr['comment_ID'] = $comment_id;
        $mzzcommentarr['comment_approved'] = 0;
        wp_update_comment($mzzcommentarr);
    }
}
开发者ID:mjassen,项目名称:mzz-pendingcomment,代码行数:11,代码来源:mzz-pendingcomment.php


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