/**
  * Output the no results text, depending on current type context
  *
  * @param  string $current_type
  */
 function wc_product_reviews_pro_contributions_list_no_results_text($current_type = '')
 {
     if (!$current_type) {
         _e('There are no reviews yet.', WC_Product_Reviews_Pro::TEXT_DOMAIN);
     } else {
         $contribution_type = wc_product_reviews_pro_get_contribution_type($current_type);
         echo $contribution_type->get_no_results_text();
     }
 }
 /**
  * Replace Edit/Moderate Comment title/headline with Edit {$type}, when editing/moderating a contribution
  *
  * @param  string $translation Translated text.
  * @param  string $text        Text to translate.
  * @return string              Translated text.
  */
 public function filter_edit_comments_screen_translations($translation, $text)
 {
     $replace_texts = array('Edit Comment', 'Moderate Comment');
     // Bail out if not a text we should replace
     if (!in_array($text, $replace_texts)) {
         return $translation;
     }
     global $comment;
     // Try to get comment from query params
     if (!$comment && isset($_GET['action']) && 'editcomment' == $_GET['action'] && isset($_GET['c'])) {
         $comment_id = intval($_GET['c']);
         $comment = get_comment($comment_id);
     }
     // Bail out if no comment type is set
     if (!$comment || !$comment->comment_type) {
         return $translation;
     }
     $contribution_types = wc_product_reviews_pro()->get_contribution_types();
     // Only replace the translated text if we are editing a comment left on a product,
     // which effectively means it's a review
     if (in_array($comment->comment_type, $contribution_types)) {
         $contribution_type = wc_product_reviews_pro_get_contribution_type($comment->comment_type);
         switch ($text) {
             case 'Edit Comment':
                 $translation = $contribution_type->get_edit_text();
                 break;
             case 'Moderate Comment':
                 $translation = $contribution_type->get_moderate_text();
                 break;
         }
     }
     return $translation;
 }
 /**
  * Customize the review product tab
  *
  * Will replace the review tab title with a more generic
  * one if multiple contribution types are enabled, or
  * with a specific title, if only one type is enabled.
  *
  * @since 1.0.0
  * @param array $tabs
  * @return array
  */
 public function customize_review_tab($tabs)
 {
     global $post;
     if (isset($tabs['reviews'])) {
         $enabled_contribution_types = wc_product_reviews_pro()->get_enabled_contribution_types();
         // Do not take contribution_comments into account
         if (($key = array_search('contribution_comment', $enabled_contribution_types)) !== false) {
             unset($enabled_contribution_types[$key]);
         }
         // Hide reviews tab if none of the types are enabled
         if (empty($enabled_contribution_types)) {
             unset($tabs['reviews']);
         } elseif (count($enabled_contribution_types) == 1) {
             $type = $enabled_contribution_types[0];
             $contribution_type = wc_product_reviews_pro_get_contribution_type($type);
             $count = wc_product_reviews_pro_get_comments_number($post->ID, $type);
             $tabs['reviews']['title'] = $contribution_type->get_tab_title($count);
         } else {
             $count = wc_product_reviews_pro_get_comments_number($post->ID, $enabled_contribution_types);
             $contribution_type = wc_product_reviews_pro_get_contribution_type(null);
             $tabs['reviews']['title'] = $contribution_type->get_tab_title($count);
         }
     }
     return $tabs;
 }
Пример #4
0
     */
    do_action('wc_product_reviews_pro_my_account_column_headers');
    ?>

					<th class="contributions-actions">&nbsp;</th>
				</tr>
			</thead>

			<tbody>

			<?php 
    foreach ($comments as $comment) {
        ?>

				<?php 
        $contribution_type = wc_product_reviews_pro_get_contribution_type($comment->comment_type);
        if ($comment->comment_type) {
            $contribution_type_title = $contribution_type->get_title();
        } else {
            $contribution_type_title = __('Comment', WC_Product_Reviews_Pro::TEXT_DOMAIN);
        }
        $product_name = get_the_title($comment->comment_post_ID);
        $product_url = get_permalink($comment->comment_post_ID);
        $rating = get_comment_meta($comment->comment_ID, 'rating', true);
        ?>

				<?php 
        if (get_post_type($comment->comment_post_ID) == 'product') {
            ?>

					<tr class="contribution">
Пример #5
0
	<?php 
// Comments list
?>
	<div id="comments">

		<form method="get" action="#comments" class="contributions-filter">
			<?php 
// Filter options
$options = array('' => __('Show everything', WC_Product_Reviews_Pro::TEXT_DOMAIN));
// Add option for each contribution type
foreach ($contribution_types as $type) {
    if ('contribution_comment' == $type) {
        continue;
    }
    $contribution_type = wc_product_reviews_pro_get_contribution_type($type);
    $options['comment_type=' . $type] = $contribution_type->get_filter_title();
}
// Review qualifier options
$review_qualifiers = wp_get_post_terms($product->id, 'product_review_qualifier');
foreach ($review_qualifiers as $review_qualifier) {
    $qualifier_options = array_filter(explode("\n", get_woocommerce_term_meta($review_qualifier->term_id, 'options')));
    foreach ($qualifier_options as $option) {
        $options['comment_type=review&review_qualifier=' . $review_qualifier->term_id . ':' . $option] = sprintf(__('Show all reviews that said %s is "%s"', WC_Product_Reviews_Pro::TEXT_DOMAIN), $review_qualifier->name, $option);
    }
}
// Special options
$options['comment_type=review&classification=positive&helpful=1'] = __('Show helpful positive reviews', WC_Product_Reviews_Pro::TEXT_DOMAIN);
$options['comment_type=review&classification=negative&helpful=1'] = __('Show helpful negative reviews', WC_Product_Reviews_Pro::TEXT_DOMAIN);
$options['comment_type=question&unanswered=1'] = __('Show unanswered questions', WC_Product_Reviews_Pro::TEXT_DOMAIN);
/**