WP Product Review Lite - Version 2.9.5

Version Description

Download this release

Release Info

Developer codeinwp
Plugin Icon WP Product Review Lite
Version 2.9.5
Comparing to
See all releases

Code changes from version 2.9.3 to 2.9.5

CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
0
- Added amazon integration support
1
- Fixed some design issues
 
 
 
2
- Added filters for nofollow links in widgets
3
- Added dashes in pros/cons list
 
 
 
4
- Added color options in pro
5
- Fixed issue with shortcode markup
6
- Removed rel=friend
 
 
 
7
- Removed buy now or read review if text values are empty
8
- Fixed undefined notice on plugin activation.
 
 
 
9
- Removed addons page
10
- Changed title and urls
11
- Updated Upsell texts
12
- Apply do_shortcode on all review fields.
 
 
 
13
- Fixed img closing tag issue
14
- Fixed rich snippet error when comment influence is off
 
 
 
15
- Added compatibility with new pro addons
16
- Fixed layout issues with the review
17
- Fixed responsiveness bugs
18
- Fixed bug with enable/disable review box
19
 
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
 
css/frontpage.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- Version: 2.9.2
3
  */
4
  #review-statistics{
5
 
1
  /*
2
+ Version: 2.9.5
3
  */
4
  #review-statistics{
5
 
