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>';
}
/**
 * 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);
    }
}
 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;
 }
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;
}
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 /**
  * 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);
 }
 /**
  * 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);
 }
Esempio n. 8
0
 /**
  * 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', '*****@*****.**');
     // 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');
 }
Esempio n. 9
0
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;
}
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>";
}
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;
}
 /**
  * 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);
 }
Esempio n. 13
0
 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)) . '&nbsp;' . 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;
 }
Esempio n. 14
0
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 
}
Esempio n. 15
0
/**
 * 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;
}
 public function get()
 {
     $this->rating = get_comment_meta($this->object_id, 'rating', true);
     if (!$this->rating) {
         $this->rating = 0;
     }
     return $this->rating;
 }
Esempio n. 17
0
 /**
  * Get comment meta values
  *
  * @param  integer  $id
  * @param  string   $key
  * @param  mixed    $default
  * @param  boolean  $format
  * @return mixed
  */
 protected function meta($id, $key, $default = null, $format = true)
 {
     $value = get_comment_meta($id, $key, $format);
     if (is_null($value) or $value === false or $value === '') {
         $value = $default;
     }
     return $value;
 }
Esempio n. 18
0
function vortex_system_get_total_dislikes_comment_epoch($id)
{
    $dislikes = get_comment_meta($id, 'vortex_system_dislikes', true);
    if (empty($dislikes)) {
        return 0;
    } elseif (!$dislikes == '') {
        return $dislikes = get_comment_meta($id, 'vortex_system_dislikes', true);
    }
}
 public function move_to_original($duplicate_of, $post_duplicates, $comment)
 {
     global $wpml_post_translations, $wpdb;
     $_orig_lang = $wpml_post_translations->get_element_lang_code($duplicate_of);
     $post_duplicates[$_orig_lang] = $duplicate_of;
     $original_parent = get_comment_meta($comment['comment_parent'], '_icl_duplicate_of', true);
     $wpdb->update($wpdb->comments, array('comment_post_ID' => $duplicate_of, 'comment_parent' => $original_parent), array('comment_ID' => $comment['comment_ID']), array('%d', '%d'), array('%d'));
     wp_update_comment_count_now($duplicate_of);
 }
 public function get_meta($object, $field_name, $request)
 {
     $meta = get_comment_meta($object['id'], $field_name);
     $result = null;
     if (is_array($meta) && count($meta) > 0) {
         $result = $meta[0];
     }
     return $result;
 }
 /**
  * Broadcasts the message to the specified account. Returns the broadcasted ID.
  *
  * @param  Social_Service_Facebook_Account|object  $account     account to broadcast to
  * @param  string                                  $message     message to broadcast
  * @param  array                                   $args        extra arguments to pass to the request
  * @param  int                                     $post_id     post ID being broadcasted
  * @param  int                                     $comment_id  comment ID being broadcasted
  *
  * @return Social_Response
  */
 public function broadcast($account, $message, array $args = array(), $post_id = null, $comment_id = null)
 {
     global $post;
     // if post ID is set, this is a broadcast of a post,
     // if the comment ID is set it is a broadcast of a comment
     // TODO - add wrapper functions that abstract these actions out to separate methods
     // check comment being replied to, if it is a facebook comment on a post then
     // send the comment as a reply on the same post.
     // If that fails, then send as posting a link with a comment.
     $args = $args + array('message' => $message);
     // first try to send comment to an existing Fb post
     if (!is_null($comment_id)) {
         $comment = get_comment($comment_id);
         if (!empty($comment->comment_parent)) {
             $parent_comment = get_comment($comment->comment_parent);
             if (!is_null($parent_comment) && in_array($parent_comment->comment_type, self::comment_types())) {
                 $status_id = get_comment_meta($parent_comment->comment_ID, 'social_status_id', true);
                 if (!empty($status_id)) {
                     // we have a Facebook post to reply to
                     $parts = explode('_', $status_id);
                     if (count($parts) == 3) {
                         $status_id = $parts[0] . '_' . $parts[1];
                     }
                     $args = apply_filters($this->key() . '_broadcast_args', $args, $post_id, $comment_id);
                     $response = $this->request($account, $status_id . '/comments', $args, 'POST');
                     if ($response !== false && $response->id() !== '0') {
                         // post succeeded, return response
                         return $response;
                     }
                     // ...broadcast failed, continue and send as post to feed
                 }
             }
         }
         // posting with a link, do not include URL in comment.
         $format = trim(str_replace('{url}', '', Social::option('comment_broadcast_format')));
         $message = $this->format_comment_content($comment, $format);
         $args['message'] = $message;
         // prep data
         $post = get_post($comment->comment_post_ID);
         setup_postdata($post);
         $link_args = array('link' => get_post_permalink($post->ID), 'title' => get_the_title($post->ID), 'description' => get_the_excerpt());
         if (function_exists('has_post_thumbnail') and has_post_thumbnail($post->ID)) {
             $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
             $link_args = $link_args + array('picture' => $image[0]);
         }
         wp_reset_postdata();
         $args = $args + $link_args;
     }
     // Set access token?
     $broadcast_account = $account->broadcast_page();
     if ($broadcast_account !== null) {
         $args = $args + array('access_token' => $broadcast_account->access_token, 'page_id' => $broadcast_account->id);
     }
     $args = apply_filters($this->key() . '_broadcast_args', $args, $post_id, $comment_id);
     return $this->request($account, 'me/feed', $args, 'POST');
 }
 function dislike_text($comment_id)
 {
     $comment_likes = get_comment_meta($comment_id, 'comment_dislikes', true);
     $user_ip = $_SERVER['REMOTE_ADDR'];
     if (!empty($comment_likes) && in_array($user_ip, $comment_likes)) {
         return 'wpad_liked';
     } else {
         return;
     }
 }
 public function __construct($comment)
 {
     $this->comment = $comment;
     $this->replaces = get_comment_meta($comment->comment_ID, self::replaces_meta_key, true);
     if ($this->replaces && $this->get_content()) {
         $this->type = 'update';
     }
     if ($this->replaces && !$this->get_content()) {
         $this->type = 'delete';
     }
 }
