--- a/customer-reviews-woocommerce/class-ivole.php
+++ b/customer-reviews-woocommerce/class-ivole.php
@@ -84,7 +84,7 @@
require_once( __DIR__ . '/includes/analytics/class-cr-reviews-top-charts.php' );
class Ivole {
- const CR_VERSION = '5.97.0';
+ const CR_VERSION = '5.98.0';
public function __construct() {
if( function_exists( 'wc' ) ) {
--- a/customer-reviews-woocommerce/includes/reminders/class-cr-local-forms-ajax.php
+++ b/customer-reviews-woocommerce/includes/reminders/class-cr-local-forms-ajax.php
@@ -24,10 +24,13 @@
}
public function submit_form() {
- if( isset( $_POST['formId'] ) ) {
+ if ( isset( $_POST['formId'] ) ) {
+ // fetch product recommendations
+ $recommendations = $this->get_recommended_products_html();
+ //
if( CR_Local_Forms::TEST_FORM === $_POST['formId'] ) {
// submission of a test form
- return;
+ wp_send_json_success( $recommendations );
} else {
global $wpdb;
$table_name = $wpdb->prefix . CR_Local_Forms::FORMS_TABLE;
@@ -80,6 +83,7 @@
CR_Endpoint::create_review( $req, true );
};
}
+ wp_send_json_success( $recommendations );
}
}
}
@@ -223,6 +227,109 @@
return $update_result;
}
+ private function get_recommended_products() {
+ if ( ! function_exists( 'wc_get_products' ) ) {
+ return [];
+ }
+
+ $products = wc_get_products( [
+ 'limit' => 3,
+ 'status' => 'publish',
+ 'stock_status' => 'instock',
+ 'visibility' => 'catalog',
+ 'orderby' => 'rand',
+ ] );
+
+ $result = [];
+
+ foreach ( $products as $product ) {
+ $image_id = $product->get_image_id();
+ $image_url = $image_id
+ ? wp_get_attachment_image_url( $image_id, 'woocommerce_thumbnail' )
+ : wc_placeholder_img_src();
+
+ $result[] = [
+ 'name' => $product->get_name(),
+ 'price' => wc_get_price_to_display( $product ),
+ 'rating' => (float) $product->get_average_rating(),
+ 'review_count' => (int) $product->get_review_count(),
+ 'image' => $image_url,
+ 'permalink' => get_permalink( $product->get_id() ),
+ ];
+ }
+
+ return $result;
+ }
+
+ private function get_recommended_products_html() {
+ $products = $this->get_recommended_products();
+
+ if ( empty( $products ) ) {
+ return '';
+ }
+
+ // create HTML to return
+ ob_start();
+ foreach ( $products as $product ) :
+ ?>
+ <div class="cr-form-recommend-prod-container">
+ <div class="cr-form-recommend-prod-price">
+ <?php echo wc_price( $product['price'] ); ?>
+ </div>
+
+ <img
+ src="<?php echo esc_url( $product['image'] ); ?>"
+ alt="<?php echo esc_attr( $product['name'] ); ?>"
+ />
+
+ <div class="cr-form-recommend-prod-content">
+ <h3 class="cr-form-recommend-prod-title">
+ <?php echo esc_html( $product['name'] ); ?>
+ </h3>
+
+ <div class="cr-form-recommend-prod-rating">
+ <div class="cr-form-recommend-prod-rating-top">
+ <div class="cr-form-recommend-prod-rating-rng">
+ <?php echo esc_html( number_format( $product['rating'], 1 ) ); ?>
+ </div>
+ <div class="cr-form-recommend-prod-rating-str">
+ <?php
+ $label = sprintf( __( 'Rated %s out of 5', 'customer-reviews-woocommerce' ), number_format( $product['rating'], 1 ) );
+ $html_star_rating = '<div class="crstar-rating-svg" role="img" aria-label="' . esc_attr( $label ) . '">' . CR_Reviews::get_star_rating_svg( $product['rating'], 0, '' ) . '</div>';
+ echo $html_star_rating;
+ ?>
+ </div>
+ </div>
+ <div class="cr-form-recommend-prod-rating-btm">
+ <?php
+ $count = (int) $product['review_count'];
+ echo esc_html(
+ sprintf(
+ /* translators: %s: number of reviews */
+ _n( '%s review', '%s reviews', $count, 'customer-reviews-woocommerce' ),
+ $count
+ )
+ );
+ ?>
+ </div>
+ </div>
+
+ <a
+ href="<?php echo esc_url( $product['permalink'] ); ?>"
+ class="cr-form-recommend-prod-buy"
+ >
+ <?php esc_html_e( 'View', 'customer-reviews-woocommerce' ); ?>
+ </a>
+ </div>
+ </div>
+ <?php
+ endforeach;
+
+ $html = ob_get_clean();
+
+ return $html;
+ }
+
}
endif;
--- a/customer-reviews-woocommerce/includes/reminders/class-cr-local-forms.php
+++ b/customer-reviews-woocommerce/includes/reminders/class-cr-local-forms.php
@@ -146,6 +146,7 @@
$cr_form_subm_header = __( 'Thank you for submitting a review!', 'customer-reviews-woocommerce' );
$cr_form_subm_desc = __( 'Your response has been recorded.', 'customer-reviews-woocommerce' );
$cr_form_edit_label = __( 'Edit your review', 'customer-reviews-woocommerce' );
+ $cr_form_edit_recom = __( 'Items You May Be Interested In', 'customer-reviews-woocommerce' );
$cr_form_edit = $this->display_name ? true : false;
$cr_form_color1 = $this->cr_form_color1;
$cr_form_color2 = $this->cr_form_color2;
--- a/customer-reviews-woocommerce/includes/reviews/class-cr-endpoint.php
+++ b/customer-reviews-woocommerce/includes/reviews/class-cr-endpoint.php
@@ -313,14 +313,14 @@
if( wp_attachment_is( 'image', $body2->order->items[$i]->media[$m] ) ) {
$media_meta[] = array(
'meta' => CR_Reviews::REVIEWS_META_LCL_IMG,
- 'value' => $body2->order->items[$i]->media[$m]
+ 'value' => esc_url_raw( $body2->order->items[$i]->media[$m] )
);
}
// video
else if( wp_attachment_is( 'video', $body2->order->items[$i]->media[$m] ) ) {
$media_meta[] = array(
'meta' => CR_Reviews::REVIEWS_META_LCL_VID,
- 'value' => $body2->order->items[$i]->media[$m]
+ 'value' => esc_url_raw( $body2->order->items[$i]->media[$m] )
);
}
}
@@ -333,14 +333,14 @@
if( 'image' === $body2->order->items[$i]->media[$m]->type && isset( $body2->order->items[$i]->media[$m]->href ) ) {
$media_meta[] = array(
'meta' => 'ivole_review_image',
- 'value' => array( 'url' => $body2->order->items[$i]->media[$m]->href )
+ 'value' => array( 'url' => esc_url_raw( $body2->order->items[$i]->media[$m]->href ) )
);
}
// video
else if( 'video' === $body2->order->items[$i]->media[$m]->type && isset( $body2->order->items[$i]->media[$m]->href) ) {
$media_meta[] = array(
'meta' => 'ivole_review_video',
- 'value' => array( 'url' => $body2->order->items[$i]->media[$m]->href )
+ 'value' => array( 'url' => esc_url_raw( $body2->order->items[$i]->media[$m]->href ) )
);
}
}
--- a/customer-reviews-woocommerce/includes/reviews/class-cr-reviews-list-table.php
+++ b/customer-reviews-woocommerce/includes/reviews/class-cr-reviews-list-table.php
@@ -1045,8 +1045,8 @@
for ( $i = 0; $i < $pics_n; $i++ ) {
if ( isset( $pics[$i]['url'] ) ) {
echo '<div class="iv-comment-image">';
- echo '<a href="' . $pics[$i]['url'] . $cr_query . '" class="cr-comment-a" rel="nofollow"><img src="' .
- $pics[$i]['url'] . $cr_query . '" alt="' .
+ echo '<a href="' . esc_url( $pics[$i]['url'] . $cr_query ) . '" class="cr-comment-a" rel="nofollow"><img src="' .
+ esc_url( $pics[$i]['url'] . $cr_query ) . '" alt="' .
esc_attr(
sprintf( __( 'Image #%1$d from %2$s', 'customer-reviews-woocommerce' ), $k, $comment->comment_author )
) . '"></a>';
@@ -1066,8 +1066,8 @@
if ( $attachmentUrl ) {
$temp_comment_content_flag = true;
$temp_comment_content .= '<div class="iv-comment-image">';
- $temp_comment_content .= '<a href="' . $attachmentUrl . '" class="cr-comment-a"><img src="' .
- $attachmentUrl . '" alt="' .
+ $temp_comment_content .= '<a href="' . esc_url( $attachmentUrl ) . '" class="cr-comment-a"><img src="' .
+ esc_url( $attachmentUrl ) . '" alt="' .
esc_attr(
sprintf( __( 'Image #%1$d from %2$s', 'customer-reviews-woocommerce' ), $k, $comment->comment_author )
) . '" /></a>';
@@ -1088,7 +1088,7 @@
echo '<div class="cr-comment-video cr-comment-video-' . $k . '">';
echo '<div class="cr-video-cont">';
echo '<video preload="metadata" class="cr-video-a" ';
- echo 'src="' . $pics_v[$i]['url'] . $cr_query . '#t=0.1';
+ echo 'src="' . esc_url( $pics_v[$i]['url'] . $cr_query . '#t=0.1' );
echo '"></video>';
echo '<img class="cr-comment-videoicon" src="' . plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'img/video.svg" ';
echo 'alt="' . esc_attr(
@@ -1112,7 +1112,7 @@
$temp_comment_content .= '<div class="cr-comment-video cr-comment-video-' . $k . '">';
$temp_comment_content .= '<div class="cr-video-cont">';
$temp_comment_content .= '<video preload="metadata" class="cr-video-a" ';
- $temp_comment_content .= 'src="' . $attachmentUrl . '#t=0.1';
+ $temp_comment_content .= 'src="' . esc_url( $attachmentUrl . '#t=0.1' );
$temp_comment_content .= '"></video>';
$temp_comment_content .= '<img class="cr-comment-videoicon" src="' . plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'img/video.svg" ';
$temp_comment_content .= 'alt="' . esc_attr(
--- a/customer-reviews-woocommerce/includes/reviews/class-cr-reviews-media-meta-box.php
+++ b/customer-reviews-woocommerce/includes/reviews/class-cr-reviews-media-meta-box.php
@@ -51,7 +51,7 @@
if ( isset( $pics[$i]['url'] ) ) {
echo '<div class="cr-comment-image">';
echo '<img src="' .
- $pics[$i]['url'] . $cr_query . '" alt="' .
+ esc_url( $pics[$i]['url'] . $cr_query ) . '" alt="' .
esc_attr(
sprintf( __( 'Image #%1$d from %2$s', 'customer-reviews-woocommerce' ), $k_image, $comment->comment_author )
) . '">';
@@ -66,7 +66,7 @@
echo '<div class="cr-comment-video cr-comment-video-' . $k_video . '">';
echo '<div class="cr-video-cont">';
echo '<video preload="metadata" class="cr-video-a" ';
- echo 'src="' . $pics_v[$i]['url'] . $cr_query . '#t=0.1';
+ echo 'src="' . esc_url( $pics_v[$i]['url'] . $cr_query . '#t=0.1' );
echo '"></video>';
echo '<img class="cr-comment-videoicon" src="' . plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'img/video.svg" ';
echo 'alt="' .
@@ -99,7 +99,7 @@
$temp_comment_content .= '<p><span class="cr-comment-image-detach-no">' . __( 'No', 'customer-reviews-woocommerce' ) . '</span>';
$temp_comment_content .= '<span class="cr-comment-image-detach-yes" data-nonce="' . wp_create_nonce( 'cr-upload-images-detach' ) . '" data-attachment="' . $pics_local[$i] . '">' . __( 'Yes', 'customer-reviews-woocommerce' ) . '</span>';
$temp_comment_content .= '</p><span class="cr-comment-image-detach-spinner"></span></div><img src="' .
- $attachmentUrl . '" alt="' .
+ esc_url( $attachmentUrl ) . '" alt="' .
esc_attr(
sprintf( __( 'Image #%1$d from %2$s', 'customer-reviews-woocommerce' ), $k_image, $comment->comment_author )
) . '" /></div>';
@@ -130,7 +130,7 @@
$temp_comment_content .= '</p><span class="cr-comment-image-detach-spinner"></span></div>';
$temp_comment_content .= '<div class="cr-video-cont">';
$temp_comment_content .= '<video preload="metadata" class="cr-video-a" ';
- $temp_comment_content .= 'src="' . $attachmentUrl . '#t=0.1';
+ $temp_comment_content .= 'src="' . esc_url( $attachmentUrl . '#t=0.1' );
$temp_comment_content .= '"></video>';
$temp_comment_content .= '<img class="cr-comment-videoicon" src="' . plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'img/video.svg" ';
$temp_comment_content .= 'alt="' .
--- a/customer-reviews-woocommerce/includes/reviews/class-cr-reviews.php
+++ b/customer-reviews-woocommerce/includes/reviews/class-cr-reviews.php
@@ -239,8 +239,8 @@
for( $i = 0; $i < $pics_n; $i++ ) {
if ( isset( $pics[$i]['url'] ) ) {
$output .= '<div class="iv-comment-image cr-comment-image-ext" data-reviewid="' . $comment->comment_ID . '">';
- $output .= '<a href="' . $pics[$i]['url'] . $cr_query . '" class="cr-comment-a" rel="nofollow"><img src="' .
- $pics[$i]['url'] . $cr_query . '" alt="' .
+ $output .= '<a href="' . esc_url( $pics[$i]['url'] . $cr_query ) . '" class="cr-comment-a" rel="nofollow"><img src="' .
+ esc_url( $pics[$i]['url'] . $cr_query ) . '" alt="' .
esc_attr(
sprintf( __( 'Image #%1$d from %2$s', 'customer-reviews-woocommerce' ), $k, $comment->comment_author )
) . '" loading="lazy"></a>';
@@ -257,8 +257,8 @@
if( $attachmentSrc ) {
$temp_comment_content_flag = true;
$temp_comment_content .= '<div class="iv-comment-image">';
- $temp_comment_content .= '<a href="' . $attachmentSrc[0] . '" class="cr-comment-a"><img src="' .
- $attachmentSrc[0] . '" width="' . $attachmentSrc[1] . '" height="' . $attachmentSrc[2] .
+ $temp_comment_content .= '<a href="' . esc_url( $attachmentSrc[0] ) . '" class="cr-comment-a"><img src="' .
+ esc_url( $attachmentSrc[0] ) . '" width="' . $attachmentSrc[1] . '" height="' . $attachmentSrc[2] .
'" alt="' .
esc_attr(
sprintf( __( 'Image #%1$d from %2$s', 'customer-reviews-woocommerce' ), $k, $comment->comment_author )
@@ -277,7 +277,7 @@
$output .= '<div class="cr-comment-video cr-comment-video-ext cr-comment-video-' . $k . '" data-reviewid="' . $comment->comment_ID . '">';
$output .= '<div class="cr-video-cont">';
$output .= '<video preload="metadata" class="cr-video-a" ';
- $output .= 'src="' . $pics_v[$i]['url'] . $cr_query . '#t=0.1';
+ $output .= 'src="' . esc_url( $pics_v[$i]['url'] . $cr_query . '#t=0.1' );
$output .= '"></video>';
$output .= '<img class="cr-comment-videoicon" src="' . plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'img/video.svg" ';
$output .= 'alt="' .
@@ -299,7 +299,7 @@
$temp_comment_content .= '<div class="cr-comment-video cr-comment-video-' . $k . '">';
$temp_comment_content .= '<div class="cr-video-cont">';
$temp_comment_content .= '<video preload="metadata" class="cr-video-a" ';
- $temp_comment_content .= 'src="' . $attachmentUrl . '#t=0.1';
+ $temp_comment_content .= 'src="' . esc_url( $attachmentUrl . '#t=0.1' );
$temp_comment_content .= '"></video>';
$temp_comment_content .= '<img class="cr-comment-videoicon" src="' . plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'img/video.svg" ';
$temp_comment_content .= 'alt="' .
--- a/customer-reviews-woocommerce/ivole.php
+++ b/customer-reviews-woocommerce/ivole.php
@@ -3,7 +3,7 @@
Plugin Name: Customer Reviews for WooCommerce
Description: Customer Reviews for WooCommerce plugin helps you get more customer reviews for your shop by sending automated reminders and coupons.
Plugin URI: https://wordpress.org/plugins/customer-reviews-woocommerce/
-Version: 5.97.0
+Version: 5.98.0
Author: CusRev
Author URI: https://www.cusrev.com/business/
Text Domain: customer-reviews-woocommerce
--- a/customer-reviews-woocommerce/templates/form-header.php
+++ b/customer-reviews-woocommerce/templates/form-header.php
@@ -34,7 +34,7 @@
.cr-form-header, .cr-form-top-line {
background-color: <?php echo esc_attr( $cr_form_color1 ); ?> !important;
}
- .cr-form-item-title div, .cr-form-customer-title {
+ .cr-form-item-title div, .cr-form-customer-title, .cr-form-recommend-prod-price {
background-color: <?php echo esc_attr( $cr_form_color1 ); ?> !important;
color: <?php echo esc_attr( $cr_form_color2 ); ?> !important;
}
@@ -67,7 +67,7 @@
.cr-form-submit .cr-form-submit-loader::after {
background-color: <?php echo esc_attr( $cr_form_color3 ); ?> !important;
}
- .cr-form-edit {
+ .cr-form-edit, .cr-form-recommend-prod-buy {
color: <?php echo esc_attr( $cr_form_color2 ); ?> !important;
background-color: <?php echo esc_attr( $cr_form_color3 ); ?> !important;
}
@@ -86,6 +86,9 @@
.cr-form-item-media-preview .cr-upload-images-containers .cr-upload-video-thumbnail {
fill: <?php echo esc_attr( $cr_form_color3 ); ?> !important;
}
+ .cr-form-recommend-prod-rating-rng {
+ color: <?php echo esc_attr( $cr_form_color3 ); ?> !important;
+ }
</style>
</head>
<body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="padding:0;">
@@ -110,6 +113,13 @@
</span>
</div>
</div>
+ <div class="cr-form-item-title cr-form-recommend-title">
+ <div>
+ <?php echo esc_html( $cr_form_edit_recom ); ?>
+ </div>
+ </div>
+ </div>
+ <div class="cr-form-recommend-cont">
</div>
<div class="cr-form-content cr-form-body">
<div class="cr-form-title">