本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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 );
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
});
}
示例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);
}
示例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 );
}
示例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;
}
示例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);
}
}