Esempio n. 24
0
 function comment_approved($cid, $comment_status)
 {
     $metaresult = get_comment_meta($cid, 'wysija_comment_subscribe', true);
     if ($comment_status == 'approve' && get_comment_meta($cid, 'wysija_comment_subscribe', true)) {
         $mConfig =& WYSIJA::get('config', 'model');
         $comment = get_comment($cid);
         $userHelper =& WYSIJA::get('user', 'helper');
         $data = array('user' => array('email' => $comment->comment_author_email, 'firstname' => $comment->comment_author), 'user_list' => array('list_ids' => $mConfig->getValue('commentform_lists')));
         $userHelper->addSubscriber($data);
     }
 }
Esempio n. 25
0
 function widget($args, $instance)
 {
     global $comments, $comment, $woocommerce;
     $cache = wp_cache_get('widget_recent_reviews', 'widget');
     if (!is_array($cache)) {
         $cache = array();
     }
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Reviews', 'woocommerce') : $instance['title'], $instance, $this->id_base);
     if (!($number = absint($instance['number']))) {
         $number = 5;
     }
     $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="ratings-small">';
         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>';
             echo '<div class="image">
                     <a href="' . esc_url(get_comment_link($comment->comment_ID)) . '" title="' . esc_attr($_product->get_title()) . '">
                         <img src="http://www.gravatar.com/avatar/' . md5(get_comment_author_email()) . '?s=60&d=retro&r=g" alt="" />
                     </a>
                 </div>';
             echo '<div class="desc">
                         <h6>' . get_comment_author() . '</h6><small>' . get_comment_date() . '</small>';
             echo '<div class="rating rating-' . (int) $_product->get_average_rating() . '">';
             for ($i = 1; $i <= (int) $_product->get_average_rating(); $i++) {
                 echo '<i class="icon-heart"></i>' . "\n";
             }
             echo '</div>';
             echo '</div>
                 </li>';
         }
         echo '</ul>';
         echo $after_widget;
     }
     $content = ob_get_clean();
     if (isset($args['widget_id'])) {
         $cache[$args['widget_id']] = $content;
     }
     echo $content;
     wp_cache_set('widget_recent_reviews', $cache, 'widget');
 }
Esempio n. 26
0
function dln_social_login_render_comment_meta($link)
{
    global $comment;
    $images_url = SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/';
    $social_login_comment_via_provider = get_comment_meta($comment->comment_ID, 'social_login_comment_via_provider', true);
    if ($social_login_comment_via_provider && current_user_can('manage_options')) {
        return $link . '&nbsp;<img class="social_login_comment_via_provider" alt="' . $social_login_comment_via_provider . '" src="' . $images_url . $social_login_comment_via_provider . '_16.png"  />';
    } else {
        return $link;
    }
}
Esempio n. 27
0
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;
}
 /**
  * Gets the avatar based on the comment type.
  *
  * @static
  * @wp-filter  get_avatar
  * @param  string  $avatar
  * @param  object  $comment
  * @param  int     $size
  * @param  string  $default
  * @param  string  $alt
  * @return string
  */
 public static function get_avatar($avatar, $comment, $size, $default, $alt = '')
 {
     if (is_object($comment) and in_array($comment->comment_type, Social_Service_Facebook::comment_types())) {
         $image = esc_url(get_comment_meta($comment->comment_ID, 'social_profile_image_url', true));
         if ($image !== null) {
             $size = esc_attr($size);
             $type = esc_attr($comment->comment_type);
             return '<img alt="' . $alt . '" src="' . $image . '" class="avatar avatar-' . $size . ' photo ' . $type . '" height="' . $size . '" width="' . $size . '" />';
         }
     }
     return $avatar;
 }
Esempio n. 29
0
 /**
  *
  * @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;
 }
Esempio n. 30
0
function houston_likes_comment_reply_link($link, $args, $comment, $post)
{
    global $post;
    global $comment;
    global $current_user;
    $commentmeta = get_comment_meta($comment->comment_ID, '_p2_likes', true);
    $users = p2_likes_generate_users_html($commentmeta);
    $like_count = $commentmeta ? count($commentmeta) : 0;
    $like_text = $commentmeta && in_array($current_user->ID, $commentmeta) ? __('Unlike', 'p2-likes') : __('Like', 'p2-likes');
    $output = " | <div class='p2-likes-link'><a rel='nofollow' class='p2-likes-link p2-likes-comment p2-likes-comment-" . $comment->comment_ID . "' href='" . get_permalink($post) . "' title='" . $like_text . "' onclick='p2Likes(1," . $comment->comment_ID . "); return false;'><span class='p2-likes-like'>" . $like_text . "</span><span class='p2-likes-count'>" . $like_count . "</span></a><div class='p2-likes-box'>" . $users . "</div></div>";
    return $link . $output;
}