本文整理汇总了PHP中get_comment_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP get_comment_meta函数的具体用法?PHP get_comment_meta怎么用?PHP get_comment_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_comment_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: woo_add_order_notes_to_email
function woo_add_order_notes_to_email()
{
global $woocommerce, $post;
$args = array('post_id' => $post->ID, 'approve' => 'approve', 'type' => 'order_note');
$notes = get_comments($args);
echo '<h2>' . __('Order Notes', 'woocommerce') . '</h2>';
echo '<ul class="order_notes">';
if ($notes) {
foreach ($notes as $note) {
$note_classes = get_comment_meta($note->comment_ID, 'is_customer_note', true) ? array('customer-note', 'note') : array('note');
?>
<li rel="<?php
echo absint($note->comment_ID);
?>
" class="<?php
echo implode(' ', $note_classes);
?>
">
<div class="note_content">
(<?php
printf(__('added %s ago', 'woocommerce'), human_time_diff(strtotime($note->comment_date_gmt), current_time('timestamp', 1)));
?>
) <?php
echo wpautop(wptexturize(wp_kses_post($note->comment_content)));
?>
</div>
</li>
<?php
}
} else {
echo '<li>' . __('There are no notes for this order yet.', 'woocommerce') . '</li>';
}
echo '</ul>';
}
开发者ID:douglaswebdesigns,项目名称:woocommerce-get-card-fields,代码行数:34,代码来源:woocommerce-order-notes-card-fields-master.php
示例2: salesforce_process_comment
/**
* Processes the comment data, and sends the lead if appropriate.
*
* @param int $id The ID of the comment
* @return void
**/
function salesforce_process_comment($comment_id)
{
if (get_comment_meta($comment_id, 'salesforce_lead_submitted', true)) {
return;
}
$options = get_option('salesforce2');
if (!$options['commentstoleads']) {
return;
}
$comment = get_comment($comment_id);
$post = get_post($comment->comment_post_ID);
// Some plugins use comments on custom post types for all kinds of things
$allowed_types = apply_filters('salesforce_allowed_comment_to_lead_types', array('post', 'page'));
if (!in_array($post->post_type, $allowed_types)) {
return;
}
$first_name = get_comment_meta($comment_id, 'author_first_name', true);
$last_name = get_comment_meta($comment_id, 'author_last_name', true);
// Let's get at least some name data in from legacy comments
if (!$first_name && !$last_name) {
$first_name = $comment->comment_author;
}
$lead_data = array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $comment->comment_author_email, 'lead_source' => 'Web comment, ' . get_site_url(), 'URL' => $comment->comment_author_url, 'description' => $comment->comment_content);
if (submit_salesforce_form($lead_data, $options)) {
add_comment_meta($comment_id, 'salesforce_lead_submitted', 1);
}
}
示例3: get_order_note_type
public static function get_order_note_type($type, $note)
{
if (get_comment_meta($note->comment_ID, 'is_seating_report_note', true) == 1) {
$type = 'seating chart note';
}
return $type;
}
示例4: response_tracker
function response_tracker($actions, $comment)
{
global $current_user;
get_currentuserinfo();
$current = get_comment_meta($comment->comment_ID, 'tracker_comment_status', true);
$responded = get_comment_meta($comment->comment_ID, 'tracker_responded_flag', true);
if ($current == "") {
$current = "todo";
}
// TODO: this is a hack... need a better way to mark the below.
// I am using an empty span and it's class to designate the current status.
// This class is then used via jQuery in response-tracker.js to set the
// colour of the comment block when the page load completes.
if ($current == 'replied') {
$curstatusclass = 'trackerstatusreplied';
} elseif ($current == 'ignore' || $comment->comment_author == $current_user->user_login) {
$curstatusclass = 'trackerstatusignored';
} elseif ($responded) {
$curstatusclass = 'trackerstatusresponded';
} else {
$curstatusclass = 'trackerstatustodo';
}
$actions['status'] = "<span class='{$curstatusclass}'> </span>";
$actions['status'] .= "Mark: (";
foreach (array('todo', 'replied', 'ignore') as $status) {
$class = "trackerstatusaction trackeraction{$status}";
$class .= $status == $current ? " trackercurrentselected" : "";
$onclick = "onClick='setCommentStatus(this, {$comment->comment_ID}, \"{$status}\");'";
$actions['status'] .= " <span class='{$class}' {$onclick}>" . ucfirst($status) . "</span>";
}
$actions['status'] .= " )";
return $actions;
}
示例5: get_dados
public function get_dados($postID = false, $tipo_data = false)
{
$pautas = '';
$comments = '';
if ($postID === false) {
$pautas = delibera_get_pautas_em();
$comments = delibera_wp_get_comments();
} else {
$pautas = array(get_post($postID));
$comments = delibera_wp_get_comments(array('post_id' => $postID));
}
$events = array();
foreach ($pautas as $pauta) {
$data = strtotime($pauta->post_date_gmt);
if (!array_key_exists($data, $events)) {
$events[$data] = array();
}
$events[$data][] = array('type' => 'pauta', 'title' => get_the_title($postID), 'body' => apply_filters('the_content', $pauta->post_content), 'date_event' => $data);
}
foreach ($comments as $comment) {
$data = strtotime($comment->comment_date_gmt);
if (!array_key_exists($data, $events)) {
$events[$data] = array();
}
$events[$data][] = array('type' => 'comment-' . get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true), 'title' => "@" . $comment->comment_author, 'body' => apply_filters('comment_text', get_comment_text($comment->comment_ID)), 'date_event' => $data);
}
ksort($events, SORT_NUMERIC);
return $this->filtrar($events, $tipo_data);
}
示例6: delete
/**
* Use this method to prevent excluding something that was not configured by FakerPress
*
* @param array|int|\WP_Comment $comment The ID for the Post or the Object
* @return bool
*/
public static function delete($comment)
{
if (is_array($comment)) {
$deleted = array();
foreach ($comment as $id) {
$id = $id instanceof \WP_Comment ? $id->comment_ID : $id;
if (!is_numeric($id)) {
continue;
}
$deleted[$id] = self::delete($id);
}
return $deleted;
}
if (is_numeric($comment)) {
$comment = \WP_Comment::get_instance($comment);
}
if (!$comment instanceof \WP_Comment) {
return false;
}
$flag = (bool) get_comment_meta($comment->comment_ID, self::$flag, true);
if (true !== $flag) {
return false;
}
return wp_delete_comment($comment->comment_ID, true);
}
示例7: widget
/**
* widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
public function widget($args, $instance)
{
global $comments, $comment, $woocommerce;
if ($this->get_cached_widget($args)) {
return;
}
ob_start();
extract($args);
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
$number = absint($instance['number']);
$comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product'));
if ($comments) {
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
echo '<ul class="product_list_widget">';
foreach ((array) $comments as $comment) {
$_product = get_product($comment->comment_post_ID);
$rating = intval(get_comment_meta($comment->comment_ID, 'rating', true));
$rating_html = $_product->get_rating_html($rating);
echo '<li><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">';
echo $_product->get_image();
echo $_product->get_title() . '</a>';
echo $rating_html;
printf('<span class="reviewer">' . _x('by %1$s', 'by comment author', 'woocommerce') . '</span>', get_comment_author());
echo '</li>';
}
echo '</ul>';
echo $after_widget;
}
$content = ob_get_clean();
echo $content;
$this->cache_widget($args, $content);
}
示例8: testUpdateUserData
/**
* This tests Woothemes_Sensei_Utils::update_user_data
*/
public function testUpdateUserData()
{
//setup data needed for this test
$test_user_id = wp_create_user('testUpdateUserData', 'testUpdateUserData', 'testUpdateUserData@test.com');
// does this function add_user_data exist?
$this->assertTrue(method_exists('WooThemes_Sensei_Utils', 'update_user_data'), 'The utils class function `update_user_data` does not exist ');
// does it return false for invalid data
$invalid_data_message = 'This function does not check false data correctly';
$this->assertFalse(WooThemes_Sensei_Utils::update_user_data('', '', '', ''), $invalid_data_message . ": '','','','' ");
$this->assertFalse(WooThemes_Sensei_Utils::update_user_data(' ', ' ', ' ', ' '), $invalid_data_message . ": ' ', ' ', ' ', ' ' ");
$this->assertFalse(WooThemes_Sensei_Utils::update_user_data(-1, -2, -3, -1), $invalid_data_message . ": -1,-2, -3, -1 ");
$this->assertFalse(WooThemes_Sensei_Utils::update_user_data('key', 500, 'val', 5000), $invalid_data_message . ": 'key', 500, 'val', 5000 ");
//does this function return false when attempting to add user data on non sensei post types
$test_post = $this->factory->post->create();
$this->assertFalse(WooThemes_Sensei_Utils::update_user_data('key', $test_post, 'val', $test_user_id), 'This function does not reject unsupported post types');
//does this function return false when attempting to add user data on non sensei post types
$test_array = array(1, 2, 3, 4);
$test_course_id = $this->factory->post->create(array('post_type' => "course"));
$test_data_key = 'test_key';
WooThemes_Sensei_Utils::update_user_data($test_data_key, $test_course_id, $test_array, $test_user_id);
$course_status = WooThemes_Sensei_Utils::user_course_status($test_course_id, $test_user_id);
// is the status updated on the passed in sensei post type ?
$this->assertTrue(isset($course_status->comment_ID), 'This function did not create the status on the passed in sensei post type');
// setup the next group of assertions
$retrieved_array = get_comment_meta($course_status->comment_ID, $test_data_key, true);
// is the data saved still intact
$this->assertEquals($test_array, $retrieved_array, 'The saved and retrieved data does not match');
}
示例9: 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;
}
示例10: cwp_pac_comment_single
function cwp_pac_comment_single($text)
{
global $post;
global $comment;
$return = '';
for ($i = 1; $i <= cwppos("cwppos_option_nr"); $i++) {
$post_options[$i] = get_post_meta($post->ID, "option_{$i}_content", true);
$comment_meta_options["comment-meta-option-{$i}"] = get_comment_meta($comment->comment_ID, "meta_option_{$i}", true);
}
$filtered_post_options = array_filter($comment_meta_options);
if (!empty($filtered_post_options)) {
$return .= "<div class='user-comments-grades'>";
$k = 1;
// keep track
foreach ($comment_meta_options as $comment_meta_option => $comment_meta_value) {
if (!empty($comment_meta_value)) {
$comment_meta_score = $comment_meta_value * 10;
$return .= "<div class='comment-meta-option'>\r\n\r\n\t\t\t\t\t\t\t<p class='comment-meta-option-name'>{$post_options[$k]}</p>\r\n\r\n\t\t\t\t\t\t\t<p class='comment-meta-option-grade'>{$comment_meta_value}</p>\r\n\r\n\t\t\t\t\t\t\t<div class='cwpr_clearfix'></div>\r\n\r\n\t\t\t\t\t\t\t<div class='comment-meta-grade-bar'>\r\n\r\n\t\t\t\t\t\t\t\t<div class='comment-meta-grade' style='width: {$comment_meta_score}%'></div>\r\n\r\n\t\t\t\t\t\t\t</div><!-- end .comment-meta-grade-bar -->\r\n\r\n\t\t\t\t\t\t</div><!-- end .comment-meta-option -->\r\n\r\n\t\t\t\t\t";
}
$k++;
}
$return .= "</div><!-- end .user-comments-grades -->";
}
return $return . $text . "<div class='cwpr_clearfix'></div>";
}
示例11: 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;
}
示例12: widget
/**
* widget function.
*
* @see WP_Widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
global $comments, $comment;
if ($this->get_cached_widget($args)) {
return;
}
ob_start();
$number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std'];
$comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product'));
if ($comments) {
$this->widget_start($args, $instance);
echo '<ul class="product_list_widget">';
foreach ((array) $comments as $comment) {
$_product = wc_get_product($comment->comment_post_ID);
$rating = intval(get_comment_meta($comment->comment_ID, 'rating', true));
$rating_html = $_product->get_rating_html($rating);
echo '<li><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">';
echo $_product->get_image();
echo $_product->get_title() . '</a>';
echo $rating_html;
printf('<span class="reviewer">' . _x('by %1$s', 'by comment author', 'woocommerce') . '</span>', get_comment_author());
echo '</li>';
}
echo '</ul>';
$this->widget_end($args);
}
$content = ob_get_clean();
echo $content;
$this->cache_widget($args, $content);
}
示例13: convert
function convert($comment, $thumb = 'thumbnail', $merge_post = false, $merge_author = false)
{
$date_format = get_option('date_format');
$time_format = get_option('time_format');
/**
* add comment meta
*/
if (!empty($this->meta)) {
foreach ($this->meta as $key => $value) {
$comment->{$value} = get_comment_meta($comment->comment_ID, $value, true);
}
}
$comment->comment_content = wpautop(esc_attr($comment->comment_content));
// comment link
$comment->comment_link = get_permalink($comment->comment_post_ID);
$comment->ID = $comment->comment_ID;
$comment->id = $comment->comment_ID;
$comment->avatar = get_avatar($comment->user_id, '33');
unset($comment->comment_author_email);
$comment->message_time = sprintf(__('on %s', 'messages-backend'), get_comment_date($date_format, $comment)) . ' ' . sprintf(__('at %s', 'messages-backend'), get_comment_date($time_format, $comment));
$file_arr = get_comment_meta($comment->comment_ID, 'fre_comment_file', true);
$comment->file_list = '';
if (!empty($file_arr)) {
$attachment = get_posts(array('post_type' => 'attachment', 'post__in' => $file_arr));
ob_start();
echo '<ul class="list-file-attack">';
foreach ($attachment as $key => $file) {
echo '<li><a target="_blank" href="' . $file->guid . '" class="attack-file"><i class="fa fa-paperclip"></i> ' . $file->post_title . '</a></li>';
}
echo '</ul>';
$message_file = ob_get_clean();
$comment->file_list = $message_file;
}
return $comment;
}
示例14: smittenkitchen_comment_meta_box
function smittenkitchen_comment_meta_box($comment)
{
$sk_madethis = get_comment_meta($comment->comment_ID, 'sk_madethis', true);
$sk_question = get_comment_meta($comment->comment_ID, 'sk_question', true);
wp_nonce_field('sk_comment_update', 'sk_comment_update', false);
?>
<p>
<label for="sk_madethis"><?php
_e('I Made This');
?>
</label>
<input type="checkbox" name="sk_madethis" <?php
if ($sk_madethis) {
echo 'checked="checked"';
}
?>
/>
</p>
<p>
<label for="sk_question"><?php
_e('I Have a Question');
?>
</label>
<input type="checkbox" name="sk_question" <?php
if ($sk_question) {
echo 'checked="checked"';
}
?>
/>
</p>
<?php
}
示例15: cwppos_calc_overall_rating
/**
* Core functions of WPPR
* @package WPPR
* @author ThemeIsle
* @since 1.0.0
*
*/
function cwppos_calc_overall_rating($id)
{
$options = cwppos();
for ($i = 1; $i <= cwppos("cwppos_option_nr"); $i++) {
${"option" . $i . "_grade"} = get_post_meta($id, "option_" . $i . "_grade", true);
// echo ${"option".$i."_grade"};
${"comment_meta_option_nr_" . $i} = 0;
${"comment_meta_option_" . $i} = 0;
}
$nr_of_comments = 0;
if ($options['cwppos_show_userreview'] == "yes") {
$args = array('status' => 'approve', 'post_id' => $id);
$comments = get_comments($args);
$nr_of_comments = get_comments_number($id);
foreach ($comments as $comment) {
for ($i = 1; $i <= cwppos("cwppos_option_nr"); $i++) {
if (get_comment_meta($comment->comment_ID, "meta_option_{$i}", true) !== '') {
${"comment_meta_option_nr_" . $i}++;
${"comment_meta_option_" . $i} += get_comment_meta($comment->comment_ID, "meta_option_{$i}", true) * 10;
}
//var_dump(${"comment_meta_option_".$i});
}
}
for ($i = 1; $i <= cwppos("cwppos_option_nr"); $i++) {
if (${"comment_meta_option_nr_" . $i} !== 0) {
${"comment_meta_option_" . $i} = ${"comment_meta_option_" . $i} / ${"comment_meta_option_nr_" . $i};
}
}
} else {
$options['cwppos_infl_userreview'] = 0;
}
if ($nr_of_comments == 0) {
$options['cwppos_infl_userreview'] = 0;
}
$overall_score = 0;
$iter = 0;
$rating = array();
for ($i = 1; $i <= cwppos("cwppos_option_nr"); $i++) {
if (${"comment_meta_option_nr_" . $i} !== 0) {
$infl = $options['cwppos_infl_userreview'];
} else {
$infl = 0;
}
if (!empty(${'option' . $i . '_grade'}) || ${'option' . $i . '_grade'} === '0') {
${'option' . $i . '_grade'} = round((${'option' . $i . '_grade'} * (100 - $infl) + ${'comment_meta_option_' . $i} * $infl) / 100);
$iter++;
$rating['option' . $i] = round(${'option' . $i . '_grade'});
$overall_score += ${'option' . $i . '_grade'};
}
}
//$overall_score = ($option1_grade + $option2_grade + $option3_grade + $option4_grade + $option5_grade) / $iter;
if ($iter !== 0) {
$rating['overall'] = $overall_score / $iter;
} else {
$rating['overall'] = 0;
}
update_post_meta($id, 'option_overall_score', $rating['overall']);
return $rating;
}