WP Customer Reviews - Version 2.4.8

Version Description

  • [Update] Updates to comply with WP plugin directory guidelines
Download this release

Release Info

Developer bompus
Plugin Icon wp plugin WP Customer Reviews
Version 2.4.8
Comparing to
See all releases

Version 2.4.8

button.png ADDED
Binary file
newstars.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Customer Reviews ===
2
+ Contributors: bompus
3
+ Donate link: http://www.gowebsolutions.com/wp-customer-reviews/
4
+ Tags: business, google, hcard, hproduct, hreview, microformat, microformats, mu, places, plugin, product, rating, ratings, rdfa, review, review box, review widget, reviews, seo, service, shortcode, snippet, snippets, testimonial, testimonials, widget, wordpressmu, wpmu
5
+ Requires at least: 2.8.6
6
+ Tested up to: 4.2
7
+ Stable tag: 2.4.8
8
+
9
+ WP Customer Reviews allows your customers and visitors to leave reviews or testimonials of your services. Reviews are Microformat enabled (hReview).
10
+
11
+ == Description ==
12
+
13
+ There are many sites that are crawling for user-generated reviews now, including Google Places and Google Local Search. WP Customer Reviews allows you to setup a specific page on your blog to receive customer testimonials for your business/service OR to write reviews about multiple products (using multiple pages).
14
+
15
+ **Big News! Version 3 is on the way.** [Click here for details](http://www.gowebsolutions.com/wp-customer-reviews/?from=wpcr_directory_notice_1 "Click here for details")
16
+
17
+ * WP Multisite and Multiuser (WPMU / WPMS / Wordpress MU) compatible.
18
+ * All submissions are moderated, which means that YOU choose which reviews get shown.
19
+ * Reviews are displayed to visitors in a friendly format, but search engines see the hReview microformat (and RDFa soon!)
20
+ * Multiple anti-spam measures to prevent automated spambots from submitting reviews.
21
+ * Provides a configurable `Business hCard`, to help identify all pages of your site as belonging to your business.
22
+ * Completely customizable, including which fields to ask for, require, and show.
23
+ * Shortcodes available for inserting reviews and review form on any page or widget.
24
+ * Works with caching plugins and a majority of themes.
25
+ * Includes an external stylesheet so you can modify it to better fit your theme.
26
+ * Reviews can be edited by admin for content and date.
27
+ * Admin responses can be made and shown under each review.
28
+ * Support for adding your own custom fields.
29
+ * The plugin can be used on more than one page, and can be used on posts.
30
+ * Supports both `Business` and `Product` hReview types.
31
+ * Shows aggregate reviews microformat (`hReview-aggregate`).
32
+ * Fast and lightweight, even including the star rating image. This plugin will not slow down your blog.
33
+ * Validates as valid XHTML 1.1 (W3C) and valid Microformats (Rich Snippets Testing Tool).
34
+ * And much more...
35
+
36
+ This is a community-driven , donation-funded plugin. Almost every new feature that has been added was due to the generous support and suggestions of our users. If you have a suggestion or question, do not hesitate to ask in our forum.
37
+
38
+ More information at: [**WP Customer Reviews**](http://www.gowebsolutions.com/wp-customer-reviews/)
39
+
40
+ == Installation ==
41
+
42
+ 1. Upload contents of compressed file (wp-customer-reviews) to the `/wp-content/plugins/` directory.
43
+ 2. Activate the plugin through the `Plugins` menu in WordPress admin.
44
+ 3. Create a WordPress page to be used specifically for gathering reviews or testimonials.
45
+ 4. Go into settings for WP Customer Reviews and configure the plugin.
46
+
47
+ == Screenshots ==
48
+
49
+ 1. Admin Moderation of Comments (v1.2.4)
50
+ 2. Admin Options #1 (v1.2.4)
51
+ 3. Admin Options #2 (v1.2.4)
52
+ 4. Example of what visitors will see (v1.2.4)
53
+ 5. A visitor submitting a review (v1.2.4)
54
+
55
+ == Frequently Asked Questions ==
56
+ * If you have any feedback, suggestions, questions, or issues, please: [**Visit our support forum**](http://wordpress.org/tags/wp-customer-reviews?forum_id=10)
57
+
58
+ == Changelog ==
59
+
60
+ = 2.4.8 =
61
+ * [Update] Updates to comply with WP plugin directory guidelines
62
+
63
+ = 2.4.7 =
64
+ * [Fix] Menu item in Admin Dashboard hides other plugin menu items
65
+
66
+ = 2.4.6 =
67
+ * [Fix] Fixed an issue where a non-breaking space character was not properly output in the footer aggregate review
68
+
69
+ = 2.4.5 =
70
+ * [Fix] In some cases, the database table was not being created on activation
71
+
72
+ = 2.4.3 =
73
+ * [Fix] We will leave clearing any caching plugins up to the user
74
+ * [Fix] Prevented some PHP notices in admin area
75
+
76
+ = 2.4.2 =
77
+ * [Fix] Reverting change - We will use the wp_update_post function to trigger caching plugins/WP to refresh their cache
78
+ * [Fix] Plugin was not honoring asking without requiring custom fields
79
+ * [Fix] Plugin was not saving data that was entered into custom fields
80
+ * [Update] We will no longer show "There are no reviews yet" verbiage, since shortcodes can do odd things. We may add this back in with a future update
81
+ * [Update] Added multiple methods of adding plugin CSS/JS into theme header
82
+
83
+ = 2.4.1 =
84
+ * [Fix] Admin - Minor fix for a user-reported error in admin
85
+ * [Update] An update to prevent firing of wp_update_post hooks. Please report any issues with cached pages not updating
86
+
87
+ = 2.4.0 =
88
+ * [Fix] Admin - Some checkbox plugin settings could not be saved
89
+
90
+ = 2.3.9 =
91
+ * [Fix] Admin - Added better support for WPMU and to ensure ongoing WP compatibility
92
+ * [Fix] Shortcodes were not outputting inside of the correct container
93
+ * [Update] An option has been added to hide the submit review form
94
+ * [Update] Shortcode implementation has been updated with additional options
95
+ * [Update] Cleaned up some more code that was triggering E_NOTICE warnings
96
+ * [Update] hCard output can now be displayed for better visibility to search engines
97
+
98
+ = 2.3.8 =
99
+ * [Fix] 2.3.7 had introduced a redirect loop when loaded on a new page with no reviews
100
+
101
+ == Upgrade Notice ==
102
+
103
+ = 2.4.4 =
104
+ An important fix regarding database table creation
red_pen.png ADDED
Binary file
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
star.png ADDED
Binary file
wp-customer-reviews-admin.css ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .best_in_place {
2
+ padding:0.1em !important;
3
+ cursor: hand;
4
+ cursor: pointer;
5
+ -moz-transition: background 0.5s linear;
6
+ -o-transition: background 0.5s linear;
7
+ -webkit-transition: background 0.5s linear;
8
+ -moz-border-radius: 5px;
9
+ -webkit-border-radius: 5px;
10
+ -o-border-radius: 5px;
11
+ -ms-border-radius: 5px;
12
+ -khtml-border-radius: 5px;
13
+ border-radius: 5px;
14
+ }
15
+ .best_in_place:hover {
16
+ padding:0.2em 1.5em 0.4em 0.1em !important;
17
+ background: url("red_pen.png") no-repeat right center;
18
+ background-color: #CCC;
19
+ }
20
+ .info_edit {
21
+ float: right;
22
+ cursor: hand;
23
+ cursor: pointer;
24
+ }
25
+
26
+ #wpcr_ad label {
27
+ vertical-align:inherit !important;
28
+ }
29
+
30
+ .purr {
31
+ position: fixed;
32
+ width: 324px;
33
+ top: 20px;
34
+ right: 15px;
35
+ padding: 20px;
36
+ background-color: #000000;
37
+ color: #FFFFFF;
38
+ border: 2px solid #FFFFFF;
39
+ }
40
+ .purr:hover .close {
41
+ position: absolute;
42
+ top: 5px;
43
+ right: 3px;
44
+ display: block;
45
+ width: 25px;
46
+ height: 25px;
47
+ text-indent: -9999px;
48
+ /*background: url("/images/close-button.gif") no-repeat;*/
49
+ }
wp-customer-reviews-admin.js ADDED
@@ -0,0 +1,777 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+
3
+ jQuery("#comments-form").submit(function(e) {
4
+ var hasbip = jQuery(this).find('input.bip');
5
+ if (hasbip.size() > 0) {
6
+ return false;
7
+ }
8
+ });
9
+
10
+ jQuery(".best_in_place").best_in_place();
11
+
12
+ jQuery("#require_fname, #show_fname").click(function(){
13
+ if ( jQuery(this).is(":checked") ) {
14
+ jQuery("#ask_fname").attr('checked','checked');
15
+ }
16
+ else if ( jQuery("#ask_fname").not(":checked") ) {
17
+ jQuery("#show_fname").removeAttr('checked');
18
+ jQuery("#require_fname").removeAttr('checked');
19
+ }
20
+ });
21
+
22
+ jQuery("#require_femail, #show_femail").click(function(){
23
+ if ( jQuery(this).is(":checked") ) {
24
+ jQuery("#ask_femail").attr('checked','checked');
25
+ }
26
+ else if ( jQuery("#ask_femail").not(":checked") ) {
27
+ jQuery("#show_femail").removeAttr('checked');
28
+ jQuery("#require_femail").removeAttr('checked');
29
+ }
30
+ });
31
+
32
+ jQuery("#require_fwebsite, #show_fwebsite").click(function(){
33
+ if ( jQuery(this).is(":checked") ) {
34
+ jQuery("#ask_fwebsite").attr('checked','checked');
35
+ }
36
+ else if ( jQuery("#ask_fwebsite").not(":checked") ) {
37
+ jQuery("#show_fwebsite").removeAttr('checked');
38
+ jQuery("#require_fwebsite").removeAttr('checked');
39
+ }
40
+ });
41
+
42
+ jQuery("#require_ftitle, #show_ftitle").click(function(){
43
+ if ( jQuery(this).is(":checked") ) {
44
+ jQuery("#ask_ftitle").attr('checked','checked');
45
+ }
46
+ else if ( jQuery("#ask_ftitle").not(":checked") ) {
47
+ jQuery("#show_ftitle").removeAttr('checked');
48
+ jQuery("#require_ftitle").removeAttr('checked');
49
+ }
50
+ });
51
+
52
+ jQuery("#ask_fname, #ask_femail, #ask_fwebsite, #ask_ftitle").click(function(){
53
+ if ( jQuery(this).not(":checked") ) {
54
+ var datawhat = jQuery(this).attr('data-what');
55
+ jQuery("#show_"+datawhat).removeAttr('checked');
56
+ jQuery("#require_"+datawhat).removeAttr('checked');
57
+ }
58
+ });
59
+
60
+ jQuery(".custom_req, .custom_show").each(function(){
61
+ jQuery(this).click(function(){
62
+ var dataid = jQuery(this).attr('data-id');
63
+
64
+ if ( jQuery(this).is(":checked") ) {
65
+ jQuery("#ask_custom"+dataid).attr('checked','checked');
66
+ }
67
+ else if ( jQuery("#ask_custom"+dataid).not(":checked") ) {
68
+ jQuery("#show_custom"+dataid).removeAttr('checked');
69
+ jQuery("#require_custom"+dataid).removeAttr('checked');
70
+ }
71
+ });
72
+ });
73
+
74
+ jQuery(".custom_ask").click(function(){
75
+ if ( jQuery(this).not(":checked") ) {
76
+ var dataid = jQuery(this).attr('data-id');
77
+ jQuery("#show_custom"+dataid).removeAttr('checked');
78
+ jQuery("#require_custom"+dataid).removeAttr('checked');
79
+ }
80
+ });
81
+ });
82
+
83
+ function wpcr_strip_tags(html){
84
+
85
+ //PROCESS STRING
86
+ if(arguments.length < 3) {
87
+ html=html.replace(/<\/?(?!\!)[^>]*>/gi, '');
88
+ } else {
89
+ var allowed = arguments[1];
90
+ var specified = eval("["+arguments[2]+"]");
91
+ if(allowed){
92
+ var regex='</?(?!(' + specified.join('|') + '))\b[^>]*>';
93
+ html=html.replace(new RegExp(regex, 'gi'), '');
94
+ } else{
95
+ var regex='</?(' + specified.join('|') + ')\b[^>]*>';
96
+ html=html.replace(new RegExp(regex, 'gi'), '');
97
+ }
98
+ }
99
+
100
+ //CHANGE NAME TO CLEAN JUST BECAUSE
101
+ var clean_string = html;
102
+
103
+ //RETURN THE CLEAN STRING
104
+ return clean_string;
105
+ }
106
+
107
+ function wpcr_nl2br(str)
108
+ {
109
+ return str.replace(/(\r|\n|\r\n)/ig, "<br />");
110
+ }
111
+
112
+ function wpcr_br2nl(str)
113
+ {
114
+ return str.replace(/(<br \/>|<br>|<br >|<br\/>|<p>)/ig, "\r\n");
115
+ }
116
+
117
+ function callback_review_text(me) {
118
+ var mehtml = jQuery(me).html();
119
+ mehtml = wpcr_nl2br(mehtml);
120
+ jQuery(me).html(mehtml);
121
+ }
122
+
123
+ function make_stars_from_rating(me) {
124
+
125
+ var w = '';
126
+
127
+ switch (me.html()) {
128
+ case 'Rated 1 Star':
129
+ w = '20';
130
+ break;
131
+ case 'Rated 2 Stars':
132
+ w = '40';
133
+ break;
134
+ case 'Rated 3 Stars':
135
+ w = '60';
136
+ break;
137
+ case 'Rated 4 Stars':
138
+ w = '80';
139
+ break;
140
+ case 'Rated 5 Stars':
141
+ w = '100';
142
+ break;
143
+ }
144
+
145
+ var out = '<div class="sp_rating"><div class="base"><div class="average" style="width:'+w+'%"></div></div></div>';
146
+ me.html(out);
147
+ }
148
+
149
+ /**
150
+ * jquery.purr.js
151
+ * Copyright (c) 2008 Net Perspective (net-perspective.com)
152
+ * Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
153
+ *
154
+ * @author R.A. Ray
155
+ * @projectDescription jQuery plugin for dynamically displaying unobtrusive messages in the browser. Mimics the behavior of the MacOS program "Growl."
156
+ * @version 0.1.0
157
+ *
158
+ * @requires jquery.js (tested with 1.2.6)
159
+ *
160
+ * @param fadeInSpeed int - Duration of fade in animation in miliseconds
161
+ * default: 500
162
+ * @param fadeOutSpeed int - Duration of fade out animationin miliseconds
163
+ default: 500
164
+ * @param removeTimer int - Timeout, in miliseconds, before notice is removed once it is the top non-sticky notice in the list
165
+ default: 4000
166
+ * @param isSticky bool - Whether the notice should fade out on its own or wait to be manually closed
167
+ default: false
168
+ * @param usingTransparentPNG bool - Whether or not the notice is using transparent .png images in its styling
169
+ default: false
170
+ */
171
+
172
+ (function($) {
173
+
174
+ $.purr = function(notice, options)
175
+ {
176
+ // Convert notice to a jQuery object
177
+ notice = $(notice);
178
+
179
+ // Add a class to denote the notice as not sticky
180
+ notice.addClass('purr');
181
+
182
+ // Get the container element from the page
183
+ var cont = document.getElementById('purr-container');
184
+
185
+ // If the container doesn't yet exist, we need to create it
186
+ if (!cont)
187
+ {
188
+ cont = '<div id="purr-container"></div>';
189
+ }
190
+
191
+ // Convert cont to a jQuery object
192
+ cont = $(cont);
193
+
194
+ // Add the container to the page
195
+ $('body').append(cont);
196
+
197
+ notify();
198
+
199
+ function notify ()
200
+ {
201
+ // Set up the close button
202
+ var close = document.createElement('a');
203
+ $(close).attr({
204
+ className: 'close',
205
+ href: '#close'
206
+ }).appendTo(notice).click(function() {
207
+ removeNotice();
208
+ return false;
209
+ });
210
+
211
+ // If ESC is pressed remove notice
212
+ $(document).keyup(function(e) {
213
+ if (e.keyCode == 27) {
214
+ removeNotice();
215
+ }
216
+ });
217
+
218
+ // Add the notice to the page and keep it hidden initially
219
+ notice.appendTo(cont).hide();
220
+
221
+ if (jQuery.browser.msie && options.usingTransparentPNG)
222
+ {
223
+ // IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
224
+ // notice style, we'll just skip the fading in.
225
+ notice.show();
226
+ }
227
+ else
228
+ {
229
+ //Fade in the notice we just added
230
+ notice.fadeIn(options.fadeInSpeed);
231
+ }
232
+
233
+ // Set up the removal interval for the added notice if that notice is not a sticky
234
+ if (!options.isSticky)
235
+ {
236
+ var topSpotInt = setInterval(function() {
237
+ // Check to see if our notice is the first non-sticky notice in the list
238
+ if (notice.prevAll('.purr').length == 0)
239
+ {
240
+ // Stop checking once the condition is met
241
+ clearInterval(topSpotInt);
242
+
243
+ // Call the close action after the timeout set in options
244
+ setTimeout(function() {
245
+ removeNotice();
246
+ }, options.removeTimer);
247
+ }
248
+ }, 200);
249
+ }
250
+ }
251
+
252
+ function removeNotice()
253
+ {
254
+ // IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
255
+ // notice style, we'll just skip the fading out.
256
+ if (jQuery.browser.msie && options.usingTransparentPNG)
257
+ {
258
+ notice.css({ opacity: 0 }).animate({ height: '0px'},
259
+ {
260
+ duration: options.fadeOutSpeed,
261
+ complete: function ()
262
+ {
263
+ notice.remove();
264
+ }
265
+ }
266
+ );
267
+ }
268
+ else
269
+ {
270
+ // Fade the object out before reducing its height to produce the sliding effect
271
+ notice.animate({ opacity: '0' },
272
+ {
273
+ duration: options.fadeOutSpeed,
274
+ complete: function ()
275
+ {
276
+ notice.animate({ height: '0px' },
277
+ {
278
+ duration: options.fadeOutSpeed,
279
+ complete: function()
280
+ {
281
+ notice.remove();
282
+ }
283
+ }
284
+ );
285
+ }
286
+ }
287
+ );
288
+ }
289
+ };
290
+ };
291
+
292
+ $.fn.purr = function(options)
293
+ {
294
+ options = options || {};
295
+ options.fadeInSpeed = options.fadeInSpeed || 500;
296
+ options.fadeOutSpeed = options.fadeOutSpeed || 500;
297
+ options.removeTimer = options.removeTimer || 4000;
298
+ options.isSticky = options.isSticky || false;
299
+ options.usingTransparentPNG = options.usingTransparentPNG || false;
300
+
301
+ this.each(function()
302
+ {
303
+ new $.purr( this, options );
304
+ }
305
+ );
306
+
307
+ return this;
308
+ };
309
+ })( jQuery );
310
+
311
+ /*
312
+ BestInPlace (for jQuery)
313
+ version: 0.1.9 (02/12/2011)
314
+ @requires jQuery >= v1.4
315
+ @requires jQuery.purr to display pop-up windows
316
+
317
+ By Bernat Farrero based on the work of Jan Varwig.
318
+ Examples at http://bernatfarrero.com
319
+
320
+ Licensed under the MIT:
321
+ http://www.opensource.org/licenses/mit-license.php
322
+
323
+ Usage:
324
+
325
+ Attention.
326
+ The format of the JSON object given to the select inputs is the following:
327
+ [["key", "value"],["key", "value"]]
328
+ The format of the JSON object given to the checkbox inputs is the following:
329
+ ["falseValue", "trueValue"]
330
+ */
331
+
332
+ function BestInPlaceEditor(e) {
333
+ this.element = jQuery(e);
334
+ this.initOptions();
335
+ this.bindForm();
336
+ this.initNil();
337
+ jQuery(this.activator).bind('click', {editor: this}, this.clickHandler);
338
+ }
339
+
340
+ BestInPlaceEditor.prototype = {
341
+ // Public Interface Functions //////////////////////////////////////////////
342
+
343
+ activate : function() {
344
+ var elem = this.isNil ? "" : this.element.html();
345
+ this.oldValue = elem;
346
+ jQuery(this.activator).unbind("click", this.clickHandler);
347
+ this.activateForm();
348
+ },
349
+
350
+ abort : function() {
351
+ if (this.isNil) this.element.html(this.nil);
352
+ else this.element.html(this.oldValue);
353
+ jQuery(this.activator).bind('click', {editor: this}, this.clickHandler);
354
+ if (this.callback != '') { window[this.callback](this.element); } /* AQ */
355
+ },
356
+
357
+ update : function() {
358
+ var editor = this;
359
+ if (this.formType in {"input":1, "textarea":1} && this.getValue() == this.oldValue)
360
+ { // Avoid request if no change is made
361
+ this.abort();
362
+ return true;
363
+ }
364
+ this.isNil = false;
365
+ editor.ajax({
366
+ "type" : "post",
367
+ "dataType" : "text",
368
+ "data" : editor.requestData(),
369
+ "success" : function(data){ editor.loadSuccessCallback(data); },
370
+ "error" : function(request, error){ editor.loadErrorCallback(request, error); }
371
+ });
372
+ if (this.formType == "select") {
373
+ var value = this.getValue();
374
+ jQuery.each(this.values, function(i, v) {
375
+ if (value == v[0]) {
376
+ editor.element.html(v[1]);
377
+ }
378
+ }
379
+ );
380
+ } else if (this.formType == "checkbox") {
381
+ editor.element.html(this.getValue() ? this.values[1] : this.values[0]);
382
+ } else {
383
+ editor.element.html(this.getValue());
384
+ }
385
+ },
386
+
387
+ activateForm : function() {
388
+ alert("The form was not properly initialized. activateForm is unbound");
389
+ },
390
+
391
+ // Helper Functions ////////////////////////////////////////////////////////
392
+
393
+ initOptions : function() {
394
+ // Try parent supplied info
395
+ var self = this;
396
+ self.element.parents().each(function(){
397
+ self.url = self.url || jQuery(this).attr("data-url");
398
+ self.collection = self.collection || jQuery(this).attr("data-collection");
399
+ self.formType = self.formType || jQuery(this).attr("data-type");
400
+ self.objectName = self.objectName || jQuery(this).attr("data-object");
401
+ self.attributeName = self.attributeName || jQuery(this).attr("data-attribute");
402
+ self.nil = self.nil || jQuery(this).attr("data-nil");
403
+ self.callback = self.callback || jQuery(this).attr("data-callback");
404
+ });
405
+
406
+ // Try Rails-id based if parents did not explicitly supply something
407
+ self.element.parents().each(function(){
408
+ var res = this.id.match(/^(\w+)_(\d+)$/i);
409
+ if (res) {
410
+ self.objectName = self.objectName || res[1];
411
+ }
412
+ });
413
+
414
+ // Load own attributes (overrides all others)
415
+ self.url = self.element.attr("data-url") || self.url || document.location.pathname;
416
+ self.collection = self.element.attr("data-collection") || self.collection;
417
+ self.formType = self.element.attr("data-type") || self.formtype || "input";
418
+ self.objectName = self.element.attr("data-object") || self.objectName;
419
+ self.attributeName = self.element.attr("data-attribute") || self.attributeName;
420
+ self.activator = self.element.attr("data-activator") || self.element;
421
+ self.nil = self.element.attr("data-nil") || self.nil || "----------";
422
+ self.callback = self.element.attr("data-callback") || self.callback || "";
423
+
424
+ if (!self.element.attr("data-sanitize")) {
425
+ self.sanitize = true;
426
+ }
427
+ else {
428
+ self.sanitize = (self.element.attr("data-sanitize") == "true");
429
+ }
430
+
431
+ if ((self.formType == "select" || self.formType == "checkbox") && self.collection !== null)
432
+ {
433
+ self.values = jQuery.parseJSON(self.collection);
434
+ }
435
+ },
436
+
437
+ bindForm : function() {
438
+ this.activateForm = BestInPlaceEditor.forms[this.formType].activateForm;
439
+ this.getValue = BestInPlaceEditor.forms[this.formType].getValue;
440
+ },
441
+
442
+ initNil: function() {
443
+ if (this.element.html() == "")
444
+ {
445
+ this.isNil = true
446
+ this.element.html(this.nil)
447
+ }
448
+ },
449
+
450
+ getValue : function() {
451
+ alert("The form was not properly initialized. getValue is unbound");
452
+ },
453
+
454
+ // Trim and Strips HTML from text
455
+ sanitizeValue : function(s) {
456
+ if (this.sanitize)
457
+ {
458
+ var news = wpcr_br2nl(s);
459
+ return jQuery.trim(wpcr_strip_tags(s));
460
+ }
461
+ return jQuery.trim(s);
462
+ },
463
+
464
+ /* Generate the data sent in the POST request */
465
+ requestData : function() {
466
+ // To prevent xss attacks, a csrf token must be defined as a meta attribute
467
+ csrf_token = jQuery('meta[name=csrf-token]').attr('content');
468
+ csrf_param = jQuery('meta[name=csrf-param]').attr('content');
469
+
470
+ var data = "_method=put";
471
+ data += "&" + this.objectName + '[' + this.attributeName + ']=' + encodeURIComponent(this.getValue());
472
+
473
+ if (csrf_param !== undefined && csrf_token !== undefined) {
474
+ data += "&" + csrf_param + "=" + encodeURIComponent(csrf_token);
475
+ }
476
+ return data;
477
+ },
478
+
479
+ ajax : function(options) {
480
+ options.url = this.url;
481
+ options.beforeSend = function(xhr){ xhr.setRequestHeader("Accept", "application/json"); };
482
+ return jQuery.ajax(options);
483
+ },
484
+
485
+ // Handlers ////////////////////////////////////////////////////////////////
486
+
487
+ loadSuccessCallback : function(data) {
488
+ this.element.html(data[this.objectName]);
489
+ // Binding back after being clicked
490
+ jQuery(this.activator).bind('click', {editor: this}, this.clickHandler);
491
+ if (this.callback != '') { window[this.callback](this.element); } /* AQ */
492
+ },
493
+
494
+ loadErrorCallback : function(request, error) {
495
+ this.element.html(this.oldValue);
496
+
497
+ // Display all error messages from server side validation
498
+ jQuery.each(jQuery.parseJSON(request.responseText), function(index, value) {
499
+ var container = jQuery("<span class='flash-error'></span>").html(value);
500
+ container.purr();
501
+ });
502
+
503
+ // Binding back after being clicked
504
+ jQuery(this.activator).bind('click', {editor: this}, this.clickHandler);
505
+ if (this.callback != '') { window[this.callback](this.element); } /* AQ */
506
+ },
507
+
508
+ clickHandler : function(event) {
509
+ event.data.editor.activate();
510
+ }
511
+ };
512
+
513
+
514
+ BestInPlaceEditor.forms = {
515
+ "input" : {
516
+ activateForm : function() {
517
+ var output = '<form class="form_in_place" action="javascript:void(0)" style="display:inline;">';
518
+ output += '<input class="bip" type="text" value="' + this.sanitizeValue(this.oldValue) + '"></form>';
519
+ this.element.html(output);
520
+ this.element.find('input')[0].select();
521
+ this.element.find("form").bind('submit', {editor: this}, BestInPlaceEditor.forms.input.submitHandler);
522
+ this.element.find("input").bind('blur', {editor: this}, BestInPlaceEditor.forms.input.inputBlurHandler);
523
+ this.element.find("input").bind('keyup', {editor: this}, BestInPlaceEditor.forms.input.keyupHandler);
524
+ },
525
+
526
+ getValue : function() {
527
+ return this.sanitizeValue(this.element.find("input").val());
528
+ },
529
+
530
+ inputBlurHandler : function(event) {
531
+ event.data.editor.update();
532
+ },
533
+
534
+ submitHandler : function(event) {
535
+ event.data.editor.update();
536
+ return false;
537
+ },
538
+
539
+ keyupHandler : function(event) {
540
+ if (event.keyCode == 27) {
541
+ event.data.editor.abort();
542
+ }
543
+
544
+ if (event.keyCode == 10 || event.keyCode == 13) {
545
+ event.data.editor.update();
546
+ }
547
+ }
548
+ },
549
+
550
+ "select" : {
551
+ activateForm : function() {
552
+ var output = "<form action='javascript:void(0)' style='display:inline;'><select>";
553
+ var selected = "";
554
+ var oldValue = this.oldValue;
555
+ jQuery.each(this.values, function(index, value) {
556
+ selected = (value[1] == oldValue ? "selected='selected'" : "");
557
+ output += "<option value='" + value[0] + "' " + selected + ">" + value[1] + "</option>";
558
+ });
559
+ output += "</select></form>";
560
+ this.element.html(output);
561
+ this.element.find("select").bind('change', {editor: this}, BestInPlaceEditor.forms.select.blurHandler);
562
+ this.element.find("select").bind('blur', {editor: this}, BestInPlaceEditor.forms.select.blurHandler);
563
+ this.element.find("select").bind('keyup', {editor: this}, BestInPlaceEditor.forms.select.keyupHandler);
564
+ this.element.find("select")[0].focus();
565
+ },
566
+
567
+ getValue : function() {
568
+ return this.sanitizeValue(this.element.find("select").val());
569
+ },
570
+
571
+ blurHandler : function(event) {
572
+ event.data.editor.update();
573
+ },
574
+
575
+ keyupHandler : function(event) {
576
+ if (event.keyCode == 27) event.data.editor.abort();
577
+ }
578
+ },
579
+
580
+ "checkbox" : {
581
+ activateForm : function() {
582
+ var newValue = Boolean(this.oldValue != this.values[1]);
583
+ var output = newValue ? this.values[1] : this.values[0];
584
+ this.element.html(output);
585
+ this.update();
586
+ },
587
+
588
+ getValue : function() {
589
+ return Boolean(this.element.html() == this.values[1]);
590
+ }
591
+ },
592
+
593
+ "textarea" : {
594
+ activateForm : function() {
595
+ // grab width and height of text
596
+ width = this.element.css('width');
597
+ height = this.element.css('height');
598
+
599
+ // construct the form
600
+ var output = '<form action="javascript:void(0)" style="display:inline;"><textarea>';
601
+ //output += this.sanitizeValue(this.oldValue); /* fix for IE 8 issues */
602
+ output += wpcr_br2nl(this.oldValue); /* fix for IE 8 issues */
603
+ output += '</textarea></form>';
604
+ this.element.html(output);
605
+
606
+ // set width and height of textarea
607
+ jQuery(this.element.find("textarea")[0]).css({ 'min-width': width, 'min-height': height });
608
+ jQuery(this.element.find("textarea")[0]).elastic();
609
+
610
+ this.element.find("textarea")[0].focus();
611
+ this.element.find("textarea").bind('blur', {editor: this}, BestInPlaceEditor.forms.textarea.blurHandler);
612
+ this.element.find("textarea").bind('keyup', {editor: this}, BestInPlaceEditor.forms.textarea.keyupHandler);
613
+ },
614
+
615
+ getValue : function() {
616
+ //var sanval = this.sanitizeValue(this.element.find("textarea").val());
617
+ var sanval = this.sanitizeValue(this.element.find("textarea").val());
618
+ sanval = wpcr_nl2br(sanval);
619
+ return sanval;
620
+ },
621
+
622
+ blurHandler : function(event) {
623
+ event.data.editor.update();
624
+ },
625
+
626
+ keyupHandler : function(event) {
627
+ if (event.keyCode == 27) {
628
+ BestInPlaceEditor.forms.textarea.abort(event.data.editor);
629
+ }
630
+ },
631
+
632
+ abort : function(editor) {
633
+ if (confirm("Are you sure you want to discard your changes?")) {
634
+ editor.abort();
635
+ }
636
+ }
637
+ }
638
+ };
639
+
640
+ jQuery.fn.best_in_place = function() {
641
+ this.each(function(){
642
+ jQuery(this).data('bestInPlaceEditor', new BestInPlaceEditor(this));
643
+ });
644
+ return this;
645
+ };
646
+
647
+ /**
648
+ * @name Elastic
649
+ * @descripton Elastic is Jquery plugin that grow and shrink your textareas automaticliy
650
+ * @version 1.6.5
651
+ * @requires Jquery 1.2.6+
652
+ *
653
+ * @author Jan Jarfalk
654
+ * @author-email jan.jarfalk@unwrongest.com
655
+ * @author-website http://www.unwrongest.com
656
+ *
657
+ * @licens MIT License - http://www.opensource.org/licenses/mit-license.php
658
+ */
659
+
660
+ (function(jQuery){
661
+ jQuery.fn.extend({
662
+ elastic: function() {
663
+ // We will create a div clone of the textarea
664
+ // by copying these attributes from the textarea to the div.
665
+ var mimics = [
666
+ 'paddingTop',
667
+ 'paddingRight',
668
+ 'paddingBottom',
669
+ 'paddingLeft',
670
+ 'fontSize',
671
+ 'lineHeight',
672
+ 'fontFamily',
673
+ 'width',
674
+ 'fontWeight'];
675
+
676
+ return this.each( function() {
677
+
678
+ // Elastic only works on textareas
679
+ if ( this.type != 'textarea' ) {
680
+ return false;
681
+ }
682
+
683
+ var $textarea = jQuery(this),
684
+ $twin = jQuery('<div />').css({'position': 'absolute','display':'none'}),
685
+ lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'),
686
+ minheight = parseInt($textarea.css('height'),10) || lineHeight*3,
687
+ maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE,
688
+ goalheight = 0,
689
+ i = 0;
690
+
691
+ // Opera returns max-height of -1 if not set
692
+ if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
693
+
694
+ // Append the twin to the DOM
695
+ // We are going to meassure the height of this, not the textarea.
696
+ $twin.appendTo($textarea.parent());
697
+
698
+ // Copy the essential styles (mimics) from the textarea to the twin
699
+ var i = mimics.length;
700
+ while(i--){
701
+ $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
702
+ }
703
+
704
+
705
+ // Sets a given height and overflow state on the textarea
706
+ function setHeightAndOverflow(height, overflow){
707
+ curratedHeight = Math.floor(parseInt(height,10));
708
+ if($textarea.height() != curratedHeight){
709
+ $textarea.css({'height': curratedHeight + 'px','overflow':overflow});
710
+
711
+ }
712
+ }
713
+
714
+
715
+ // This function will update the height of the textarea if necessary
716
+ function update() {
717
+
718
+ // Get curated content from the textarea.
719
+ var textareaContent = $textarea.val().replace(/&/g,'&amp;').replace(/ /g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />');
720
+
721
+ // Compare curated content with curated twin.
722
+ var twinContent = $twin.html().replace(/<br>/ig,'<br />');
723
+
724
+ if(textareaContent+'&nbsp;' != twinContent){
725
+
726
+ // Add an extra white space so new rows are added when you are at the end of a row.
727
+ $twin.html(textareaContent+'&nbsp;');
728
+
729
+ // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
730
+ if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){
731
+
732
+ var goalheight = $twin.height()+lineHeight;
733
+ if(goalheight >= maxheight) {
734
+ setHeightAndOverflow(maxheight,'auto');
735
+ } else if(goalheight <= minheight) {
736
+ setHeightAndOverflow(minheight,'hidden');
737
+ } else {
738
+ setHeightAndOverflow(goalheight,'hidden');
739
+ }
740
+
741
+ }
742
+
743
+ }
744
+
745
+ }
746
+
747
+ // Hide scrollbars
748
+ $textarea.css({'overflow':'hidden'});
749
+
750
+ // Update textarea size on keyup, change, cut and paste
751
+ $textarea.bind('keyup change cut paste', function(){
752
+ update();
753
+ });
754
+
755
+ // Compact textarea on blur
756
+ // Lets animate this....
757
+ $textarea.bind('blur',function(){
758
+ if($twin.height() < maxheight){
759
+ if($twin.height() > minheight) {
760
+ $textarea.height($twin.height());
761
+ } else {
762
+ $textarea.height(minheight);
763
+ }
764
+ }
765
+ });
766
+
767
+ // And this line is to catch the browser paste event
768
+ $textarea.live('input paste',function(e){ setTimeout( update, 250); });
769
+
770
+ // Run update once when elastic is initialized
771
+ update();
772
+
773
+ });
774
+
775
+ }
776
+ });
777
+ })(jQuery);
wp-customer-reviews-admin.php ADDED
@@ -0,0 +1,1224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WPCustomerReviewsAdmin
3
+ {
4
+ var $parentClass = '';
5
+
6
+ function WPCustomerReviewsAdmin($parentClass) {
7
+ define('IN_WPCR_ADMIN',1);
8
+
9
+ /* begin - haxish but it works */
10
+ $this->parentClass = &$parentClass;
11
+ foreach ($this->parentClass as $col => $val) {
12
+ $this->$col = &$this->parentClass->$col;
13
+ }
14
+ /* end - haxish but it works */
15
+ }
16
+
17
+ function real_admin_init() {
18
+ $this->parentClass->init();
19
+ $this->enqueue_admin_stuff();
20
+
21
+ register_setting( 'wpcr_options', 'wpcr_options' );
22
+
23
+ /* used for redirecting to settings page upon initial activation */
24
+ if (get_option('wpcr_gotosettings', false)) {
25
+ delete_option('wpcr_gotosettings');
26
+ unregister_setting('wpcr_gotosettings', 'wpcr_gotosettings');
27
+
28
+ /* no auto settings redirect if upgrading */
29
+ if ( isset($this->p->action) && $this->p->action == 'activate-plugin' ) { return false; }
30
+
31
+ $url = get_admin_url().'options-general.php?page=wpcr_options';
32
+ $this->parentClass->wpcr_redirect($url);
33
+ }
34
+
35
+ $this->notice_ignore(); /* admin notices */
36
+ }
37
+
38
+ function notice_ignore() {
39
+ global $current_user;
40
+ $user_id = $current_user->ID;
41
+ /* If user clicks to ignore the notice, add to user meta */
42
+ if ( isset($_GET['wpcr_notice_1']) ) {
43
+ $n1 = $_GET['wpcr_notice_1'];
44
+ if ( $n1 == 'redir' ) {
45
+ wp_redirect('http://www.gowebsolutions.com/wp-customer-reviews/?from=wpcr_admin_notice_1');
46
+ exit();
47
+ } else if ( $n1 == 'ignore' ) {
48
+ add_user_meta($user_id, 'wpcr_admin_notice_read_1', 'true', true);
49
+ }
50
+ }
51
+ }
52
+ /* end - admin notices */
53
+
54
+ function wpcr_add_meta_box() {
55
+ global $meta_box;
56
+
57
+ $prefix = 'wpcr_';
58
+
59
+ $meta_box = array(
60
+ 'id' => 'wpcr-meta-box',
61
+ 'title' => '<img src="'.$this->parentClass->getpluginurl().'star.png" />&nbsp;WP Customer Reviews',
62
+ 'page' => 'page',
63
+ 'context' => 'normal',
64
+ 'priority' => 'high',
65
+ 'fields' => array(
66
+ array(
67
+ 'name' => '<span style="font-weight:bold;">Enable WP Customer Reviews</span> for this page',
68
+ 'desc' => 'Plugin content will be displayed below your page contents',
69
+ 'id' => $prefix . 'enable',
70
+ 'type' => 'checkbox'
71
+ ),
72
+ array(
73
+ 'name' => 'Product Name',
74
+ 'desc' => '<span style="color:#BE5409;">This is where you need to enter in the product name. Only necessary if you are showing PRODUCT style reviews. This field will be ignored if you have the plugin setup for BUSINESS style reviews</span>',
75
+ 'id' => $prefix . 'product_name',
76
+ 'type' => 'text',
77
+ 'std' => ''
78
+ ),
79
+ array(
80
+ 'name' => 'Product Description',
81
+ 'desc' => '',
82
+ 'id' => $prefix . 'product_desc',
83
+ 'type' => 'text',
84
+ 'std' => ''
85
+ ),
86
+ array(
87
+ 'name' => 'Manufacturer/Brand of Product',
88
+ 'desc' => '',
89
+ 'id' => $prefix . 'product_brand',
90
+ 'type' => 'text',
91
+ 'std' => ''
92
+ ),
93
+ array(
94
+ 'name' => 'Model',
95
+ 'desc' => '',
96
+ 'id' => $prefix . 'product_model',
97
+ 'type' => 'text',
98
+ 'std' => ''
99
+ ),
100
+ array(
101
+ 'name' => 'SKU',
102
+ 'desc' => '',
103
+ 'id' => $prefix . 'product_sku',
104
+ 'type' => 'text',
105
+ 'std' => ''
106
+ ),
107
+ array(
108
+ 'name' => 'UPC',
109
+ 'desc' => '',
110
+ 'id' => $prefix . 'product_upc',
111
+ 'type' => 'text',
112
+ 'std' => ''
113
+ )
114
+ )
115
+ );
116
+
117
+ /* add for pages and posts */
118
+ add_meta_box($meta_box['id'], $meta_box['title'], array(&$this, 'wpcr_show_meta_box'), 'page', $meta_box['context'], $meta_box['priority']);
119
+ add_meta_box($meta_box['id'], $meta_box['title'], array(&$this, 'wpcr_show_meta_box'), 'post', $meta_box['context'], $meta_box['priority']);
120
+ }
121
+
122
+ function real_admin_save_post($post_id) {
123
+ global $meta_box,$wpdb;
124
+
125
+ // check autosave
126
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
127
+ return $post_id;
128
+ }
129
+
130
+ // check permissions
131
+ if ( isset($this->p->post_type) && $this->p->post_type == 'page' ) {
132
+ if (!current_user_can('edit_page', $post_id)) {
133
+ return $post_id;
134
+ }
135
+ } elseif (!current_user_can('edit_post', $post_id)) {
136
+ return $post_id;
137
+ }
138
+
139
+ if ( isset($meta_box) && isset($meta_box['fields']) && is_array($meta_box['fields']) )
140
+ {
141
+ foreach ($meta_box['fields'] as $field) {
142
+
143
+ if ( isset($this->p->post_title) ) {
144
+ $old = get_post_meta($post_id, $field['id'], true);
145
+
146
+ if (isset($this->p->$field['id'])) {
147
+ $new = $this->p->$field['id'];
148
+ if ($new && $new != $old) {
149
+ update_post_meta($post_id, $field['id'], $new);
150
+ } elseif ($new == '' && $old) {
151
+ delete_post_meta($post_id, $field['id'], $old);
152
+ }
153
+ } else {
154
+ delete_post_meta($post_id, $field['id'], $old);
155
+ }
156
+ }
157
+
158
+ }
159
+ }
160
+
161
+ return $post_id;
162
+ }
163
+
164
+ function wpcr_show_meta_box() {
165
+ global $meta_box, $post;
166
+
167
+ echo '<table class="form-table">';
168
+
169
+ foreach ($meta_box['fields'] as $field) {
170
+ // get current post meta data
171
+ $meta = get_post_meta($post->ID, $field['id'], true);
172
+
173
+ if ($field['id'] == 'wpcr_enable' && $post->post_name == '') {
174
+ if ($post->post_type == 'post' && $this->options['enable_posts_default'] == 1) {
175
+ $meta = 1; /* enable by default for posts */
176
+ }
177
+ else if ($post->post_type == 'page' && $this->options['enable_pages_default'] == 1) {
178
+ $meta = 1; /* enable by default for pages */
179
+ }
180
+ }
181
+
182
+ echo '<tr>',
183
+ '<th style="width:30%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
184
+ '<td>';
185
+ switch ($field['type']) {
186
+ case 'text':
187
+ echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '<br />', $field['desc'];
188
+ break;
189
+ case 'textarea':
190
+ echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '<br />', $field['desc'];
191
+ break;
192
+ case 'select':
193
+ echo '<select name="', $field['id'], '" id="', $field['id'], '">';
194
+ foreach ($field['options'] as $option) {
195
+ echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
196
+ }
197
+ echo '</select>';
198
+ break;
199
+ case 'radio':
200
+ foreach ($field['options'] as $option) {
201
+ echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
202
+ }
203
+ break;
204
+ case 'checkbox':
205
+ echo '<input value="1" type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
206
+ break;
207
+ }
208
+ echo '<td></tr>';
209
+ }
210
+
211
+ echo '</table>';
212
+ }
213
+
214
+ function createUpdateReviewTable() {
215
+ require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
216
+
217
+ $sql = "CREATE TABLE $this->dbtable (
218
+ id int(11) NOT NULL AUTO_INCREMENT,
219
+ date_time datetime NOT NULL,
220
+ reviewer_name varchar(150) DEFAULT NULL,
221
+ reviewer_email varchar(150) DEFAULT NULL,
222
+ reviewer_ip varchar(15) DEFAULT NULL,
223
+ review_title varchar(150) DEFAULT NULL,
224
+ review_text text,
225
+ review_response text,
226
+ status tinyint(1) DEFAULT '0',
227
+ review_rating tinyint(2) DEFAULT '0',
228
+ reviewer_url varchar(255) NOT NULL,
229
+ page_id int(11) NOT NULL DEFAULT '0',
230
+ custom_fields text,
231
+ PRIMARY KEY (id),
232
+ KEY status (status),
233
+ KEY page_id (page_id)
234
+ )";
235
+
236
+ dbDelta($sql);
237
+ }
238
+
239
+ function force_update_cache() {
240
+ return; /* testing to increase performance */
241
+ global $wpdb;
242
+
243
+ /* update all pages, since some may have just disabled the plugin */
244
+ $pages = $wpdb->get_results( "SELECT `ID` FROM $wpdb->posts AS `p`" );
245
+ foreach ($pages as $page) {
246
+ $post = get_post($page->ID);
247
+ if ($post) {
248
+ clean_post_cache($page->ID);
249
+ wp_update_post($post); /* comment to prevent some plugins from firing tweets/etc when updating, can have side effects */
250
+ }
251
+ }
252
+ }
253
+
254
+ /* some admin styles can override normal styles for inplace edits */
255
+ function enqueue_admin_stuff() {
256
+ $pluginurl = $this->parentClass->getpluginurl();
257
+
258
+ if (isset($this->p->page) && ( $this->p->page == 'wpcr_view_reviews' || $this->p->page == 'wpcr_options' ) ) {
259
+ wp_register_script('wp-customer-reviews-admin',$pluginurl.'wp-customer-reviews-admin.js',array('jquery'),$this->plugin_version);
260
+ wp_register_style('wp-customer-reviews-admin',$pluginurl.'wp-customer-reviews-admin.css',array(),$this->plugin_version);
261
+ wp_enqueue_script('wp-customer-reviews-admin');
262
+ wp_enqueue_style('wp-customer-reviews-admin');
263
+ }
264
+ }
265
+
266
+ /* v4 uuid */
267
+ function gen_uuid() {
268
+ return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
269
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
270
+ mt_rand( 0, 0xffff ),
271
+ mt_rand( 0, 0x0fff ) | 0x4000,
272
+ mt_rand( 0, 0x3fff ) | 0x8000,
273
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
274
+ );
275
+ }
276
+
277
+ /*
278
+ * This is used purely for analytics and for notification of critical security releases.
279
+ * It gives us a chance to review who is using it, how it is being used,
280
+ * and to verify theme and version compatibility. None of this information will ever be
281
+ * shared, sold, or given away.
282
+ */
283
+ function notify_activate($act_flag) {
284
+ global $wp_version;
285
+
286
+ /* TO DISABLE THIS FUNCTION, UNCOMMENT THE FOLLOWING LINE */
287
+ /* return false; */
288
+
289
+ if ($this->options['act_uniq'] == '') {
290
+ $this->options['act_uniq'] = $this->gen_uuid();
291
+ update_option('wpcr_options', $this->options);
292
+ }
293
+
294
+ $request = 'doact='.$act_flag.'&email='.urlencode(stripslashes($this->options['act_email'])).'&version='.$this->plugin_version.'&support='.$this->options['support_us'].'&uuid='.$this->options['act_uniq'];
295
+ $host = "www.gowebsolutions.com";
296
+ $port = 80;
297
+ $wpurl = get_bloginfo('wpurl');
298
+
299
+ $http_request = "POST /plugin-activation/activate.php HTTP/1.0\r\n";
300
+ $http_request .= "Host: www.gowebsolutions.com\r\n";
301
+ $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=".get_option('blog_charset')."\r\n";
302
+ $http_request .= "Content-Length: ".strlen($request)."\r\n";
303
+ $http_request .= "Referer: $wpurl\r\n";
304
+ $http_request .= "User-Agent: WordPress/$wp_version\r\n\r\n";
305
+ $http_request .= $request;
306
+
307
+ $response = '';
308
+ if( false != ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
309
+ fwrite($fs, $http_request);
310
+ while ( !feof($fs) ) {
311
+ $response .= fgets($fs, 1160);
312
+ }
313
+ fclose($fs);
314
+ $response = explode("\r\n\r\n", $response, 2);
315
+ }
316
+
317
+ return $response;
318
+ }
319
+
320
+ function update_options() {
321
+ /* we still process and validate this internally, instead of using the Settings API */
322
+
323
+ global $wpdb;
324
+ $msg ='';
325
+
326
+ $this->security();
327
+
328
+ if (isset($this->p->optin))
329
+ {
330
+ if ($this->options['activate'] == 0)
331
+ {
332
+ $this->options['activate'] = 1;
333
+ $this->options['act_email'] = $this->p->email;
334
+
335
+ update_option('wpcr_options', $this->options);
336
+ $this->notify_activate(1);
337
+ $msg = 'Thank you. Please configure the plugin below.';
338
+ }
339
+ }
340
+ else
341
+ {
342
+ check_admin_referer('wpcr_options-options'); /* nonce check */
343
+
344
+ $updated_options = $this->options;
345
+
346
+ /* reset these to 0 so we can grab the settings below */
347
+ $updated_options['ask_fields']['fname'] = 0;
348
+ $updated_options['ask_fields']['femail'] = 0;
349
+ $updated_options['ask_fields']['fwebsite'] = 0;
350
+ $updated_options['ask_fields']['ftitle'] = 0;
351
+ $updated_options['require_fields']['fname'] = 0;
352
+ $updated_options['require_fields']['femail'] = 0;
353
+ $updated_options['require_fields']['fwebsite'] = 0;
354
+ $updated_options['require_fields']['ftitle'] = 0;
355
+ $updated_options['show_fields']['fname'] = 0;
356
+ $updated_options['show_fields']['femail'] = 0;
357
+ $updated_options['show_fields']['fwebsite'] = 0;
358
+ $updated_options['show_fields']['ftitle'] = 0;
359
+ $updated_options['ask_custom'] = array();
360
+ $updated_options['field_custom'] = array();
361
+ $updated_options['require_custom'] = array();
362
+ $updated_options['show_custom'] = array();
363
+
364
+ /* quick update of all options needed */
365
+ foreach ($this->p as $col => $val)
366
+ {
367
+ if (isset($this->options[$col]))
368
+ {
369
+ switch($col)
370
+ {
371
+ case 'field_custom': /* we should always hit field_custom before ask_custom, etc */
372
+ foreach ($val as $i => $name) { $updated_options[$col][$i] = ucwords( strtolower( $name ) ); } /* we are so special */
373
+ break;
374
+ case 'ask_custom':
375
+ case 'require_custom':
376
+ case 'show_custom':
377
+ foreach ($val as $i => $v) { $updated_options[$col][$i] = 1; } /* checkbox array with ints */
378
+ break;
379
+ case 'ask_fields':
380
+ case 'require_fields':
381
+ case 'show_fields':
382
+ foreach ($val as $v) { $updated_options[$col]["$v"] = 1; } /* checkbox array with names */
383
+ break;
384
+ default:
385
+ $updated_options[$col] = $val; /* a non-array normal field */
386
+ break;
387
+ }
388
+ }
389
+ }
390
+
391
+ /* prevent E_NOTICE warnings */
392
+ if (!isset($this->p->enable_pages_default)) { $this->p->enable_pages_default = 0; }
393
+ if (!isset($this->p->enable_posts_default)) { $this->p->enable_posts_default = 0; }
394
+ if (!isset($this->p->goto_show_button)) { $this->p->goto_show_button = 0; }
395
+ if (!isset($this->p->support_us)) { $this->p->support_us = 0; }
396
+
397
+ /* some int validation */
398
+ $updated_options['enable_pages_default'] = intval($this->p->enable_pages_default);
399
+ $updated_options['enable_posts_default'] = intval($this->p->enable_posts_default);
400
+ $updated_options['form_location'] = intval($this->p->form_location);
401
+ $updated_options['goto_show_button'] = intval($this->p->goto_show_button);
402
+ $updated_options['reviews_per_page'] = intval($this->p->reviews_per_page);
403
+ $updated_options['show_hcard'] = intval($this->p->show_hcard);
404
+ $updated_options['show_hcard_on'] = intval($this->p->show_hcard_on);
405
+ $updated_options['support_us'] = intval($this->p->support_us);
406
+
407
+ if ($updated_options['reviews_per_page'] < 1) { $updated_options['reviews_per_page'] = 10; }
408
+
409
+ if ($updated_options['show_hcard_on']) {
410
+ if (
411
+ empty($updated_options['business_name']) ||
412
+ empty($updated_options['business_url']) ||
413
+ empty($updated_options['business_email']) ||
414
+ empty($updated_options['business_street']) ||
415
+ empty($updated_options['business_city']) ||
416
+ empty($updated_options['business_state']) ||
417
+ empty($updated_options['business_zip']) ||
418
+ empty($updated_options['business_phone'])
419
+ ) {
420
+ $msg .= "* Notice: You must enter in ALL business information to use the hCard output *<br /><br />";
421
+ $updated_options['show_hcard_on'] = 0;
422
+ }
423
+ }
424
+
425
+ $msg .= 'Your settings have been saved.';
426
+ update_option('wpcr_options', $updated_options);
427
+ $this->force_update_cache(); /* update any caches */
428
+ }
429
+
430
+ return $msg;
431
+ }
432
+
433
+ function show_activation() {
434
+ echo '
435
+ <div class="postbox" style="width:700px;">
436
+ <h3>Notify me of new releases</h3>
437
+ <div style="padding:10px; background:#ffffff;">
438
+ <p style="color:#060;">If you would like to be notified of any critical security updates, please enter your email address below. Your information will only be used for notification of future releases.</p><br />
439
+ <form method="post" action="">
440
+ <input type="hidden" name="optin" value="1" />
441
+ <label for="email">Email Address: </label><input type="text" size="32" id="email" name="email" />&nbsp;
442
+ <input type="submit" class="button-primary" value="OK!" name="submit" />&nbsp;
443
+ <input type="submit" class="button-primary" value="No Thanks!" name="submit" />
444
+ </form>
445
+ <p style="color:#BE5409;font-size:14px;font-weight:bold;"><br />Click "OK!" or "No Thanks!" above to access the full plugin settings.</p>
446
+ </div>
447
+ </div>';
448
+ }
449
+
450
+ function my_get_pages() { /* gets pages, even if hidden using a plugin */
451
+ global $wpdb;
452
+
453
+ $res = $wpdb->get_results("SELECT `ID`,`post_title` FROM `$wpdb->posts` WHERE `post_status` = 'publish' AND `post_type` = 'page' ORDER BY `ID`");
454
+ return $res;
455
+ }
456
+
457
+ function show_options() {
458
+
459
+ $su_checked = '';
460
+ if ($this->options['support_us']) {
461
+ $su_checked = 'checked';
462
+ }
463
+
464
+ $enable_posts_checked = '';
465
+ if ($this->options['enable_posts_default']) {
466
+ $enable_posts_checked = 'checked';
467
+ }
468
+
469
+ $enable_pages_checked = '';
470
+ if ($this->options['enable_pages_default']) {
471
+ $enable_pages_checked = 'checked';
472
+ }
473
+
474
+ $goto_show_button_checked = '';
475
+ if ($this->options['goto_show_button']) {
476
+ $goto_show_button_checked = 'checked';
477
+ }
478
+
479
+ $af = array('fname' => '','femail' => '','fwebsite' => '','ftitle' => '');
480
+ if ($this->options['ask_fields']['fname'] == 1) { $af['fname'] = 'checked'; }
481
+ if ($this->options['ask_fields']['femail'] == 1) { $af['femail'] = 'checked'; }
482
+ if ($this->options['ask_fields']['fwebsite'] == 1) { $af['fwebsite'] = 'checked'; }
483
+ if ($this->options['ask_fields']['ftitle'] == 1) { $af['ftitle'] = 'checked'; }
484
+
485
+ $rf = array('fname' => '','femail' => '','fwebsite' => '','ftitle' => '');
486
+ if ($this->options['require_fields']['fname'] == 1) { $rf['fname'] = 'checked'; }
487
+ if ($this->options['require_fields']['femail'] == 1) { $rf['femail'] = 'checked'; }
488
+ if ($this->options['require_fields']['fwebsite'] == 1) { $rf['fwebsite'] = 'checked'; }
489
+ if ($this->options['require_fields']['ftitle'] == 1) { $rf['ftitle'] = 'checked'; }
490
+
491
+ $sf = array('fname' => '','femail' => '','fwebsite' => '','ftitle' => '');
492
+ if ($this->options['show_fields']['fname'] == 1) { $sf['fname'] = 'checked'; }
493
+ if ($this->options['show_fields']['femail'] == 1) { $sf['femail'] = 'checked'; }
494
+ if ($this->options['show_fields']['fwebsite'] == 1) { $sf['fwebsite'] = 'checked'; }
495
+ if ($this->options['show_fields']['ftitle'] == 1) { $sf['ftitle'] = 'checked'; }
496
+
497
+ echo '
498
+ <div class="postbox" style="width:700px;">
499
+ <h3>Display Options</h3>
500
+ <div id="wpcr_ad">
501
+ <div style="background:#eaf2fa;padding:6px;border-top:1px solid #ccc;border-bottom:1px solid #ccc;">
502
+ <legend>Tips</legend>
503
+ </div>
504
+ <div style="padding:10px;">
505
+ How to use: <small>When adding/editing any post/page, you have a setting block on the page for WP Customer Reviews. If you enable the plugin for that post, it will then use the default options set on this page.</small>
506
+ <br /><br />
507
+ Shortcodes: <small>The following shortcodes can be used in the page/post content of any page. These codes will not work when placed directly in a theme template file, since Wordpress does not parse their content. Shortcode features are in beta testing.</small>
508
+ <br /><br />
509
+ [WPCR_INSERT] <small>is available for you to use on any page/post. Simply include [WPCR_INSERT] in the content of the post where you would like the reviews/form output to be displayed. If this code is found, the plugin will automatically enable itself for the post.</small>
510
+ <br /><br />
511
+ [WPCR_SHOW
512
+ POSTID="<span style="color:#00c;">ALL</span>"
513
+ NUM="<span style="color:#00c;">3</span>"
514
+ SNIPPET=""
515
+ MORE=""
516
+ HIDECUSTOM="<span style="color:#00c;">0</span>"
517
+ HIDERESPONSE="<span style="color:#00c;">0</span>"]
518
+ <br /><small>is available to show the latest reviews. Explanation below: <br />
519
+ POSTID="ALL" to show recent reviews from ALL posts/pages or POSTID="123" to show recent reviews from post/page ID #123<br />
520
+ NUM="3" will show a maximum of 3 reviews (without pagination).<br />
521
+ SNIPPET="140" will only show the first 140 characters of a review.<br />
522
+ MORE="view more" will show "... view more" with a link to the actual review on the associated page.<br />
523
+ HIDECUSTOM="1" will hide all custom fields in the shortcode output.<br />
524
+ HIDERESPONSE="1" will hide the administrator response to the review.<br />
525
+ </small>
526
+ </div>
527
+ <form method="post" action="">
528
+ <div style="background:#eaf2fa;padding:6px;border-top:1px solid #ccc;border-bottom:1px solid #ccc;">
529
+ <legend>Business Information (for hidden hCard)</legend>
530
+ </div>
531
+ <div style="padding:10px;">
532
+ <label for="show_hcard_on">Enable Business hCard output on: </label>
533
+ <select id="show_hcard_on" name="show_hcard_on">
534
+ <option ';if ($this->options['show_hcard_on'] == 1) { echo "selected"; } echo ' value="1">All wordpress posts &amp; pages</option>
535
+ <option ';if ($this->options['show_hcard_on'] == 2) { echo "selected"; } echo ' value="2">Homepage &amp; review page</option>
536
+ <option ';if ($this->options['show_hcard_on'] == 3) { echo "selected"; } echo ' value="3">Only the review page</option>
537
+ <option ';if ($this->options['show_hcard_on'] == 0) { echo "selected"; } echo ' value="0">Never</option>
538
+ </select><br />
539
+ <small>This will enable the hCard microformat, which includes your business contact information. This is recommended to enable for all posts &amp; pages.</small>
540
+ <br /><br />
541
+ <label for="show_hcard">Business hCard Visibility: </label>
542
+ <select id="show_hcard" name="show_hcard">
543
+ <option ';if ($this->options['show_hcard'] == 0) { echo "selected"; } echo ' value="0">Hide hCard to Visitors</option>
544
+ <option ';if ($this->options['show_hcard'] == 1) { echo "selected"; } echo ' value="1">Show hCard to Visitors</option>
545
+ </select><br />
546
+ <small>This will display the hCard to visitors (and search engines). Search engines will normally ignore microformat information that is hidden, so it is usually a good idea to set this to "Show". "Show" will ONLY affect individual enabled pages/posts. If you want to hide elements of the hCard output, the individual styles can be overridden by your theme CSS.</small>
547
+ <br /><br />
548
+ <label for="business_name">Business Name (<span style="color:#c00;">Required</span>): </label><input style="width:250px;" type="text" id="business_name" name="business_name" value="'.$this->options['business_name'].'" />
549
+ <br />
550
+ <small>This business name is a required field in the review microformat. This is why it is required.</small>
551
+ <br /><br />
552
+ <label for="business_url">Business URL: </label><input style="width:350px;" type="text" id="business_url" name="business_url" value="'.$this->options['business_url'].'" />
553
+ <br /><br />
554
+ <label for="business_email">Business Email: </label><input style="width:250px;" type="text" id="business_email" name="business_email" value="'.$this->options['business_email'].'" />
555
+ <br /><br />
556
+ <label for="business_street">Business Street Address: </label><input style="width:320px;" type="text" id="business_street" name="business_street" value="'.$this->options['business_street'].'" />
557
+ <br /><br />
558
+ <label for="business_city">City: </label><input style="width:150px;" type="text" id="business_city" name="business_city" value="'.$this->options['business_city'].'" />
559
+ &nbsp;
560
+ <label for="business_state">State (2 letters): </label><input style="width:40px;" type="text" id="business_state" name="business_state" value="'.$this->options['business_state'].'" />
561
+ &nbsp;
562
+ <label for="business_zip">Zip Code: </label><input style="width:60px;" type="text" id="business_zip" name="business_zip" value="'.$this->options['business_zip'].'" />
563
+ <br /><br />
564
+ <label for="business_country">Country: </label><input style="width:100px;" type="text" id="business_country" name="business_country" value="'.$this->options['business_country'].'" />
565
+ &nbsp;
566
+ <label for="business_phone">Phone # (555-555-5555): </label><input style="width:120px;" type="text" id="business_phone" name="business_phone" value="'.$this->options['business_phone'].'" />
567
+ <br />
568
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Save Changes" name="Submit"></div>
569
+ </div>
570
+ <div style="background:#eaf2fa;padding:6px;border-top:1px solid #ccc;border-bottom:1px solid #ccc;">
571
+ <legend>General Settings</legend>
572
+ </div>
573
+ <div style="padding:10px;padding-bottom:10px;">
574
+ <label for="hreview_type">Review Format: </label>
575
+ <select id="hreview_type" name="hreview_type">
576
+ <option ';if ($this->options['hreview_type'] == 'business') { echo "selected"; } echo ' value="business">Business</option>
577
+ <option ';if ($this->options['hreview_type'] == 'product') { echo "selected"; } echo ' value="product">Product</option>
578
+ </select><br />
579
+ <small>If using the "Product" type, you can enter the product name in the "WP Customer Reviews" box when editing your pages. If this is set to "Business", the plugin will present all reviews as if they are reviews of your business as listed above.</small>
580
+ <br /><br />
581
+ <input id="enable_posts_default" name="enable_posts_default" type="checkbox" '.$enable_posts_checked.' value="1" />&nbsp;<label for="enable_posts_default"><small>Enable the plugin by default for new posts.</small></label>
582
+ <br /><br />
583
+ <input id="enable_pages_default" name="enable_pages_default" type="checkbox" '.$enable_pages_checked.' value="1" />&nbsp;<label for="enable_pages_default"><small>Enable the plugin by default for new pages.</small></label>
584
+ <br /><br />
585
+ <input id="support_us" name="support_us" type="checkbox" '.$su_checked.' value="1" />&nbsp;<label for="support_us"><small>Support our work and keep this plugin free. By checking this box, a small "Powered by WP Customer Reviews" link will be placed at the bottom of pages that use the plugin.</small></label>
586
+ <br />
587
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Save Changes" name="Submit"></div>
588
+ </div>
589
+ <div style="background:#eaf2fa;padding:6px;border-top:1px solid #ccc;border-bottom:1px solid #ccc;">
590
+ <legend>Review Page Settings</legend>
591
+ </div>
592
+ <div style="padding:10px;padding-bottom:10px;">
593
+ <span style="color:#BE5409;">You can use this plugin on multiple pages/posts. You will find a "WP Customer Reviews" settings box when editing any page/post.</span>
594
+ <br /><br />
595
+ <label for="reviews_per_page">Reviews shown per page: </label><input style="width:40px;" type="text" id="reviews_per_page" name="reviews_per_page" value="'.$this->options['reviews_per_page'].'" />
596
+ <br /><br />
597
+ <label for="form_location">Location of Review Form: </label>
598
+ <select id="form_location" name="form_location">
599
+ <option ';if ($this->options['form_location'] == 0) { echo "selected"; } echo ' value="0">Above Reviews</option>
600
+ <option ';if ($this->options['form_location'] == 1) { echo "selected"; } echo ' value="1">Below Reviews</option>
601
+ </select>
602
+ <br /><br />
603
+ <label>Fields to ask for on review form: </label>
604
+ <input data-what="fname" id="ask_fname" name="ask_fields[]" type="checkbox" '.$af['fname'].' value="fname" />&nbsp;<label for="ask_fname"><small>Name</small></label>&nbsp;&nbsp;&nbsp;
605
+ <input data-what="femail" id="ask_femail" name="ask_fields[]" type="checkbox" '.$af['femail'].' value="femail" />&nbsp;<label for="ask_femail"><small>Email</small></label>&nbsp;&nbsp;&nbsp;
606
+ <input data-what="fwebsite" id="ask_fwebsite" name="ask_fields[]" type="checkbox" '.$af['fwebsite'].' value="fwebsite" />&nbsp;<label for="ask_fwebsite"><small>Website</small></label>&nbsp;&nbsp;&nbsp;
607
+ <input data-what="ftitle" id="ask_ftitle" name="ask_fields[]" type="checkbox" '.$af['ftitle'].' value="ftitle" />&nbsp;<label for="ask_ftitle"><small>Review Title</small></label>
608
+ <br /><br />
609
+ <label>Fields to require on review form: </label>
610
+ <input id="require_fname" name="require_fields[]" type="checkbox" '.$rf['fname'].' value="fname" />&nbsp;<label for="require_fname"><small>Name</small></label>&nbsp;&nbsp;&nbsp;
611
+ <input id="require_femail" name="require_fields[]" type="checkbox" '.$rf['femail'].' value="femail" />&nbsp;<label for="require_femail"><small>Email</small></label>&nbsp;&nbsp;&nbsp;
612
+ <input id="require_fwebsite" name="require_fields[]" type="checkbox" '.$rf['fwebsite'].' value="fwebsite" />&nbsp;<label for="require_fwebsite"><small>Website</small></label>&nbsp;&nbsp;&nbsp;
613
+ <input id="require_ftitle" name="require_fields[]" type="checkbox" '.$rf['ftitle'].' value="ftitle" />&nbsp;<label for="require_ftitle"><small>Review Title</small></label>
614
+ <br /><br />
615
+ <label>Fields to show on each approved review: </label>
616
+ <input id="show_fname" name="show_fields[]" type="checkbox" '.$sf['fname'].' value="fname" />&nbsp;<label for="show_fname"><small>Name</small></label>&nbsp;&nbsp;&nbsp;
617
+ <input id="show_femail" name="show_fields[]" type="checkbox" '.$sf['femail'].' value="femail" />&nbsp;<label for="show_femail"><small>Email</small></label>&nbsp;&nbsp;&nbsp;
618
+ <input id="show_fwebsite" name="show_fields[]" type="checkbox" '.$sf['fwebsite'].' value="fwebsite" />&nbsp;<label for="show_fwebsite"><small>Website</small></label>&nbsp;&nbsp;&nbsp;
619
+ <input id="show_ftitle" name="show_fields[]" type="checkbox" '.$sf['ftitle'].' value="ftitle" />&nbsp;<label for="show_ftitle"><small>Review Title</small></label>
620
+ <br />
621
+ <small>It is usually NOT a good idea to show email addresses publicly.</small>
622
+ <br /><br />
623
+ <label>Custom fields on review form: </label>(<small>You can type in the names of any additional fields you would like here.</small>)
624
+ <div style="font-size:10px;padding-top:6px;">
625
+ ';
626
+ for ($i = 0; $i < 6; $i++) /* 6 custom fields */
627
+ {
628
+ if ( !isset($this->options['ask_custom'][$i]) ) { $this->options['ask_custom'][$i] = 0; }
629
+ if ( !isset($this->options['require_custom'][$i]) ) { $this->options['require_custom'][$i] = 0; }
630
+ if ( !isset($this->options['show_custom'][$i]) ) { $this->options['show_custom'][$i] = 0; }
631
+
632
+ if ($this->options['ask_custom'][$i] == 1) { $caf = 'checked'; } else { $caf = ''; }
633
+ if ($this->options['require_custom'][$i] == 1) { $crf = 'checked'; } else { $crf = ''; }
634
+ if ($this->options['show_custom'][$i] == 1) { $csf = 'checked'; } else { $csf = ''; }
635
+ echo '
636
+ <label for="field_custom'.$i.'">Field Name: </label><input id="field_custom'.$i.'" name="field_custom['.$i.']" type="text" value="'.$this->options['field_custom'][$i].'" />&nbsp;&nbsp;&nbsp;
637
+ <input '.$caf.' class="custom_ask" data-id="'.$i.'" id="ask_custom'.$i.'" name="ask_custom['.$i.']" type="checkbox" value="1" />&nbsp;<label for="ask_custom'.$i.'">Ask</label>&nbsp;&nbsp;&nbsp;
638
+ <input '.$crf.' class="custom_req" data-id="'.$i.'" id="require_custom'.$i.'" name="require_custom['.$i.']" type="checkbox" value="1" />&nbsp;<label for="require_custom'.$i.'">Require</label>&nbsp;&nbsp;&nbsp;
639
+ <input '.$csf.' class="custom_show" data-id="'.$i.'" id="show_custom'.$i.'" name="show_custom['.$i.']" type="checkbox" value="1" />&nbsp;<label for="show_custom'.$i.'">Show</label><br />
640
+ ';
641
+ }
642
+ echo '
643
+ </div>
644
+ <br /><br />
645
+ <label for="title_tag">Heading to use for Review Titles: </label>
646
+ <select id="title_tag" name="title_tag">
647
+ <option ';if ($this->options['title_tag'] == 'h2') { echo "selected"; } echo ' value="h2">H2</option>
648
+ <option ';if ($this->options['title_tag'] == 'h3') { echo "selected"; } echo ' value="h3">H3</option>
649
+ <option ';if ($this->options['title_tag'] == 'h4') { echo "selected"; } echo ' value="h4">H4</option>
650
+ <option ';if ($this->options['title_tag'] == 'h5') { echo "selected"; } echo ' value="h5">H6</option>
651
+ <option ';if ($this->options['title_tag'] == 'h6') { echo "selected"; } echo ' value="h6">H7</option>
652
+ </select>
653
+ <br /><br />
654
+ <label for="goto_show_button">Show review form: </label><input type="checkbox" id="goto_show_button" name="goto_show_button" value="1" '.$goto_show_button_checked.' />
655
+ <br />
656
+ <small>If this option is unchecked, there will be no visible way for visitors to submit reviews.</small>
657
+ <br /><br />
658
+ <label for="goto_leave_text">Button text used to show review form: </label><input style="width:250px;" type="text" id="goto_leave_text" name="goto_leave_text" value="'.$this->options['goto_leave_text'].'" />
659
+ <br />
660
+ <small>This button will be shown above the first review.</small>
661
+ <br /><br />
662
+ <label for="leave_text">Text to be displayed above review form: </label><input style="width:250px;" type="text" id="goto_leave_text" name="goto_leave_text" value="'.$this->options['goto_leave_text'].'" />
663
+ <br />
664
+ <small>This will be shown as a heading immediately above the review form.</small>
665
+ <br /><br />
666
+ <label for="submit_button_text">Text to use for review form submit button: </label><input style="width:200px;" type="text" id="submit_button_text" name="submit_button_text" value="'.$this->options['submit_button_text'].'" />
667
+ <br />
668
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Save Changes" name="Submit"></div>
669
+ </div>
670
+ <div style="background:#eaf2fa;padding:6px;border-top:1px solid #ccc;border-bottom:1px solid #ccc;">
671
+ <legend>Advanced</legend>
672
+ </div>
673
+ <div style="padding:10px;padding-bottom:0px;">
674
+ <small><span style="color:#c00;">Be very careful when using these options. They should do exactly what they say, but are experimental, so use them at your own risk. Most users do not need to even think about using these options, but they are here in case you need them.</span></small>
675
+ <br /><br />
676
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Enable Plugin for all Existing Posts" name="Submit"></div>
677
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Disable Plugin for all Existing Posts" name="Submit"></div>
678
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Enable Plugin for all Existing Pages" name="Submit"></div>
679
+ <div class="submit" style="padding:10px 0px 0px 0px;"><input type="submit" class="button-primary" value="Disable Plugin for all Existing Pages" name="Submit"></div>
680
+ </div>';
681
+ settings_fields("wpcr_options");
682
+ echo '
683
+ </form>
684
+ <br />
685
+ </div>
686
+ </div>';
687
+ /* settings_fields is for Settings API / WPMU / future WP compatibility */
688
+ }
689
+
690
+ function security() {
691
+ if (!current_user_can('manage_options'))
692
+ {
693
+ wp_die( __('You do not have sufficient permissions to access this page.') );
694
+ }
695
+ }
696
+
697
+ function real_admin_options() {
698
+ $this->security();
699
+
700
+ $msg = '';
701
+
702
+ // make sure the db is created
703
+ global $wpdb;
704
+ $exists = $wpdb->get_var("SHOW TABLES LIKE '$this->dbtable'");
705
+ if ($exists != $this->dbtable) {
706
+ $this->parentClass->check_migrate(true);
707
+ $exists = $wpdb->get_var("SHOW TABLES LIKE '$this->dbtable'");
708
+ if ($exists != $this->dbtable) {
709
+ print "<br /><br /><br />COULD NOT CREATE DATABASE TABLE, PLEASE REPORT THIS ERROR";
710
+ }
711
+ }
712
+
713
+ if (!isset($this->p->Submit)) { $this->p->Submit = ''; }
714
+
715
+ if ($this->p->Submit == 'Save Changes') {
716
+ $msg = $this->update_options();
717
+ $this->parentClass->get_options();
718
+ }
719
+ elseif ($this->p->Submit == 'Enable Plugin for all Existing Posts') {
720
+ global $wpdb;
721
+ $wpdb->query( "DELETE $wpdb->postmeta FROM $wpdb->postmeta
722
+ LEFT JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->postmeta.post_id
723
+ WHERE $wpdb->posts.post_type = 'post' AND $wpdb->postmeta.meta_key = 'wpcr_enable' " );
724
+
725
+ $wpdb->query( "INSERT INTO $wpdb->postmeta
726
+ SELECT 0,$wpdb->posts.ID,'wpcr_enable',1
727
+ FROM $wpdb->posts
728
+ WHERE $wpdb->posts.post_type = 'post' " );
729
+ }
730
+ elseif ($this->p->Submit == 'Disable Plugin for all Existing Posts') {
731
+ global $wpdb;
732
+ $wpdb->query( "DELETE $wpdb->postmeta FROM $wpdb->postmeta
733
+ LEFT JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->postmeta.post_id
734
+ WHERE $wpdb->posts.post_type = 'post' AND $wpdb->postmeta.meta_key = 'wpcr_enable' " );
735
+ }
736
+ elseif ($this->p->Submit == 'Enable Plugin for all Existing Pages') {
737
+ global $wpdb;
738
+ $wpdb->query( "DELETE $wpdb->postmeta FROM $wpdb->postmeta
739
+ LEFT JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->postmeta.post_id
740
+ WHERE $wpdb->posts.post_type = 'page' AND $wpdb->postmeta.meta_key = 'wpcr_enable' " );
741
+
742
+ $wpdb->query( "INSERT INTO $wpdb->postmeta
743
+ SELECT 0,$wpdb->posts.ID,'wpcr_enable',1
744
+ FROM $wpdb->posts
745
+ WHERE $wpdb->posts.post_type = 'page' " );
746
+ }
747
+ elseif ($this->p->Submit == 'Disable Plugin for all Existing Pages') {
748
+ global $wpdb;
749
+ $wpdb->query( "DELETE $wpdb->postmeta FROM $wpdb->postmeta
750
+ LEFT JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->postmeta.post_id
751
+ WHERE $wpdb->posts.post_type = 'page' AND $wpdb->postmeta.meta_key = 'wpcr_enable' " );
752
+ }
753
+
754
+ if (isset($this->p->email)) {
755
+ $msg = $this->update_options();
756
+ $this->parentClass->get_options();
757
+ }
758
+
759
+ echo '
760
+ <div id="wpcr_respond_1" class="wrap">
761
+ <h2>WP Customer Reviews - Options</h2>';
762
+ if ($msg) { echo '<h3 style="color:#a00;">'.$msg.'</h3>'; }
763
+ echo '
764
+ <div class="metabox-holder">
765
+ <div class="postbox" style="width:700px;">
766
+ <h3 style="cursor:default;">About WP Customer Reviews</h3>
767
+ <div style="padding:0 10px; background:#ffffff;">
768
+ <p>
769
+ Version: <strong>'.$this->plugin_version.'</strong>
770
+ </p>';
771
+
772
+ echo '
773
+ <p style="margin-top:10px !important;padding:3px 5px 3px 5px !important;background:#fffbcc;border:1px solid #e6db55;color:#555;">
774
+ WP Customer Reviews: Big News! Version 3 is on the way.
775
+ <a style="font-weight:bold;" target="_blank" href="http://www.gowebsolutions.com/wp-customer-reviews/?from=wpcr_plugin_notice_1">Click here for details</a> and to submit your feature requests.
776
+ </p>
777
+ ';
778
+
779
+ echo '
780
+ <p style="margin-top:10px !important;">
781
+ WP Customer Reviews allows your customers and visitors to leave reviews or testimonials of your services. Reviews are Microformat enabled and can help crawlers such as Google Local Search and Google Places to index these reviews. The plugin also allows for your business information, in hCard microformat, to be (non-visibly) added to all pages.
782
+ </p>
783
+ ';
784
+
785
+ echo '
786
+ <br />
787
+ </div>
788
+ <div style="padding:6px; background:#eaf2fa;">
789
+ Plugin Homepage: <a target="_blank" href="http://www.gowebsolutions.com/wp-customer-reviews/">http://www.gowebsolutions.com/wp-customer-reviews/</a><br /><br />
790
+ Support Forum: <a target="_blank" href="http://wordpress.org/tags/wp-customer-reviews?forum_id=10">http://wordpress.org/tags/wp-customer-reviews?forum_id=10</a><br /><br />
791
+ Support Email: <a href="mailto:aaron@gowebsolutions.com">aaron@gowebsolutions.com</a><br /><br />
792
+ <div style="color:#BE5409;font-weight:bold;">If you like this plugin, please <a target="_blank" href="http://wordpress.org/extend/plugins/wp-customer-reviews/">login and rate it 5 stars here</a> or consider a donation via our plugin homepage.</div>
793
+ </div>
794
+ </div>';
795
+
796
+ if ($this->options['activate'] == 0) {
797
+ $this->show_activation();
798
+ echo '<br /></div>';
799
+ return;
800
+ }
801
+
802
+ $this->show_options();
803
+ echo '<br /></div>';
804
+ }
805
+
806
+ function real_admin_view_reviews() {
807
+ global $wpdb;
808
+
809
+ if (!isset($this->p->s)) { $this->p->s = ''; }
810
+ $this->p->s_orig = $this->p->s;
811
+
812
+ if (!isset($this->p->review_status)) { $this->p->review_status = 0; }
813
+ $this->p->review_status = intval($this->p->review_status);
814
+
815
+ /* begin - actions */
816
+ if (isset($this->p->action)) {
817
+
818
+ if (isset($this->p->r)) {
819
+ $this->p->r = intval($this->p->r);
820
+
821
+ switch ($this->p->action) {
822
+ case 'deletereview':
823
+ $wpdb->query("DELETE FROM `$this->dbtable` WHERE `id`={$this->p->r} LIMIT 1");
824
+ break;
825
+ case 'trashreview':
826
+ $wpdb->query("UPDATE `$this->dbtable` SET `status`=2 WHERE `id`={$this->p->r} LIMIT 1");
827
+ break;
828
+ case 'approvereview':
829
+ $wpdb->query("UPDATE `$this->dbtable` SET `status`=1 WHERE `id`={$this->p->r} LIMIT 1");
830
+ break;
831
+ case 'unapprovereview':
832
+ $wpdb->query("UPDATE `$this->dbtable` SET `status`=0 WHERE `id`={$this->p->r} LIMIT 1");
833
+ break;
834
+ case 'update_field':
835
+
836
+ ob_end_clean();
837
+
838
+ if (!is_array($this->p->json)) {
839
+ header('HTTP/1.1 403 Forbidden');
840
+ echo json_encode(array("errors" => 'Bad Request'));
841
+ exit();
842
+ }
843
+
844
+ $show_val = '';
845
+ $update_col = false;
846
+ $update_val = false;
847
+
848
+ foreach ($this->p->json as $col => $val) {
849
+
850
+ switch ($col) {
851
+ case 'date_time':
852
+ $d = date("m/d/Y g:i a",strtotime($val));
853
+ if (!$d || $d == '01/01/1970 12:00 am') {
854
+ header('HTTP/1.1 403 Forbidden');
855
+ echo json_encode(array("errors" => 'Bad Date Format'));
856
+ exit();
857
+ }
858
+
859
+ $show_val = $d;
860
+ $d2 = date("Y-m-d H:i:s",strtotime($val));
861
+ $update_col = mysql_real_escape_string($col);
862
+ $update_val = mysql_real_escape_string($d2);
863
+ break;
864
+
865
+ default:
866
+ if ($val == '') {
867
+ header('HTTP/1.1 403 Forbidden');
868
+ echo json_encode(array("errors" => 'Bad Value'));
869
+ exit();
870
+ }
871
+
872
+ /* for storing in DB - fix with IE 8 workaround */
873
+ $val = str_replace( array("<br />","<br/>","<br>") , "\n" , $val );
874
+
875
+ if (substr($col,0,7) == 'custom_') /* updating custom fields */
876
+ {
877
+ $custom_fields = array(); /* used for insert as well */
878
+ $custom_count = count($this->options['field_custom']); /* used for insert as well */
879
+ for ($i = 0; $i < $custom_count; $i++)
880
+ {
881
+ $custom_fields[$i] = $this->options['field_custom'][$i];
882
+ }
883
+
884
+ $custom_num = substr($col,7); /* gets the number after the _ */
885
+ /* get the old custom value */
886
+ $old_value = $wpdb->get_results("SELECT `custom_fields` FROM `$this->dbtable` WHERE `id`={$this->p->r} LIMIT 1");
887
+ if ($old_value && $wpdb->num_rows)
888
+ {
889
+ $old_value = @unserialize($old_value[0]->custom_fields);
890
+ if (!is_array($old_value)) { $old_value = array(); }
891
+ $custom_name = $custom_fields[$custom_num];
892
+ $old_value[$custom_name] = $val;
893
+ $new_value = serialize($old_value);
894
+ $update_col = mysql_real_escape_string('custom_fields');
895
+ $update_val = mysql_real_escape_string($new_value);
896
+ }
897
+ }
898
+ else /* updating regular fields */
899
+ {
900
+ $update_col = mysql_real_escape_string($col);
901
+ $update_val = mysql_real_escape_string($val);
902
+ }
903
+
904
+ $show_val = $val;
905
+
906
+ break;
907
+ }
908
+
909
+ }
910
+
911
+ if ($update_col !== false && $update_val !== false) {
912
+ $query = "UPDATE `$this->dbtable` SET `$update_col`='$update_val' WHERE `id`={$this->p->r} LIMIT 1";
913
+ $wpdb->query($query);
914
+ echo $show_val;
915
+ }
916
+
917
+ exit();
918
+ break;
919
+ }
920
+ }
921
+
922
+ if ( isset($this->p->delete_reviews) && is_array($this->p->delete_reviews) && count($this->p->delete_reviews) ) {
923
+
924
+ foreach ($this->p->delete_reviews as $i => $rid) {
925
+ $this->p->delete_reviews[$i] = intval($rid);
926
+ }
927
+
928
+ if (isset($this->p->act2)) { $this->p->action = $this->p->action2; }
929
+
930
+ switch ($this->p->action) {
931
+ case 'bapprove':
932
+ $wpdb->query("UPDATE `$this->dbtable` SET `status`=1 WHERE `id` IN(".implode(',',$this->p->delete_reviews).")");
933
+ break;
934
+ case 'bunapprove':
935
+ $wpdb->query("UPDATE `$this->dbtable` SET `status`=0 WHERE `id` IN(".implode(',',$this->p->delete_reviews).")");
936
+ break;
937
+ case 'btrash':
938
+ $wpdb->query("UPDATE `$this->dbtable` SET `status`=2 WHERE `id` IN(".implode(',',$this->p->delete_reviews).")");
939
+ break;
940
+ case 'bdelete':
941
+ $wpdb->query("DELETE FROM `$this->dbtable` WHERE `id` IN(".implode(',',$this->p->delete_reviews).")");
942
+ break;
943
+ }
944
+ }
945
+
946
+ $this->force_update_cache(); /* update any caches */
947
+ $this->parentClass->wpcr_redirect("?page=wpcr_view_reviews&review_status={$this->p->review_status}");
948
+ }
949
+ /* end - actions */
950
+
951
+ /* begin - searching */
952
+ if ($this->p->review_status == -1) {
953
+ $sql_where = '-1=-1';
954
+ } else {
955
+ $sql_where = 'status='.$this->p->review_status;
956
+ }
957
+
958
+ $and_clause = '';
959
+ if ($this->p->s != '') { /* searching */
960
+ $this->p->s = '%'.$this->p->s.'%';
961
+ $sql_where = '-1=-1';
962
+ $this->p->review_status = -1;
963
+ $and_clause = "AND (`reviewer_name` LIKE %s OR `reviewer_email` LIKE %s OR `reviewer_ip` LIKE %s OR `review_text` LIKE %s OR `review_response` LIKE %s OR `reviewer_url` LIKE %s)";
964
+ $and_clause = $wpdb->prepare($and_clause,$this->p->s,$this->p->s,$this->p->s,$this->p->s,$this->p->s,$this->p->s);
965
+
966
+ $query = "SELECT
967
+ `id`,
968
+ `date_time`,
969
+ `reviewer_name`,
970
+ `reviewer_email`,
971
+ `reviewer_ip`,
972
+ `review_title`,
973
+ `review_text`,
974
+ `review_response`,
975
+ `review_rating`,
976
+ `reviewer_url`,
977
+ `status`,
978
+ `page_id`,
979
+ `custom_fields`
980
+ FROM `$this->dbtable` WHERE $sql_where $and_clause ORDER BY `id` DESC";
981
+
982
+ $reviews = $wpdb->get_results($query);
983
+ $total_reviews = 0; /* no pagination for searches */
984
+ }
985
+ /* end - searching */
986
+ else
987
+ {
988
+ $arr_Reviews = $this->parentClass->get_reviews(-1,$this->page,$this->options['reviews_per_page'],$this->p->review_status);
989
+ $reviews = $arr_Reviews[0];
990
+ $total_reviews = $arr_Reviews[1];
991
+ }
992
+
993
+ $status_text = "";
994
+ switch ($this->p->review_status)
995
+ {
996
+ case -1:
997
+ $status_text = 'Submitted';
998
+ break;
999
+ case 0:
1000
+ $status_text = 'Pending';
1001
+ break;
1002
+ case 1:
1003
+ $status_text = 'Approved';
1004
+ break;
1005
+ case 2:
1006
+ $status_text = 'Trashed';
1007
+ break;
1008
+ }
1009
+
1010
+ $pending_count = $wpdb->get_results("SELECT COUNT(*) AS `count_pending` FROM `$this->dbtable` WHERE `status`=0");
1011
+ $pending_count = $pending_count[0]->count_pending;
1012
+
1013
+ $approved_count = $wpdb->get_results("SELECT COUNT(*) AS `count_approved` FROM `$this->dbtable` WHERE `status`=1");
1014
+ $approved_count = $approved_count[0]->count_approved;
1015
+
1016
+ $trash_count = $wpdb->get_results("SELECT COUNT(*) AS `count_trash` FROM `$this->dbtable` WHERE `status`=2");
1017
+ $trash_count = $trash_count[0]->count_trash;
1018
+ ?>
1019
+ <div id="wpcr_respond_1" class="wrap">
1020
+ <div class="icon32" id="icon-edit-comments"><br /></div>
1021
+ <h2>Customer Reviews - <?php echo $status_text; ?> Reviews</h2>
1022
+
1023
+ <ul class="subsubsub">
1024
+ <li class="all"><a <?php if ($this->p->review_status == -1) { echo 'class="current"'; } ?> href="?page=wpcr_view_reviews&amp;review_status=-1">All</a> |</li>
1025
+ <li class="moderated"><a <?php if ($this->p->review_status == 0) { echo 'class="current"'; } ?> href="?page=wpcr_view_reviews&amp;review_status=0">Pending
1026
+ <span class="count">(<span class="pending-count"><?php echo $pending_count;?></span>)</span></a> |
1027
+ </li>
1028
+ <li class="approved"><a <?php if ($this->p->review_status == 1) { echo 'class="current"'; } ?> href="?page=wpcr_view_reviews&amp;review_status=1">Approved
1029
+ <span class="count">(<span class="pending-count"><?php echo $approved_count;?></span>)</span></a> |
1030
+ </li>
1031
+ <li class="trash"><a <?php if ($this->p->review_status == 2) { echo 'class="current"'; } ?> href="?page=wpcr_view_reviews&amp;review_status=2">Trash</a>
1032
+ <span class="count">(<span class="pending-count"><?php echo $trash_count;?></span>)</span></a>
1033
+ </li>
1034
+ </ul>
1035
+
1036
+ <form method="GET" action="" id="search-form" name="search-form">
1037
+ <p class="search-box">
1038
+ <?php if ($this->p->s_orig): ?><span style='color:#c00;font-weight:bold;'>RESULTS FOR: </span><?php endif; ?>
1039
+ <label for="comment-search-input" class="screen-reader-text">Search Reviews:</label>
1040
+ <input type="text" value="<?php echo $this->p->s_orig; ?>" name="s" id="comment-search-input" />
1041
+ <input type="hidden" name="page" value="wpcr_view_reviews" />
1042
+ <input type="submit" class="button" value="Search Reviews" />
1043
+ </p>
1044
+ </form>
1045
+
1046
+ <form method="POST" action="?page=wpcr_view_reviews" id="comments-form" name="comments-form">
1047
+ <input type="hidden" name="review_status" value="<?php echo $this->p->review_status; ?>" />
1048
+ <div class="tablenav">
1049
+ <div class="alignleft actions">
1050
+ <select name="action">
1051
+ <option selected="selected" value="-1">Bulk Actions</option>
1052
+ <option value="bunapprove">Unapprove</option>
1053
+ <option value="bapprove">Approve</option>
1054
+ <option value="btrash">Move to Trash</option>
1055
+ <option value="bdelete">Delete Forever</option>
1056
+ </select>&nbsp;
1057
+ <input type="submit" class="button-secondary apply" name="act" value="Apply" id="doaction" />
1058
+ </div><br class="clear" />
1059
+ </div>
1060
+
1061
+ <div class="clear"></div>
1062
+ <table cellspacing="0" class="widefat comments fixed">
1063
+ <thead>
1064
+ <tr>
1065
+ <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox" /></th>
1066
+ <th style="" class="manage-column column-author" id="author" scope="col">Author</th>
1067
+ <th style="" class="manage-column column-comment" id="comment" scope="col">Review</th>
1068
+ </tr>
1069
+ </thead>
1070
+
1071
+ <tfoot>
1072
+ <tr>
1073
+ <th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox" /></th>
1074
+ <th style="" class="manage-column column-author" scope="col">Author</th>
1075
+ <th style="" class="manage-column column-comment" scope="col">Review</th>
1076
+ </tr>
1077
+ </tfoot>
1078
+
1079
+ <tbody class="list:comment" id="the-comment-list">
1080
+ <?php
1081
+ if (count($reviews) == 0) {
1082
+ ?>
1083
+ <tr><td colspan="3" align="center"><br />There are no <strong><?php echo $status_text; ?></strong> reviews yet.<br /><br /></td></tr>
1084
+ <?php
1085
+ }
1086
+
1087
+ foreach ($reviews as $review)
1088
+ {
1089
+ $rid = $review->id;
1090
+ $update_path = get_admin_url()."admin-ajax.php?page=wpcr_view_reviews&r=$rid&action=update_field";
1091
+ $hash = md5( strtolower( trim( $review->reviewer_email ) ) );
1092
+ $review->review_title = stripslashes($review->review_title);
1093
+ $review->review_text = stripslashes($review->review_text);
1094
+ $review->review_response = stripslashes($review->review_response);
1095
+ $review->reviewer_name = stripslashes($review->reviewer_name);
1096
+ if ($review->reviewer_name == '') { $review->reviewer_name = 'Anonymous'; }
1097
+ $review_text = nl2br($review->review_text);
1098
+ $review_text = str_replace( array("\r\n","\r","\n") , "" , $review_text );
1099
+ $review_response = nl2br($review->review_response);
1100
+ $review_response = str_replace( array("\r\n","\r","\n") , "" , $review_response );
1101
+ $page = get_post($review->page_id);
1102
+ if (!$page) { continue; } /* page no longer exists */
1103
+ ?>
1104
+ <tr class="approved" id="review-<?php echo $rid;?>">
1105
+ <th class="check-column" scope="row"><input type="checkbox" value="<?php echo $rid;?>" name="delete_reviews[]" /></th>
1106
+ <td class="author column-author">
1107
+ <img width="32" height="32" class="avatar avatar-32 photo" src=
1108
+ "http://1.gravatar.com/avatar/<?php echo $hash; ?>?s=32&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&amp;r=G"
1109
+ alt="" />&nbsp;<span style="font-weight:bold;" class="best_in_place" data-url='<?php echo $update_path; ?>' data-object='json' data-attribute='reviewer_name'><?php echo $review->reviewer_name; ?></span>
1110
+ <br />
1111
+ <a href="<?php echo $review->reviewer_url; ?>"><?php echo $review->reviewer_url; ?></a><br />
1112
+ <a href="mailto:<?php echo $review->reviewer_email; ?>"><?php echo $review->reviewer_email; ?></a><br />
1113
+ <a href="?page=wpcr_view_reviews&amp;s=<?php echo $review->reviewer_ip; ?>"><?php echo $review->reviewer_ip; ?></a><br />
1114
+ <?php
1115
+ $custom_count = count($this->options['field_custom']); /* used for insert as well */
1116
+ $custom_unserialized = @unserialize($review->custom_fields);
1117
+ if ($custom_unserialized !== false)
1118
+ {
1119
+ for ($i = 0; $i < $custom_count; $i++)
1120
+ {
1121
+ $custom_field_name = $this->options['field_custom'][$i];
1122
+ if ( isset($custom_unserialized[$custom_field_name]) ) {
1123
+ $custom_value = $custom_unserialized[$custom_field_name];
1124
+ if ($custom_value != '')
1125
+ {
1126
+ echo "$custom_field_name: <span class='best_in_place' data-url='$update_path' data-object='json' data-attribute='custom_$i'>$custom_value</span><br />";
1127
+ }
1128
+ }
1129
+ }
1130
+ }
1131
+ ?>
1132
+ <div style="margin-left:-4px;">
1133
+ <div style="height:22px;" class="best_in_place"
1134
+ data-collection='[[1,"Rated 1 Star"],[2,"Rated 2 Stars"],[3,"Rated 3 Stars"],[4,"Rated 4 Stars"],[5,"Rated 5 Stars"]]'
1135
+ data-url='<?php echo $update_path; ?>'
1136
+ data-object='json'
1137
+ data-attribute='review_rating'
1138
+ data-callback='make_stars_from_rating'
1139
+ data-type='select'><?php echo $this->parentClass->output_rating($review->review_rating,false); ?></div>
1140
+ </div>
1141
+ </td>
1142
+ <td class="comment column-comment">
1143
+ <div class="wpcr-submitted-on">
1144
+ <span class="best_in_place" data-url='<?php echo $update_path; ?>' data-object='json' data-attribute='date_time'>
1145
+ <?php echo date("m/d/Y g:i a",strtotime($review->date_time)); ?></a>
1146
+ </span>&nbsp;on&nbsp;<?php echo get_the_title($review->page_id); ?>
1147
+ <?php if ($review->status == 1) : ?>[<a target="_blank" href="<?php echo $this->parentClass->get_jumplink_for_review($review,$this->page); ?>">View Review on Page</a>]<?php endif; ?>
1148
+ </div>
1149
+ <p>
1150
+ <span style="font-size:13px;font-weight:bold;">Title:&nbsp;</span>
1151
+ <span style="font-size:14px; font-weight:bold;"
1152
+ class="best_in_place"
1153
+ data-url='<?php echo $update_path; ?>'
1154
+ data-object='json'
1155
+ data-attribute='review_title'><?php echo $review->review_title; ?></span>
1156
+ <br /><br />
1157
+ <div class="best_in_place"
1158
+ data-url='<?php echo $update_path; ?>'
1159
+ data-object='json'
1160
+ data-attribute='review_text'
1161
+ data-callback='callback_review_text'
1162
+ data-type='textarea'><?php echo $review_text; ?></div>
1163
+ <div style="font-size:13px;font-weight:bold;">
1164
+ <br />
1165
+ Official Response:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1166
+ <span style="font-size:11px;font-style:italic;">Leave this blank if you do not want it to be public</span>
1167
+ </div>
1168
+ <div class="best_in_place"
1169
+ data-url='<?php echo $update_path; ?>'
1170
+ data-object='json'
1171
+ data-attribute='review_response'
1172
+ data-callback='callback_review_text'
1173
+ data-type='textarea'><?php echo $review_response; ?></div>
1174
+ </p>
1175
+ <div class="row-actions">
1176
+ <span class="approve <?php if ($review->status == 0 || $review->status == 2) { echo 'wpcr_show'; } else { echo 'wpcr_hide'; }?>"><a title="Mark as Approved"
1177
+ href="?page=wpcr_view_reviews&amp;action=approvereview&amp;r=<?php echo $rid;?>&amp;review_status=<?php echo $this->p->review_status;?>">
1178
+ Mark as Approved</a>&nbsp;|&nbsp;</span>
1179
+ <span class="unapprove <?php if ($review->status == 1 || $review->status == 2) { echo 'wpcr_show'; } else { echo 'wpcr_hide'; }?>"><a title="Mark as Unapproved"
1180
+ href="?page=wpcr_view_reviews&amp;action=unapprovereview&amp;r=<?php echo $rid;?>&amp;review_status=<?php echo $this->p->review_status;?>">
1181
+ Mark as Unapproved</a><?php if ($review->status != 2): ?>&nbsp;|&nbsp;<?php endif; ?></span>
1182
+ <span class="trash <?php if ($review->status == 2) { echo 'wpcr_hide'; } else { echo 'wpcr_show'; }?>"><a title="Move to Trash"
1183
+ href= "?page=wpcr_view_reviews&amp;action=trashreview&amp;r=<?php echo $rid;?>&amp;review_status=<?php echo $this->p->review_status;?>">
1184
+ Move to Trash</a><?php if ($review->status != 2): ?>&nbsp;|&nbsp;<?php endif; ?></span>
1185
+ <span class="trash <?php if ($review->status == 2) { echo 'wpcr_hide'; } else { echo 'wpcr_show'; }?>"><a title="Delete Forever"
1186
+ href= "?page=wpcr_view_reviews&amp;action=deletereview&amp;r=<?php echo $rid;?>&amp;review_status=<?php echo $this->p->review_status;?>">
1187
+ Delete Forever</a></span>
1188
+ </div>
1189
+ </td>
1190
+ </tr>
1191
+ <?php
1192
+ }
1193
+ ?>
1194
+ </tbody>
1195
+ </table>
1196
+
1197
+ <div class="tablenav">
1198
+ <div class="alignleft actions" style="float:left;">
1199
+ <select name="action2">
1200
+ <option selected="selected" value="-1">Bulk Actions</option>
1201
+ <option value="bunapprove">Unapprove</option>
1202
+ <option value="bapprove">Approve</option>
1203
+ <option value="btrash">Move to Trash</option>
1204
+ <option value="bdelete">Delete Forever</option>
1205
+ </select>&nbsp;
1206
+ <input type="submit" class="button-secondary apply" name="act2" value="Apply" id="doaction2" />
1207
+ </div>
1208
+ <div class="alignleft actions" style="float:left;padding-left:20px;"><?php echo $this->parentClass->pagination($total_reviews, $this->options['reviews_per_page']); ?></div>
1209
+ <br class="clear" />
1210
+ </div>
1211
+ </form>
1212
+
1213
+ <div id="ajax-response"></div>
1214
+ </div>
1215
+ <?php
1216
+ }
1217
+
1218
+ }
1219
+
1220
+ if (!defined('IN_WPCR_ADMIN')) {
1221
+ global $WPCustomerReviews, $WPCustomerReviewsAdmin;
1222
+ $WPCustomerReviewsAdmin = new WPCustomerReviewsAdmin($WPCustomerReviews);
1223
+ }
1224
+ ?>
wp-customer-reviews.css ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ WP Customer Reviews
3
+ You can override any of these values in your theme CSS if you use !important
4
+ Example: #wpcr_respond_1 blockquote.description p { font-size:12px !important; font-weight:bold !important; }
5
+ */
6
+
7
+ .wpcr_show { display:inline; }
8
+ .wpcr_hide { display:none; }
9
+ .wpcr_fl { float:left; }
10
+ .wpcr_sc { padding:0px 10px 0px 0px; }
11
+ .wpcr_rname { padding:0px 0px 0px 0px; line-height:20px; }
12
+ .wpcr_clear { clear:both; }
13
+ .wpcr_spacing1 { padding-bottom:5px; }
14
+ .wpcr_lh30 { line-height:30px; }
15
+ .wpcr_pb5 { padding-bottom:5px; }
16
+ .wpcr_power { padding-top:30px !important; padding-bottom:5px !important; font-size:10px !important; }
17
+ .wpcr_status_msg { color:#c00;font-weight:bold; }
18
+ .wpcr_status_msg div { color:#c00;font-weight:bold;padding-bottom:15px;padding-top:15px; }
19
+
20
+ /* title of review */
21
+ #wpcr_respond_1 h2.summary { padding: 5px 0 5px 0; }
22
+ #wpcr_respond_1 h3.summary { padding: 5px 0 5px 0; }
23
+ #wpcr_respond_1 h4.summary { padding: 5px 0 5px 0; }
24
+ #wpcr_respond_1 h5.summary { padding: 5px 0 5px 0; }
25
+ #wpcr_respond_1 h6.summary { padding: 5px 0 5px 0; }
26
+
27
+ /* review text */
28
+ #wpcr_respond_1 blockquote.description { font-size:14px; font-weight:normal; }
29
+ #wpcr_respond_1 blockquote.description p { font-size:14px; font-weight:normal; display:inline !important; }
30
+ #wpcr_respond_1 p.response { font-size:14px; font-weight:normal; font-style:italic; }
31
+
32
+ /* hcard */
33
+ #wpcr_respond_1 .vcard { font-size:10px !important; padding-bottom:5px; line-height:11px !important; }
34
+ #wpcr_hcard_h { display:none; }
35
+ #wpcr_hcard_s { display:block; }
36
+
37
+ #wpcr_postcomment { font-size:1.1em; font-weight:bold; }
38
+
39
+ #wpcr_commentform label { display:inline !important; }
40
+ #wpcr_commentform #fconfirm1, #wpcr_commentform #fconfirm3 { display:none; }
41
+ #wpcr_ad { background:#ffffff; }
42
+ #wpcr_ad label { font-weight:bold; }
43
+
44
+ #wpcr_commentform #fconfirm2 { width:auto !important; }
45
+
46
+ #wpcr_respond_1, #wpcr_respond_2 { margin:0 !important; padding:0 !important; clear:both !important; }
47
+ #wpcr_respond_1 p, #wpcr_respond_2 p {
48
+ margin:0 !important;
49
+ padding:0 !important;
50
+ line-height:120% !important;
51
+ margin-top:2px !important;
52
+ margin-bottom:2px !important;
53
+ }
54
+
55
+ #wpcr_respond_1 .wpcr_rating, #wpcr_commentform .wpcr_rating {
56
+ border:0 !important;
57
+ margin:0 !important;
58
+ padding:0 !important;
59
+ margin-left:0px !important;
60
+ margin-top:0px !important;
61
+ overflow:hidden;
62
+ height:16px;
63
+ }
64
+
65
+ /* Thank you ColorRating for the inspiration and image */
66
+ #wpcr_respond_1 .sp_rating { line-height:1.7em; display:block; }
67
+ #wpcr_respond_1 .sp_rating * { border:0 none; margin:0; padding:0; }
68
+
69
+ #wpcr_respond_1 .base { background:url(newstars.png) 0 0 no-repeat; width:85px; height:17px; float:left; padding-right:4px; overflow:hidden; display:block; }
70
+ #wpcr_respond_1 .average { background:url(newstars.png) 0 -15px no-repeat; text-indent:-9999px; height:17px; }
71
+
72
+ #wpcr_respond_2 { display:none; background-color:inherit; }
73
+
74
+ #wpcr_commentform .sp_rating { line-height:1.7em; display:block; }
75
+ #wpcr_commentform .sp_rating * { border:0 none; margin:0; padding:0; }
76
+
77
+ #wpcr_commentform .status { height:16px; width:100px; overflow:hidden; position:relative; cursor:pointer; display:block; }
78
+
79
+ #wpcr_commentform .base { display:none; }
80
+
81
+ #wpcr_commentform .score { background:url(newstars.png) 0 0 no-repeat; width:85px; height:17px; float:left; position:relative; }
82
+ #wpcr_commentform .score a {
83
+ display:block;
84
+ height:17px;
85
+ float:left;
86
+ text-indent:-9999px;
87
+ position:absolute;
88
+ overflow:hidden;
89
+ line-height:1em;
90
+ }
91
+ #wpcr_commentform .score a:hover { background:url(newstars.png) bottom right no-repeat; }
92
+ #wpcr_commentform .score1 {width:20%; z-index:55;}
93
+ #wpcr_commentform .score2 {width:40%; z-index:54;}
94
+ #wpcr_commentform .score3 {width:60%; z-index:53;}
95
+ #wpcr_commentform .score4 {width:80%; z-index:52;}
96
+ #wpcr_commentform .score5 {width:100%; z-index:51;}
97
+
98
+ #wpcr_div_2 { width:600px; }
99
+ #wpcr_table_2 { text-align:left; width:100%; }
100
+ #wpcr_table_2 td { text-align:left; }
101
+ #wpcr_check_confirm { margin-top:10px;font-size:13px;color:#c00;margin-bottom:4px; }
102
+
103
+ #wpcr_button_1, #wpcr_button_1:link, #wpcr_button_1:visited, #wpcr_submit_btn, #wpcr_submit_btn:link, #wpcr_submit_btn:visited {
104
+ -moz-border-radius: 3px !important;
105
+ -webkit-border-radius: 3px !important;
106
+ background: white url('button.png') 0 0 repeat-x !important;
107
+ background: -moz-linear-gradient(0% 170% 90deg, #c4c4c4, white) !important;
108
+ background: -webkit-gradient(linear, 0% 0%, 0% 170%, from(white), to(#c4c4c4)) !important;
109
+ border: 1px solid !important;
110
+ border-color: #e6e6e6 #cccccc #cccccc #e6e6e6 !important;
111
+ border-radius: 3px !important;
112
+ color: #404040 !important;
113
+ cursor:pointer !important;
114
+ display: inline-block !important;
115
+ font-size: 13px !important;
116
+ font-weight: normal !important;
117
+ outline: 0 !important;
118
+ padding: 5px 8px 5px !important;
119
+ text-align: center !important;
120
+ text-decoration: none !important;
121
+ text-shadow: 1px 1px 0 white !important;
122
+ white-space: nowrap !important;
123
+ float:none !important;
124
+ height:auto !important;
125
+ text-indent:0 !important;
126
+ }
127
+
128
+ #wpcr_button_1:hover, #wpcr_submit_btn:hover {
129
+ background: -moz-linear-gradient(0% 170% 90deg, #b8b8b8, white) !important;
130
+ background: -webkit-gradient(linear, 0% 0%, 0% 170%, from(white), to(#b8b8b8)) !important;
131
+ border-color: #99ccff !important;
132
+ color: #333333 !important;
133
+ cursor:pointer !important;
134
+ font-weight: normal !important;
135
+ }
136
+
137
+ #wpcr_button_1:active, #wpcr_submit_btn:active {
138
+ position: relative !important;
139
+ top: 1px !important;
140
+ }
141
+
142
+ #wpcr_button_1:active, #wpcr_button_1:focus, #wpcr_submit_btn:active, #wpcr_submit_btn:focus {
143
+ background-position: 0 -25px !important;
144
+ background: -moz-linear-gradient(0% 170% 90deg, white, #dedede) !important;
145
+ background: -webkit-gradient(linear, 0% 0%, 0% 170%, from(#dedede), to(white)) !important;
146
+ border-color: #8fc7ff #94c9ff #94c9ff #8fc7ff !important;
147
+ color:#1a1a1a !important;
148
+ text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5) !important;
149
+ }
150
+
151
+ #wpcr_commentform input { padding:0; margin:0 !important; width:200px !important; }
152
+ #wpcr_commentform textarea { padding:0 !important; margin:0 !important; width:400px !important; height:100px !important; }
153
+ #wpcr_commentform small { padding:0 !important; margin:0 !important; }
154
+ #wpcr_commentform table, #wpcr_commentform td { border:0 !important; border-style:none !important; }
155
+
156
+ #wpcr_pagination {
157
+ clear:both;
158
+ padding:0px 0px 0px 0px;
159
+ position:relative;
160
+ font-size:11px;
161
+ line-height:13px;
162
+ }
163
+
164
+ #wpcr_pagination_page {
165
+ float:left;
166
+ display:block;
167
+ line-height:30px;
168
+ padding-right:5px;
169
+ }
170
+
171
+ #wpcr_pagination .wpcr_current, #wpcr_pagination a {
172
+ display:block;
173
+ float:left;
174
+ margin: 2px 2px 2px 0;
175
+ padding:6px 9px 5px 9px;
176
+ text-decoration:none;
177
+ width:auto;
178
+ color:#fff;
179
+ background: #555;
180
+ }
181
+
182
+ #wpcr_pagination a:hover{
183
+ color:#fff;
184
+ background: #3279BB;
185
+ }
186
+
187
+ #wpcr_pagination .wpcr_current{
188
+ padding:6px 9px 5px 9px;
189
+ background: #3279BB;
190
+ color:#fff;
191
+ }
wp-customer-reviews.js ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var wpcr_old_btn_val = 'Click here to hide form';
2
+ var wpcr_req = [];
3
+
4
+ function wpcr_strpos (haystack, needle, offset) {
5
+ var i = (haystack+'').indexOf(needle, (offset || 0));
6
+ return i === -1 ? false : i;
7
+ }
8
+
9
+ function wpcr_ucfirst(str) {
10
+ var firstLetter = str.slice(0,1);
11
+ return firstLetter.toUpperCase() + str.substring(1);
12
+ }
13
+
14
+ function wpcr_del_cookie(name) {
15
+ document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
16
+ }
17
+
18
+ function wpcr_jump_to() {
19
+ jQuery(document).ready(function(){
20
+ window.location.hash="wpcr_respond_1";
21
+ });
22
+ }
23
+
24
+ function valwpcrform_2(newid,oldid,err) {
25
+
26
+ var myval = '';
27
+
28
+ for (var i in wpcr_req) {
29
+ var col = wpcr_req[i];
30
+ if (newid === col && jQuery("#"+oldid).val() === "") {
31
+ var nice_name = jQuery('label[for="'+oldid+'"]').html();
32
+ nice_name = nice_name.replace(":","");
33
+ nice_name = nice_name.replace("*","");
34
+ nice_name = jQuery.trim(nice_name);
35
+ err.push("You must include your "+nice_name+".");
36
+ }
37
+ }
38
+
39
+ if (newid === 'femail' && jQuery("#"+oldid).val() !== "") {
40
+ myval = jQuery("#"+oldid).val();
41
+ if (/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(myval) == false) {
42
+ err.push("The email address provided is not valid.");
43
+ }
44
+ }
45
+
46
+ if (newid === 'fwebsite' && jQuery("#"+oldid).val() !== "") {
47
+ myval = jQuery("#"+oldid).val();
48
+ if (/^\S+:\/\/\S+\.\S+.+$/.test(myval) == false) {
49
+ err.push("The website provided is not valid. Be sure to include http://");
50
+ }
51
+ }
52
+
53
+ if (newid === "ftext" && jQuery("#"+oldid).val().length < 30) {
54
+ err.push("You must include a review. Please make reviews at least a couple of sentences.");
55
+ }
56
+ if (newid === "fconfirm2" && jQuery("#fconfirm2").is(":checked") === false) {
57
+ err.push("You must confirm that you are human.");
58
+ }
59
+ if (newid === "fconfirm1" && jQuery("#fconfirm1").is(":checked") ) {
60
+ err.push("You must confirm that you are human. Code 2.");
61
+ }
62
+ if (newid === "fconfirm3" && jQuery("#fconfirm3").is(":checked") ) {
63
+ err.push("You must confirm that you are human. Code 3.");
64
+ }
65
+
66
+ return err;
67
+ }
68
+
69
+ function valwpcrform() {
70
+ var frating = parseInt(jQuery("#frating").val(), 10);
71
+ if (!frating) { frating = 0; }
72
+
73
+ var err = [];
74
+
75
+ jQuery("#wpcr_commentform").find('input, textarea').each(function(){
76
+ var oldid = jQuery(this).attr('name');
77
+ var newid = oldid;
78
+ var pos = wpcr_strpos(oldid,'-',0) + 1;
79
+ if (pos > 1) {
80
+ newid = oldid.substring(pos);
81
+ } else {
82
+ newid = oldid;
83
+ }
84
+ err = valwpcrform_2(newid,oldid,err);
85
+ });
86
+
87
+ if (frating < 1 || frating > 5) {
88
+ err.push("Please select a star rating from 1 to 5.");
89
+ }
90
+
91
+ if (err.length) {
92
+ var err2 = err.join("\n");
93
+ alert(err2);
94
+ jQuery("#wpcr_table_2").find("input:text:visible:first").focus();
95
+ return false;
96
+ }
97
+
98
+ var f = jQuery("#wpcr_commentform");
99
+ var newact = document.location.pathname + document.location.search;
100
+ f.attr("action",newact).removeAttr("onsubmit");
101
+ return true;
102
+ }
103
+
104
+ function wpcr_set_hover() {
105
+ jQuery("#wpcr_commentform .wpcr_rating").unbind("click",wpcr_set_hover);
106
+ wpcr_onhover();
107
+ }
108
+
109
+ function wpcr_onhover() {
110
+ jQuery("#wpcr_commentform .wpcr_rating").unbind("click",wpcr_set_hover);
111
+ jQuery("#wpcr_commentform .base").hide();
112
+ jQuery("#wpcr_commentform .status").show();
113
+ }
114
+
115
+ function wpcr_showform() {
116
+ jQuery("#wpcr_respond_2").slideToggle();
117
+ if (wpcr_old_btn_val == 'Click here to hide form') {
118
+ wpcr_old_btn_val = jQuery("#wpcr_button_1").html();
119
+ jQuery("#wpcr_button_1").html('Click here to hide form');
120
+ } else {
121
+ jQuery("#wpcr_button_1").html(wpcr_old_btn_val);
122
+ wpcr_old_btn_val = 'Click here to hide form';
123
+ }
124
+ jQuery("#wpcr_table_2").find("input:text:visible:first").focus();
125
+ }
126
+
127
+ function wpcr_init() {
128
+
129
+ jQuery("#wpcr_button_1").click(wpcr_showform);
130
+ jQuery("#wpcr_commentform").submit(valwpcrform);
131
+
132
+ jQuery("#wpcr_commentform .wpcr_rating a").click(function(e) {
133
+ e.preventDefault();
134
+ e.stopPropagation();
135
+
136
+ var wpcr_rating = jQuery(this).html();
137
+ var new_w = 20 * wpcr_rating + "%";
138
+
139
+ jQuery("#frating").val(wpcr_rating);
140
+ jQuery("#wpcr_commentform .base").show();
141
+ jQuery("#wpcr_commentform .average").css("width",new_w);
142
+ jQuery("#wpcr_commentform .status").hide();
143
+
144
+ jQuery("#wpcr_commentform .wpcr_rating").unbind("mouseover",wpcr_onhover);
145
+ jQuery("#wpcr_commentform .wpcr_rating").bind("click",wpcr_set_hover);
146
+ });
147
+
148
+ jQuery("#wpcr_commentform .wpcr_rating").bind("mouseover",wpcr_onhover);
149
+ }
150
+
151
+ jQuery(document).ready(wpcr_init);
wp-customer-reviews.php ADDED
@@ -0,0 +1,1344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: WP Customer Reviews
4
+ * Plugin URI: http://www.gowebsolutions.com/wp-customer-reviews/
5
+ * Description: WP Customer Reviews allows your customers and visitors to leave reviews or testimonials of your services. Reviews are Microformat enabled (hReview).
6
+ * Version: 2.4.8
7
+ * Revision Date: August 22, 2013
8
+ * Requires at least: WP 2.8.6
9
+ * Tested up to: WP 3.6
10
+ * Author: Go Web Solutions
11
+ * Author URI: http://www.gowebsolutions.com/
12
+ * License: GNU General Public License
13
+ *
14
+ * This program is free software; you can redistribute it and/or modify
15
+ * it under the terms of the GNU General Public License as published by
16
+ * the Free Software Foundation; either version 2 of the License, or
17
+ * (at your option) any later version.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program; if not, write to the Free Software
26
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ *
28
+ */
29
+
30
+ class WPCustomerReviews {
31
+
32
+ var $dbtable = 'wpcreviews';
33
+ var $force_active_page = false;
34
+ var $got_aggregate = false;
35
+ var $options = array();
36
+ var $p = '';
37
+ var $page = 1;
38
+ var $plugin_version = '0.0.0';
39
+ var $shown_form = false;
40
+ var $shown_hcard = false;
41
+ var $status_msg = '';
42
+
43
+ function WPCustomerReviews() {
44
+ global $wpdb;
45
+
46
+ define('IN_WPCR', 1);
47
+
48
+ /* uncomment the below block to display strict/notice errors */
49
+ /*
50
+ restore_error_handler();
51
+ error_reporting(E_ALL);
52
+ ini_set('error_reporting', E_ALL);
53
+ ini_set('html_errors',TRUE);
54
+ ini_set('display_errors',TRUE);
55
+ */
56
+
57
+ $this->dbtable = $wpdb->prefix . $this->dbtable;
58
+ $this->plugin_version = $this->plugin_get_version();
59
+
60
+ add_action('the_content', array(&$this, 'do_the_content'), 10); /* prio 10 prevents a conflict with some odd themes */
61
+ add_action('init', array(&$this, 'init')); /* init also tries to insert script/styles */
62
+ add_action('admin_init', array(&$this, 'admin_init'));
63
+
64
+ add_action('admin_notices', array(&$this, 'notice_init')); /* admin notices */
65
+
66
+ add_action('template_redirect',array(&$this, 'template_redirect')); /* handle redirects and form posts, and add style/script if needed */
67
+
68
+ add_action('admin_menu', array(&$this, 'addmenu'));
69
+ add_action('wp_ajax_update_field', array(&$this, 'admin_view_reviews')); /* special ajax stuff */
70
+ add_action('save_post', array(&$this, 'admin_save_post'), 10, 2); /* 2 arguments */
71
+
72
+ add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'plugin_settings_link'));
73
+ }
74
+
75
+ /* begin - admin notices */
76
+ /* keep out of admin file */
77
+ function notice_init() {
78
+
79
+ return true; /* removed per WP guidelines */
80
+
81
+ global $current_user;
82
+ $user_id = $current_user->ID;
83
+
84
+ $url = get_admin_url().'options-general.php?page=wpcr_options';
85
+
86
+ /* Check if the user has already clicked to ignore the message using meta */
87
+ if ( ! get_user_meta($user_id, 'wpcr_admin_notice_read_1') ) {
88
+ echo '<div class="updated"><p>';
89
+ echo '
90
+ WP Customer Reviews: Big News! Version 3 is on the way.
91
+ <a style="font-weight:bold;" target="_blank" href="'.$url.'&wpcr_notice_1=redir">Click here for details</a> and to submit your feature requests.&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
92
+ <a href="'.$url.'&wpcr_notice_1=ignore">Hide Notice</a>
93
+ ';
94
+ echo "</p></div>";
95
+ }
96
+ }
97
+ /* end - admin notices */
98
+
99
+ /* keep out of admin file */
100
+ function plugin_settings_link($links) {
101
+ $url = get_admin_url().'options-general.php?page=wpcr_options';
102
+ $settings_link = '<a href="'.$url.'"><img src="' . $this->getpluginurl() . 'star.png" />&nbsp;Settings</a>';
103
+ array_unshift($links, $settings_link);
104
+ return $links;
105
+ }
106
+
107
+ /* keep out of admin file */
108
+ function addmenu() {
109
+ add_options_page('Customer Reviews', '<img src="' . $this->getpluginurl() . 'star.png" />&nbsp;Customer Reviews', 'manage_options', 'wpcr_options', array(&$this, 'admin_options'));
110
+ add_menu_page('Customer Reviews', 'Customer Reviews', 'edit_others_posts', 'wpcr_view_reviews', array(&$this, 'admin_view_reviews'), $this->getpluginurl() . 'star.png', '50.91'); /* try to resolve issues with other plugins */
111
+ global $WPCustomerReviewsAdmin;
112
+ $this->include_admin(); /* include admin functions */
113
+ $WPCustomerReviewsAdmin->wpcr_add_meta_box();
114
+ }
115
+
116
+ /* forward to admin file */
117
+ function admin_options() {
118
+ global $WPCustomerReviewsAdmin;
119
+ $this->include_admin(); /* include admin functions */
120
+ $WPCustomerReviewsAdmin->real_admin_options();
121
+ }
122
+
123
+ /* forward to admin file */
124
+ function admin_save_post($post_id, $post) {
125
+ global $WPCustomerReviewsAdmin;
126
+ $this->include_admin(); /* include admin functions */
127
+ $WPCustomerReviewsAdmin->real_admin_save_post($post_id);
128
+ }
129
+
130
+ /* forward to admin file */
131
+ function admin_view_reviews() {
132
+ global $WPCustomerReviewsAdmin;
133
+ $this->include_admin(); /* include admin functions */
134
+ $WPCustomerReviewsAdmin->real_admin_view_reviews();
135
+ }
136
+
137
+ /* returns current plugin version */
138
+ function plugin_get_version() {
139
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php');
140
+ $plugin_data = get_plugin_data( __FILE__ );
141
+ $plugin_version = $plugin_data['Version'];
142
+ return $plugin_version;
143
+ }
144
+
145
+ function get_jumplink_for_review($review,$page) {
146
+ /* $page will be 1 for shortcode usage since it pulls most recent, which SHOULD all be on page 1 */
147
+ $link = get_permalink( $review->page_id );
148
+
149
+ if (strpos($link,'?') === false) {
150
+ $link = trailingslashit($link) . "?wpcrp=$page#hreview-$review->id";
151
+ } else {
152
+ $link = $link . "&wpcrp=$page#hreview-$review->id";
153
+ }
154
+
155
+ return $link;
156
+ }
157
+
158
+ function get_options() {
159
+ $home_domain = @parse_url(get_home_url());
160
+ $home_domain = $home_domain['scheme'] . "://" . $home_domain['host'] . '/';
161
+
162
+ $default_options = array(
163
+ 'act_email' => '',
164
+ 'act_uniq' => '',
165
+ 'activate' => 0,
166
+ 'ask_custom' => array(),
167
+ 'ask_fields' => array('fname' => 1, 'femail' => 1, 'fwebsite' => 1, 'ftitle' => 1, 'fage' => 0, 'fgender' => 0),
168
+ 'business_city' => '',
169
+ 'business_country' => 'USA',
170
+ 'business_email' => get_bloginfo('admin_email'),
171
+ 'business_name' => get_bloginfo('name'),
172
+ 'business_phone' => '',
173
+ 'business_state' => '',
174
+ 'business_street' => '',
175
+ 'business_url' => $home_domain,
176
+ 'business_zip' => '',
177
+ 'dbversion' => 0,
178
+ 'enable_posts_default' => 0,
179
+ 'enable_pages_default' => 0,
180
+ 'field_custom' => array(),
181
+ 'form_location' => 0,
182
+ 'goto_leave_text' => 'Click here to submit your review.',
183
+ 'goto_show_button' => 1,
184
+ 'hreview_type' => 'business',
185
+ 'leave_text' => 'Submit your review',
186
+ 'require_custom' => array(),
187
+ 'require_fields' => array('fname' => 1, 'femail' => 1, 'fwebsite' => 0, 'ftitle' => 0, 'fage' => 0, 'fgender' => 0),
188
+ 'reviews_per_page' => 10,
189
+ 'show_custom' => array(),
190
+ 'show_fields' => array('fname' => 1, 'femail' => 0, 'fwebsite' => 0, 'ftitle' => 1, 'fage' => 0, 'fgender' => 0),
191
+ 'show_hcard' => 1,
192
+ 'show_hcard_on' => 1,
193
+ 'submit_button_text' => 'Submit your review',
194
+ 'support_us' => 0,
195
+ 'title_tag' => 'h2'
196
+ );
197
+
198
+ $this->options = get_option('wpcr_options', $default_options);
199
+
200
+ /* magically easy migrations to newer versions */
201
+ $has_new = false;
202
+ foreach ($default_options as $col => $def_val) {
203
+
204
+ if (!isset($this->options[$col])) {
205
+ $this->options[$col] = $def_val;
206
+ $has_new = true;
207
+ }
208
+
209
+ if (is_array($def_val)) {
210
+ foreach ($def_val as $acol => $aval) {
211
+ if (!isset($this->options[$col][$acol])) {
212
+ $this->options[$col][$acol] = $aval;
213
+ $has_new = true;
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+ if ($has_new) {
220
+ update_option('wpcr_options', $this->options);
221
+ }
222
+ }
223
+
224
+ function make_p_obj() {
225
+ $this->p = new stdClass();
226
+
227
+ foreach ($_GET as $c => $val) {
228
+ if (is_array($val)) {
229
+ $this->p->$c = $val;
230
+ } else {
231
+ $this->p->$c = trim(stripslashes($val));
232
+ }
233
+ }
234
+
235
+ foreach ($_POST as $c => $val) {
236
+ if (is_array($val)) {
237
+ $this->p->$c = $val;
238
+ } else {
239
+ $this->p->$c = trim(stripslashes($val));
240
+ }
241
+ }
242
+ }
243
+
244
+ function check_migrate() {
245
+ global $wpdb;
246
+ $migrated = false;
247
+
248
+ /* remove me after official release */
249
+ $current_dbversion = intval(str_replace('.', '', $this->options['dbversion']));
250
+ $plugin_db_version = intval(str_replace('.', '', $this->plugin_version));
251
+
252
+ if ($current_dbversion == $plugin_db_version) {
253
+ return false;
254
+ }
255
+
256
+ global $WPCustomerReviewsAdmin;
257
+ $this->include_admin(); /* include admin functions */
258
+ $WPCustomerReviewsAdmin->createUpdateReviewtable(); /* creates AND updates table */
259
+
260
+ /* initial installation */
261
+ if ($current_dbversion == 0) {
262
+ $this->options['dbversion'] = $plugin_db_version;
263
+ $current_dbversion = $plugin_db_version;
264
+ update_option('wpcr_options', $this->options);
265
+ return false;
266
+ }
267
+
268
+ /* check for upgrades if needed */
269
+
270
+ /* upgrade to 2.0.0 */
271
+ if ($current_dbversion < 200) {
272
+ /* add multiple page support to database */
273
+
274
+ /* change all current reviews to use the selected page id */
275
+ $pageID = intval($this->options['selected_pageid']);
276
+ $wpdb->query("UPDATE `$this->dbtable` SET `page_id`=$pageID WHERE `page_id`=0");
277
+
278
+ /* add new meta to existing selected page */
279
+ update_post_meta($pageID, 'wpcr_enable', 1);
280
+
281
+ $this->options['dbversion'] = 200;
282
+ $current_dbversion = 200;
283
+ update_option('wpcr_options', $this->options);
284
+ $migrated = true;
285
+ }
286
+
287
+ /* done with all migrations, push dbversion to current version */
288
+ if ($current_dbversion != $plugin_db_version || $migrated == true) {
289
+ $this->options['dbversion'] = $plugin_db_version;
290
+ $current_dbversion = $plugin_db_version;
291
+ update_option('wpcr_options', $this->options);
292
+
293
+ global $WPCustomerReviewsAdmin;
294
+ $this->include_admin(); /* include admin functions */
295
+ $WPCustomerReviewsAdmin->notify_activate(3);
296
+ $WPCustomerReviewsAdmin->force_update_cache(); /* update any caches */
297
+
298
+ return true;
299
+ }
300
+
301
+ return false;
302
+ }
303
+
304
+ function is_active_page() {
305
+ global $post;
306
+
307
+ $has_shortcode = $this->force_active_page;
308
+ if ( $has_shortcode !== false ) {
309
+ return 'shortcode';
310
+ }
311
+
312
+ if ( !isset($post) || !isset($post->ID) || intval($post->ID) == 0 ) {
313
+ return false; /* we can only use the plugin if we have a valid post ID */
314
+ }
315
+
316
+ if (!is_singular()) {
317
+ return false; /* not on a single post/page view */
318
+ }
319
+
320
+ $wpcr_enabled_post = get_post_meta($post->ID, 'wpcr_enable', true);
321
+ if ( $wpcr_enabled_post ) {
322
+ return 'enabled';
323
+ }
324
+
325
+ return false;
326
+ }
327
+
328
+ function add_style_script() {
329
+ /* to prevent compatibility issues and for shortcodes, add to every page */
330
+ wp_enqueue_style('wp-customer-reviews');
331
+ wp_enqueue_script('wp-customer-reviews');
332
+ }
333
+
334
+ function template_redirect() {
335
+
336
+ /* do this in template_redirect so we can try to redirect cleanly */
337
+ global $post;
338
+ if (!isset($post) || !isset($post->ID)) {
339
+ $post = new stdClass();
340
+ $post->ID = 0;
341
+ }
342
+
343
+ if (isset($_COOKIE['wpcr_status_msg'])) {
344
+ $this->status_msg = $_COOKIE['wpcr_status_msg'];
345
+ if ( !headers_sent() ) {
346
+ setcookie('wpcr_status_msg', '', time() - 3600); /* delete the cookie */
347
+ unset($_COOKIE['wpcr_status_msg']);
348
+ }
349
+ }
350
+
351
+ $GET_P = "submitwpcr_$post->ID";
352
+
353
+ if ($post->ID > 0 && isset($this->p->$GET_P) && $this->p->$GET_P == $this->options['submit_button_text'])
354
+ {
355
+ $msg = $this->add_review($post->ID);
356
+ $has_error = $msg[0];
357
+ $status_msg = $msg[1];
358
+ $url = get_permalink($post->ID);
359
+ $cookie = array('wpcr_status_msg' => $status_msg);
360
+ $this->wpcr_redirect($url, $cookie);
361
+ }
362
+ }
363
+
364
+ function rand_string($length) {
365
+ $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
366
+ $str = '';
367
+
368
+ $size = strlen($chars);
369
+ for ($i = 0; $i < $length; $i++) {
370
+ $str .= $chars[rand(0, $size - 1)];
371
+ }
372
+
373
+ return $str;
374
+ }
375
+
376
+ function get_aggregate_reviews($pageID) {
377
+ if ($this->got_aggregate !== false) {
378
+ return $this->got_aggregate;
379
+ }
380
+
381
+ global $wpdb;
382
+
383
+ $pageID = intval($pageID);
384
+ $row = $wpdb->get_results("SELECT COUNT(*) AS `total`,AVG(review_rating) AS `aggregate_rating`,MAX(review_rating) AS `max_rating` FROM `$this->dbtable` WHERE `page_id`=$pageID AND `status`=1");
385
+
386
+ /* make sure we have at least one review before continuing below */
387
+ if ($wpdb->num_rows == 0 || $row[0]->total == 0) {
388
+ $this->got_aggregate = array("aggregate" => 0, "max" => 0, "total" => 0, "text" => 'Reviews for my site');
389
+ return false;
390
+ }
391
+
392
+ $aggregate_rating = $row[0]->aggregate_rating;
393
+ $max_rating = $row[0]->max_rating;
394
+ $total_reviews = $row[0]->total;
395
+
396
+ $row = $wpdb->get_results("SELECT `review_text` FROM `$this->dbtable` WHERE `page_id`=$pageID AND `status`=1 ORDER BY `date_time` DESC LIMIT 1");
397
+ $sample_text = substr($row[0]->review_text, 0, 180);
398
+
399
+ $this->got_aggregate = array("aggregate" => $aggregate_rating, "max" => $max_rating, "total" => $total_reviews, "text" => $sample_text);
400
+ return true;
401
+ }
402
+
403
+ function get_reviews($postID, $startpage, $perpage, $status) {
404
+ global $wpdb;
405
+
406
+ $startpage = $startpage - 1; /* mysql starts at 0 instead of 1, so reduce them all by 1 */
407
+ if ($startpage < 0) { $startpage = 0; }
408
+
409
+ $limit = 'LIMIT ' . $startpage * $perpage . ',' . $perpage;
410
+
411
+ if ($status == -1) {
412
+ $qry_status = '1=1';
413
+ } else {
414
+ $qry_status = "`status`=$status";
415
+ }
416
+
417
+ $postID = intval($postID);
418
+ if ($postID == -1) {
419
+ $and_post = '';
420
+ } else {
421
+ $and_post = "AND `page_id`=$postID";
422
+ }
423
+
424
+ $reviews = $wpdb->get_results("SELECT
425
+ `id`,
426
+ `date_time`,
427
+ `reviewer_name`,
428
+ `reviewer_email`,
429
+ `review_title`,
430
+ `review_text`,
431
+ `review_response`,
432
+ `review_rating`,
433
+ `reviewer_url`,
434
+ `reviewer_ip`,
435
+ `status`,
436
+ `page_id`,
437
+ `custom_fields`
438
+ FROM `$this->dbtable` WHERE $qry_status $and_post ORDER BY `date_time` DESC $limit
439
+ ");
440
+
441
+ $total_reviews = $wpdb->get_results("SELECT COUNT(*) AS `total` FROM `$this->dbtable` WHERE $qry_status $and_post");
442
+ $total_reviews = $total_reviews[0]->total;
443
+
444
+ return array($reviews, $total_reviews);
445
+ }
446
+
447
+ function aggregate_footer() {
448
+
449
+ $aggregate_footer_output = '';
450
+
451
+ if ($this->options['show_hcard_on'] != 0 && $this->shown_hcard === false) {
452
+
453
+ $this->shown_hcard = true;
454
+
455
+ /* start - make sure we should continue */
456
+ $show = false;
457
+
458
+ if ( $this->options['show_hcard_on'] == 1 ) {
459
+ $show = true;
460
+ } else if ( $this->options['show_hcard_on'] == 2 && ( is_home() || is_front_page() ) ) {
461
+ $show = true;
462
+ } else if ( $this->options['show_hcard_on'] == 3 && $this->is_active_page() ) {
463
+ $show = true;
464
+ }
465
+ /* end - make sure we should continue */
466
+
467
+ $div_id = "wpcr_hcard_h";
468
+ if ( $this->is_active_page() ) {
469
+ if ( $this->options['show_hcard'] == 1 ) {
470
+ $div_id = "wpcr_hcard_s";
471
+ }
472
+ }
473
+
474
+ if ($show) { /* we append like this to prevent newlines and wpautop issues */
475
+
476
+ $aggregate_footer_output = '<div id="' . $div_id . '" class="vcard">';
477
+ $aggregate_footer_output .= '<a class="url fn org" href="' . $this->options['business_url'] . '">' . $this->options['business_name'] . '</a><br />';
478
+
479
+ if (
480
+ $this->options['business_street'] != '' ||
481
+ $this->options['business_city'] != '' ||
482
+ $this->options['business_state'] != '' ||
483
+ $this->options['business_zip'] != '' ||
484
+ $this->options['business_country'] != ''
485
+ )
486
+ {
487
+ $aggregate_footer_output .= '<span class="adr">';
488
+ if ($this->options['business_street'] != '') {
489
+ $aggregate_footer_output .= '<span class="street-address">' . $this->options['business_street'] . '</span>&nbsp;';
490
+ }
491
+ if ($this->options['business_city'] != '') {
492
+ $aggregate_footer_output .='<span class="locality">' . $this->options['business_city'] . '</span>,&nbsp;';
493
+ }
494
+ if ($this->options['business_state'] != '') {
495
+ $aggregate_footer_output .='<span class="region">' . $this->options['business_state'] . '</span>,&nbsp;';
496
+ }
497
+ if ($this->options['business_zip'] != '') {
498
+ $aggregate_footer_output .='<span class="postal-code">' . $this->options['business_zip'] . '</span>&nbsp;';
499
+ }
500
+ if ($this->options['business_country'] != '') {
501
+ $aggregate_footer_output .='<span class="country-name">' . $this->options['business_country'] . '</span>&nbsp;';
502
+ }
503
+
504
+ $aggregate_footer_output .= '</span>';
505
+ }
506
+
507
+ if ($this->options['business_email'] != '' && $this->options['business_phone'] != '') {
508
+ $aggregate_footer_output .= '<br />';
509
+ }
510
+
511
+ if ($this->options['business_email'] != '') {
512
+ $aggregate_footer_output .= '<a class="email" href="mailto:' . $this->options['business_email'] . '">' . $this->options['business_email'] . '</a>';
513
+ }
514
+ if ($this->options['business_email'] != '' && $this->options['business_phone'] != '') {
515
+ $aggregate_footer_output .= '&nbsp;&bull;&nbsp;';
516
+ }
517
+ if ($this->options['business_phone'] != '') {
518
+ $aggregate_footer_output .= '<span class="tel">' . $this->options['business_phone'] . '</span>';
519
+ }
520
+
521
+ $aggregate_footer_output .= '</div>';
522
+ }
523
+ }
524
+
525
+ return $aggregate_footer_output;
526
+ }
527
+
528
+ function iso8601($time=false) {
529
+ if ($time === false)
530
+ $time = time();
531
+ $date = date('Y-m-d\TH:i:sO', $time);
532
+ return (substr($date, 0, strlen($date) - 2) . ':' . substr($date, -2));
533
+ }
534
+
535
+ function pagination($total_results, $reviews_per_page) {
536
+ global $post; /* will exist if on a post */
537
+
538
+ $out = '';
539
+ $uri = false;
540
+ $pretty = false;
541
+
542
+ $range = 2;
543
+ $showitems = ($range * 2) + 1;
544
+
545
+ $paged = $this->page;
546
+ if ($paged == 0) { $paged = 1; }
547
+
548
+ if (!isset($this->p->review_status)) { $this->p->review_status = 0; }
549
+
550
+ $pages = ceil($total_results / $reviews_per_page);
551
+
552
+ if ($pages > 1) {
553
+ if (is_admin()) {
554
+ $url = '?page=wpcr_view_reviews&amp;review_status=' . $this->p->review_status . '&amp;';
555
+ } else {
556
+ $uri = trailingslashit(get_permalink($post->ID));
557
+ if (strpos($uri, '?') === false) {
558
+ $url = $uri . '?';
559
+ $pretty = true;
560
+ } /* page is using pretty permalinks */ else {
561
+ $url = $uri . '&amp;';
562
+ $pretty = false;
563
+ } /* page is using get variables for pageid */
564
+ }
565
+
566
+ $out .= '<div id="wpcr_pagination"><div id="wpcr_pagination_page">Page: </div>';
567
+
568
+ if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) {
569
+ if ($uri && $pretty) {
570
+ $url2 = $uri;
571
+ } /* not in admin AND using pretty permalinks */ else {
572
+ $url2 = $url;
573
+ }
574
+ $out .= '<a href="' . $url2 . '">&laquo;</a>';
575
+ }
576
+
577
+ if ($paged > 1 && $showitems < $pages) {
578
+ $out .= '<a href="' . $url . 'wpcrp=' . ($paged - 1) . '">&lsaquo;</a>';
579
+ }
580
+
581
+ for ($i = 1; $i <= $pages; $i++) {
582
+ if ($i == $paged) {
583
+ $out .= '<span class="wpcr_current">' . $paged . '</span>';
584
+ } else if (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems) {
585
+ if ($i == 1) {
586
+ if ($uri && $pretty) {
587
+ $url2 = $uri;
588
+ } /* not in admin AND using pretty permalinks */ else {
589
+ $url2 = $url;
590
+ }
591
+ $out .= '<a href="' . $url2 . '" class="wpcr_inactive">' . $i . '</a>';
592
+ } else {
593
+ $out .= '<a href="' . $url . 'wpcrp=' . $i . '" class="wpcr_inactive">' . $i . '</a>';
594
+ }
595
+ }
596
+ }
597
+
598
+ if ($paged < $pages && $showitems < $pages) {
599
+ $out .= '<a href="' . $url . 'wpcrp=' . ($paged + 1) . '">&rsaquo;</a>';
600
+ }
601
+ if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) {
602
+ $out .= '<a href="' . $url . 'wpcrp=' . $pages . '">&raquo;</a>';
603
+ }
604
+ $out .= '</div>';
605
+ $out .= '<div class="wpcr_clear wpcr_pb5"></div>';
606
+
607
+ return $out;
608
+ }
609
+ }
610
+
611
+ function output_reviews_show($inside_div, $postid, $perpage, $max, $hide_custom = 0, $hide_response = 0, $snippet_length = 0, $show_morelink = '') {
612
+
613
+ if ($max != -1) {
614
+ $thispage = 1;
615
+ } else {
616
+ $thispage = $this->page;
617
+ }
618
+
619
+ $arr_Reviews = $this->get_reviews($postid, $thispage, $perpage, 1);
620
+
621
+ $reviews = $arr_Reviews[0];
622
+ $total_reviews = intval($arr_Reviews[1]);
623
+
624
+ $reviews_content = '';
625
+ $hidesummary = '';
626
+ $title_tag = $this->options['title_tag'];
627
+
628
+ /* trying to access a page that does not exists -- send to main page */
629
+ if ( isset($this->p->wpcrp) && $this->p->wpcrp != 1 && count($reviews) == 0 ) {
630
+ $url = get_permalink($postid);
631
+ $this->wpcr_redirect($url);
632
+ }
633
+
634
+ if ($postid == 0) {
635
+ /* NOTE: if using shortcode to show reviews for all pages, could do weird things when using product type */
636
+ $postid = $reviews[0]->page_id;
637
+ }
638
+
639
+ $meta_product_name = get_post_meta($postid, 'wpcr_product_name', true);
640
+ if (!$meta_product_name) {
641
+ $meta_product_name = get_the_title($postid);
642
+ }
643
+
644
+ $meta_product_desc = get_post_meta($postid, 'wpcr_product_desc', true);
645
+ $meta_product_brand = get_post_meta($postid, 'wpcr_product_brand', true);
646
+ $meta_product_upc = get_post_meta($postid, 'wpcr_product_upc', true);
647
+ $meta_product_sku = get_post_meta($postid, 'wpcr_product_sku', true);
648
+ $meta_product_model = get_post_meta($postid, 'wpcr_product_model', true);
649
+
650
+ if (!$inside_div) {
651
+ $reviews_content .= '<div id="wpcr_respond_1">';
652
+ }
653
+
654
+ if (count($reviews) == 0) {
655
+ /* $reviews_content .= '<p>There are no reviews yet. Be the first to leave yours!</p>'; */
656
+ } else {
657
+
658
+ $this->get_aggregate_reviews($postid);
659
+
660
+ $summary = $this->got_aggregate["text"];
661
+ $best_score = number_format($this->got_aggregate["max"], 1);
662
+ $average_score = number_format($this->got_aggregate["aggregate"], 1);
663
+
664
+ if ($this->options['hreview_type'] == 'product') {
665
+ $reviews_content .= '
666
+ <span class="item hproduct" id="hproduct-' . $postid . '">
667
+ <span class="wpcr_hide">
668
+ <span class="brand">' . $meta_product_brand . '</span>
669
+ <span class="fn">' . $meta_product_name . '</span>
670
+ <span class="description">' . $meta_product_desc . '</span>
671
+ <span class="identifier">
672
+ <span class="type">SKU</span>
673
+ <span class="value">' . $meta_product_sku . '</span>
674
+ </span>
675
+ <span class="identifier">
676
+ <span class="type">UPC</span>
677
+ <span class="value">' . $meta_product_upc . '</span>
678
+ </span>
679
+ <span class="identifier">
680
+ <span class="type">Model</span>
681
+ <span class="value">' . $meta_product_model . '</span>
682
+ </span>
683
+ </span>
684
+ ';
685
+ }
686
+
687
+ foreach ($reviews as $review) {
688
+
689
+ if ($snippet_length > 0)
690
+ {
691
+ $review->review_text = $this->trim_text_to_word($review->review_text,$snippet_length);
692
+ }
693
+
694
+ $review->review_text .= '<br />';
695
+
696
+ $hide_name = '';
697
+ if ($this->options['show_fields']['fname'] == 0) {
698
+ $review->reviewer_name = 'Anonymous';
699
+ $hide_name = 'wpcr_hide';
700
+ }
701
+ if ($review->reviewer_name == '') {
702
+ $review->reviewer_name = 'Anonymous';
703
+ }
704
+
705
+ if ($this->options['show_fields']['fwebsite'] == 1 && $review->reviewer_url != '') {
706
+ $review->review_text .= '<br /><small><a href="' . $review->reviewer_url . '">' . $review->reviewer_url . '</a></small>';
707
+ }
708
+ if ($this->options['show_fields']['femail'] == 1 && $review->reviewer_email != '') {
709
+ $review->review_text .= '<br /><small>' . $review->reviewer_email . '</small>';
710
+ }
711
+ if ($this->options['show_fields']['ftitle'] == 1) {
712
+ /* do nothing */
713
+ } else {
714
+ $review->review_title = substr($review->review_text, 0, 150);
715
+ $hidesummary = 'wpcr_hide';
716
+ }
717
+
718
+ if ($show_morelink != '') {
719
+ $review->review_text .= " <a href='".$this->get_jumplink_for_review($review,1)."'>$show_morelink</a>";
720
+ }
721
+
722
+ $review->review_text = nl2br($review->review_text);
723
+ $review_response = '';
724
+
725
+ if ($hide_response == 0)
726
+ {
727
+ if (strlen($review->review_response) > 0) {
728
+ $review_response = '<p class="response"><strong>Response:</strong> ' . nl2br($review->review_response) . '</p>';
729
+ }
730
+ }
731
+
732
+ $custom_shown = '';
733
+ if ($hide_custom == 0)
734
+ {
735
+ $custom_fields_unserialized = @unserialize($review->custom_fields);
736
+ if (!is_array($custom_fields_unserialized)) {
737
+ $custom_fields_unserialized = array();
738
+ }
739
+
740
+ foreach ($this->options['field_custom'] as $i => $val) {
741
+ if ( isset($custom_fields_unserialized[$val]) ) {
742
+ $show = $this->options['show_custom'][$i];
743
+ if ($show == 1 && $custom_fields_unserialized[$val] != '') {
744
+ $custom_shown .= "<div class='wpcr_fl'>" . $val . ': ' . $custom_fields_unserialized[$val] . '&nbsp;&bull;&nbsp;</div>';
745
+ }
746
+ }
747
+ }
748
+
749
+ $custom_shown = preg_replace("%&bull;&nbsp;</div>$%si","</div><div class='wpcr_clear'></div>",$custom_shown);
750
+ }
751
+
752
+ $name_block = '' .
753
+ '<div class="wpcr_fl wpcr_rname">' .
754
+ '<abbr title="' . $this->iso8601(strtotime($review->date_time)) . '" class="dtreviewed">' . date("M d, Y", strtotime($review->date_time)) . '</abbr>&nbsp;' .
755
+ '<span class="' . $hide_name . '">by</span>&nbsp;' .
756
+ '<span class="reviewer vcard" id="hreview-wpcr-reviewer-' . $review->id . '">' .
757
+ '<span class="fn ' . $hide_name . '">' . $review->reviewer_name . '</span>' .
758
+ '</span>' .
759
+ '<div class="wpcr_clear"></div>' .
760
+ $custom_shown .
761
+ '</div>';
762
+
763
+ if ($this->options['hreview_type'] == 'product') {
764
+ $reviews_content .= '
765
+ <div class="hreview" id="hreview-' . $review->id . '">
766
+ <' . $title_tag . ' class="summary ' . $hidesummary . '">' . $review->review_title . '</' . $title_tag . '>
767
+ <span class="item" id="hreview-wpcr-hproduct-for-' . $review->id . '" style="display:none;">
768
+ <span class="fn">' . $meta_product_name . '</span>
769
+ </span>
770
+ <div class="wpcr_fl wpcr_sc">
771
+ <abbr class="rating" title="' . $review->review_rating . '"></abbr>
772
+ <div class="wpcr_rating">
773
+ ' . $this->output_rating($review->review_rating, false) . '
774
+ </div>
775
+ </div>
776
+ ' . $name_block . '
777
+ <div class="wpcr_clear wpcr_spacing1"></div>
778
+ <blockquote class="description"><p>' . $review->review_text . '</p></blockquote>
779
+ ' . $review_response . '
780
+ <span style="display:none;" class="type">product</span>
781
+ <span style="display:none;" class="version">0.3</span>
782
+ </div>
783
+ <hr />';
784
+ } else if ($this->options['hreview_type'] == 'business') {
785
+ $reviews_content .= '
786
+ <div class="hreview" id="hreview-' . $review->id . '">
787
+ <' . $title_tag . ' class="summary ' . $hidesummary . '">' . $review->review_title . '</' . $title_tag . '>
788
+ <div class="wpcr_fl wpcr_sc">
789
+ <abbr class="rating" title="' . $review->review_rating . '"></abbr>
790
+ <div class="wpcr_rating">
791
+ ' . $this->output_rating($review->review_rating, false) . '
792
+ </div>
793
+ </div>
794
+ ' . $name_block . '
795
+ <div class="wpcr_clear wpcr_spacing1"></div>
796
+ <span class="item vcard" id="hreview-wpcr-hcard-for-' . $review->id . '" style="display:none;">
797
+ <a class="url fn org" href="' . $this->options['business_url'] . '">' . $this->options['business_name'] . '</a>
798
+ <span class="tel">' . $this->options['business_phone'] . '</span>
799
+ <span class="adr">
800
+ <span class="street-address">' . $this->options['business_street'] . '</span>
801
+ <span class="locality">' . $this->options['business_city'] . '</span>
802
+ <span class="region">' . $this->options['business_state'] . '</span>, <span class="postal-code">' . $this->options['business_zip'] . '</span>
803
+ <span class="country-name">' . $this->options['business_country'] . '</span>
804
+ </span>
805
+ </span>
806
+ <blockquote class="description"><p>' . $review->review_text . '</p></blockquote>
807
+ ' . $review_response . '
808
+ <span style="display:none;" class="type">business</span>
809
+ <span style="display:none;" class="version">0.3</span>
810
+ </div>
811
+ <hr />';
812
+ }
813
+ }
814
+
815
+ if ($this->options['hreview_type'] == 'product') {
816
+ $reviews_content .= '
817
+ <span class="hreview-aggregate haggregatereview" id="hreview-wpcr-aggregate">
818
+ <span style="display:none;">
819
+ <span class="rating">
820
+ <span class="average">' . $average_score . '</span>
821
+ <span class="best">' . $best_score . '</span>
822
+ </span>
823
+ <span class="votes">' . $this->got_aggregate["total"] . '</span>
824
+ <span class="count">' . $this->got_aggregate["total"] . '</span>
825
+ <span class="summary">' . $summary . '</span>
826
+ <span class="item" id="hreview-wpcr-vcard">
827
+ <span class="fn">' . $meta_product_name . '</span>
828
+ </span>
829
+ </span>
830
+ </span>';
831
+ $reviews_content .= '</span>'; /* end hProduct */
832
+ } else if ($this->options['hreview_type'] == 'business') {
833
+ $reviews_content .= '
834
+ <span class="hreview-aggregate" id="hreview-wpcr-aggregate">
835
+ <span style="display:none;">
836
+ <span class="item vcard" id="hreview-wpcr-vcard">
837
+ <a class="url fn org" href="' . $this->options['business_url'] . '">' . $this->options['business_name'] . '</a>
838
+ <span class="tel">' . $this->options['business_phone'] . '</span>
839
+ <span class="adr">
840
+ <span class="street-address">' . $this->options['business_street'] . '</span>
841
+ <span class="locality">' . $this->options['business_city'] . '</span>
842
+ <span class="region">' . $this->options['business_state'] . '</span>, <span class="postal-code">' . $this->options['business_zip'] . '</span>
843
+ <span class="country-name">' . $this->options['business_country'] . '</span>
844
+ </span>
845
+ </span>
846
+ <span class="rating">
847
+ <span class="average">' . $average_score . '</span>
848
+ <span class="best">' . $best_score . '</span>
849
+ </span>
850
+ <span class="votes">' . $this->got_aggregate["total"] . '</span>
851
+ <span class="count">' . $this->got_aggregate["total"] . '</span>
852
+ <span class="summary">' . $summary . '</span>
853
+ </span>
854
+ </span>
855
+ ';
856
+ }
857
+ }
858
+
859
+ if (!$inside_div) {
860
+ $reviews_content .= '</div>'; /* wpcr_respond_1 */
861
+ }
862
+
863
+ return array($reviews_content, $total_reviews);
864
+ }
865
+
866
+ /* trims text, but does not break up a word */
867
+ function trim_text_to_word($text,$len) {
868
+ if(strlen($text) > $len) {
869
+ $matches = array();
870
+ preg_match("/^(.{1,$len})[\s]/i", $text, $matches);
871
+ $text = $matches[0];
872
+ }
873
+ return $text.'... ';
874
+ }
875
+
876
+ function do_the_content($original_content) {
877
+ global $post;
878
+
879
+ $using_shortcode_insert = false;
880
+ if ($original_content == 'shortcode_insert') {
881
+ $original_content = '';
882
+ $using_shortcode_insert = true;
883
+ }
884
+
885
+ $the_content = '';
886
+ $is_active_page = $this->is_active_page();
887
+
888
+ /* return normal content if this is not an enabled page, or if this is a post not on single post view */
889
+ if (!$is_active_page) {
890
+ $the_content .= '<div id="wpcr_respond_1">';
891
+ $the_content .= $this->aggregate_footer(); /* check if we need to show something in the footer then */
892
+ $the_content .= '</div>';
893
+ return $original_content . $the_content;
894
+ }
895
+
896
+ $the_content .= '<div id="wpcr_respond_1">'; /* start the div */
897
+ $inside_div = true;
898
+
899
+ if ($this->options['form_location'] == 0) {
900
+ $the_content .= $this->show_reviews_form();
901
+ }
902
+
903
+ $ret_Arr = $this->output_reviews_show( $inside_div, $post->ID, $this->options['reviews_per_page'], -1 );
904
+ $the_content .= $ret_Arr[0];
905
+ $total_reviews = $ret_Arr[1];
906
+
907
+ $the_content .= $this->pagination($total_reviews, $this->options['reviews_per_page']);
908
+
909
+ if ($this->options['form_location'] == 1) {
910
+ $the_content .= $this->show_reviews_form();
911
+ }
912
+
913
+ if ($this->options['support_us'] == 1) {
914
+ $the_content .= '<div class="wpcr_clear wpcr_power">Powered by <strong><a href="http://www.gowebsolutions.com/wp-customer-reviews/">WP Customer Reviews</a></strong></div>';
915
+ }
916
+
917
+ $the_content .= $this->aggregate_footer(); /* check if we need to show something in the footer also */
918
+
919
+ $the_content .= '</div>'; /* wpcr_respond_1 */
920
+
921
+ //$the_content = preg_replace('/\n\r|\r\n|\n|\r|\t|\s{2}/', '', $the_content); /* minify to prevent automatic line breaks */
922
+ $the_content = preg_replace('/\n\r|\r\n|\n|\r|\t/', '', $the_content); /* minify to prevent automatic line breaks, not removing double spaces */
923
+
924
+ return $original_content . $the_content;
925
+ }
926
+
927
+ function output_rating($rating, $enable_hover) {
928
+ $out = '';
929
+
930
+ $rating_width = 20 * $rating; /* 20% for each star if having 5 stars */
931
+
932
+ $out .= '<div class="sp_rating">';
933
+
934
+ if ($enable_hover) {
935
+ $out .= '<div class="status"><div class="score"><a class="score1">1</a><a class="score2">2</a><a class="score3">3</a><a class="score4">4</a><a class="score5">5</a></div></div>';
936
+ }
937
+
938
+ $out .= '<div class="base"><div class="average" style="width:' . $rating_width . '%"></div></div>';
939
+ $out .= '</div>';
940
+
941
+ return $out;
942
+ }
943
+
944
+ function show_reviews_form() {
945
+ global $post, $current_user;
946
+
947
+ $fields = '';
948
+ $out = '';
949
+ $req_js = "<script type='text/javascript'>";
950
+
951
+ if ( isset($_COOKIE['wpcr_status_msg']) ) {
952
+ $this->status_msg = $_COOKIE['wpcr_status_msg'];
953
+ }
954
+
955
+ if ($this->status_msg != '') {
956
+ $req_js .= "wpcr_del_cookie('wpcr_status_msg');";
957
+ }
958
+
959
+ /* a silly and crazy but effective antispam measure.. bots wont have a clue */
960
+ $rand_prefixes = array();
961
+ for ($i = 0; $i < 15; $i++) {
962
+ $rand_prefixes[] = $this->rand_string(mt_rand(1, 8));
963
+ }
964
+
965
+ if (!isset($this->p->fname)) { $this->p->fname = ''; }
966
+ if (!isset($this->p->femail)) { $this->p->femail = ''; }
967
+ if (!isset($this->p->fwebsite)) { $this->p->fwebsite = ''; }
968
+ if (!isset($this->p->ftitle)) { $this->p->ftitle = ''; }
969
+ if (!isset($this->p->ftext)) { $this->p->ftext = ''; }
970
+
971
+ if ($this->options['ask_fields']['fname'] == 1) {
972
+ if ($this->options['require_fields']['fname'] == 1) {
973
+ $req = '*';
974
+ } else {
975
+ $req = '';
976
+ }
977
+ $fields .= '<tr><td><label for="' . $rand_prefixes[0] . '-fname" class="comment-field">Name: ' . $req . '</label></td><td><input class="text-input" type="text" id="' . $rand_prefixes[0] . '-fname" name="' . $rand_prefixes[0] . '-fname" value="' . $this->p->fname . '" /></td></tr>';
978
+ }
979
+ if ($this->options['ask_fields']['femail'] == 1) {
980
+ if ($this->options['require_fields']['femail'] == 1) {
981
+ $req = '*';
982
+ } else {
983
+ $req = '';
984
+ }
985
+ $fields .= '<tr><td><label for="' . $rand_prefixes[1] . '-femail" class="comment-field">Email: ' . $req . '</label></td><td><input class="text-input" type="text" id="' . $rand_prefixes[1] . '-femail" name="' . $rand_prefixes[1] . '-femail" value="' . $this->p->femail . '" /></td></tr>';
986
+ }
987
+ if ($this->options['ask_fields']['fwebsite'] == 1) {
988
+ if ($this->options['require_fields']['fwebsite'] == 1) {
989
+ $req = '*';
990
+ } else {
991
+ $req = '';
992
+ }
993
+ $fields .= '<tr><td><label for="' . $rand_prefixes[2] . '-fwebsite" class="comment-field">Website: ' . $req . '</label></td><td><input class="text-input" type="text" id="' . $rand_prefixes[2] . '-fwebsite" name="' . $rand_prefixes[2] . '-fwebsite" value="' . $this->p->fwebsite . '" /></td></tr>';
994
+ }
995
+ if ($this->options['ask_fields']['ftitle'] == 1) {
996
+ if ($this->options['require_fields']['ftitle'] == 1) {
997
+ $req = '*';
998
+ } else {
999
+ $req = '';
1000
+ }
1001
+ $fields .= '<tr><td><label for="' . $rand_prefixes[3] . '-ftitle" class="comment-field">Review Title: ' . $req . '</label></td><td><input class="text-input" type="text" id="' . $rand_prefixes[3] . '-ftitle" name="' . $rand_prefixes[3] . '-ftitle" maxlength="150" value="' . $this->p->ftitle . '" /></td></tr>';
1002
+ }
1003
+
1004
+ $custom_fields = array(); /* used for insert as well */
1005
+ $custom_count = count($this->options['field_custom']); /* used for insert as well */
1006
+ for ($i = 0; $i < $custom_count; $i++) {
1007
+ $custom_fields[$i] = $this->options['field_custom'][$i];
1008
+ }
1009
+
1010
+ foreach ($this->options['ask_custom'] as $i => $val) {
1011
+ if ( isset($this->options['ask_custom'][$i]) ) {
1012
+ if ($val == 1) {
1013
+ if ($this->options['require_custom'][$i] == 1) {
1014
+ $req = '*';
1015
+ } else {
1016
+ $req = '';
1017
+ }
1018
+
1019
+ $custom_i = "custom_$i";
1020
+ if (!isset($this->p->$custom_i)) { $this->p->$custom_i = ''; }
1021
+ $fields .= '<tr><td><label for="custom_' . $i . '" class="comment-field">' . $custom_fields[$i] . ': ' . $req . '</label></td><td><input class="text-input" type="text" id="custom_' . $i . '" name="custom_' . $i . '" maxlength="150" value="' . $this->p->$custom_i . '" /></td></tr>';
1022
+ }
1023
+ }
1024
+ }
1025
+
1026
+ $some_required = '';
1027
+
1028
+ foreach ($this->options['require_fields'] as $col => $val) {
1029
+ if ($val == 1) {
1030
+ $col = str_replace("'","\'",$col);
1031
+ $req_js .= "wpcr_req.push('$col');";
1032
+ $some_required = '<small>* Required Field</small>';
1033
+ }
1034
+ }
1035
+
1036
+ foreach ($this->options['require_custom'] as $i => $val) {
1037
+ if ($val == 1) {
1038
+ $req_js .= "wpcr_req.push('custom_$i');";
1039
+ $some_required = '<small>* Required Field</small>';
1040
+ }
1041
+ }
1042
+
1043
+ $req_js .= "</script>\n";
1044
+
1045
+ if ($this->options['goto_show_button'] == 1) {
1046
+ $button_html = '<div class="wpcr_status_msg">' . $this->status_msg . '</div>'; /* show errors or thank you message here */
1047
+ $button_html .= '<p><a id="wpcr_button_1" href="javascript:void(0);">' . $this->options['goto_leave_text'] . '</a></p><hr />';
1048
+ $out .= $button_html;
1049
+ }
1050
+
1051
+ /* different output variables make it easier to debug this section */
1052
+ $out .= '<div id="wpcr_respond_2">' . $req_js . '
1053
+ <form class="wpcrcform" id="wpcr_commentform" method="post" action="javascript:void(0);">
1054
+ <div id="wpcr_div_2">
1055
+ <input type="hidden" id="frating" name="frating" />
1056
+ <table id="wpcr_table_2">
1057
+ <tbody>
1058
+ <tr><td colspan="2"><div id="wpcr_postcomment">' . $this->options["leave_text"] . '</div></td></tr>
1059
+ ' . $fields;
1060
+
1061
+ $out2 = '
1062
+ <tr>
1063
+ <td><label class="comment-field">Rating:</label></td>
1064
+ <td><div class="wpcr_rating">' . $this->output_rating(0, true) . '</div></td>
1065
+ </tr>';
1066
+
1067
+ $out3 = '
1068
+ <tr><td colspan="2"><label for="' . $rand_prefixes[5] . '-ftext" class="comment-field">Review:</label></td></tr>
1069
+ <tr><td colspan="2"><textarea id="' . $rand_prefixes[5] . '-ftext" name="' . $rand_prefixes[5] . '-ftext" rows="8" cols="50">' . $this->p->ftext . '</textarea></td></tr>
1070
+ <tr>
1071
+ <td colspan="2" id="wpcr_check_confirm">
1072
+ ' . $some_required . '
1073
+ <div class="wpcr_clear"></div>
1074
+ <input type="checkbox" name="' . $rand_prefixes[6] . '-fconfirm1" id="fconfirm1" value="1" />
1075
+ <div class="wpcr_fl"><input type="checkbox" name="' . $rand_prefixes[7] . '-fconfirm2" id="fconfirm2" value="1" /></div><div class="wpcr_fl" style="margin:-2px 0px 0px 5px"><label for="fconfirm2">Check this box to confirm you are human.</label></div>
1076
+ <div class="wpcr_clear"></div>
1077
+ <input type="checkbox" name="' . $rand_prefixes[8] . '-fconfirm3" id="fconfirm3" value="1" />
1078
+ </td>
1079
+ </tr>
1080
+ <tr><td colspan="2"><input id="wpcr_submit_btn" name="submitwpcr_' . $post->ID . '" type="submit" value="' . $this->options['submit_button_text'] . '" /></td></tr>
1081
+ </tbody>
1082
+ </table>
1083
+ </div>
1084
+ </form>';
1085
+
1086
+ $out4 = '<hr /></div>';
1087
+ $out4 .= '<div class="wpcr_clear wpcr_pb5"></div>';
1088
+
1089
+ return $out . $out2 . $out3 . $out4;
1090
+ }
1091
+
1092
+ function add_review($pageID) {
1093
+ global $wpdb;
1094
+
1095
+ /* begin - some antispam magic */
1096
+ $this->newp = new stdClass();
1097
+
1098
+ foreach ($this->p as $col => $val) {
1099
+ $pos = strpos($col, '-');
1100
+ if ($pos !== false) {
1101
+ $col = substr($col, $pos + 1); /* off by one */
1102
+ }
1103
+ $this->newp->$col = $val;
1104
+ }
1105
+
1106
+ $this->p = $this->newp;
1107
+ unset($this->newp);
1108
+ /* end - some antispam magic */
1109
+
1110
+ /* some sanitation */
1111
+ $date_time = date('Y-m-d H:i:s');
1112
+ $ip = $_SERVER['REMOTE_ADDR'];
1113
+
1114
+ if (!isset($this->p->fname)) { $this->p->fname = ''; }
1115
+ if (!isset($this->p->femail)) { $this->p->femail = ''; }
1116
+ if (!isset($this->p->fwebsite)) { $this->p->fwebsite = ''; }
1117
+ if (!isset($this->p->ftitle)) { $this->p->ftitle = ''; }
1118
+ if (!isset($this->p->ftext)) { $this->p->ftext = ''; }
1119
+ if (!isset($this->p->femail)) { $this->p->femail = ''; }
1120
+ if (!isset($this->p->fwebsite)) { $this->p->fwebsite = ''; }
1121
+ if (!isset($this->p->frating)) { $this->p->frating = 0; } /* default to 0 */
1122
+ if (!isset($this->p->fconfirm1)) { $this->p->fconfirm1 = 0; } /* default to 0 */
1123
+ if (!isset($this->p->fconfirm2)) { $this->p->fconfirm2 = 0; } /* default to 0 */
1124
+ if (!isset($this->p->fconfirm3)) { $this->p->fconfirm3 = 0; } /* default to 0 */
1125
+
1126
+ $this->p->fname = trim(strip_tags($this->p->fname));
1127
+ $this->p->femail = trim(strip_tags($this->p->femail));
1128
+ $this->p->ftitle = trim(strip_tags($this->p->ftitle));
1129
+ $this->p->ftext = trim(strip_tags($this->p->ftext));
1130
+ $this->p->frating = intval($this->p->frating);
1131
+
1132
+ /* begin - server-side validation */
1133
+ $errors = '';
1134
+
1135
+ foreach ($this->options['require_fields'] as $col => $val) {
1136
+ if ($val == 1) {
1137
+ if (!isset($this->p->$col) || $this->p->$col == '') {
1138
+ $nice_name = ucfirst(substr($col, 1));
1139
+ $errors .= 'You must include your ' . $nice_name . '.<br />';
1140
+ }
1141
+ }
1142
+ }
1143
+
1144
+ $custom_fields = array(); /* used for insert as well */
1145
+ $custom_count = count($this->options['field_custom']); /* used for insert as well */
1146
+ for ($i = 0; $i < $custom_count; $i++) {
1147
+ $custom_fields[$i] = $this->options['field_custom'][$i];
1148
+ }
1149
+
1150
+ foreach ($this->options['require_custom'] as $i => $val) {
1151
+ if ($val == 1) {
1152
+ $custom_i = "custom_$i";
1153
+ if (!isset($this->p->$custom_i) || $this->p->$custom_i == '') {
1154
+ $nice_name = $custom_fields[$i];
1155
+ $errors .= 'You must include your ' . $nice_name . '.<br />';
1156
+ }
1157
+ }
1158
+ }
1159
+
1160
+ /* only do regex matching if not blank */
1161
+ if ($this->p->femail != '' && $this->options['ask_fields']['femail'] == 1) {
1162
+ if (!preg_match('/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/', $this->p->femail)) {
1163
+ $errors .= 'The email address provided is not valid.<br />';
1164
+ }
1165
+ }
1166
+
1167
+ /* only do regex matching if not blank */
1168
+ if ($this->p->fwebsite != '' && $this->options['ask_fields']['fwebsite'] == 1) {
1169
+ if (!preg_match('/^\S+:\/\/\S+\.\S+.+$/', $this->p->fwebsite)) {
1170
+ $errors .= 'The website provided is not valid. Be sure to include http://<br />';
1171
+ }
1172
+ }
1173
+
1174
+ if (intval($this->p->fconfirm1) == 1 || intval($this->p->fconfirm3) == 1) {
1175
+ $errors .= 'You have triggered our anti-spam system. Please try again. Code 001.<br />';
1176
+ }
1177
+
1178
+ if (intval($this->p->fconfirm2) != 1) {
1179
+ $errors .= 'You have triggered our anti-spam system. Please try again. Code 002<br />';
1180
+ }
1181
+
1182
+ if ($this->p->frating < 1 || $this->p->frating > 5) {
1183
+ $errors .= 'You have triggered our anti-spam system. Please try again. Code 003<br />';
1184
+ }
1185
+
1186
+ if (strlen(trim($this->p->ftext)) < 30) {
1187
+ $errors .= 'You must include a review. Please make reviews at least a couple of sentences.<br />';
1188
+ }
1189
+
1190
+ /* returns true for errors */
1191
+ if ($errors) {
1192
+ return array(true, "<div>$errors</div>");
1193
+ }
1194
+ /* end - server-side validation */
1195
+
1196
+ $custom_insert = array();
1197
+ for ($i = 0; $i < $custom_count; $i++) {
1198
+ if ($this->options['ask_custom'][$i] == 1) {
1199
+ $name = $custom_fields[$i];
1200
+ $custom_i = "custom_$i";
1201
+ if ( isset($this->p->$custom_i) ) {
1202
+ $custom_insert[$name] = ucfirst($this->p->$custom_i);
1203
+ }
1204
+ }
1205
+ }
1206
+ $custom_insert = serialize($custom_insert);
1207
+
1208
+ $query = $wpdb->prepare("INSERT INTO `$this->dbtable`
1209
+ (`date_time`, `reviewer_name`, `reviewer_email`, `reviewer_ip`, `review_title`, `review_text`, `status`, `review_rating`, `reviewer_url`, `custom_fields`, `page_id`)
1210
+ VALUES (%s, %s, %s, %s, %s, %s, %d, %d, %s, %s, %d)", $date_time, $this->p->fname, $this->p->femail, $ip, $this->p->ftitle, $this->p->ftext, 0, $this->p->frating, $this->p->fwebsite, $custom_insert, $pageID);
1211
+
1212
+ $wpdb->query($query);
1213
+
1214
+ $admin_link = get_admin_url().'admin.php?page=wpcr_view_reviews';
1215
+ $admin_link = "Link to admin approval page: $admin_link";
1216
+
1217
+ @wp_mail(get_bloginfo('admin_email'), "WP Customer Reviews: New Review Posted on " . date('m/d/Y h:i'), "A new review has been posted for " . $this->options['business_name'] . " via WP Customer Reviews. \n\nYou will need to login to the admin area and approve this review before it will appear on your site.\n\n{$admin_link}");
1218
+
1219
+ /* returns false for no error */
1220
+ return array(false, '<div>Thank you for your comments. All submissions are moderated and if approved, yours will appear soon.</div>');
1221
+ }
1222
+
1223
+ function deactivate() {
1224
+ /* do not fire on upgrading plugin or upgrading WP - only on true manual deactivation */
1225
+ if (isset($this->p->action) && $this->p->action == 'deactivate') {
1226
+ $this->options['activate'] = 0;
1227
+ update_option('wpcr_options', $this->options);
1228
+ global $WPCustomerReviewsAdmin;
1229
+ $this->include_admin(); /* include admin functions */
1230
+ $WPCustomerReviewsAdmin->notify_activate(2);
1231
+ }
1232
+ }
1233
+
1234
+ function wpcr_redirect($url, $cookie = array()) {
1235
+
1236
+ $headers_sent = headers_sent();
1237
+
1238
+ if ($headers_sent == true) {
1239
+ /* use JS redirect and add cookie before redirect */
1240
+ /* we do not html comment script blocks here - to prevent any issues with other plugins adding content to newlines, etc */
1241
+ $out = "<html><head><title>Redirecting...</title></head><body><div style='clear:both;text-align:center;padding:10px;'>" .
1242
+ "Processing... Please wait..." .
1243
+ "<script type='text/javascript'>";
1244
+ foreach ($cookie as $col => $val) {
1245
+ $val = preg_replace("/\r?\n/", "\\n", addslashes($val));
1246
+ $out .= "document.cookie=\"$col=$val\";";
1247
+ }
1248
+ $out .= "window.location='$url';";
1249
+ $out .= "</script>";
1250
+ $out .= "</div></body></html>";
1251
+ echo $out;
1252
+ } else {
1253
+ foreach ($cookie as $col => $val) {
1254
+ setcookie($col, $val); /* add cookie via headers */
1255
+ }
1256
+ ob_end_clean();
1257
+ wp_redirect($url); /* nice redirect */
1258
+ }
1259
+
1260
+ exit();
1261
+ }
1262
+
1263
+ function init() { /* used for admin_init also */
1264
+ $this->make_p_obj(); /* make P variables object */
1265
+ $this->get_options(); /* populate the options array */
1266
+ $this->check_migrate(); /* call on every instance to see if we have upgraded in any way */
1267
+
1268
+ if ( !isset($this->p->wpcrp) ) { $this->p->wpcrp = 1; }
1269
+
1270
+ $this->page = intval($this->p->wpcrp);
1271
+ if ($this->page < 1) { $this->page = 1; }
1272
+
1273
+ add_shortcode( 'WPCR_INSERT', array(&$this, 'shortcode_wpcr_insert') );
1274
+ add_shortcode( 'WPCR_SHOW', array(&$this, 'shortcode_wpcr_show') );
1275
+
1276
+ wp_register_style('wp-customer-reviews', $this->getpluginurl() . 'wp-customer-reviews.css', array(), $this->plugin_version);
1277
+ wp_register_script('wp-customer-reviews', $this->getpluginurl() . 'wp-customer-reviews.js', array('jquery'), $this->plugin_version);
1278
+ /* add style and script here if needed for some theme compatibility */
1279
+ $this->add_style_script();
1280
+ }
1281
+
1282
+ function shortcode_wpcr_insert() {
1283
+ $this->force_active_page = 1;
1284
+ return $this->do_the_content('shortcode_insert');
1285
+ }
1286
+
1287
+ function shortcode_wpcr_show($atts) {
1288
+ $this->force_active_page = 1;
1289
+
1290
+ extract( shortcode_atts( array('postid' => 'all','num' => '3','hidecustom' => '0','hideresponse' => '0', 'snippet' => '0','more' => ''), $atts ) );
1291
+
1292
+ if (strtolower($postid) == 'all') { $postid = -1; /* -1 queries all reviews */ }
1293
+ $postid = intval($postid);
1294
+ $num = intval($num);
1295
+ $hidecustom = intval($hidecustom);
1296
+ $hideresponse = intval($hideresponse);
1297
+ $snippet = intval($snippet);
1298
+ $more = $more;
1299
+
1300
+ if ($postid < -1) { $postid = -1; }
1301
+ if ($num < 1) { $num = 3; }
1302
+ if ($hidecustom < 0 || $hidecustom > 1) { $hidecustom = 0; }
1303
+ if ($hideresponse < 0 || $hideresponse > 1) { $hideresponse = 0; }
1304
+ if ($snippet < 0) { $snippet = 0; }
1305
+
1306
+ $inside_div = false;
1307
+
1308
+ $ret_Arr = $this->output_reviews_show( $inside_div, $postid, $num, $num, $hidecustom, $hideresponse, $snippet, $more );
1309
+ return $ret_Arr[0];
1310
+ }
1311
+
1312
+ function activate() {
1313
+ register_setting('wpcr_gotosettings', 'wpcr_gotosettings');
1314
+ add_option('wpcr_gotosettings', true); /* used for redirecting to settings page upon initial activation */
1315
+ }
1316
+
1317
+ function include_admin() {
1318
+ global $WPCustomerReviewsAdmin;
1319
+ require_once($this->getplugindir() . 'wp-customer-reviews-admin.php'); /* include admin functions */
1320
+ }
1321
+
1322
+ function admin_init() {
1323
+ global $WPCustomerReviewsAdmin;
1324
+ $this->include_admin(); /* include admin functions */
1325
+ $WPCustomerReviewsAdmin->real_admin_init();
1326
+ }
1327
+
1328
+ function getpluginurl() {
1329
+ return trailingslashit(plugins_url(basename(dirname(__FILE__))));
1330
+ }
1331
+
1332
+ function getplugindir() {
1333
+ return trailingslashit(WP_PLUGIN_DIR . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
1334
+ }
1335
+
1336
+ }
1337
+
1338
+ if (!defined('IN_WPCR')) {
1339
+ global $WPCustomerReviews;
1340
+ $WPCustomerReviews = new WPCustomerReviews();
1341
+ register_activation_hook(__FILE__, array(&$WPCustomerReviews, 'activate'));
1342
+ register_deactivation_hook(__FILE__, array(&$WPCustomerReviews, 'deactivate'));
1343
+ }
1344
+ ?>