inc/abtesting/abtesting.php CHANGED
@@ -4,9 +4,11 @@ class TIABTesting
4
  {
5
  private $config;
6
  private $slug;
 
7
 
8
- public function __construct($slug = "")
9
  {
 
10
  $this->loadHooks($slug);
11
  }
12
 
@@ -24,13 +26,17 @@ class TIABTesting
24
  {
25
  $filter = current_filter();
26
  if (strpos($filter, $this->slug) !== false) {
27
- $attr = explode("_", str_replace($this->slug . "_", "", $filter));
28
- if (is_array($attr) && !empty($attr)) {
29
- $section = $attr[0];
30
  if (array_key_exists($section, $this->config)) {
 
 
 
31
  $values = $this->config[$section];
32
  $html = $values[rand(0, count($values) - 1)];
33
- return $escapeHTML ? esc_html($html) : $html;
 
 
34
  }
35
  }
36
  }
4
  {
5
  private $config;
6
  private $slug;
7
+ private $version;
8
 
9
+ public function __construct($slug, $version)
10
  {
11
+ $this->version = str_replace(".", "_", $version);
12
  $this->loadHooks($slug);
13
  }
14
 
26
  {
27
  $filter = current_filter();
28
  if (strpos($filter, $this->slug) !== false) {
29
+ $section = str_replace(array($this->slug . "_", "_upsell_text"), "", $filter);
30
+ if (!empty($section)) {
 
31
  if (array_key_exists($section, $this->config)) {
32
+ // check if a value has already been saved against this slug, version, section
33
+ $savedVal = get_option($this->slug . "_" . $this->version . "_" . $section, "");
34
+ if (!empty($savedVal)) return $savedVal;
35
  $values = $this->config[$section];
36
  $html = $values[rand(0, count($values) - 1)];
37
+ $html = $escapeHTML ? esc_html($html) : $html;
38
+ update_option($this->slug . "_" . $this->version . "_" . $section, $html);
39
+ return $html;
40
  }
41
  }
42
  }
inc/cwp_metabox.php CHANGED
@@ -1,418 +1,369 @@
1
  <?php
2
- function cwp_review_meta_boxes(){
3
- add_meta_box( 'cwp_review_meta_box', 'Product Review Extra Settings', 'cwp_review_meta_box_callback');
4
  }
5
 
6
  /*
7
  * Function for rendering the review custom meta boxes.
8
- */ function cwp_review_meta_box_callback( $post ){
9
- wp_nonce_field( 'cwp_product_review_meta_box_nonce', 'cwp_meta_box_nonce' );
10
- $cwp_review_stored_meta = get_post_meta( $post->ID );
11
- $check = isset( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) ? esc_attr( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) : "No";
12
-
13
- $query_args = array(
14
-
15
- 'posts_per_page'=> '1', // limit it to the specified no of posts
16
- 'post_type' => "any",
17
- 'post__not_in' => get_option('sticky_posts'),
18
- 'meta_key' => 'option_overall_score',
19
-
20
- 'meta_query' => array(
21
-
22
- array(
23
-
24
- 'key' => 'cwp_meta_box_check',
25
-
26
- 'value' => 'Yes',
27
-
28
-
29
- ),
30
-
31
- ),
32
- 'orderby' => 'date',
33
- 'order' => 'DESC'
34
-
35
- );
36
-
37
-
38
-
39
- $cwp_latest_products_loop = get_posts( $query_args );
40
- foreach ( $cwp_latest_products_loop as $w_post ) : setup_postdata( $w_post );
41
- $wppr_id= $w_post->ID;
42
-
43
- endforeach;
44
- wp_reset_postdata();
45
-
46
- $p_meta = isset($wppr_id ) ? get_post_meta ($wppr_id) : array();
47
-
48
- if (isset( $cwp_review_stored_meta['cwp_image_link'][0])) {
49
- $checkset = esc_attr( $cwp_review_stored_meta['cwp_image_link'][0]);
50
- }
51
- else {
52
- $checkset = isset( $p_meta['cwp_image_link'][0] ) ? esc_attr( $p_meta['cwp_image_link'][0] ) : "image";
53
-
54
- }
55
- //$checkset = isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ? ) : "image";
56
-
57
- ?>
58
- <p class="isReview<?php echo $check; ?>">
59
- <label for="my_meta_box_check">Is this a review post ? </label>
60
- <input type="radio" id="cwp_meta_box_check_yes" name="cwp_meta_box_check" value="Yes" <?php checked( $check, 'Yes' ); ?> />
61
- <label for="my_meta_box_check">Yes</label>
62
- <input type="radio" id="cwp_meta_box_check_no" name="cwp_meta_box_check" value="No" <?php checked( $check, 'No' ); ?> />
63
- <label for="my_meta_box_check" style="margin-right:30px;">No</label>
64
-
65
- </p>
66
- <div class="product-review-meta-<?php echo $check; ?>">
67
-
68
- <div class="review-settings-notice">
69
- <h4><?php _e("Product Details", "cwppos"); ?></h4>
70
- <p style="margin:0;"><?php _e("Specify the general details for the reviewed product.", "cwppos"); ?></p>
71
- </div><!-- end .review-settings-notice -->
72
- <div class="review-settings-group">
73
- <div class="review-settings-group-option">
74
- <ul>
75
- <?php
76
- // Added by Ash/Upwork
77
- do_action("wppr-amazon-addfields", $cwp_review_stored_meta);
78
- // Added by Ash/Upwork
79
- ?>
80
-
81
- <li>
82
- <label for="cwp_rev_product_name"><?php _e("Product Name", "cwppos"); ?></label>
83
- <input type="text" name="cwp_rev_product_name" id="cwp_rev_product_name" value="<?php
84
-
85
- if(isset($cwp_review_stored_meta['cwp_rev_product_name'][0])) {
86
- echo $cwp_review_stored_meta['cwp_rev_product_name'][0];
87
- }
88
-
89
- ?>"/>
90
- </li>
91
- <li>
92
- <label for="cwp_rev_product_image" class="cwp_rev_product_image-title"><?php _e( 'Product Image', 'cwp' ) ?></label>
93
- <input type="text" name="cwp_rev_product_image" id="cwp_rev_product_image" value="<?php if ( isset ( $cwp_review_stored_meta['cwp_rev_product_image'][0] ) ) echo $cwp_review_stored_meta['cwp_rev_product_image'][0]; ?>" />
94
- <input type="button" id="cwp_rev_product_image-button" class="button" value="<?php _e( 'Choose or Upload an Image', 'cwp' ) ?>" />
95
- <p><?php _e("*If no image is provided, featured image is used"); ?>
96
- </li>
97
- <li class="cwp_image_link">
98
- <label for="cwp_image_link_aff">Product Image Click : </label>
99
- <input type="radio" id="cwp_image_link_aff" name="cwp_image_link" value="image" <?php checked( $checkset, 'image' ); ?> />
100
- <label for="cwp_image_link_image">Show Whole Image</label>
101
- <input type="radio" id="cwp_image_link_image" name="cwp_image_link" value="link" <?php checked( $checkset, 'link' ); ?> />
102
- <label for="my_meta_box_check">Open Affiliate link</label>
103
- </li>
104
- <li>
105
- <label for="cwp_product_affiliate_text"><?php _e("Affiliate Button Text", "cwppos"); ?></label>
106
- <input type="text" name="cwp_product_affiliate_text" id="cwp_product_affiliate_text" value="<?php
107
-
108
- if(isset($cwp_review_stored_meta['cwp_product_affiliate_text'][0])) {
109
- echo $cwp_review_stored_meta['cwp_product_affiliate_text'][0];
110
- } else {
111
- if(isset($p_meta['cwp_product_affiliate_text'][0]))
112
- echo $p_meta['cwp_product_affiliate_text'][0];
113
- }
114
-
115
- ?>"/>
116
- </li>
117
- <li>
118
- <label for="cwp_product_affiliate_link"><?php _e("Affiliate Link", "cwppos"); ?></label>
119
- <input type="text" name="cwp_product_affiliate_link" id="cwp_product_affiliate_link" value="<?php
120
-
121
- if(isset($cwp_review_stored_meta['cwp_product_affiliate_link'][0])) {
122
- echo $cwp_review_stored_meta['cwp_product_affiliate_link'][0];
123
- }
124
-
125
- ?>"/>
126
- <?php
127
- $hide_button2 = false;
128
- if (!isset($cwp_review_stored_meta['cwp_product_affiliate_text2'][0])) {
129
- $hide_button2 = true;
130
- ?>
131
- <a href="#" id="cwp_add_button" title="Add new button">+</a>
132
- <?php } ?>
133
- </li>
134
-
135
- <li class="<?php if ($hide_button2) echo 'cwp_hide_button2';?>" >
136
- <label for="cwp_product_affiliate_text2"><?php _e("Affiliate Button Text 2", "cwppos"); ?></label>
137
- <input type="text" name="cwp_product_affiliate_text2" id="cwp_product_affiliate_text2" value="<?php
138
-
139
- if(isset($cwp_review_stored_meta['cwp_product_affiliate_text2'][0])) {
140
- echo $cwp_review_stored_meta['cwp_product_affiliate_text2'][0];
141
- }
142
-
143
- ?>"/>
144
- </li>
145
- <li class="<?php if ($hide_button2) echo 'cwp_hide_button2';?>" >
146
- <label for="cwp_product_affiliate_link2"><?php _e("Affiliate Link 2", "cwppos"); ?></label>
147
- <input type="text" name="cwp_product_affiliate_link2" id="cwp_product_affiliate_link2" value="<?php
148
-
149
- if(isset($cwp_review_stored_meta['cwp_product_affiliate_link2'][0])) {
150
- echo $cwp_review_stored_meta['cwp_product_affiliate_link2'][0];
151
- }
152
-
153
- ?>"/>
154
- </li>
155
-
156
- <li>
157
- <label for="cwp_cwp_rev_price"><?php _e("Product Price", "cwppos"); ?></label>
158
- <input type="text" name="cwp_rev_price" id="cwp_rev_price" value="<?php
159
-
160
- if(isset($cwp_review_stored_meta['cwp_rev_price'][0])) {
161
- echo $cwp_review_stored_meta['cwp_rev_price'][0];
162
- }
163
-
164
- ?>"/>
165
- </li>
166
-
167
-
168
- </ul>
169
- </div><!-- end .review-settings-group option -->
170
- </div><!-- end .review-settings group -->
171
- <div class="review-settings-notice">
172
- <h4><?php _e("Product Options Setting", "cwppos"); ?></h4>
173
- <?php _e("Insert your options and their grades. Grading must be done <b><i>from 0 to 100</i></b>.");
174
- if(cwppos("cwppos_show_poweredby") === 'yes' || class_exists('CWP_PR_PRO_Core')|| function_exists('wppr_ep_js_preloader')) { ?>
175
- <a href="#" class="preload_info"><?php _e("Preload Info","cwppos"); ?></a>
176
- <?php
177
- } else {
178
- $pageURL = admin_url('admin.php?page=cwppos_options#tab-upgrade_to_pro');
179
- $pageURL = str_replace(":80","",$pageURL);
180
- echo apply_filters(WPPR_SLUG."_"."preloader"."_upsell_text", "");
181
- } ?>
182
- </div><!-- end .review-settings-notice -->
183
- <div class="review-settings-group">
184
- <?php
185
- for($i=1;$i<=cwppos("cwppos_option_nr");$i++) {?>
186
- <div class="review-settings-group-option">
187
- <label for="option_<?php echo $i;?>_content" class="option_label"><?php echo $i;?></label>
188
- <input type="text" name="option_<?php echo $i;?>_content" id="option_<?php echo $i;?>_content" class="option_content" placeholder="Option <?php echo $i;?>" value="<?php
189
-
190
- if(isset($cwp_review_stored_meta['option_'.$i.'_content'][0])) {
191
- echo $cwp_review_stored_meta['option_'.$i.'_content'][0];
192
- }
193
- else {
194
- //Get latest modified post from the same category id
195
- if (isset($p_meta['option_'.$i.'_content'][0]))
196
- echo $p_meta['option_'.$i.'_content'][0];
197
- }
198
-
199
- ?>"/>
200
- <input type="text" name="option_<?php echo $i;?>_grade" class="option_grade" placeholder="Grade" value="<?php
201
-
202
- if(isset($cwp_review_stored_meta['option_'.$i.'_grade'][0])) {
203
- echo $cwp_review_stored_meta['option_'.$i.'_grade'][0];
204
- }
205
-
206
- ?>"/>
207
- </div><!-- end .review-settings-group option -->
208
- <?php } ?>
209
-
210
- </div><!-- end .review-settings group -->
211
- <div class="cwp_proscons">
212
- <div class="review-settings-notice">
213
- <h4><?php _e("Pro Features", "cwppos"); ?></h4>
214
- <p style="margin:0;"><?php _e("Insert product's pro features below.", "cwppos"); ?></p>
215
- </div><!-- end .review-settings-notice -->
216
- <div class="review-settings-group">
217
- <?php for ($i=1;$i<=cwppos("cwppos_option_nr");$i++) { ?>
218
-
219
- <div class="review-settings-group-option">
220
- <label for="cwp_option_<?php echo $i;?>_pro" class="option_label"><?php echo $i;?></label>
221
- <input type="text" name="cwp_option_<?php echo $i;?>_pro" id="cwp_option_<?php echo $i;?>_pro" class="option_content" placeholder="Option <?php echo $i;?>" value="<?php
222
-
223
- if(isset($cwp_review_stored_meta['cwp_option_'.$i.'_pro'][0])) {
224
- echo $cwp_review_stored_meta['cwp_option_'.$i.'_pro'][0];
225
- }
226
-
227
- ?>"/>
228
- </div><!-- end .review-settings-group option -->
229
- <?php } ?>
230
-
231
- </div><!-- end .review-settings group -->
232
- </div>
233
- <div class="cwp_proscons">
234
- <div class="review-settings-notice">
235
- <h4><?php _e("Cons Features", "cwppos"); ?></h4>
236
- <p style="margin:0;"><?php _e("Insert product's cons features below.", "cwppos"); ?></p>
237
- </div><!-- end .review-settings-notice -->
238
- <div class="review-settings-group">
239
- <?php for ($i=1;$i<=cwppos("cwppos_option_nr");$i++) { ?>
240
-
241
- <div class="review-settings-group-option">
242
- <label for="cwp_option_<?php echo $i;?>_cons" class="option_label"><?php echo $i;?></label>
243
- <input type="text" name="cwp_option_<?php echo $i;?>_cons" id="cwp_option_<?php echo $i;?>_cons" class="option_content" placeholder="Option <?php echo $i;?>" value="<?php
244
-
245
- if(isset($cwp_review_stored_meta['cwp_option_'.$i.'_cons'][0])) {
246
- echo $cwp_review_stored_meta['cwp_option_'.$i.'_cons'][0];
247
- }
248
-
249
- ?>"/>
250
- </div><!-- end .review-settings-group option -->
251
- <?php } ?>
252
-
253
-
254
- </div><!-- end .review-settings group -->
255
- </div>
256
- <?php if(!shortcode_exists("P_REVIEW")): ?>
257
- <label > You can use the shortcode <b>[P_REVIEW]</b> to show a review you already made or <b>[wpr_landing]</b> to display a comparision table of them. The shortcodes are available on the <a target="_blank" href="http://bit.ly/2bpKIlP">Pro Bundle</a><br/><br/></label>
258
- <?php endif; ?>
259
- </div>
260
- <?php
261
  }
262
 
263
  /**
264
  * Function for saving the review custom meta boxes.
265
  */
266
- function cwp_review_meta_boxes_save($post_id){
267
- $is_autosave = wp_is_post_autosave( $post_id );
268
- $is_revision = wp_is_post_revision( $post_id );
269
- $is_valid_nonce = ( isset( $_POST[ 'cwp_meta_box_nonce' ] ) && wp_verify_nonce( $_POST[ 'cwp_meta_box_nonce' ], 'cwp_product_review_meta_box_nonce' ) ) ? 'true' :
270
- 'false';
271
-
272
- if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
273
- return;
274
- }
275
-
276
- // Added by Ash/Upwork
277
- do_action("wppr-amazon-savefields", $post_id);
278
- // Added by Ash/Upwork
279
-
280
- // Moved from inside the if loop to here by Ash/Upwork
281
- if( isset( $_POST[ 'cwp_meta_box_check' ] ) ) {
282
- update_post_meta( $post_id, 'cwp_meta_box_check', sanitize_text_field( $_POST[ 'cwp_meta_box_check' ] ) );
283
- }
284
- // Moved from inside the if loop to here by Ash/Upwork
285
-
286
- if( isset( $_POST[ 'cwp_meta_box_check' ] ) && $_POST[ 'cwp_meta_box_check' ]=="Yes") {
287
-
288
- if( isset( $_POST[ 'cwp_rev_product_name' ] ) ) {
289
- update_post_meta( $post_id, 'cwp_rev_product_name', sanitize_text_field( $_POST[ 'cwp_rev_product_name' ] ) );
290
- }
291
-
292
- if( isset( $_POST[ 'cwp_rev_price' ] ) ) {
293
- update_post_meta( $post_id, 'cwp_rev_price', sanitize_text_field( $_POST[ 'cwp_rev_price' ] ) );
294
- }
295
-
296
- if( isset( $_POST[ 'cwp_image_link' ] ) ) {
297
- update_post_meta( $post_id, 'cwp_image_link', sanitize_text_field( $_POST[ 'cwp_image_link' ] ) );
298
- }
299
-
300
-
301
- if( isset( $_POST[ 'cwp_product_affiliate_text' ] ) ) {
302
- update_post_meta( $post_id, 'cwp_product_affiliate_text', sanitize_text_field( $_POST[ 'cwp_product_affiliate_text' ] ) );
303
- }
304
-
305
-
306
- if( isset( $_POST[ 'cwp_product_affiliate_link' ] ) ) {
307
- update_post_meta( $post_id, 'cwp_product_affiliate_link', esc_url( $_POST[ 'cwp_product_affiliate_link' ] ) );
308
- }
309
-
310
- if( isset( $_POST[ 'cwp_product_affiliate_text2' ] ) ) {
311
- update_post_meta( $post_id, 'cwp_product_affiliate_text2', sanitize_text_field( $_POST[ 'cwp_product_affiliate_text2' ] ) );
312
- }
313
-
314
-
315
- if( isset( $_POST[ 'cwp_product_affiliate_link2' ] ) ) {
316
- update_post_meta( $post_id, 'cwp_product_affiliate_link2', esc_url( $_POST[ 'cwp_product_affiliate_link2' ] ) );
317
- }
318
-
319
- if( !empty($_POST[ 'cwp_bar_icon' ] )) {
320
- update_post_meta( $post_id, 'cwp_bar_icon', esc_url( $_POST[ 'cwp_bar_icon' ] ) );
321
- } else {
322
- update_post_meta( $post_id, 'cwp_bar_icon', "");
323
- }
324
-
325
- for ($i=1;$i<=cwppos("cwppos_option_nr");$i++) {
326
-
327
- if( isset( $_POST[ 'option_'.$i.'_content' ] )) {
328
- update_post_meta( $post_id, 'option_'.$i.'_content', sanitize_text_field( $_POST[ 'option_'.$i.'_content' ] ) );
329
- }
330
-
331
-
332
- if( isset( $_POST[ 'option_'.$i.'_grade' ])) {
333
- update_post_meta( $post_id, 'option_'.$i.'_grade', sanitize_text_field( $_POST[ 'option_'.$i.'_grade' ] ) );
334
- }
335
- }
336
-
337
-
338
-
339
- if( isset( $_POST[ 'cwp_rev_product_image' ] )) {
340
- update_post_meta( $post_id, 'cwp_rev_product_image', sanitize_text_field( $_POST[ 'cwp_rev_product_image' ] ) );
341
- }
342
-
343
- elseif (cwppos("cwppos_show_poweredby") == 'yes' || class_exists('CWP_PR_PRO_Core')) {
344
- $image="";
345
-
346
- if ( strlen( $img = get_the_post_thumbnail( $post_id, array( 150, 150 ) ) ) ) :
347
- $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'optional-size' );
348
- $image = $image_array[0]; else :
349
- $post = get_post($post_id);
350
- $image = '';
351
- ob_start();
352
- ob_end_clean();
353
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
354
- //$image = $matches[1][0];
355
-
356
- endif;
357
- update_post_meta( $post_id, 'cwp_rev_product_image', $image );
358
- }
359
-
360
- for ($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
361
- if( isset( $_POST[ 'cwp_option_'.$i.'_pro' ] ) ) {
362
- update_post_meta( $post_id, 'cwp_option_'.$i.'_pro', sanitize_text_field( $_POST[ 'cwp_option_'.$i.'_pro' ] ) );
363
- }
364
-
365
- if( isset( $_POST[ 'cwp_option_'.$i.'_cons' ] ) ) {
366
- update_post_meta( $post_id, 'cwp_option_'.$i.'_cons', sanitize_text_field( $_POST[ 'cwp_option_'.$i.'_cons' ] ) );
367
- }
368
-
369
- }
370
-
371
- $overall_score = "";
372
- $iter = 0;
373
-
374
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
375
- ${"option".$i."_grade"}= get_post_meta($post_id, "option_".$i."_grade", true);
376
- if(!empty(${"option".$i."_grade"}) || ${"option".$i."_grade"} === '0') {
377
- $overall_score += ${"option".$i."_grade"};
378
- $iter++;
379
- }
380
- }
381
-
382
-
383
-
384
- if($iter == 0){
385
- $overall_score = 0;
386
- } else {
387
- $overall_score = $overall_score / $iter;
388
- }
389
-
390
- update_post_meta($post_id, 'option_overall_score', $overall_score/10);
391
- }
392
  }
393
- function cwp_review_plugin_activation() {
394
-
395
-
396
- if( "yes" != get_option( 'cwp_review_activate' ) ) {
397
 
398
- add_option( 'cwp_review_activate', "yes" );
399
- update_option( 'cwp_review_activate', "yes" );
400
-
401
- $html = '<div class="updated">';
402
- $html .= '<p>';
403
- $html .= __( 'In order to use the WP Product Review plugin, go on a edit a post and set : <strong>Is this a review to yes</strong>.', 'cwppos' );
404
- $html .= '</p>';
405
- $html .= '</div><!-- /.updated -->';
406
-
407
- echo $html;
408
-
409
- } // end if
410
-
411
- } // end plugin_activation
412
  /**
413
  * Hooks.
414
  */
415
  add_action( 'add_meta_boxes', 'cwp_review_meta_boxes' );
416
  add_action( 'save_post', 'cwp_review_meta_boxes_save' );
417
- add_action("admin_notices", "cwp_review_plugin_activation");
418
  ?>
1
  <?php
2
+ function cwp_review_meta_boxes() {
3
+ add_meta_box( 'cwp_review_meta_box', 'Product Review Extra Settings', 'cwp_review_meta_box_callback' );
4
  }
5
 
6
  /*
7
  * Function for rendering the review custom meta boxes.
8
+ */
9
+ function cwp_review_meta_box_callback( $post ) {
10
+ wp_nonce_field( 'cwp_product_review_meta_box_nonce', 'cwp_meta_box_nonce' );
11
+ $cwp_review_stored_meta = get_post_meta( $post->ID );
12
+ $check = isset( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) ? esc_attr( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) : "No";
13
+ $query_args = array(
14
+ 'posts_per_page' => '1', // limit it to the specified no of posts
15
+ 'post_type' => "any",
16
+ 'post__not_in' => get_option( 'sticky_posts' ),
17
+ 'meta_key' => 'option_overall_score',
18
+ 'meta_query' => array(
19
+ array(
20
+ 'key' => 'cwp_meta_box_check',
21
+ 'value' => 'Yes',
22
+ ),
23
+ ),
24
+ 'orderby' => 'date',
25
+ 'order' => 'DESC'
26
+ );
27
+ $cwp_latest_products_loop = get_posts( $query_args );
28
+ foreach ( $cwp_latest_products_loop as $w_post ) : setup_postdata( $w_post );
29
+ $wppr_id = $w_post->ID;
30
+ endforeach;
31
+ wp_reset_postdata();
32
+ $p_meta = isset( $wppr_id ) ? get_post_meta( $wppr_id ) : array();
33
+ if ( isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ) {
34
+ $checkset = esc_attr( $cwp_review_stored_meta['cwp_image_link'][0] );
35
+ } else {
36
+ $checkset = isset( $p_meta['cwp_image_link'][0] ) ? esc_attr( $p_meta['cwp_image_link'][0] ) : "image";
37
+
38
+ }
39
+ //$checkset = isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ? ) : "image";
40
+ ?>
41
+ <p class="isReview<?php echo $check; ?>">
42
+ <label for="my_meta_box_check">Is this a review post ? </label>
43
+ <input type="radio" id="cwp_meta_box_check_yes" name="cwp_meta_box_check"
44
+ value="Yes" <?php checked( $check, 'Yes' ); ?> />
45
+ <label for="my_meta_box_check">Yes</label>
46
+ <input type="radio" id="cwp_meta_box_check_no" name="cwp_meta_box_check"
47
+ value="No" <?php checked( $check, 'No' ); ?> />
48
+ <label for="my_meta_box_check" style="margin-right:30px;">No</label>
49
+
50
+ </p>
51
+ <div class="product-review-meta-<?php echo $check; ?>">
52
+
53
+ <div class="review-settings-notice">
54
+ <h4><?php _e( "Product Details", "cwppos" ); ?></h4>
55
+ <p style="margin:0;"><?php _e( "Specify the general details for the reviewed product.", "cwppos" ); ?></p>
56
+ </div><!-- end .review-settings-notice -->
57
+ <div class="review-settings-group">
58
+ <div class="review-settings-group-option">
59
+ <ul>
60
+ <?php
61
+ // Added by Ash/Upwork
62
+ do_action( "wppr-amazon-addfields", $cwp_review_stored_meta );
63
+ // Added by Ash/Upwork
64
+ ?>
65
+
66
+ <li>
67
+ <label for="cwp_rev_product_name"><?php _e( "Product Name", "cwppos" ); ?></label>
68
+ <input type="text" name="cwp_rev_product_name" id="cwp_rev_product_name" value="<?php
69
+ if ( isset( $cwp_review_stored_meta['cwp_rev_product_name'][0] ) ) {
70
+ echo $cwp_review_stored_meta['cwp_rev_product_name'][0];
71
+ }
72
+ ?>"/>
73
+ </li>
74
+ <li>
75
+ <label for="cwp_rev_product_image"
76
+ class="cwp_rev_product_image-title"><?php _e( 'Product Image', 'cwp' ) ?></label>
77
+ <input type="text" name="cwp_rev_product_image" id="cwp_rev_product_image"
78
+ value="<?php if ( isset ( $cwp_review_stored_meta['cwp_rev_product_image'][0] ) ) {
79
+ echo $cwp_review_stored_meta['cwp_rev_product_image'][0];
80
+ } ?>"/>
81
+ <input type="button" id="cwp_rev_product_image-button" class="button"
82
+ value="<?php _e( 'Choose or Upload an Image', 'cwp' ) ?>"/>
83
+ <p><?php _e( "*If no image is provided, featured image is used" ); ?>
84
+ </li>
85
+ <li class="cwp_image_link">
86
+ <label for="cwp_image_link_aff">Product Image Click : </label>
87
+ <input type="radio" id="cwp_image_link_aff" name="cwp_image_link"
88
+ value="image" <?php checked( $checkset, 'image' ); ?> />
89
+ <label for="cwp_image_link_image">Show Whole Image</label>
90
+ <input type="radio" id="cwp_image_link_image" name="cwp_image_link"
91
+ value="link" <?php checked( $checkset, 'link' ); ?> />
92
+ <label for="my_meta_box_check">Open Affiliate link</label>
93
+ </li>
94
+ <li>
95
+ <label
96
+ for="cwp_product_affiliate_text"><?php _e( "Affiliate Button Text", "cwppos" ); ?></label>
97
+ <input type="text" name="cwp_product_affiliate_text" id="cwp_product_affiliate_text"
98
+ value="<?php
99
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_text'][0] ) ) {
100
+ echo $cwp_review_stored_meta['cwp_product_affiliate_text'][0];
101
+ } else {
102
+ if ( isset( $p_meta['cwp_product_affiliate_text'][0] ) ) {
103
+ echo $p_meta['cwp_product_affiliate_text'][0];
104
+ }
105
+ }
106
+ ?>"/>
107
+ </li>
108
+ <li>
109
+ <label for="cwp_product_affiliate_link"><?php _e( "Affiliate Link", "cwppos" ); ?></label>
110
+ <input type="text" name="cwp_product_affiliate_link" id="cwp_product_affiliate_link"
111
+ value="<?php
112
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_link'][0] ) ) {
113
+ echo $cwp_review_stored_meta['cwp_product_affiliate_link'][0];
114
+ }
115
+ ?>"/>
116
+ <span id="wppr_product_affiliate_link_upsell" style="display: none">&nbsp;</span>
117
+ <?php
118
+ $hide_button2 = false;
119
+ if ( ! isset( $cwp_review_stored_meta['cwp_product_affiliate_text2'][0] ) ) {
120
+ $hide_button2 = true;
121
+ ?>
122
+ <a href="#" id="cwp_add_button" title="Add new button">+</a>
123
+ <?php } ?>
124
+ </li>
125
+
126
+ <li class="<?php if ( $hide_button2 ) {
127
+ echo 'cwp_hide_button2';
128
+ } ?>">
129
+ <label
130
+ for="cwp_product_affiliate_text2"><?php _e( "Affiliate Button Text 2", "cwppos" ); ?></label>
131
+ <input type="text" name="cwp_product_affiliate_text2" id="cwp_product_affiliate_text2"
132
+ value="<?php
133
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_text2'][0] ) ) {
134
+ echo $cwp_review_stored_meta['cwp_product_affiliate_text2'][0];
135
+ }
136
+ ?>"/>
137
+ </li>
138
+ <li class="<?php if ( $hide_button2 ) {
139
+ echo 'cwp_hide_button2';
140
+ } ?>">
141
+ <label for="cwp_product_affiliate_link2"><?php _e( "Affiliate Link 2", "cwppos" ); ?></label>
142
+ <input type="text" name="cwp_product_affiliate_link2" id="cwp_product_affiliate_link2"
143
+ value="<?php
144
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_link2'][0] ) ) {
145
+ echo $cwp_review_stored_meta['cwp_product_affiliate_link2'][0];
146
+ }
147
+ ?>"/>
148
+ </li>
149
+
150
+ <li>
151
+ <label for="cwp_cwp_rev_price"><?php _e( "Product Price", "cwppos" ); ?></label>
152
+ <input type="text" name="cwp_rev_price" id="cwp_rev_price" value="<?php
153
+ if ( isset( $cwp_review_stored_meta['cwp_rev_price'][0] ) ) {
154
+ echo $cwp_review_stored_meta['cwp_rev_price'][0];
155
+ }
156
+ ?>"/>
157
+ </li>
158
+
159
+ </ul>
160
+ </div><!-- end .review-settings-group option -->
161
+ </div><!-- end .review-settings group -->
162
+ <div class="review-settings-notice">
163
+ <h4><?php _e( "Product Options Setting", "cwppos" ); ?></h4>
164
+ <?php _e( "Insert your options and their grades. Grading must be done <b><i>from 0 to 100</i></b>." );
165
+ if ( cwppos( "cwppos_show_poweredby" ) === 'yes' || class_exists( 'CWP_PR_PRO_Core' ) || function_exists( 'wppr_ep_js_preloader' ) ) { ?>
166
+ <a href="#" class="preload_info"><?php _e( "Preload Info", "cwppos" ); ?></a>
167
+ <?php
168
+ } else {
169
+ $pageURL = admin_url( 'admin.php?page=cwppos_options#tab-upgrade_to_pro' );
170
+ $pageURL = str_replace( ":80", "", $pageURL );
171
+ echo apply_filters( WPPR_SLUG . "_" . "preloader" . "_upsell_text", "" );
172
+ } ?>
173
+ </div><!-- end .review-settings-notice -->
174
+ <div class="review-settings-group">
175
+ <?php
176
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) { ?>
177
+ <div class="review-settings-group-option">
178
+ <label for="option_<?php echo $i; ?>_content" class="option_label"><?php echo $i; ?></label>
179
+ <input type="text" name="option_<?php echo $i; ?>_content" id="option_<?php echo $i; ?>_content"
180
+ class="option_content" placeholder="Option <?php echo $i; ?>" value="<?php
181
+ if ( isset( $cwp_review_stored_meta[ 'option_' . $i . '_content' ][0] ) ) {
182
+ echo $cwp_review_stored_meta[ 'option_' . $i . '_content' ][0];
183
+ } else {
184
+ //Get latest modified post from the same category id
185
+ if ( isset( $p_meta[ 'option_' . $i . '_content' ][0] ) ) {
186
+ echo $p_meta[ 'option_' . $i . '_content' ][0];
187
+ }
188
+ }
189
+ ?>"/>
190
+ <input type="text" name="option_<?php echo $i; ?>_grade" class="option_grade" placeholder="Grade"
191
+ value="<?php
192
+ if ( isset( $cwp_review_stored_meta[ 'option_' . $i . '_grade' ][0] ) ) {
193
+ echo $cwp_review_stored_meta[ 'option_' . $i . '_grade' ][0];
194
+ }
195
+ ?>"/>
196
+ </div><!-- end .review-settings-group option -->
197
+ <?php } ?>
198
+
199
+ </div><!-- end .review-settings group -->
200
+ <div class="cwp_proscons">
201
+ <div class="review-settings-notice">
202
+ <h4><?php _e( "Pro Features", "cwppos" ); ?></h4>
203
+ <p style="margin:0;"><?php _e( "Insert product's pro features below.", "cwppos" ); ?></p>
204
+ </div><!-- end .review-settings-notice -->
205
+ <div class="review-settings-group">
206
+ <?php for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) { ?>
207
+
208
+ <div class="review-settings-group-option">
209
+ <label for="cwp_option_<?php echo $i; ?>_pro" class="option_label"><?php echo $i; ?></label>
210
+ <input type="text" name="cwp_option_<?php echo $i; ?>_pro" id="cwp_option_<?php echo $i; ?>_pro"
211
+ class="option_content" placeholder="Option <?php echo $i; ?>" value="<?php
212
+ if ( isset( $cwp_review_stored_meta[ 'cwp_option_' . $i . '_pro' ][0] ) ) {
213
+ echo $cwp_review_stored_meta[ 'cwp_option_' . $i . '_pro' ][0];
214
+ }
215
+ ?>"/>
216
+ </div><!-- end .review-settings-group option -->
217
+ <?php } ?>
218
+
219
+ </div><!-- end .review-settings group -->
220
+ </div>
221
+ <div class="cwp_proscons">
222
+ <div class="review-settings-notice">
223
+ <h4><?php _e( "Cons Features", "cwppos" ); ?></h4>
224
+ <p style="margin:0;"><?php _e( "Insert product's cons features below.", "cwppos" ); ?></p>
225
+ </div><!-- end .review-settings-notice -->
226
+ <div class="review-settings-group">
227
+ <?php for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) { ?>
228
+
229
+ <div class="review-settings-group-option">
230
+ <label for="cwp_option_<?php echo $i; ?>_cons" class="option_label"><?php echo $i; ?></label>
231
+ <input type="text" name="cwp_option_<?php echo $i; ?>_cons"
232
+ id="cwp_option_<?php echo $i; ?>_cons" class="option_content"
233
+ placeholder="Option <?php echo $i; ?>" value="<?php
234
+ if ( isset( $cwp_review_stored_meta[ 'cwp_option_' . $i . '_cons' ][0] ) ) {
235
+ echo $cwp_review_stored_meta[ 'cwp_option_' . $i . '_cons' ][0];
236
+ }
237
+ ?>"/>
238
+ </div><!-- end .review-settings-group option -->
239
+ <?php } ?>
240
+
241
+ </div><!-- end .review-settings group -->
242
+ </div>
243
+ <?php if ( ! shortcode_exists( "P_REVIEW" ) ): ?>
244
+ <label> You can use the shortcode <b>[P_REVIEW]</b> to show a review you already made or
245
+ <b>[wpr_landing]</b> to display a comparision table of them. The shortcodes are available on the <a
246
+ target="_blank" href="http://bit.ly/2bpKIlP">Pro Bundle</a><br/><br/></label>
247
+ <?php endif; ?>
248
+ </div>
249
+ <?php
 
 
 
 
 
 
 
 
 
 
 
