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


PHP add_comment_meta函数代码示例

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


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

示例1: customer_note_added

 public function customer_note_added($data)
 {
     global $wpdb;
     $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE id = %d", $data['order_id']));
     if ($post && $post->post_type == 'order_shipment') {
         $parent_id = $post->post_parent;
         $is_customer_note = intval(1);
         if (isset($_SERVER['HTTP_HOST'])) {
             $comment_author_email = sanitize_email(strtolower(__('WooCommerce', 'woocommerce')) . '@' . str_replace('www.', '', $_SERVER['HTTP_HOST']));
         } else {
             $comment_author_email = sanitize_email(strtolower(__('WooCommerce', 'woocommerce')) . '@noreply.com');
         }
         $comment_post_ID = $parent_id;
         $comment_author = __('WooCommerce', 'woocommerce');
         $comment_author_url = '';
         $comment_content = $data['customer_note'];
         $comment_agent = 'WooCommerce';
         $comment_type = 'order_note';
         $comment_parent = 0;
         $comment_approved = 1;
         $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_agent', 'comment_type', 'comment_parent', 'comment_approved');
         $comment_id = wp_insert_comment($commentdata);
         add_comment_meta($comment_id, 'is_customer_note', $is_customer_note);
     }
 }
开发者ID:RainyDayMedia,项目名称:carbide-probes,代码行数:25,代码来源:wcms-shipworks.php

示例2: custom_save_comment_wp

function custom_save_comment_wp($postID, $userID, $author, $email, $comment, $ratingvalue)
{
    remove_all_actions('comment_post', 1);
    $_POST['crfp-rating'] = $ratingvalue;
    $commentdata = array('comment_post_ID' => $postID, 'comment_author' => $author, 'comment_author_email' => $email, 'comment_content' => $comment, 'comment_type' => '', 'comment_parent' => 0, 'user_id' => $userID);
    /*Graba el comentario y me da el ID*/
    $commentID = wp_new_comment($commentdata);
    /*Añade el meta con el rating*/
    add_comment_meta($commentID, 'crfp-rating', $ratingvalue, true);
    //add_comment_meta($commentID, 'crfp-rating', 4, true);
    /*Actualiza el total y el promedio del rating*/
    $comments = get_comments(array('post_id' => $postID, 'status' => 'approve'));
    $totalRating = 0;
    $totalRatings = 0;
    $averageRating = 0;
    if (is_array($comments) and count($comments) > 0) {
        foreach ($comments as $comment) {
            $rating = get_comment_meta($comment->comment_ID, 'crfp-rating', true);
            if ($rating > 0) {
                $totalRatings++;
                $totalRating += $rating;
            }
        }
        $averageRating = ($totalRatings == 0 or $totalRating == 0) ? 0 : round($totalRating / $totalRatings, 0);
    }
    update_post_meta($postID, 'crfp-total-ratings', $totalRatings);
    update_post_meta($postID, 'crfp-average-rating', $averageRating);
    return true;
}
开发者ID:Rempty,项目名称:supch,代码行数:29,代码来源:save_comment.php

示例3: test_orderby_meta

 /**
  * @ticket 21003
  */
 function test_orderby_meta()
 {
     $comment_id = $this->factory->comment->create();
     $comment_id2 = $this->factory->comment->create();
     $comment_id3 = $this->factory->comment->create();
     add_comment_meta($comment_id, 'key', 'value1', true);
     add_comment_meta($comment_id, 'key1', 'value1', true);
     add_comment_meta($comment_id, 'key3', 'value3', true);
     add_comment_meta($comment_id2, 'key', 'value2', true);
     add_comment_meta($comment_id2, 'key2', 'value2', true);
     add_comment_meta($comment_id3, 'key3', 'value3', true);
     $comments = get_comments(array('meta_key' => 'key', 'orderby' => array('meta_value')));
     $this->assertEquals(2, count($comments));
     $this->assertEquals($comment_id2, $comments[0]->comment_ID);
     $this->assertEquals($comment_id, $comments[1]->comment_ID);
     $comments = get_comments(array('meta_key' => 'key', 'orderby' => array('meta_value'), 'order' => 'ASC'));
     $this->assertEquals(2, count($comments));
     $this->assertEquals($comment_id, $comments[0]->comment_ID);
     $this->assertEquals($comment_id2, $comments[1]->comment_ID);
     $comments = get_comments(array('meta_value' => 'value3', 'orderby' => array('meta_value')));
     $this->assertEquals(2, count($comments));
     $this->assertEquals($comment_id, $comments[0]->comment_ID);
     $this->assertEquals($comment_id3, $comments[1]->comment_ID);
     // value1 is present on two different keys for $comment_id yet we should get only one instance
     // of that comment in the results
     $comments = get_comments(array('meta_value' => 'value1', 'orderby' => array('meta_value')));
     $this->assertEquals(1, count($comments));
 }
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:31,代码来源:query.php

