本文整理汇总了PHP中update_comment_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP update_comment_meta函数的具体用法?PHP update_comment_meta怎么用?PHP update_comment_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_comment_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: evc_comments_add_comment
function evc_comments_add_comment($comment, $post_id, $widget_api_id, $comment_parent = null)
{
if (isset($comment['cid'])) {
$comment['id'] = $comment['cid'];
}
$vk_item_id = 'app' . $widget_api_id . '_' . $comment['id'];
$comment_wp_id = evc_get_wpid_by_vkid($vk_item_id, 'comment');
if ($comment_wp_id && isset($comment_wp_id[$vk_item_id])) {
return $comment_wp_id[$vk_item_id];
}
if (isset($comment['user']) && !empty($comment['user'])) {
$user_wp_id = evc_get_wpid_by_vkid($comment['user']['id'], 'user');
if (!$user_wp_id) {
$user_wp_id = evc_add_user($comment['user']);
if (!$user_wp_id) {
return false;
}
} else {
$user_wp_id = $user_wp_id[$comment['user']['id']];
}
} else {
return false;
}
$args = array('comment_post_ID' => $post_id, 'comment_content' => $comment['text'], 'user_id' => $user_wp_id, 'comment_date' => date('Y-m-d H:i:s', $comment['date'] + get_option('gmt_offset') * 3600), 'comment_approved' => 1, 'comment_author_IP' => preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']), 'comment_agent' => substr($_SERVER['HTTP_USER_AGENT'], 0, 254));
if (isset($comment_parent) && !empty($comment_parent)) {
$args['comment_parent'] = $comment_parent;
}
$args = apply_filters('evc_comments_add_comment_args', $args, $comment);
//print__r($args); //
$comment_wp_id = wp_insert_comment($args);
if ($comment_wp_id) {
update_comment_meta($comment_wp_id, 'vk_item_id', $vk_item_id);
}
return $comment_wp_id;
}
示例2: fre_create_invite
/**
* create a comment with type fre_invite
* @param int $user_id
* @param int $project
* @return int $invite_id
* @since 1.3.1
* @author Dakachi
*/
function fre_create_invite($user_id, $project_id)
{
global $user_ID, $current_user;
$invite_id = wp_insert_comment(array('comment_post_ID' => $project_id, 'comment_author' => $current_user->data->user_login, 'comment_author_email' => $current_user->data->user_email, 'comment_content' => sprintf(__("Invite %s to bid project", 'invites-backend'), get_the_author_meta('display_name', $user_id)), 'comment_type' => 'fre_invite', 'user_id' => $user_ID, 'comment_approved' => 1));
update_comment_meta($invite_id, 'invite', $user_id);
return $invite_id;
}
示例3: test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template
/**
* @ticket 16894
*/
public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template()
{
global $wpdb;
$p = $this->factory->post->create(array('post_status' => 'publish'));
$comment_ids = $this->factory->comment->create_post_comments($p, 3);
foreach ($comment_ids as $cid) {
update_comment_meta($cid, 'sauce', 'fire');
}
$this->go_to(get_permalink($p));
if (have_posts()) {
while (have_posts()) {
the_post();
// Load comments with `comments_template()`.
$cform = get_echo('comments_template');
// First request will hit the database.
$num_queries = $wpdb->num_queries;
get_comment_meta($comment_ids[0], 'sauce');
$this->assertSame($num_queries + 1, $wpdb->num_queries);
// Second and third requests should be in cache.
get_comment_meta($comment_ids[1], 'sauce');
get_comment_meta($comment_ids[2], 'sauce');
$this->assertSame($num_queries + 1, $wpdb->num_queries);
}
}
}
示例4: comment_posted
/**
* Executed comment posted
*
* @param int $comment_id
*/
public function comment_posted($comment_id)
{
$comment = get_comment($comment_id);
if ($this->is_thread(get_post_type($comment->comment_post_ID))) {
// This may anonymous comment.
if ($this->input->post('_nichancommentnonce') && $comment->user_id && $comment->user_id == $this->option->post_as) {
// Mark this as anonymous comment
update_comment_meta($comment_id, '_is_anonymous', 1);
// If hash exists, save it
if ($this->option->use_trip && ($trip = $this->input->post('trip'))) {
update_comment_meta($comment_id, '_trip', $this->hash->generate($trip));
}
// Put cookie for anonymous user.
if (isset($_COOKIE['nichan_posted'])) {
$cookies = explode('-', $_COOKIE['nichan_posted']);
} else {
$cookies = array();
}
if (false === array_search($comment->comment_post_ID, $cookies)) {
$cookies[] = $comment->comment_post_ID;
}
setcookie('nichan_posted', implode('-', $cookies), current_time('timestamp', true) + 60 * 30, '/');
}
}
}
示例5: 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;
}
示例6: dln_social_login_add_comment_meta
function dln_social_login_add_comment_meta($comment_id)
{
$social_login_comment_via_provider = isset($_POST['social_login_comment_via_provider']) ? $_POST['social_login_comment_via_provider'] : '';
if ($social_login_comment_via_provider != '') {
update_comment_meta($comment_id, 'social_login_comment_via_provider', $social_login_comment_via_provider);
}
}
示例7: activity_log
function activity_log($wp_comment_id = "", $lf_comment_id = "", $lf_activity_id = "")
{
// Use meta keys that will allow us to lookup by Livefyre comment i
update_comment_meta($wp_comment_id, LF_CMETA_PREFIX . $lf_comment_id, $lf_comment_id);
update_comment_meta($wp_comment_id, LF_AMETA_PREFIX . $lf_activity_id, $lf_activity_id);
return false;
}
示例8: testCommentWithMeta
function testCommentWithMeta()
{
$post_id = $this->factory->post->create();
$comment_id = $this->factory->comment->create(array('comment_post_ID' => $post_id));
update_comment_meta($comment_id, 'rebney', 'Winnebago Man');
update_comment_meta($comment_id, 'quote', 'Will you do me a kindness?');
$comment = new TimberComment($comment_id);
$this->assertEquals('Winnebago Man', $comment->rebney);
}
示例9: create_object
/**
* Create a mock webhook delivery.
*
* @since 2.2
* @see WP_UnitTest_Factory_For_comment::create_object()
* @param array $args
* @return int webhook delivery (comment) ID
*/
public function create_object($args)
{
$id = parent::create_object($args);
$comment_meta_args = array('_request_method' => 'POST', '_request_headers' => array('User-Agent', 'WooCommerce Hookshot'), '_request_body' => "webhook_id={$id}", '_response_code' => 200, '_response_messaage' => 'OK', '_response_headers' => array('server' => 'nginx'), '_response_body' => 'OK', '_duration' => '0.47976');
foreach ($comment_meta_args as $key => $value) {
update_comment_meta($id, $key, $value);
}
return $id;
}
示例10: update_comment
function update_comment($comment_id)
{
$comment = get_comment($comment_id);
$terms = $this->update_comment_terms($comment_id, $comment);
delete_comment_meta($comment_id, $this->meta_key);
foreach ($terms as $term) {
update_comment_meta($comment_id, $this->meta_key, $term);
}
$this->update_terms($comment->comment_post_ID);
}
示例11: save
/**
* Save meta box data
*/
public static function save($location, $comment_id)
{
// Not allowed, return regular value without updating meta
if (!wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data') && !isset($_POST['rating'])) {
return $location;
}
// Update meta
update_comment_meta($comment_id, 'rating', intval($_POST['rating']));
// Return regular value after updating
return $location;
}
示例12: do_save
public function do_save($return_val, $params, $metas, $module)
{
$comment_id = wp_insert_comment($params);
if (!is_numeric($comment_id)) {
return false;
}
foreach ($metas as $key => $value) {
update_comment_meta($comment_id, $key, $value);
}
return $comment_id;
}
示例13: tracker_set_comment_status
function tracker_set_comment_status()
{
global $_POST;
$commentid = $_POST['id'];
$status = $_POST['status'];
if (!current_user_can('edit_post', $commentid)) {
die("Sorry you can't do that.");
}
add_comment_meta($commentid, 'tracker_comment_status', $status, true) or update_comment_meta($commentid, 'tracker_comment_status', $status) or die("Failed to add or update status for comment.");
die("OK");
}
示例14: record_successful_outbound_message_batch
/**
*
* @since 2.0.0
*
* @param object $data
* @return $this
*/
protected function record_successful_outbound_message_batch($data)
{
if (empty($data->id)) {
Prompt_Logging::add_error(Prompt_Enum_Error_Codes::OUTBOUND, __('Got an unrecognized outbound message batch response.', 'Postmatic'), array('result' => $data, 'comment_id' => $this->comment->comment_ID));
return $this;
}
$sent_ids = get_comment_meta($this->comment->comment_ID, self::$outbound_message_batch_ids_meta_key, true);
$sent_ids = $sent_ids ? $sent_ids : array();
$sent_ids[] = $data->id;
update_comment_meta($this->comment->comment_ID, self::$outbound_message_batch_ids_meta_key, $sent_ids);
return $this;
}
示例15: wpad_edit_comment_saved
function wpad_edit_comment_saved()
{
$ignore = array('comment_status', 'comment_id', 'comment', 'action');
foreach ($_POST as $key => $value) {
if (!in_array($key, $ignore)) {
update_comment_meta($_POST['comment_id'], $key, $value);
}
}
$this->set_comment_status($_POST['comment_id'], $_POST['comment_status']);
$this->update_comment($_POST);
die;
}