250
  }
251
 
252
  /**
253
  * Function for saving the review custom meta boxes.
254
  */
255
+ function cwp_review_meta_boxes_save( $post_id ) {
256
+ $is_autosave = wp_is_post_autosave( $post_id );
257
+ $is_revision = wp_is_post_revision( $post_id );
258
+ $is_valid_nonce = ( isset( $_POST['cwp_meta_box_nonce'] ) && wp_verify_nonce( $_POST['cwp_meta_box_nonce'], 'cwp_product_review_meta_box_nonce' ) ) ? 'true' :
259
+ 'false';
260
+ if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
261
+ return;
262
+ }
263
+ // Added by Ash/Upwork
264
+ do_action( "wppr-amazon-savefields", $post_id );
265
+ // Added by Ash/Upwork
266
+ // Moved from inside the if loop to here by Ash/Upwork
267
+ if ( isset( $_POST['cwp_meta_box_check'] ) ) {
268
+ update_post_meta( $post_id, 'cwp_meta_box_check', sanitize_text_field( $_POST['cwp_meta_box_check'] ) );
269
+ }
270
+ // Moved from inside the if loop to here by Ash/Upwork
271
+ if ( isset( $_POST['cwp_meta_box_check'] ) && $_POST['cwp_meta_box_check'] == "Yes" ) {
272
+ if ( isset( $_POST['cwp_rev_product_name'] ) ) {
273
+ update_post_meta( $post_id, 'cwp_rev_product_name', sanitize_text_field( $_POST['cwp_rev_product_name'] ) );
274
+ }
275
+ if ( isset( $_POST['cwp_rev_price'] ) ) {
276
+ update_post_meta( $post_id, 'cwp_rev_price', sanitize_text_field( $_POST['cwp_rev_price'] ) );
277
+ }
278
+ if ( isset( $_POST['cwp_image_link'] ) ) {
279
+ update_post_meta( $post_id, 'cwp_image_link', sanitize_text_field( $_POST['cwp_image_link'] ) );
280
+ }
281
+ if ( isset( $_POST['cwp_product_affiliate_text'] ) ) {
282
+ update_post_meta( $post_id, 'cwp_product_affiliate_text', sanitize_text_field( $_POST['cwp_product_affiliate_text'] ) );
283
+ }
284
+ if ( isset( $_POST['cwp_product_affiliate_link'] ) ) {
285
+ update_post_meta( $post_id, 'cwp_product_affiliate_link', esc_url( $_POST['cwp_product_affiliate_link'] ) );
286
+ }
287
+ if ( isset( $_POST['cwp_product_affiliate_text2'] ) ) {
288
+ update_post_meta( $post_id, 'cwp_product_affiliate_text2', sanitize_text_field( $_POST['cwp_product_affiliate_text2'] ) );
289
+ }
290
+ if ( isset( $_POST['cwp_product_affiliate_link2'] ) ) {
291
+ update_post_meta( $post_id, 'cwp_product_affiliate_link2', esc_url( $_POST['cwp_product_affiliate_link2'] ) );
292
+ }
293
+ if ( ! empty( $_POST['cwp_bar_icon'] ) ) {
294
+ update_post_meta( $post_id, 'cwp_bar_icon', esc_url( $_POST['cwp_bar_icon'] ) );
295
+ } else {
296
+ update_post_meta( $post_id, 'cwp_bar_icon', "" );
297
+ }
298
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
299
+ if ( isset( $_POST[ 'option_' . $i . '_content' ] ) ) {
300
+ update_post_meta( $post_id, 'option_' . $i . '_content', sanitize_text_field( $_POST[ 'option_' . $i . '_content' ] ) );
301
+ }
302
+ if ( isset( $_POST[ 'option_' . $i . '_grade' ] ) ) {
303
+ update_post_meta( $post_id, 'option_' . $i . '_grade', sanitize_text_field( $_POST[ 'option_' . $i . '_grade' ] ) );
304
+ }
305
+ }
306
+ if ( isset( $_POST['cwp_rev_product_image'] ) ) {
307
+ update_post_meta( $post_id, 'cwp_rev_product_image', sanitize_text_field( $_POST['cwp_rev_product_image'] ) );
308
+ } elseif ( cwppos( "cwppos_show_poweredby" ) == 'yes' || class_exists( 'CWP_PR_PRO_Core' ) ) {
309
+ $image = "";
310
+ if ( strlen( $img = get_the_post_thumbnail( $post_id, array( 150, 150 ) ) ) ) :
311
+ $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'optional-size' );
312
+ $image = $image_array[0];
313
+ else :
314
+ $post = get_post( $post_id );
315
+ $image = '';
316
+ ob_start();
317
+ ob_end_clean();
318
+ $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
319
+ //$image = $matches[1][0];
320
+ endif;
321
+ update_post_meta( $post_id, 'cwp_rev_product_image', $image );
322
+ }
323
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
324
+ if ( isset( $_POST[ 'cwp_option_' . $i . '_pro' ] ) ) {
325
+ update_post_meta( $post_id, 'cwp_option_' . $i . '_pro', sanitize_text_field( $_POST[ 'cwp_option_' . $i . '_pro' ] ) );
326
+ }
327
+ if ( isset( $_POST[ 'cwp_option_' . $i . '_cons' ] ) ) {
328
+ update_post_meta( $post_id, 'cwp_option_' . $i . '_cons', sanitize_text_field( $_POST[ 'cwp_option_' . $i . '_cons' ] ) );
329
+ }
330
+
331
+ }
332
+ $overall_score = "";
333
+ $iter = 0;
334
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
335
+ ${"option" . $i . "_grade"} = get_post_meta( $post_id, "option_" . $i . "_grade", true );
336
+ if ( ! empty( ${"option" . $i . "_grade"} ) || ${"option" . $i . "_grade"} === '0' ) {
337
+ $overall_score += ${"option" . $i . "_grade"};
338
+ $iter ++;
339
+ }
340
+ }
341
+ if ( $iter == 0 ) {
342
+ $overall_score = 0;
343
+ } else {
344
+ $overall_score = $overall_score / $iter;
345
+ }
346
+ update_post_meta( $post_id, 'option_overall_score', $overall_score / 10 );
347
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  }
 
 
 
 
349
 