示例4: import_comments

 /**
  * Import comments from Instagram and load as WP comments for an image and post
  *
  * @param      $access_token
  * @param      $comments
  * @param      $image_id
  * @param      $post_id
  * @param      $id
  * @param bool $sync
  */
 public function import_comments($access_token, $comments, $image_id, $post_id, $id, $sync = false)
 {
     global $wpdb;
     if ($comments == '') {
         $comments = instagrate_pro()->accounts->get_comments($access_token, $image_id);
         $data = array('comments' => isset($comments) ? base64_encode(serialize($comments)) : array());
         $where = array('id' => $id);
         $wpdb->update(instagrate_pro()->images->get_table_name(), $data, $where);
     }
     $meta_table = $wpdb->prefix . 'commentmeta';
     if (!is_array($comments)) {
         return;
     }
     foreach ($comments as $comment) {
         $querystr = "\tSELECT count(*)\n\t\t\t\t\t\t\tFROM {$meta_table} m\n\t\t\t\t\t\t\tWHERE m.meta_key = '_igp_comment_id'\n\t\t\t\t\t\t\tAND m.meta_value = '{$comment->id}'\t";
         $exists = $wpdb->get_var($querystr);
         if ($exists > 0) {
             continue;
         }
         // set comment data
         $data = array('comment_post_ID' => $post_id, 'comment_author' => $comment->from->username, 'comment_author_email' => '@instagram_igp', 'comment_author_url' => 'http://instagram.com/' . $comment->from->username, 'comment_content' => instagrate_pro()->helper->clean_caption($comment->text), 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0, 'comment_author_IP' => '127.0.0.1', 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', 'comment_date' => date('Y-m-d H:i:s', $comment->created_time), 'comment_approved' => Instagrate_Pro_Helper::setting('igpsettings_comments_auto-approve', '0'));
         $comment_id = wp_insert_comment($data);
         //set comment meta ig comment id
         add_comment_meta($comment_id, '_igp_comment_id', $comment->id, true);
         //set comment meta with user image url
         add_comment_meta($comment_id, '_igp_comment_avatar', $comment->from->profile_picture, true);
     }
 }
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:38,代码来源:class-comments.php

示例5: import

            function import() {

                $comment_author = $this->author;
                $comment_author_url = $this->authoruri;
                $comment_author_email = $this->authoremail;
                $comment_date = $this->updated;
    
                $comment_content = $this->content;
                $comment_post_ID = $this->post_ID;
                $comment_author_IP = '127.0.0.1'; //Blogger does not supply the IP so default this
    
                // Clean up content
                // Simplepie does some cleaning but does not do these.
                $comment_content = str_replace('<br>', '<br />', $comment_content);
                $comment_content = str_replace('<hr>', '<hr />', $comment_content);
    
                $comment_parent = isset($this->parentcommentid) ? $this->parentcommentid : 0;
    
                $comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email','comment_author_IP','comment_date', 'comment_content', 'comment_parent');
    
                $comment = wp_filter_comment($comment);
                $comment_id = wp_insert_comment($comment);
                
                //links of the form  /feeds/417730729915399755/8397846992898424746/comments/default/7732208643735403000
                add_comment_meta($comment_id, 'blogger_internal', $this->self, true);

            return $comment_id;
        }
开发者ID:niamherinoc,项目名称:rctractors,代码行数:28,代码来源:comment-entry.php

示例6: process_comments

 function process_comments($post_id, $item_id)
 {
     if (empty($post_id)) {
         return;
     }
     if (!is_numeric($post_id)) {
         return;
     }
     $comments = $this->model->get_item_comments($item_id);
     if (!$comments || !isset($comments['data'])) {
         return;
     }
     $comments = $comments['data'];
     if (!count($comments)) {
         return false;
     }
     foreach ($comments as $comment) {
         if ($this->model->comment_already_imported($comment['id'])) {
             continue;
         }
         // We already have this comment, continue.
         $data = array('comment_post_ID' => $post_id, 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime($comment['created_time'])), 'comment_author' => $comment['from']['name'], 'comment_author_url' => 'http://www.facebook.com/profile.php?id=' . $comment['from']['id'], 'comment_content' => $comment['message']);
         $meta = array('fb_comment_id' => $comment['id'], 'fb_author_id' => $comment['from']['id']);
         $data = wp_filter_comment($data);
         $comment_id = wp_insert_comment($data);
         add_comment_meta($comment_id, 'wdfb_comment', $meta);
         if ($this->model->data->get_option('wdfb_comments', 'notify_authors')) {
             wp_notify_postauthor($comment_id, 'comment');
         }
     }
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:31,代码来源:class_wdfb_comments_importer.php

示例7: add_users_list_to_comment_for_notice

function add_users_list_to_comment_for_notice($comment_id, $comment)
{
    //get post ID and $post
    $post_id = $comment->comment_post_ID;
    $r = get_post($post_id);
    //it is cases?
    if ($r->post_type != 'cases') {
        return;
    }
    if ($comment->comment_type == 'visited') {
        return;
    }
    //add tag for plan email
    add_comment_meta($comment_id, 'email_notify', 0, true);
    //get members for cases
    $members = get_post_meta($post_id, 'members-cp-posts-sql');
    //$message = $post_id . '<пост, участник: ' . print_r($members, true);
    //error_log($message);
    //add user id to list for notification
    foreach ($members as $member) {
        $id_usr = get_user_by_person($member);
        //Если участник и автор комментария есть одно и то же, то не нужно добавлять в список уведомлений (зачем автору читать свой же коммент на почте?)
        if ($comment->user_id == $id_usr) {
            continue;
        }
        //Если у участника есть пользователь
        if ($id_usr > 0) {
            add_comment_meta($comment_id, 'notify_user', $id_usr);
            //error_log('comment: '. $comment_id . ', val: ' . $user);
        }
    }
    return;
}
开发者ID:Laxiston,项目名称:casepress,代码行数:33,代码来源:add_case_members_to_notify.php

示例8: cwp_add_comment_meta_values

function cwp_add_comment_meta_values($comment_id)
{
    for ($i = 1; $i <= cwppos("cwppos_option_nr"); $i++) {
        if (isset($_POST['meta_option_' . $i])) {
            ${'meta_option_' . $i} = wp_filter_nohtml_kses($_POST['meta_option_' . $i]);
            add_comment_meta($comment_id, 'meta_option_' . $i, ${'meta_option_' . $i}, false);
        }
    }
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:9,代码来源:cwp_comment.php

示例9: add_comment_rating

 /**
  * Rating field for comments.
  *
  * @param mixed $comment_id
  */
 public static function add_comment_rating($comment_id)
 {
     if (isset($_POST['rating'])) {
         if (!$_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0) {
             return;
         }
         add_comment_meta($comment_id, 'rating', (int) esc_attr($_POST['rating']), true);
     }
 }
开发者ID:emzo,项目名称:Recipe-Hero,代码行数:14,代码来源:class-rh-comments.php

示例10: update_comment

 function update_comment($comment_id)
 {
     $comment = get_comment($comment_id);
     delete_comment_meta($comment_id, $this->meta_key);
     $terms = $this->update_comment_terms($comment_id, $comment);
     foreach ($terms as $term) {
         add_comment_meta($comment_id, $this->meta_key, $term);
     }
     $this->update_terms($comment->comment_post_ID);
 }
开发者ID:cabelotaina,项目名称:redelivre,代码行数:10,代码来源:terms-in-comments.php

示例11: smittenkitten_save_comment_meta_data

/**
 * Save the extra comment field values when the comment is posted.
**/
function smittenkitten_save_comment_meta_data($comment_id)
{
    if (isset($_POST['sk_madethis']) && '' != $_POST['sk_madethis']) {
        $sk_madethis = wp_filter_nohtml_kses($_POST['sk_madethis']);
    }
    add_comment_meta($comment_id, 'sk_madethis', $sk_madethis);
    if (isset($_POST['sk_question']) && '' != $_POST['sk_question']) {
        $sk_question = wp_filter_nohtml_kses($_POST['sk_question']);
    }
    add_comment_meta($comment_id, 'sk_question', $sk_question);
}
开发者ID:a8cteam51,项目名称:smittenkitchen,代码行数:14,代码来源:comment-extras.php

示例12: save_rating

 /**
  * @param Rating $rating
  *
  * @return bool
  */
 public function save_rating(Rating $rating)
 {
     // save rating
     $id = wp_insert_comment($rating->to_comment());
     if ($id) {
         $rating->comment_ID = $id;
         add_comment_meta($id, '_wpkb_rating', $rating->rating, true);
         return true;
     }
     return false;
 }
开发者ID:ibericode,项目名称:wp-knowledge-base,代码行数:16,代码来源:class-rater.php

示例13: add_mention_users_to_notify_list

function add_mention_users_to_notify_list($meta_id, $object_id, $meta_key, $meta_value)
{
    if ($meta_key != 'users_mention_cp') {
        return;
    }
    $notify_user = get_comment_meta($object_id, 'notify_user');
    if (!in_array($meta_value, $notify_user)) {
        add_comment_meta($object_id, 'notify_user', $meta_value);
        add_comment_meta($object_id, 'email_notify', 0, true);
    }
    return;
}
开发者ID:Laxiston,项目名称:casepress,代码行数:12,代码来源:at_js_integrate.php

示例14: kt_save_comment_meta_data

function kt_save_comment_meta_data($comment_id)
{
    $comment_obj = get_comment($comment_id);
    $post_id = get_post($comment_obj->comment_post_ID);
    $post_obj = get_post($post_id);
    if ($post_obj->post_type == 'shop' || $post_obj->post_type == 'tour') {
        if (isset($_POST['rating']) && $_POST['rating'] != '') {
            $rating = wp_filter_nohtml_kses($_POST['rating']);
            add_comment_meta($comment_id, '_kt_rating', $rating, TRUE);
        }
    }
}
开发者ID:KL-Kim,项目名称:my-theme,代码行数:12,代码来源:comment-functions.php

示例15: salesforce_comment_post

/**
 * Hooks the WP salesforce_comment_post action to save the first and last name data,
 * and send a Salesforce Web-to-Lead API request when an approved comment is added.
 *
 * @param int $id The ID of the comment
 * @param int|string $comment_approved Either 1, 0 or 'spam' as returned from wp_allow_comment
 * @return void
 **/
function salesforce_comment_post($comment_id, $comment_approved)
{
    $options = get_option('salesforce2');
    if (!$options['commentstoleads']) {
        return;
    }
    add_comment_meta($comment_id, 'author_first_name', $_POST['author_first_name']);
    add_comment_meta($comment_id, 'author_last_name', $_POST['author_last_name']);
    if (1 !== $comment_approved) {
        return;
    }
    salesforce_process_comment($comment_id);
}
开发者ID:jimdough,项目名称:Roadmaster,代码行数:21,代码来源:salesforce_comment_to_lead.php


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