350
+ function cwp_review_plugin_activation() {
351
+ if ( "yes" != get_option( 'cwp_review_activate' ) ) {
352
+ add_option( 'cwp_review_activate', "yes" );
353
+ update_option( 'cwp_review_activate', "yes" );
354
+ $html = '<div class="updated">';
355
+ $html .= '<p>';
356
+ $html .= __( 'In order to use the WP Product Review plugin, go on a edit a post and set : <strong>Is this a review to yes</strong>.', 'cwppos' );
357
+ $html .= '</p>';
358
+ $html .= '</div><!-- /.updated -->';
359
+ echo $html;
360
+
361
+ } // end if
362
+ } // end plugin_activation
 
363
  /**
364
  * Hooks.
365
  */
366
  add_action( 'add_meta_boxes', 'cwp_review_meta_boxes' );
367
  add_action( 'save_post', 'cwp_review_meta_boxes_save' );
368
+ add_action( "admin_notices", "cwp_review_plugin_activation" );
369
  ?>
inc/wppr-filters.php CHANGED
@@ -84,3 +84,19 @@ function wppr_review_cons_text_filter( $id = 0, $name = '' ) {
84
  return ( ! empty( $name ) ) ? '<h2>'.$name.'</h2>' : '';
85
 
86
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  return ( ! empty( $name ) ) ? '<h2>'.$name.'</h2>' : '';
85
 
86
  }
87
+
88
+
89
+ add_filter( 'wppr_admin_pointers-post', 'wppr_admin_pointers' );
90
+ function wppr_admin_pointers( $p ) {
91
+ $p['amazon_upsell'] = array(
92
+ 'target' => '#wppr_product_affiliate_link_upsell',
93
+ 'options' => array(
94
+ 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
95
+ apply_filters("wppr_amazon_title_upsell_text", null),
96
+ apply_filters("wppr_amazon_body_upsell_text", null)
97
+ ),
98
+ 'position' => array( 'edge' => 'left', 'align' => 'left' )
99
+ )
100
+ );
101
+ return $p;
102
+ }
inc/wppr-main.php CHANGED
@@ -6,427 +6,394 @@
6
  * @since 1.0.0
7
  *
8
  */
9
-
10
-
11
- function cwppos_calc_overall_rating($id){
12
  $options = cwppos();
13
-
14
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
15
-
16
- ${"option".$i."_grade"} = get_post_meta($id, "option_".$i."_grade", true);
17
  // echo ${"option".$i."_grade"};
18
-
19
- ${"comment_meta_option_nr_".$i} = 0;
20
- ${"comment_meta_option_".$i} = 0;
21
 
22
  }
23
  $nr_of_comments = 0;
24
- if( $options['cwppos_show_userreview'] == "yes" ) {
25
- $args = array(
26
- 'status' => 'approve',
27
  'post_id' => $id, // use post_id, not post_ID
28
  );
29
- $comments = get_comments($args);
30
- $nr_of_comments = get_comments_number($id);
31
-
32
- foreach($comments as $comment) :
33
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
34
-
35
- if (get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true)!=='') {
36
- ${"comment_meta_option_nr_".$i}++;
37
- ${"comment_meta_option_".$i} += get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true)*10;
38
  }
39
 
40
-
41
  //var_dump(${"comment_meta_option_".$i});
42
  }
43
-
44
-
45
  endforeach;
46
-
47
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
48
- if (${"comment_meta_option_nr_".$i}!==0)
49
- ${"comment_meta_option_".$i} = ${"comment_meta_option_".$i}/${"comment_meta_option_nr_".$i};
50
  }
51
 
52
- }
53
- else {
54
  $options['cwppos_infl_userreview'] = 0;
55
  }
56
- if ( $nr_of_comments==0 )
57
  $options['cwppos_infl_userreview'] = 0;
58
-
59
  $overall_score = 0;
60
- $iter = 0;
61
- $rating = array();
62
-
63
- for ($i=1;$i<=cwppos("cwppos_option_nr");$i++) {
64
-
65
- if (${"comment_meta_option_nr_".$i}!==0)
66
  $infl = $options['cwppos_infl_userreview'];
67
- else {
68
  $infl = 0;
69
 
70
  }
71
- if(!empty(${'option'.$i.'_grade'})|| ${'option'.$i.'_grade'} === '0') {
72
  //if($infl !== 0 ){
73
- ${'option'.$i.'_grade'} = round((${'option'.$i.'_grade'}*(100-$infl) + ${'comment_meta_option_'.$i}*$infl)/100);
74
  //}else{
75
-
76
  //}
77
- $iter++;
78
- $rating['option'.$i] = round(${'option'.$i.'_grade'});
79
- $overall_score+=${'option'.$i.'_grade'};
80
  }
81
  }
82
  //$overall_score = ($option1_grade + $option2_grade + $option3_grade + $option4_grade + $option5_grade) / $iter;
83
- if ($iter !==0) $rating['overall'] = $overall_score/$iter;
84
- else $rating['overall'] = 0;
85
- update_post_meta($id, 'option_overall_score', $rating['overall']);
86
- return $rating;
 
 
87
 
 
88
 
89
  }
90
 
91
- function cwppos_show_review($id="", $visual="full") {
92
  global $post;
93
- if ( post_password_required($post) ) return false;
94
-
95
- if ($id=="") {
 
96
  $id = $post->ID;
97
- }
98
  $cwp_review_stored_meta = get_post_meta( $id );
99
- $return_string = "";
100
- if(@$cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' ) {
101
-
102
- wp_enqueue_style( 'cwp-pac-frontpage-stylesheet', WPPR_URL.'/css/frontpage.css',array(),WPPR_LITE_VERSION );
103
- wp_enqueue_script( 'pie-chart', WPPR_URL.'/javascript/pie-chart.js',array("jquery"), WPPR_LITE_VERSION,true );
104
- wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL.'/javascript/main.js',array("jquery",'pie-chart'),WPPR_LITE_VERSION,true );
105
- $cwp_price = get_post_meta($id, "cwp_rev_price", true);
106
- $p_string = $cwp_price;
107
- $p_name = apply_filters("wppr_review_product_name", $id) ;
108
-
109
- if ($p_string!="") {
110
- // Added by Ash/Upwork
111
- $cwp_price = do_shortcode($cwp_price);
112
- // Added by Ash/Upwork
113
-
114
- $p_price = preg_replace("/[^0-9.,]/","",$cwp_price);
115
- $p_currency = preg_replace("/[0-9.,]/","",$cwp_price);
116
-
117
- // Added by Ash/Upwork
118
- $p_disable = apply_filters("wppr_disable_price_richsnippet", FALSE);
119
- // Added by Ash/Upwork
120
- if(!$p_disable){
121
- $p_string = '<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span itemprop="priceCurrency">'.$p_currency.'</span><span itemprop="price">'.$p_price.'</span></span>';
122
- }
123
 
124
  }
125
-
126
- $product_image = do_shortcode(get_post_meta($id, "cwp_rev_product_image", true));
127
- $imgurl = do_shortcode(get_post_meta($id, "cwp_image_link", true));
128
- $lightbox = "";
129
- $feat_image = wp_get_attachment_url( get_post_thumbnail_id( $id ) );
130
-
131
- if(!empty($product_image)) {
132
- $product_image_cropped = wppr_get_image_id($id,$product_image);
133
  } else {
134
- $product_image_cropped = wppr_get_image_id($id);
135
- $product_image = $feat_image;
136
  }
137
-
138
- if ($imgurl =="image") {
139
-
140
  //no means no disabled
141
- if(cwppos("cwppos_lighbox") == "no"){
142
- $lightbox = 'data-lightbox="' . $product_image . '"';
143
- wp_enqueue_script("img-lightbox",WPPR_URL.'/javascript/lightbox.min.js',array(), WPPR_LITE_VERSION, array());
144
- wp_enqueue_style("img-lightbox-css", WPPR_URL.'/css/lightbox.css' , array(), WPPR_LITE_VERSION );
145
  }
146
- }else{
147
- $product_image = do_shortcode(get_post_meta($id, "cwp_product_affiliate_link", true));
148
  }
149
-
150
- $rating = cwppos_calc_overall_rating($id);
151
- $divrating = $rating['overall']/10;
152
-
153
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
154
- ${"option".$i."_content"} = do_shortcode(get_post_meta($id, "option_".$i."_content", true));
155
-
156
- if(empty(${"option".$i."_content"})) {
157
- ${"option".$i."_content"} = __("Default Feature ".$i, "cwppos");
158
  }
159
  }
160
-
161
- $commentNr = get_comments_number($id)+1;
162
-
163
- if ($visual == "full") {
164
- $return_string .= '<section id="review-statistics" class="article-section" itemscope itemtype="http://schema.org/Product">
165
  <div class="review-wrap-up cwpr_clearfix" >
166
  <div class="cwpr-review-top cwpr_clearfix">
167
- <span itemprop="name">' . $p_name. '</span>
168
 
169
- <span class="cwp-item-price cwp-item">'.$p_string.'</span>
170
  </div><!-- end .cwpr-review-top -->
171
  <div class="review-wu-left">
172
  <div class="rev-wu-image">
173
- <a href="'.$product_image.'" '.$lightbox.' rel="nofollow" target="_blank"><img itemprop="image" src="'.$product_image_cropped.'" alt="'. do_shortcode(get_post_meta($id, "cwp_rev_product_name", true)).'" class="photo photo-wrapup wppr-product-image" /></a>
174
  </div><!-- end .rev-wu-image -->
175
  <div class="review-wu-grade">';
176
- }
177
- if ($visual == "full" || $visual == "yes") {
178
- $extra_class = $visual == "yes" ? "cwp-chart-embed" : "";
179
- $return_string .= '<div class="cwp-review-chart ' . $extra_class . '">
180
- <meta itemprop="datePublished" datetime="'.get_the_time("Y-m-d", $id).'">';
181
- if(cwppos("cwppos_infl_userreview") != 0 && $commentNr>1) {
182
- $return_string .= '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="cwp-review-percentage" data-percent="';
183
- $return_string .= $rating['overall'] . '"><span itemprop="ratingValue" class="cwp-review-rating">' . $divrating . '</span><meta itemprop="bestRating" content = "10"/>
184
  <meta itemprop="ratingCount" content="' . $commentNr . '"> </div>';
185
 
186
- } else {
187
- $return_string .= '<span itemscope itemtype="http://schema.org/Review"><span itemprop="author" itemscope itemtype="http://schema.org/Person" >
188
- <meta itemprop="name" content="'.get_the_author().'"/>
189
- </span><span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product"><meta itemprop="name" content="'.do_shortcode(get_post_meta($id,'cwp_rev_product_name',true)).'"/></span><div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="cwp-review-percentage" data-percent="';
190
- $return_string .= $rating['overall'] . '"><span itemprop="ratingValue" class="cwp-review-rating">' . $divrating . '</span> <meta itemprop="bestRating" content="10"> </div></span>';
191
- }
192
-
193
- $return_string .= '</div><!-- end .chart -->';
194
- }
195
-
196
- if ($visual == "full") {
197
- $return_string .= '</div><!-- end .review-wu-grade -->
198
  <div class="review-wu-bars">';
199
-
200
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
201
- if (!empty(${'option'.$i.'_content'}) && isset($rating['option'.$i]) && (!empty($rating['option'.$i]) || $rating['option'.$i] === '0' ) && strtoupper(${'option'.$i.'_content'}) != 'DEFAULT FEATURE '.$i) {
202
- $return_string .= '<div class="rev-option" data-value='.$rating['option'.$i].'>
203
  <div class="cwpr_clearfix">
204
- '.apply_filters("wppr_option_name_html",$id, ${'option'.$i.'_content'} ).'
205
- <span>'.round($rating['option'.$i]/10).'/10</span>
206
  </div>
207
  <ul class="cwpr_clearfix"></ul>
208
  </div>';
209
- }
210
- }
211
-
212
- $return_string .='</div><!-- end .review-wu-bars -->
213
  </div><!-- end .review-wu-left -->
214
  <div class="review-wu-right">
215
  <div class="pros">';
216
- }
217
-
218
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
219
- ${"pro_option_".$i} = do_shortcode(get_post_meta($id, "cwp_option_".$i."_pro", true));
220
- if(empty(${"pro_option_".$i})) {
221
- ${"pro_option_".$i} = "" ;
222
  }
223
  }
224
-
225
- for($i=1; $i<=cwppos("cwppos_option_nr"); $i++) {
226
- ${"cons_option_".$i} = do_shortcode(get_post_meta($id, "cwp_option_".$i."_cons", true));
227
- if(empty(${"cons_option_".$i})) {
228
- ${"cons_option_".$i} = "";
229
  }
230
 
231
  }
232
-
233
- if ($visual == "full") {
234
- $return_string .= apply_filters( 'wppr_review_pros_text',$id, __(cwppos("cwppos_pros_text"), "cwppos")).' <ul>';
235
- for($i=1;$i<=cwppos("cwppos_option_nr");$i++) {
236
- if(!empty(${"pro_option_".$i})) {
237
- $return_string .= ' <li>'.${"pro_option_".$i}.'</li>';
238
- }
239
- }
240
-
241
- $return_string .= ' </ul>
242
  </div><!-- end .pros -->
243
  <div class="cons">';
244
- $return_string .= apply_filters( 'wppr_review_cons_text',$id, __(cwppos("cwppos_cons_text"), "cwppos")).' <ul>';
245
-
246
- for($i=1;$i<=cwppos("cwppos_option_nr");$i++){
247
- if(!empty(${"cons_option_".$i})) {
248
- $return_string .= ' <li>'.${"cons_option_".$i}.'</li>';
249
- }
250
-
251
- }
252
 
253
- $return_string .='
 
254
  </ul>
255
  </div>
256
  </div><!-- end .review-wu-right -->
257
  </div><!-- end .review-wrap-up -->
258
  </section><!-- end #review-statistics -->';
259
- }
260
-
261
- if(cwppos("cwppos_show_poweredby") == 'yes' && !class_exists('CWP_PR_PRO_Core')) {
262
- $return_string.='<div style="font-size:12px;width:100%;float:right"><p style="float:right;">Powered by <a href="http://wordpress.org/plugins/wp-product-review/" target="_blank" rel="nofollow" > WP Product Review</a></p></div>';
263
  }
264
-
265
- $affiliate_text = do_shortcode(get_post_meta($id, "cwp_product_affiliate_text", true));
266
- $affiliate_link = do_shortcode(get_post_meta($id, "cwp_product_affiliate_link", true));
267
- $affiliate_text2 = do_shortcode(get_post_meta($id, "cwp_product_affiliate_text2", true));
268
- $affiliate_link2 = do_shortcode(get_post_meta($id, "cwp_product_affiliate_link2", true));
269
-
270
- if(!empty($affiliate_text2) && !empty($affiliate_link2)) {
271
- $bclass="affiliate-button2 affiliate-button";
 
272
  } else {
273
- $bclass="affiliate-button";
274
- }
275
-
276
- if($visual == "full" && !empty($affiliate_text) && !empty($affiliate_link)) {
277
- $return_string .= '<div class="'.$bclass.'">
278
- <a href="'.$affiliate_link.'" rel="nofollow" target="_blank"><span>'. $affiliate_text.'</span> </a>
279
  </div><!-- end .affiliate-button -->';
280
  }
281
-
282
- if($visual == "full" && !empty($affiliate_text2) && !empty($affiliate_link2)) {
283
  $return_string .= '<div class="affiliate-button affiliate-button2">
284
- <a href="'.$affiliate_link2.'" rel="nofollow" target="_blank"><span>'. $affiliate_text2.'</span> </a>
285
  </div><!-- end .affiliate-button -->';
286
  }
287
-
288
- if ($visual == "no") {
289
- $return_string = round($divrating);
290
- }
291
  }
292
 
293
  return $return_string;
294
  }
295
 
296
-
297
-
298
  function cwppos_pac_admin_init() {
299
- wp_enqueue_style( 'cwp-pac-admin-stylesheet', WPPR_URL.'/css/dashboard_styles.css' );
300
- wp_register_script( 'cwp-pac-script', WPPR_URL.'/javascript/admin-review.js',array("jquery"),"20140101",true );
301
- wp_localize_script( 'cwp-pac-script', 'ispro', array( 'value' => class_exists('CWP_PR_PRO_Core') ) );
302
- wp_enqueue_script('cwp-pac-script' );
303
-
304
- if(class_exists('CWP_PR_PRO_Core'))
305
- wp_enqueue_style( 'cwp-pac-pro-admin-stylesheet', WPPR_URL.'/css/pro_dashboard_styles.css' );
306
-
307
- // Added by Ash/Upwork
308
- do_action("wppr-amazon-enqueue");
309
- // Added by Ash/Upwork
310
  }
311
 
312
- function wppr_get_image_id($post_id, $image_url = "", $size = "thumbnail" ) {
313
-
314
  global $wpdb;
315
  //filter for image size;
316
- $size = apply_filters("wppr_review_image_size",$size,$post_id);
317
-
318
- if(!empty($image_url) && $image_url !== false ) {
319
-
320
- $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
321
- $image_id = isset($attachment[0]) ? $attachment[0] : '';
322
- }else{
323
- $image_id = get_post_thumbnail_id($post_id );
324
 
325
  }
326
  $image_thumb = "";
327
- if(!empty($image_id)){
328
- $image_thumb = wp_get_attachment_image_src($image_id, $size);
329
-
330
- if( $size !== 'thumbnail' ) {
331
- if($image_thumb[0] === $image_url){
332
- $image_thumb = wp_get_attachment_image_src($image_id, "thumbnail");
333
  }
334
  }
335
  }
336
- return isset($image_thumb[0]) ? $image_thumb[0] : $image_url;
337
- }
338
 
 
 
339
 
340
  function custom_bar_icon() {
341
  $options = cwppos();
 
 
 
 
 
 
342
 
343
- if (( isset($options['cwppos_show_poweredby']) && $options['cwppos_show_poweredby'] == "yes" ) || function_exists("wppr_ci_custom_bar_icon") || class_exists('CWP_PR_PRO_Core')) {
344
- wp_register_script("cwp-custom-bar-icon", WPPR_URL.'/javascript/custom-bar-icon.js', false, "1.0", "all");
345
- wp_enqueue_script("cwp-custom-bar-icon");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
  }
 
 
 
 
347
  }
348
 
349
  function cwppos_pac_register() {
350
- add_image_size("wppr_widget_image",50,50);
351
  }
352
 
353
  function cwp_def_settings() {
354
  global $post;
355
  $options = cwppos();
356
- if (function_exists('wppr_ci_custom_bar_icon') || ( isset($options['cwppos_show_poweredby']) && $options['cwppos_show_poweredby']=="yes" ) ) {
357
  $isSetToPro = true;
358
  } else {
359
  $isSetToPro = false;
360
  }
361
-
362
- $uni_font = cwppos("cwppos_change_bar_icon");
363
- $track = $options['cwppos_rating_chart_default'];
364
-
365
  //if ($uni_font!=="&#")
366
-
367
- if(isset($uni_font[0])) { if ($uni_font[0]=="#") $uni_font = $uni_font; else $uni_font = $uni_font[0]; } else { $uni_font = ""; }
368
-
369
- if(!empty($uni_font)){
370
- if(function_exists("wppr_ci_custom_bar_icon") || cwppos('cwppos_show_poweredby') == 'yes'){
371
- if(cwppos("cwppos_fontawesome") === "no"){
372
- wp_enqueue_style( 'cwp-pac-fontawesome-stylesheet', WPPR_URL.'/css/font-awesome.min.css' );
 
 
 
 
 
 
373
  }
374
  }
375
  }
376
- echo "<script type='text/javascript'>
377
  var cwpCustomBarIcon = '" . $uni_font . "';
378
- var isSetToPro = '".$isSetToPro."';
379
- var trackcolor = '".$track."';
380
  </script>";
381
  }
382
 
383
  function cwppos_pac_print() {
384
- //global $add_my_script;
385
- global $post;
386
- //echo get_post_meta($post->ID, "cwp_rev_product_name", true);
387
-
388
-
389
- /*wp_print_styles('cwp-pac-frontpage-stylesheet');
390
- wp_print_styles('cwp-pac-widget-stylesheet');
391
- wp_print_styles('jqueryui');
392
- wp_print_styles('cwp-pac-fontawesome-stylesheet');
393
- //wp_print_styles('cwp-pac-widget-stylesheet');
394
- wp_print_scripts('jquery-ui-core');
395
- wp_print_scripts('jquery-ui-slider');
396
- wp_print_scripts('pie-chart');
397
- wp_print_scripts('cwp-pac-main-script');
398
- wp_print_scripts('img-lightbox');
399
- wp_print_styles('img-lightbox-css');*/
400
-
401
  cwp_def_settings();
402
-
403
-
404
  }
405
 
406
-
407
  function cwppos_dynamic_stylesheet() {
408
  $options = cwppos();
409
  //Get theme content width or plugin setting content width
410
  global $content_width;
411
  $c_width = 700;
412
- if ($options['cwppos_widget_size']!="")
413
  $c_width = $options['cwppos_widget_size'];
414
- else
415
  $c_width = $content_width;
416
-
417
- if ($c_width<200)
418
  $c_width = 600;
419
-
420
- $f_img_size = min(180,$c_width*0.51*0.4);
421
- $h_tleft = $f_img_size +10;
422
  $chart_size = 0.8 * $f_img_size;
423
-
424
  ?>
425
  <style type="text/css">
426
 
427
-
428
  @media (min-width: 820px) {
429
- #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade { height:<?php echo $h_tleft;?>px;}
 
 
430
 
431
  #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
432
 
@@ -437,17 +404,21 @@ function cwppos_dynamic_stylesheet() {
437
  font-size: <?php echo round(30*$f_img_size/140);?>px;
438
  }
439
 
440
- <?php if ($options['cwppos_widget_size']!="") { ?>
441
- #review-statistics{
442
- width:<?php echo $options['cwppos_widget_size']; ?>px;
443
- }
444
- <?php } ?>
 
 
 
445
 
 
 
446
  }
447
 
448
- #review-statistics .review-wrap-up div.cwpr-review-top { border-top: <?php echo $options['cwppos_reviewboxbd_width']; ?>px solid <?php echo $options['cwppos_reviewboxbd_color']; ?>; }
449
  .user-comments-grades .comment-meta-grade-bar,
450
- #review-statistics .review-wu-bars ul li{
451
  background: <?php echo $options['cwppos_rating_default']; ?>;
452
  }
453
 
@@ -455,68 +426,92 @@ function cwppos_dynamic_stylesheet() {
455
  color: <?php echo $options['cwppos_rating_default']; ?>;
456
  }
457
 
458
-
459
- #review-statistics .review-wrap-up .review-wu-right ul li,#review-statistics .review-wu-bars h3, .review-wu-bars span,#review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category a{
460
- color: <?php echo $options['cwppos_font_color']; ?>;
461
  }
 
462
  #review-statistics .review-wrap-up .review-wu-right .pros h2 {
463
- color: <?php echo $options['cwppos_pros_color']; ?>;
464
  }
465
- #review-statistics .review-wrap-up .review-wu-right .cons h2{
466
- color: <?php echo $options['cwppos_cons_color']; ?>;
 
467
  }
468
- div.affiliate-button a{
469
- border: 2px solid <?php echo $options['cwppos_buttonbd_color']; ?>;
 
470
  }
471
- div.affiliate-button a:hover{
472
- border: 2px solid <?php echo $options['cwppos_buttonbh_color']; ?>;
 
473
  }
474
- div.affiliate-button a{
475
- background: <?php echo $options['cwppos_buttonbkd_color']; ?>;
 
476
  }
477
- div.affiliate-button a:hover{
478
- background: <?php echo $options['cwppos_buttonbkh_color']; ?>;
 
479
  }
480
- div.affiliate-button a span{
481
- color: <?php echo $options['cwppos_buttontxtd_color']; ?>;
 
482
  }
483
- div.affiliate-button a:hover span{
484
- color: <?php echo $options['cwppos_buttontxth_color']; ?>;
 
485
  }
 
486
  <?php if($options['cwppos_show_icon'] == 'yes') { ?>
487
  div.affiliate-button a span {
488
- background:url("<?php echo WPPR_URL; ?>/images/cart-icon.png") no-repeat left center;
489
  }
490
- div.affiliate-button a:hover span{
491
- background:url("<?php echo WPPR_URL; ?>/images/cart-icon-hover.png") no-repeat left center;
 
492
  }
 
493
  <?php } ?>
494
 
495
  <?php if($options['cwppos_show_userreview'] == 'yes') { ?>
496
  .commentlist .comment-body p {
497
- clear:left;
498
  }
499
 
500
  <?php } ?>
501
  </style>
502
  <script type="text/javascript">
503
- var c1 = "<?php echo $options['cwppos_rating_weak'] ; ?>";
504
- var c2 = "<?php echo $options['cwppos_rating_notbad'] ; ?>";
505
- var c3 = "<?php echo $options['cwppos_rating_good'] ; ?>";
506
- var c4 = "<?php echo $options['cwppos_rating_very_good'] ; ?>";
507
  </script>
508
  <?php
509
  }
510
 
511
- add_action('init', 'cwppos_pac_register');
512
- add_action('wp_head', 'cwppos_pac_print');
513
- add_action('wp_footer','cwppos_dynamic_stylesheet');
514
  add_action( 'admin_init', 'cwppos_pac_admin_init' );
515
- add_action('admin_enqueue_scripts', 'custom_bar_icon');
 
 
 
 
 
 
 
 
 
 
 
 
516
 
517
- if (!class_exists('TAV_Remote_Notification_Client')) require( WPPR_PATH.'/inc/class-remote-notification-client.php' );
 
 
518
  $notification = new TAV_Remote_Notification_Client( 36, '71a28628279f6d55', 'https://themeisle.com/?post_type=notification' );
519
-
520
- if (class_exists('CWP_PR_PRO_Core')) $cwp_pr_pro = new CWP_PR_PRO_Core();
521
-
522
- load_plugin_textdomain('cwppos', false, dirname(plugin_basename(WPPR_PATH)).'/languages/');
6
  * @since 1.0.0
7
  *
8
  */
9
+ function cwppos_calc_overall_rating( $id ) {
 
 
10
  $options = cwppos();
11
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
12
+ ${"option" . $i . "_grade"} = get_post_meta( $id, "option_" . $i . "_grade", true );
 
 
13
  // echo ${"option".$i."_grade"};
14
+ ${"comment_meta_option_nr_" . $i} = 0;
15
+ ${"comment_meta_option_" . $i} = 0;
 
16
 
17
  }
18
  $nr_of_comments = 0;
19
+ if ( $options['cwppos_show_userreview'] == "yes" ) {
20
+ $args = array(
21
+ 'status' => 'approve',
22
  'post_id' => $id, // use post_id, not post_ID
23
  );
24
+ $comments = get_comments( $args );
25
+ $nr_of_comments = get_comments_number( $id );
26
+ foreach ( $comments as $comment ) :
27
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
28
+ if ( get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true ) !== '' ) {
29
+ ${"comment_meta_option_nr_" . $i} ++;
30
+ ${"comment_meta_option_" . $i} += get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true ) * 10;
 
 
31
  }
32
 
 
33
  //var_dump(${"comment_meta_option_".$i});
34
  }
 
 
35
  endforeach;
36
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
37
+ if ( ${"comment_meta_option_nr_" . $i} !== 0 ) {
38
+ ${"comment_meta_option_" . $i} = ${"comment_meta_option_" . $i} / ${"comment_meta_option_nr_" . $i};
39
+ }
40
  }
41
 
42
+ } else {
 
43
  $options['cwppos_infl_userreview'] = 0;
44
  }
45
+ if ( $nr_of_comments == 0 ) {
46
  $options['cwppos_infl_userreview'] = 0;
47
+ }
48
  $overall_score = 0;
49
+ $iter = 0;
50
+ $rating = array();
51
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
52
+ if ( ${"comment_meta_option_nr_" . $i} !== 0 ) {
 
 
53
  $infl = $options['cwppos_infl_userreview'];
54
+ } else {
55
  $infl = 0;
56
 
57
  }
58
+ if ( ! empty( ${'option' . $i . '_grade'} ) || ${'option' . $i . '_grade'} === '0' ) {
59
  //if($infl !== 0 ){
60
+ ${'option' . $i . '_grade'} = round( ( ${'option' . $i . '_grade'} * ( 100 - $infl ) + ${'comment_meta_option_' . $i} * $infl ) / 100 );
61
  //}else{
 
62
  //}
63
+ $iter ++;
64
+ $rating[ 'option' . $i ] = round( ${'option' . $i . '_grade'} );
65
+ $overall_score += ${'option' . $i . '_grade'};
66
  }
67
  }
68
  //$overall_score = ($option1_grade + $option2_grade + $option3_grade + $option4_grade + $option5_grade) / $iter;
69
+ if ( $iter !== 0 ) {
70
+ $rating['overall'] = $overall_score / $iter;
71
+ } else {
72
+ $rating['overall'] = 0;
73
+ }
74
+ update_post_meta( $id, 'option_overall_score', $rating['overall'] );
75
 
76
+ return $rating;
77
 
78
  }
79
 
80
+ function cwppos_show_review( $id = "", $visual = "full" ) {
81
  global $post;
82
+ if ( post_password_required( $post ) ) {
83
+ return false;
84
+ }
85
+ if ( $id == "" ) {
86
  $id = $post->ID;
87
+ }
88
  $cwp_review_stored_meta = get_post_meta( $id );
89
+ $return_string = "";
90
+ if ( @$cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' ) {
91
+ wp_enqueue_style( 'cwp-pac-frontpage-stylesheet', WPPR_URL . '/css/frontpage.css', array(), WPPR_LITE_VERSION );
92
+ wp_enqueue_script( 'pie-chart', WPPR_URL . '/javascript/pie-chart.js', array( "jquery" ), WPPR_LITE_VERSION, true );
93
+ wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL . '/javascript/main.js', array(
94
+ "jquery",
95
+ 'pie-chart'
96
+ ), WPPR_LITE_VERSION, true );
97
+ $cwp_price = get_post_meta( $id, "cwp_rev_price", true );
98
+ $p_string = $cwp_price;
99
+ $p_name = apply_filters( "wppr_review_product_name", $id );
100
+ if ( $p_string != "" ) {
101
+ // Added by Ash/Upwork
102
+ $cwp_price = do_shortcode( $cwp_price );
103
+ // Added by Ash/Upwork
104
+ $p_price = preg_replace( "/[^0-9.,]/", "", $cwp_price );
105
+ $p_currency = preg_replace( "/[0-9.,]/", "", $cwp_price );
106
+ // Added by Ash/Upwork
107
+ $p_disable = apply_filters( "wppr_disable_price_richsnippet", false );
108
+ // Added by Ash/Upwork
109
+ if ( ! $p_disable ) {
110
+ $p_string = '<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span itemprop="priceCurrency">' . $p_currency . '</span><span itemprop="price">' . $p_price . '</span></span>';
111
+ }
 
112
 
113
  }
114
+ $product_image = do_shortcode( get_post_meta( $id, "cwp_rev_product_image", true ) );
115
+ $imgurl = do_shortcode( get_post_meta( $id, "cwp_image_link", true ) );
116
+ $lightbox = "";
117
+ $feat_image = wp_get_attachment_url( get_post_thumbnail_id( $id ) );
118
+ if ( ! empty( $product_image ) ) {
119
+ $product_image_cropped = wppr_get_image_id( $id, $product_image );
 
 
120
  } else {
121
+ $product_image_cropped = wppr_get_image_id( $id );
122
+ $product_image = $feat_image;
123
  }
124
+ if ( $imgurl == "image" ) {
 
 
125
  //no means no disabled
126
+ if ( cwppos( "cwppos_lighbox" ) == "no" ) {
127
+ $lightbox = 'data-lightbox="' . $product_image . '"';
128
+ wp_enqueue_script( "img-lightbox", WPPR_URL . '/javascript/lightbox.min.js', array(), WPPR_LITE_VERSION, array() );
129
+ wp_enqueue_style( "img-lightbox-css", WPPR_URL . '/css/lightbox.css', array(), WPPR_LITE_VERSION );
130
  }
131
+ } else {
132
+ $product_image = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_link", true ) );
133
  }
134
+ $rating = cwppos_calc_overall_rating( $id );
135
+ $divrating = $rating['overall'] / 10;
136
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
137
+ ${"option" . $i . "_content"} = do_shortcode( get_post_meta( $id, "option_" . $i . "_content", true ) );
138
+ if ( empty( ${"option" . $i . "_content"} ) ) {
139
+ ${"option" . $i . "_content"} = __( "Default Feature " . $i, "cwppos" );
 
 
 
140
  }
141
  }
142
+ $commentNr = get_comments_number( $id ) + 1;
143
+ if ( $visual == "full" ) {
144
+ $return_string .= '<section id="review-statistics" class="article-section" itemscope itemtype="http://schema.org/Product">
 
 
145
  <div class="review-wrap-up cwpr_clearfix" >
146
  <div class="cwpr-review-top cwpr_clearfix">
147
+ <span itemprop="name">' . $p_name . '</span>
148
 
149
+ <span class="cwp-item-price cwp-item">' . $p_string . '</span>
150
  </div><!-- end .cwpr-review-top -->
151
  <div class="review-wu-left">
152
  <div class="rev-wu-image">
153
+ <a href="' . $product_image . '" ' . $lightbox . ' rel="nofollow" target="_blank"><img itemprop="image" src="' . $product_image_cropped . '" alt="' . do_shortcode( get_post_meta( $id, "cwp_rev_product_name", true ) ) . '" class="photo photo-wrapup wppr-product-image" /></a>
154
  </div><!-- end .rev-wu-image -->
155
  <div class="review-wu-grade">';
156
+ }
157
+ if ( $visual == "full" || $visual == "yes" ) {
158
+ $extra_class = $visual == "yes" ? "cwp-chart-embed" : "";
159
+ $return_string .= '<div class="cwp-review-chart ' . $extra_class . '">
160
+ <meta itemprop="datePublished" datetime="' . get_the_time( "Y-m-d", $id ) . '">';
161
+ if ( cwppos( "cwppos_infl_userreview" ) != 0 && $commentNr > 1 ) {
162
+ $return_string .= '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="cwp-review-percentage" data-percent="';
163
+ $return_string .= $rating['overall'] . '"><span itemprop="ratingValue" class="cwp-review-rating">' . $divrating . '</span><meta itemprop="bestRating" content = "10"/>
164
  <meta itemprop="ratingCount" content="' . $commentNr . '"> </div>';
165
 
166
+ } else {
167
+ $return_string .= '<span itemscope itemtype="http://schema.org/Review"><span itemprop="author" itemscope itemtype="http://schema.org/Person" >
168
+ <meta itemprop="name" content="' . get_the_author() . '"/>
169
+ </span><span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product"><meta itemprop="name" content="' . do_shortcode( get_post_meta( $id, 'cwp_rev_product_name', true ) ) . '"/></span><div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="cwp-review-percentage" data-percent="';
170
+ $return_string .= $rating['overall'] . '"><span itemprop="ratingValue" class="cwp-review-rating">' . $divrating . '</span> <meta itemprop="bestRating" content="10"> </div></span>';
171
+ }
172
+ $return_string .= '</div><!-- end .chart -->';
173
+ }
174
+ if ( $visual == "full" ) {
175
+ $return_string .= '</div><!-- end .review-wu-grade -->
 
 
176
  <div class="review-wu-bars">';
177
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
178
+ if ( ! empty( ${'option' . $i . '_content'} ) && isset( $rating[ 'option' . $i ] ) && ( ! empty( $rating[ 'option' . $i ] ) || $rating[ 'option' . $i ] === '0' ) && strtoupper( ${'option' . $i . '_content'} ) != 'DEFAULT FEATURE ' . $i ) {
179
+ $return_string .= '<div class="rev-option" data-value=' . $rating[ 'option' . $i ] . '>
 
180
  <div class="cwpr_clearfix">
181
+ ' . apply_filters( "wppr_option_name_html", $id, ${'option' . $i . '_content'} ) . '
182
+ <span>' . round( $rating[ 'option' . $i ] / 10 ) . '/10</span>
183
  </div>
184
  <ul class="cwpr_clearfix"></ul>
185
  </div>';
186
+ }
187
+ }
188
+ $return_string .= '</div><!-- end .review-wu-bars -->
 
189
  </div><!-- end .review-wu-left -->
190
  <div class="review-wu-right">
191
  <div class="pros">';
192
+ }
193
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
194
+ ${"pro_option_" . $i} = do_shortcode( get_post_meta( $id, "cwp_option_" . $i . "_pro", true ) );
195
+ if ( empty( ${"pro_option_" . $i} ) ) {
196
+ ${"pro_option_" . $i} = "";
 
197
  }
198
  }
199
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
200
+ ${"cons_option_" . $i} = do_shortcode( get_post_meta( $id, "cwp_option_" . $i . "_cons", true ) );
201
+ if ( empty( ${"cons_option_" . $i} ) ) {
202
+ ${"cons_option_" . $i} = "";
 
203
  }
204
 
205
  }
206
+ if ( $visual == "full" ) {
207
+ $return_string .= apply_filters( 'wppr_review_pros_text', $id, __( cwppos( "cwppos_pros_text" ), "cwppos" ) ) . ' <ul>';
208
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
209
+ if ( ! empty( ${"pro_option_" . $i} ) ) {
210
+ $return_string .= ' <li>' . ${"pro_option_" . $i} . '</li>';
211
+ }
212
+ }
213
+ $return_string .= ' </ul>
 
 
214
  </div><!-- end .pros -->
215
  <div class="cons">';
216
+ $return_string .= apply_filters( 'wppr_review_cons_text', $id, __( cwppos( "cwppos_cons_text" ), "cwppos" ) ) . ' <ul>';
217
+ for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
218
+ if ( ! empty( ${"cons_option_" . $i} ) ) {
219
+ $return_string .= ' <li>' . ${"cons_option_" . $i} . '</li>';
220
+ }
 
 
 
221
 
222
+ }
223
+ $return_string .= '
224
  </ul>
225
  </div>
226
  </div><!-- end .review-wu-right -->
227
  </div><!-- end .review-wrap-up -->
228
  </section><!-- end #review-statistics -->';
 
 
 
 
229
  }
230
+ if ( cwppos( "cwppos_show_poweredby" ) == 'yes' && ! class_exists( 'CWP_PR_PRO_Core' ) ) {
231
+ $return_string .= '<div style="font-size:12px;width:100%;float:right"><p style="float:right;">Powered by <a href="http://wordpress.org/plugins/wp-product-review/" target="_blank" rel="nofollow" > WP Product Review</a></p></div>';
232
+ }
233
+ $affiliate_text = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_text", true ) );
234
+ $affiliate_link = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_link", true ) );
235
+ $affiliate_text2 = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_text2", true ) );
236
+ $affiliate_link2 = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_link2", true ) );
237
+ if ( ! empty( $affiliate_text2 ) && ! empty( $affiliate_link2 ) ) {
238
+ $bclass = "affiliate-button2 affiliate-button";
239
  } else {
240
+ $bclass = "affiliate-button";
241
+ }
242
+ if ( $visual == "full" && ! empty( $affiliate_text ) && ! empty( $affiliate_link ) ) {
243
+ $return_string .= '<div class="' . $bclass . '">
244
+ <a href="' . $affiliate_link . '" rel="nofollow" target="_blank"><span>' . $affiliate_text . '</span> </a>
 
245
  </div><!-- end .affiliate-button -->';
246
  }
247
+ if ( $visual == "full" && ! empty( $affiliate_text2 ) && ! empty( $affiliate_link2 ) ) {
 
248
  $return_string .= '<div class="affiliate-button affiliate-button2">
249
+ <a href="' . $affiliate_link2 . '" rel="nofollow" target="_blank"><span>' . $affiliate_text2 . '</span> </a>
250
  </div><!-- end .affiliate-button -->';
251
  }
252
+ if ( $visual == "no" ) {
253
+ $return_string = round( $divrating );
254
+ }
 
255
  }
256
 
257
  return $return_string;
258
  }
259
 
 
 
260
  function cwppos_pac_admin_init() {
261
+ wp_enqueue_style( 'cwp-pac-admin-stylesheet', WPPR_URL . '/css/dashboard_styles.css' );
262
+ wp_register_script( 'cwp-pac-script', WPPR_URL . '/javascript/admin-review.js', array( "jquery" ), "20140101", true );
263
+ wp_localize_script( 'cwp-pac-script', 'ispro', array( 'value' => class_exists( 'CWP_PR_PRO_Core' ) ) );
264
+ wp_enqueue_script( 'cwp-pac-script' );
265
+ if ( class_exists( 'CWP_PR_PRO_Core' ) ) {
266
+ wp_enqueue_style( 'cwp-pac-pro-admin-stylesheet', WPPR_URL . '/css/pro_dashboard_styles.css' );
267
+ }
268
+ do_action( "wppr-amazon-enqueue" );
 
 
 
269
  }
270
 
271
+ function wppr_get_image_id( $post_id, $image_url = "", $size = "thumbnail" ) {
 
272
  global $wpdb;
273
  //filter for image size;
274
+ $size = apply_filters( "wppr_review_image_size", $size, $post_id );
275
+ if ( ! empty( $image_url ) && $image_url !== false ) {
276
+ $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ) );
277
+ $image_id = isset( $attachment[0] ) ? $attachment[0] : '';
278
+ } else {
279
+ $image_id = get_post_thumbnail_id( $post_id );
 
 
280
 
281
  }
282
  $image_thumb = "";
283
+ if ( ! empty( $image_id ) ) {
284
+ $image_thumb = wp_get_attachment_image_src( $image_id, $size );
285
+ if ( $size !== 'thumbnail' ) {
286
+ if ( $image_thumb[0] === $image_url ) {
287
+ $image_thumb = wp_get_attachment_image_src( $image_id, "thumbnail" );
 
288
  }
289
  }
290
  }
 
 
291
 
292
+ return isset( $image_thumb[0] ) ? $image_thumb[0] : $image_url;
293
+ }
294
 
295
  function custom_bar_icon() {
296
  $options = cwppos();
297
+ if ( ( isset( $options['cwppos_show_poweredby'] ) && $options['cwppos_show_poweredby'] == "yes" ) || function_exists( "wppr_ci_custom_bar_icon" ) || class_exists( 'CWP_PR_PRO_Core' ) ) {
298
+ wp_register_script( "cwp-custom-bar-icon", WPPR_URL . '/javascript/custom-bar-icon.js', false, "1.0", "all" );
299
+ wp_enqueue_script( "cwp-custom-bar-icon" );
300
+ }
301
+ wppr_add_pointers();
302
+ }
303
 
304
+ function wppr_add_pointers() {
305
+ $screen = get_current_screen();
306
+ $screen_id = $screen->id;
307
+ // Get pointers for this screen
308
+ $pointers = apply_filters( 'wppr_admin_pointers-' . $screen_id, array() );
309
+ if ( ! $pointers || ! is_array( $pointers ) ) {
310
+ return;
311
+ }
312
+ $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
313
+ $valid = array();
314
+ foreach ( $pointers as $pointer_id => $pointer ) {
315
+ // Sanity check
316
+ if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) {
317
+ continue;
318
+ }
319
+ $pointer['pointer_id'] = $pointer_id;
320
+ // Add the pointer to $valid_pointers array
321
+ $valid['pointers'][] = $pointer;
322
+ }
323
+ if ( empty( $valid ) ) {
324
+ return;
325
  }
326
+ // Add pointers style to queue.
327
+ wp_enqueue_style( 'wp-pointer', array( "jquery" ) );
328
+ wp_enqueue_script( 'wppr-pointers', WPPR_URL . '/javascript/cwp-pointers.js', array( "wp-pointer" ), WPPR_LITE_VERSION, true );
329
+ wp_localize_script( 'wppr-pointers', 'cwpp', array( "pointers" => $valid ) );
330
  }
331
 
332
  function cwppos_pac_register() {
333
+ add_image_size( "wppr_widget_image", 50, 50 );
334
  }
335
 
336
  function cwp_def_settings() {
337
  global $post;
338
  $options = cwppos();
339
+ if ( function_exists( 'wppr_ci_custom_bar_icon' ) || ( isset( $options['cwppos_show_poweredby'] ) && $options['cwppos_show_poweredby'] == "yes" ) ) {
340
  $isSetToPro = true;
341
  } else {
342
  $isSetToPro = false;
343
  }
344
+ $uni_font = cwppos( "cwppos_change_bar_icon" );
345
+ $track = $options['cwppos_rating_chart_default'];
 
 
346
  //if ($uni_font!=="&#")
347
+ if ( isset( $uni_font[0] ) ) {
348
+ if ( $uni_font[0] == "#" ) {
349
+ $uni_font = $uni_font;
350
+ } else {
351
+ $uni_font = $uni_font[0];
352
+ }
353
+ } else {
354
+ $uni_font = "";
355
+ }
356
+ if ( ! empty( $uni_font ) ) {
357
+ if ( function_exists( "wppr_ci_custom_bar_icon" ) || cwppos( 'cwppos_show_poweredby' ) == 'yes' ) {
358
+ if ( cwppos( "cwppos_fontawesome" ) === "no" ) {
359
+ wp_enqueue_style( 'cwp-pac-fontawesome-stylesheet', WPPR_URL . '/css/font-awesome.min.css' );
360
  }
361
  }
362
  }
363
+ echo "<script type='text/javascript'>
364
  var cwpCustomBarIcon = '" . $uni_font . "';
365
+ var isSetToPro = '" . $isSetToPro . "';
366
+ var trackcolor = '" . $track . "';
367
  </script>";
368
  }
369
 
370
  function cwppos_pac_print() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  cwp_def_settings();
 
 
372
  }
373
 
 
374
  function cwppos_dynamic_stylesheet() {
375
  $options = cwppos();
376
  //Get theme content width or plugin setting content width
377
  global $content_width;
378
  $c_width = 700;
379
+ if ( $options['cwppos_widget_size'] != "" ) {
380
  $c_width = $options['cwppos_widget_size'];
381
+ } else {
382
  $c_width = $content_width;
383
+ }
384
+ if ( $c_width < 200 ) {
385
  $c_width = 600;
386
+ }
387
+ $f_img_size = min( 180, $c_width * 0.51 * 0.4 );
388
+ $h_tleft = $f_img_size + 10;
389
  $chart_size = 0.8 * $f_img_size;
 
390
  ?>
391
  <style type="text/css">
392
 
 
393
  @media (min-width: 820px) {
394
+ #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {
395
+ height: <?php echo $h_tleft;?>px;
396
+ }
397
 
398
  #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
399
 
404
  font-size: <?php echo round(30*$f_img_size/140);?>px;
405
  }
406
 
407
+ <?php if ($options['cwppos_widget_size']!="") { ?>
408
+ #review-statistics {
409
+ width: <?php echo $options['cwppos_widget_size']; ?>px;
410
+ }
411
+
412
+ <?php } ?>
413
+
414
+ }
415
 
416
+ #review-statistics .review-wrap-up div.cwpr-review-top {
417
+ border-top: <?php echo $options['cwppos_reviewboxbd_width']; ?>px solid <?php echo $options['cwppos_reviewboxbd_color']; ?>;
418
  }
419
 
 
420
  .user-comments-grades .comment-meta-grade-bar,
421
+ #review-statistics .review-wu-bars ul li {
422
  background: <?php echo $options['cwppos_rating_default']; ?>;
423
  }
424
 
426
  color: <?php echo $options['cwppos_rating_default']; ?>;
427
  }
428
 
429
+ #review-statistics .review-wrap-up .review-wu-right ul li, #review-statistics .review-wu-bars h3, .review-wu-bars span, #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category a {
430
+ color: <?php echo $options['cwppos_font_color']; ?>;
 
431
  }
432
+
433
  #review-statistics .review-wrap-up .review-wu-right .pros h2 {
434
+ color: <?php echo $options['cwppos_pros_color']; ?>;
435
  }
436
+
437
+ #review-statistics .review-wrap-up .review-wu-right .cons h2 {
438
+ color: <?php echo $options['cwppos_cons_color']; ?>;
439
  }
440
+
441
+ div.affiliate-button a {
442
+ border: 2px solid <?php echo $options['cwppos_buttonbd_color']; ?>;
443
  }
444
+
445
+ div.affiliate-button a:hover {
446
+ border: 2px solid <?php echo $options['cwppos_buttonbh_color']; ?>;
447
  }
448
+
449
+ div.affiliate-button a {
450
+ background: <?php echo $options['cwppos_buttonbkd_color']; ?>;
451
  }
452
+
453
+ div.affiliate-button a:hover {
454
+ background: <?php echo $options['cwppos_buttonbkh_color']; ?>;
455
  }
456
+
457
+ div.affiliate-button a span {
458
+ color: <?php echo $options['cwppos_buttontxtd_color']; ?>;
459
  }
460
+
461
+ div.affiliate-button a:hover span {
462
+ color: <?php echo $options['cwppos_buttontxth_color']; ?>;
463
  }
464
+
465
  <?php if($options['cwppos_show_icon'] == 'yes') { ?>
466
  div.affiliate-button a span {
467
+ background: url("<?php echo WPPR_URL; ?>/images/cart-icon.png") no-repeat left center;
468
  }
469
+
470
+ div.affiliate-button a:hover span {
471
+ background: url("<?php echo WPPR_URL; ?>/images/cart-icon-hover.png") no-repeat left center;
472
  }
473
+
474
  <?php } ?>
475
 
476
  <?php if($options['cwppos_show_userreview'] == 'yes') { ?>
477
  .commentlist .comment-body p {
478
+ clear: left;
479
  }
480
 
481
  <?php } ?>
482
  </style>
483
  <script type="text/javascript">
484
+ var c1 = "<?php echo $options['cwppos_rating_weak']; ?>";
485
+ var c2 = "<?php echo $options['cwppos_rating_notbad']; ?>";
486
+ var c3 = "<?php echo $options['cwppos_rating_good']; ?>";
487
+ var c4 = "<?php echo $options['cwppos_rating_very_good']; ?>";
488
  </script>
489
  <?php
490
  }
491
 
492
+ add_action( 'init', 'cwppos_pac_register' );
493
+ add_action( 'wp_head', 'cwppos_pac_print' );
494
+ add_action( 'wp_footer', 'cwppos_dynamic_stylesheet' );
495
  add_action( 'admin_init', 'cwppos_pac_admin_init' );
496
+ add_action( 'admin_enqueue_scripts', 'custom_bar_icon' );
497
+ add_action( "wp_ajax_wppr-dismiss-amazon-link", "wppr_dismiss_amazon_link" );
498
+ function wppr_dismiss_amazon_link() {
499
+ $pointer_id = isset( $_POST["pointer"] ) ? $_POST["pointer"] : null;
500
+ if ( $pointer_id ) {
501
+ $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
502
+ if ( ! $dismissed ) {
503
+ $dismissed = array();
504
+ }
505
+ $dismissed[] = $pointer_id;
506
+ update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', implode( ",", $dismissed ) );
507
+ }
508
+ }
509
 
510
+ if ( ! class_exists( 'TAV_Remote_Notification_Client' ) ) {
511
+ require( WPPR_PATH . '/inc/class-remote-notification-client.php' );
512
+ }
513
  $notification = new TAV_Remote_Notification_Client( 36, '71a28628279f6d55', 'https://themeisle.com/?post_type=notification' );
514
+ if ( class_exists( 'CWP_PR_PRO_Core' ) ) {
515
+ $cwp_pr_pro = new CWP_PR_PRO_Core();
516
+ }
517
+ load_plugin_textdomain( 'cwppos', false, dirname( plugin_basename( WPPR_PATH ) ) . '/languages/' );
javascript/cwp-pointers.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($, cwpp){
2
+
3
+ $(document).ready( function() {
4
+
5
+ var timeout;
6
+
7
+ $("#cwp_product_affiliate_link").on("keyup", function(e){
8
+ if($(this).val().indexOf("amazon") != -1){
9
+ $("#wppr_product_affiliate_link_upsell").show();
10
+ timeout = setTimeout(function(){wppr_open_pointer(0);}, 1000);
11
+ }
12
+ });
13
+
14
+ function wppr_open_pointer(i) {
15
+ pointer = cwpp.pointers.pointers[i];
16
+ options = $.extend( pointer.options, {
17
+ close: function() {
18
+ $.post( ajaxurl, {
19
+ pointer: pointer.pointer_id,
20
+ action: 'wppr-dismiss-amazon-link'
21
+ });
22
+ }
23
+ });
24
+
25
+ $(pointer.target).pointer( options ).pointer('open');
26
+ clearTimeout(timeout);
27
+ }
28
+ });
29
+ })(jQuery, cwpp)
readme.txt CHANGED
@@ -72,6 +72,11 @@ If you wanna learn more about the <a href="http://www.codeinwp.com/blog/fastest-
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
75
  **New in 2.9.3**
76
 
77
  - Added dashes for pro/cons list
72
 
73
  == Changelog ==
74
 
75
+ **New in 2.9.5**
76
+
77
+ - Added amazon integration support
78
+ - Fixed some design issue with review
79
+
80
  **New in 2.9.3**
81
 
82
  - Added dashes for pro/cons list
wp-product-review.php CHANGED
@@ -9,7 +9,7 @@
9
  *
10
  * Plugin Name: WP Product Review Lite
11
  * Description: The highest rated and most complete review plugin, now with rich snippets support. Easily turn your basic posts into in-depth reviews.
12
- * Version: 2.9.3
13
  * Author: Themeisle
14
  * Author URI: http://themeisle.com/
15
  * Plugin URI: http://themeisle.com/plugins/wp-product-review-lite/
@@ -22,7 +22,7 @@
22
  * Domain Path: /languages
23
  */
24
 
25
- define( 'WPPR_LITE_VERSION','2.9.3' );
26
  define( 'WPPR_PATH',dirname( __FILE__ ) );
27
  define( 'WPPR_SLUG', "wppr" );
28
  define( 'WPPR_URL',plugins_url( 'wp-product-review' ) );
@@ -43,7 +43,7 @@ if ( wp_get_theme() !== 'Reviewgine Affiliate PRO' ) {
43
  add_filter(WPPR_SLUG . "_upsell_config", "wppr_upsell_config");
44
  if( class_exists("TIABTesting") ) {
45
 
46
- $abtesting = new TIABTesting(WPPR_SLUG);
47
 
48
  }
49
  function wppr_upsell_config($config)
@@ -53,6 +53,16 @@ function wppr_upsell_config($config)
53
  __(" In order to be able to automatically load your options from another posts, you need the PRO add-on", "cwppos"). '<a href="http://bit.ly/2bpC3vT" target="_blank" class="preload_info_upsell">'.__("View Preload features","cwppos").'</a>',
54
  "<i>".__(" You can always import options from other reviews using the preloader feature from the PRO add-on", "cwppos"). '</i><a href="http://bit.ly/2c1QNFK" target="_blank" class="preload_info_upsell">'.__("View more PRO features","cwppos").'</a>',
55
  "<i>".__(" Build review more easily by importing them from other posts using the preloader feature from the pro addon", "cwppos"). '</i><a href="http://bit.ly/2bT89Sk" target="_blank" class="preload_info_upsell">'.__("View details","cwppos").'</a>',
56
- )
 
 
 
 
 
 
 
 
 
 
57
  );
58
  }
9
  *
10
  * Plugin Name: WP Product Review Lite
11
  * Description: The highest rated and most complete review plugin, now with rich snippets support. Easily turn your basic posts into in-depth reviews.
12
+ * Version: 2.9.5
13
  * Author: Themeisle
14
  * Author URI: http://themeisle.com/
15
  * Plugin URI: http://themeisle.com/plugins/wp-product-review-lite/
22
  * Domain Path: /languages
23
  */
24
 
25
+ define( 'WPPR_LITE_VERSION','2.9.5' );
26
  define( 'WPPR_PATH',dirname( __FILE__ ) );
27
  define( 'WPPR_SLUG', "wppr" );
28
  define( 'WPPR_URL',plugins_url( 'wp-product-review' ) );
43
  add_filter(WPPR_SLUG . "_upsell_config", "wppr_upsell_config");
44
  if( class_exists("TIABTesting") ) {
45
 
46
+ $abtesting = new TIABTesting(WPPR_SLUG, WPPR_LITE_VERSION);
47
 
48
  }
49
  function wppr_upsell_config($config)
53
  __(" In order to be able to automatically load your options from another posts, you need the PRO add-on", "cwppos"). '<a href="http://bit.ly/2bpC3vT" target="_blank" class="preload_info_upsell">'.__("View Preload features","cwppos").'</a>',
54
  "<i>".__(" You can always import options from other reviews using the preloader feature from the PRO add-on", "cwppos"). '</i><a href="http://bit.ly/2c1QNFK" target="_blank" class="preload_info_upsell">'.__("View more PRO features","cwppos").'</a>',
55
  "<i>".__(" Build review more easily by importing them from other posts using the preloader feature from the pro addon", "cwppos"). '</i><a href="http://bit.ly/2bT89Sk" target="_blank" class="preload_info_upsell">'.__("View details","cwppos").'</a>',
56
+ ),
57
+ "amazon_title" => array(
58
+ __("Hold on", "cwppos"),
59
+ __("Breaking news", "cwppos"),
60
+ __("Review tip", "cwppos"),
61
+ __("Integrate with Amazon", "cwppos"),
62
+ ),
63
+ "amazon_body" => array(
64
+ __("Do you know that you can import products directly from your amazon affiliate account using the <a href='http://bit.ly/2cjpsux'>PRO</a> version", "cwppos"),
65
+ __("Do you know that you can import products from amazon and keep them synced using the <a href='http://bit.ly/2cEefYy'>PRO</a> version ", "cwppos")
66
+ ),
67
  );
68
  }