WP Customer Reviews - Version 3.1.8.1

Version Description

Download this release

Release Info

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

Code changes from version 2.4.8 to 3.1.8.1

Files changed (46) hide show
  1. button.png +0 -0
  2. changelog.txt +104 -0
  3. css/newstars.png +0 -0
  4. css/star.png +0 -0
  5. css/wp-customer-reviews-admin.css +16 -0
  6. css/wp-customer-reviews-generated.css +213 -0
  7. css/wp-customer-reviews-generated.css.php +10 -0
  8. include/admin/tools/delete-all-reviews.php +28 -0
  9. include/admin/tools/reimport-2x.php +44 -0
  10. include/admin/tools/remove-duplicates.php +43 -0
  11. include/admin/wp-customer-reviews-3-admin.php +1395 -0
  12. include/ajax.php +10 -0
  13. include/goatee-php/wpcr-goatee.php +202 -0
  14. include/migrate/2x-3x.php +233 -0
  15. include/migrate/3x-3x.php +30 -0
  16. include/templates/frontend_review_form.html +61 -0
  17. include/templates/frontend_review_form_rating_field.html +14 -0
  18. include/templates/frontend_review_form_review_field.html +15 -0
  19. include/templates/frontend_review_form_text_field.html +16 -0
  20. include/templates/frontend_review_holder.html +19 -0
  21. include/templates/frontend_review_item.html +52 -0
  22. include/templates/frontend_review_item_aggregate.html +16 -0
  23. include/templates/frontend_review_item_reviews.html +65 -0
  24. include/templates/frontend_review_pagination.html +16 -0
  25. include/templates/frontend_review_rating_stars.html +16 -0
  26. include/templates/readme_templates.txt +3 -0
  27. include/templates/wp-customer-reviews-css.css +213 -0
  28. js/wp-customer-reviews-admin.js +121 -0
  29. js/wp-customer-reviews.js +227 -0
  30. license.txt +20 -0
  31. newstars.png +0 -0
  32. readme.txt +172 -104
  33. red_pen.png +0 -0
  34. screenshot-1.png +0 -0
  35. screenshot-2.png +0 -0
  36. screenshot-3.png +0 -0
  37. screenshot-4.png +0 -0
  38. screenshot-5.png +0 -0
  39. star.png +0 -0
  40. wp-customer-reviews-3.php +1078 -0
  41. wp-customer-reviews-admin.css +0 -49
  42. wp-customer-reviews-admin.js +0 -777
  43. wp-customer-reviews-admin.php +0 -1224
  44. wp-customer-reviews.css +0 -191
  45. wp-customer-reviews.js +0 -151
  46. wp-customer-reviews.php +0 -1344
button.png DELETED
Binary file
changelog.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ = 3.1.8.1 =
2
+ * 04/02/2018
3
+ * [Update] Allow HIDEREVIEWS=0 to be used in shortcode without needing the (unreleased) Pro version
4
+
5
+ = 3.1.8 =
6
+ * 03/30/2018
7
+ * [Bugfix] Compatibility with PHP 4.3+, apparently people still use PHP 4.3.x and 4.4.x
8
+
9
+ = 3.1.7 =
10
+ * 03/27/2018
11
+ * [Bugfix] To prevent conflicts with other plugins, we renamed our usage of select2 to wpcr3_select2, and are loading it locally instead of via a CDN.
12
+
13
+ = 3.1.6 =
14
+ * 03/24/2018
15
+ * [Update] Significant performance improvements when logged in or using WP admin. Blogs with many review-enabled posts should notice significantly faster page load times.
16
+ * [Bugfix] "Enable WP Customer Reviews for this page" form should now properly initialize when adding new posts. Previously, it only worked properly on existing posts.
17
+
18
+ = 3.1.5 =
19
+ * 11/16/2017
20
+ * [Update] compatible with WP 4.9
21
+
22
+ = 3.1.4 =
23
+ * 10/16/2017
24
+ * [Bugfix] Fixed validation issue which broke AMP
25
+ * [Update] Some preparation for PRO version release
26
+
27
+ = 3.1.3 =
28
+ * 05/31/2017
29
+ * [Bugfix] css typo bug fix
30
+ * [Update] compatible with WP 4.8
31
+
32
+ = 3.1.2 =
33
+ * 04/21/2016
34
+ * [Update] Made activation process simpler
35
+ * [Update] Images losslessly compressed
36
+
37
+ = 3.1.1 =
38
+ * 04/19/2016
39
+ * [Bugfix] Fixed possible issues with WordPress 3.6
40
+
41
+ = 3.1.0 =
42
+ * 04/09/2016
43
+ * [Bugfix] Fixed possible issue with PHP 7.0
44
+
45
+ = 3.0.9 =
46
+ * 04/05/2016
47
+ * [Security] Prevented CSRF and XSS in admin tools.
48
+
49
+ = 3.0.8 =
50
+ * 01/04/2016
51
+ * [Bugfix] Fixed the appearance of a security hole with admin tools. Malicious action was not possible.
52
+ * [Bugfix] Fixed deprecation warning with wpseo_pre_analysis_post_content (Yoast SEO).
53
+
54
+ = 3.0.7 =
55
+ * 11/15/2015
56
+ * [Bugfix] In some installations, ajax requests were still failing. We are reverting to using admin-ajax once again.
57
+
58
+ = 3.0.6 =
59
+ * 11/12/2015
60
+ * [Bugfix] In some installations, a dynamic CSS file could not be written upon plugin activation.
61
+ * [Bugfix] In some installations, ajax requests to admin-ajax were failing. We are trying a new method.
62
+ * [Bugfix] In some installations, the number of reviews displayed for "Average Rating" was inflated.
63
+ * [Bugfix] Email notifications for new reviews were missing a timestamp in the subject line.
64
+ * [Bugfix] When using [WPCR_SHOW POSTID="123"] shortcode on the page ID 123, reviews would output twice.
65
+ * [Bugfix] When a page had 0 reviews, the average rating would show 2.5 stars instead of 0.
66
+ * [Feature] Added PAGINATE and PERPAGE as shortcode options.
67
+
68
+ = 3.0.5 =
69
+ * 10/19/2015
70
+ * [Bugfix] JavaScript will now work with older versions of jQuery
71
+
72
+ = 3.0.4 =
73
+ * 10/18/2015
74
+ * [Bugfix] Fixed post/page saving issue
75
+
76
+ = 3.0.3 =
77
+ * 10/18/2015
78
+ * [Bugfix] Fix for broken JavaScript
79
+
80
+ = 3.0.2 =
81
+ * 10/18/2015
82
+ * [Bugfix] Shortcode copied/pasted itno WP visual editor should now work better
83
+ * [Bugfix] Migrating from 2.x would sometimes duplicate imported reviews ( see "Tools" settings tab for fix )
84
+ * [Bugfix] Migrating from 2.x would sometimes skip importing reviews ( see "Tools" settings tab for fix )
85
+ * [Bugfix] When paginating reviews on the front-end, "reviewed on" page links would sometimes be not linked
86
+ * [Bugfix] Relaxed the human detection anti-spam rules a bit
87
+ * [Bugfix] Fixed "failed the spambot check" issue when WP back-end is SSL, but front-end is not
88
+ * [Bugfix] Fixed some PHP error notices
89
+ * [Bugfix] JavaScript will now work with older versions of jQuery
90
+ * [Update] "Tools" tab added to plugin settings. This will contain various methods for managing/fixing review data.
91
+ * [Update] When adding reviews manually in WP admin, the WP post title now matches user-added reviews
92
+ * [Update] You can now edit the WP post title of reviews
93
+
94
+ = 3.0.1 =
95
+ * 09/29/2015
96
+ * [Update] Enabled for custom post types
97
+ * [Update] Upgrading from 2.x should go smoother for some people
98
+
99
+ = 3.0.0 =
100
+ * 09/10/2015 3.0.0 Release
101
+ * [Bugfix] Bulk edit for custom review post type now works.
102
+ * [Bugfix] Fixed an awful incompatibility issue.
103
+ * [Bugfix] "Snippet" and "More" were not working.
104
+ * [Update] Removed some unnecessary JS from being output on pages
css/newstars.png ADDED
Binary file
css/star.png ADDED
Binary file
css/wp-customer-reviews-admin.css ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* v3.1.7 08.42.2018.0842 */
2
+
3
+ .wpcr3_myplugin_options h2 { position:relative; }
4
+ .wpcr3_myplugin_options h2 .need_pro { display:inline-block; font-size:13px; margin-left:20px; position:relative; top:-10px; font-weight:bold; }
5
+
6
+ .wpcr3_myplugin_options .w40px { width:40px; }
7
+ .wpcr3_myplugin_options .w200px { width:200px; }
8
+ .wpcr3_myplugin_options .w250px { width:250px; }
9
+
10
+ #wpcr3-meta-box b { font-weight:bold;color:#000; }
11
+
12
+ /* Select2 4.0.6-rc.1 ( renamed to wpcr3_select ) */
13
+ .wpcr3_select-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.wpcr3_select-container .wpcr3_select-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.wpcr3_select-container .wpcr3_select-selection--single .wpcr3_select-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wpcr3_select-container .wpcr3_select-selection--single .wpcr3_select-selection__clear{position:relative}.wpcr3_select-container[dir="rtl"] .wpcr3_select-selection--single .wpcr3_select-selection__rendered{padding-right:8px;padding-left:20px}.wpcr3_select-container .wpcr3_select-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.wpcr3_select-container .wpcr3_select-selection--multiple .wpcr3_select-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.wpcr3_select-container .wpcr3_select-search--inline{float:left}.wpcr3_select-container .wpcr3_select-search--inline .wpcr3_select-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.wpcr3_select-container .wpcr3_select-search--inline .wpcr3_select-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.wpcr3_select-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.wpcr3_select-results{display:block}.wpcr3_select-results__options{list-style:none;margin:0;padding:0}.wpcr3_select-results__option{padding:6px;user-select:none;-webkit-user-select:none}.wpcr3_select-results__option[aria-selected]{cursor:pointer}.wpcr3_select-container--open .wpcr3_select-dropdown{left:0}.wpcr3_select-container--open .wpcr3_select-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.wpcr3_select-container--open .wpcr3_select-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.wpcr3_select-search--dropdown{display:block;padding:4px}.wpcr3_select-search--dropdown .wpcr3_select-search__field{padding:4px;width:100%;box-sizing:border-box}.wpcr3_select-search--dropdown .wpcr3_select-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.wpcr3_select-search--dropdown.wpcr3_select-search--hide{display:none}.wpcr3_select-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.wpcr3_select-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.wpcr3_select-container--default .wpcr3_select-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.wpcr3_select-container--default .wpcr3_select-selection--single .wpcr3_select-selection__rendered{color:#444;line-height:28px}.wpcr3_select-container--default .wpcr3_select-selection--single .wpcr3_select-selection__clear{cursor:pointer;float:right;font-weight:bold}.wpcr3_select-container--default .wpcr3_select-selection--single .wpcr3_select-selection__placeholder{color:#999}.wpcr3_select-container--default .wpcr3_select-selection--single .wpcr3_select-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.wpcr3_select-container--default .wpcr3_select-selection--single .wpcr3_select-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--single .wpcr3_select-selection__clear{float:left}.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--single .wpcr3_select-selection__arrow{left:1px;right:auto}.wpcr3_select-container--default.wpcr3_select-container--disabled .wpcr3_select-selection--single{background-color:#eee;cursor:default}
14
+ .wpcr3_select-container--default.wpcr3_select-container--disabled .wpcr3_select-selection--single .wpcr3_select-selection__clear{display:none}.wpcr3_select-container--default.wpcr3_select-container--open .wpcr3_select-selection--single .wpcr3_select-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.wpcr3_select-container--default .wpcr3_select-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__rendered li{list-style:none}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__placeholder{color:#999;margin-top:5px;float:left}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.wpcr3_select-container--default .wpcr3_select-selection--multiple .wpcr3_select-selection__choice__remove:hover{color:#333}.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-selection__choice,.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-selection__placeholder,.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-search--inline{float:right}.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-selection__choice{margin-left:5px;margin-right:auto}.wpcr3_select-container--default[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-selection__choice__remove{margin-left:2px;margin-right:auto}.wpcr3_select-container--default.wpcr3_select-container--focus .wpcr3_select-selection--multiple{border:solid black 1px;outline:0}.wpcr3_select-container--default.wpcr3_select-container--disabled .wpcr3_select-selection--multiple{background-color:#eee;cursor:default}.wpcr3_select-container--default.wpcr3_select-container--disabled .wpcr3_select-selection__choice__remove{display:none}.wpcr3_select-container--default.wpcr3_select-container--open.wpcr3_select-container--above .wpcr3_select-selection--single,.wpcr3_select-container--default.wpcr3_select-container--open.wpcr3_select-container--above .wpcr3_select-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.wpcr3_select-container--default.wpcr3_select-container--open.wpcr3_select-container--below .wpcr3_select-selection--single,.wpcr3_select-container--default.wpcr3_select-container--open.wpcr3_select-container--below .wpcr3_select-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.wpcr3_select-container--default .wpcr3_select-search--dropdown .wpcr3_select-search__field{border:1px solid #aaa}.wpcr3_select-container--default .wpcr3_select-search--inline .wpcr3_select-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.wpcr3_select-container--default .wpcr3_select-results>.wpcr3_select-results__options{max-height:200px;overflow-y:auto}.wpcr3_select-container--default .wpcr3_select-results__option[role=group]{padding:0}.wpcr3_select-container--default .wpcr3_select-results__option[aria-disabled=true]{color:#999}.wpcr3_select-container--default .wpcr3_select-results__option[aria-selected=true]{background-color:#ddd}.wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option{padding-left:1em}.wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__group{padding-left:0}
15
+ .wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option{margin-left:-1em;padding-left:2em}.wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option{margin-left:-2em;padding-left:3em}.wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option{margin-left:-3em;padding-left:4em}.wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option{margin-left:-4em;padding-left:5em}.wpcr3_select-container--default .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option .wpcr3_select-results__option{margin-left:-5em;padding-left:6em}.wpcr3_select-container--default .wpcr3_select-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.wpcr3_select-container--default .wpcr3_select-results__group{cursor:default;display:block;padding:6px}.wpcr3_select-container--classic .wpcr3_select-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.wpcr3_select-container--classic .wpcr3_select-selection--single:focus{border:1px solid #5897fb}.wpcr3_select-container--classic .wpcr3_select-selection--single .wpcr3_select-selection__rendered{color:#444;line-height:28px}.wpcr3_select-container--classic .wpcr3_select-selection--single .wpcr3_select-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.wpcr3_select-container--classic .wpcr3_select-selection--single .wpcr3_select-selection__placeholder{color:#999}.wpcr3_select-container--classic .wpcr3_select-selection--single .wpcr3_select-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.wpcr3_select-container--classic .wpcr3_select-selection--single .wpcr3_select-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.wpcr3_select-container--classic[dir="rtl"] .wpcr3_select-selection--single .wpcr3_select-selection__clear{float:left}.wpcr3_select-container--classic[dir="rtl"] .wpcr3_select-selection--single .wpcr3_select-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.wpcr3_select-container--classic.wpcr3_select-container--open .wpcr3_select-selection--single{border:1px solid #5897fb}.wpcr3_select-container--classic.wpcr3_select-container--open .wpcr3_select-selection--single .wpcr3_select-selection__arrow{background:transparent;border:none}.wpcr3_select-container--classic.wpcr3_select-container--open .wpcr3_select-selection--single .wpcr3_select-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}
16
+ .wpcr3_select-container--classic.wpcr3_select-container--open.wpcr3_select-container--above .wpcr3_select-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.wpcr3_select-container--classic.wpcr3_select-container--open.wpcr3_select-container--below .wpcr3_select-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.wpcr3_select-container--classic .wpcr3_select-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.wpcr3_select-container--classic .wpcr3_select-selection--multiple:focus{border:1px solid #5897fb}.wpcr3_select-container--classic .wpcr3_select-selection--multiple .wpcr3_select-selection__rendered{list-style:none;margin:0;padding:0 5px}.wpcr3_select-container--classic .wpcr3_select-selection--multiple .wpcr3_select-selection__clear{display:none}.wpcr3_select-container--classic .wpcr3_select-selection--multiple .wpcr3_select-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.wpcr3_select-container--classic .wpcr3_select-selection--multiple .wpcr3_select-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.wpcr3_select-container--classic .wpcr3_select-selection--multiple .wpcr3_select-selection__choice__remove:hover{color:#555}.wpcr3_select-container--classic[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-selection__choice{float:right;margin-left:5px;margin-right:auto}.wpcr3_select-container--classic[dir="rtl"] .wpcr3_select-selection--multiple .wpcr3_select-selection__choice__remove{margin-left:2px;margin-right:auto}.wpcr3_select-container--classic.wpcr3_select-container--open .wpcr3_select-selection--multiple{border:1px solid #5897fb}.wpcr3_select-container--classic.wpcr3_select-container--open.wpcr3_select-container--above .wpcr3_select-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.wpcr3_select-container--classic.wpcr3_select-container--open.wpcr3_select-container--below .wpcr3_select-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.wpcr3_select-container--classic .wpcr3_select-search--dropdown .wpcr3_select-search__field{border:1px solid #aaa;outline:0}.wpcr3_select-container--classic .wpcr3_select-search--inline .wpcr3_select-search__field{outline:0;box-shadow:none}.wpcr3_select-container--classic .wpcr3_select-dropdown{background-color:#fff;border:1px solid transparent}.wpcr3_select-container--classic .wpcr3_select-dropdown--above{border-bottom:none}.wpcr3_select-container--classic .wpcr3_select-dropdown--below{border-top:none}.wpcr3_select-container--classic .wpcr3_select-results>.wpcr3_select-results__options{max-height:200px;overflow-y:auto}.wpcr3_select-container--classic .wpcr3_select-results__option[role=group]{padding:0}.wpcr3_select-container--classic .wpcr3_select-results__option[aria-disabled=true]{color:grey}.wpcr3_select-container--classic .wpcr3_select-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.wpcr3_select-container--classic .wpcr3_select-results__group{cursor:default;display:block;padding:6px}.wpcr3_select-container--classic.wpcr3_select-container--open .wpcr3_select-dropdown{border-color:#5897fb}
css/wp-customer-reviews-generated.css ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ WARNING: If you edit anything here, it will be overwritten with each plugin update and/or activation.
3
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
4
+
5
+ You can also override any of these values in your theme CSS if you use !important or prepend with "body "
6
+ Example: body #wpcr3_respond_1 blockquote.description p { font-size:12px !important; font-weight:bold !important; }
7
+ */
8
+
9
+ .wpcr3_in_content { margin-bottom:30px; }
10
+ .wpcr3_in_content meta { display:none; }
11
+ .wpcr3_power { padding-top:30px !important; padding-bottom:30px !important; font-size:11px !important; }
12
+ .wpcr3_status_msg { color:#c00;font-weight:bold; }
13
+ .wpcr3_status_msg div { color:#c00;font-weight:bold;padding-bottom:15px;padding-top:15px; }
14
+ .wpcr3_caps { text-transform:capitalize; }
15
+
16
+ div.wpcr3_dotline, div.wpcr3_review div.wpcr3_dotline {
17
+ display:block !important; border-bottom:1px dotted #ccc !important;
18
+ margin-bottom:10px !important; clear:both !important;
19
+ }
20
+
21
+ .wpcr3_leave_text { font-weight:bold; font-size:1.1rem; }
22
+
23
+ div.wpcr3_aggregateRating { display:block !important; margin-bottom:30px; line-height:24px; font-size:0.8em; }
24
+ div.wpcr3_aggregateRating div.wpcr3_aggregateRating_ratingValue { display:inline-block !important; position:relative; top:2px; }
25
+
26
+ div.wpcr3_review_item div.wpcr3_item_name { font-size:0.8em; font-style:italic; }
27
+
28
+ div.wpcr3_review div, div.wpcr3_review span { display:inline-block !important; line-height:24px; }
29
+ div.wpcr3_review div.wpcr3_review_ratingValue { position:relative; top:2px; margin-right:5px; }
30
+ div.wpcr3_review div.wpcr3_review_title { font-size:0.8em; display:block !important; }
31
+ div.wpcr3_review blockquote.wpcr3_content { font-size:14px; font-weight:normal; display:block !important; padding-bottom:30px; }
32
+ div.wpcr3_review blockquote.wpcr3_content p { font-size:14px; font-weight:normal; display:inline !important; }
33
+ div.wpcr3_review blockquote.wpcr3_content.wpcr3_admin_response { margin-left:30px;color:#00c; }
34
+ div.wpcr3_review div.wpcr3_review_datePublished { font-size:0.9em; font-style:italic; }
35
+ div.wpcr3_review div.wpcr3_review_author { font-size:0.8em; font-style:italic; }
36
+ div.wpcr3_review div.wpcr3_review_customs { margin-bottom:5px; }
37
+ div.wpcr3_review div.wpcr3_review_custom { font-size:12px; float:left; margin-right:60px; }
38
+
39
+ .wpcr3_respond_2 { position:relative; }
40
+ .wpcr3_respond_2 label { display:inline-block; !important; }
41
+ .wpcr3_respond_2 .fconfirm2 { width:auto !important; }
42
+
43
+ .wpcr3_respond_2 input { }
44
+ .wpcr3_respond_2 input[type="text"] { min-width:200px; }
45
+ .wpcr3_respond_2 textarea { height:100px !important; min-width:500px; }
46
+ .wpcr3_respond_2 small { padding:0 !important; margin:0 !important; }
47
+ .wpcr3_respond_2 table, .wpcr3_respond_2 td { border:0 !important; border-style:none !important; }
48
+
49
+ .wpcr3_respond_2 .wpcr3_check_confirm label { margin:-2px 0px 0px 5px; }
50
+
51
+ .wpcr3_ad { background:#ffffff; }
52
+ .wpcr3_ad label { font-weight:bold; }
53
+
54
+ .wpcr3_respond_1, .wpcr3_respond_2 { margin:0 !important; padding:0 !important; clear:both !important; }
55
+ .wpcr3_respond_1 p, .wpcr3_respond_2 p {
56
+ margin:0 !important;
57
+ padding:0 !important;
58
+ line-height:120% !important;
59
+ margin-top:2px !important;
60
+ margin-bottom:2px !important;
61
+ }
62
+
63
+ .wpcr3_respond_1 .wpcr3_rating, .wpcr3_respond_2 .wpcr3_rating {
64
+ border:0 !important;
65
+ margin:0 !important;
66
+ padding:0 !important;
67
+ margin-left:0px !important;
68
+ margin-top:0px !important;
69
+ overflow:hidden;
70
+ height:16px;
71
+ }
72
+
73
+ div.wpcr3_rating_style1 { line-height:17px; display:inline-block; }
74
+ div.wpcr3_rating_style1 div { line-height:17px; }
75
+ div.wpcr3_rating_style1 * { border:0 none; margin:0; padding:0; line-height:17px; }
76
+ div.wpcr3_rating_style1_base { background:url(newstars.png) 0 0 no-repeat; width:85px; height:17px; line-height:17px; float:left; padding-right:4px; overflow:hidden; display:block; }
77
+ div.wpcr3_rating_style1_average { background:url(newstars.png) 0 -15px no-repeat; text-indent:-9999px; height:17px; line-height:17px; }
78
+ div.wpcr3_rating_style1_status { height:17px; line-height:17px; width:100px; overflow:hidden; position:relative; cursor:pointer; display:block; }
79
+ div.wpcr3_rating_style1_score { background:url(newstars.png) 0 0 no-repeat; width:85px; height:17px; line-height:17px; float:left; position:relative; }
80
+ div.wpcr3_rating_style1_score div { display:block; height:17px; float:left; text-indent:-9999px; position:absolute; overflow:hidden; line-height:17px; }
81
+ div.wpcr3_rating_style1_score div:hover { background:url(newstars.png) bottom right no-repeat; }
82
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score1 {width:20%; z-index:55;}
83
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score2 {width:40%; z-index:54;}
84
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score3 {width:60%; z-index:53;}
85
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score4 {width:80%; z-index:52;}
86
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score5 {width:100%; z-index:51;}
87
+
88
+ .wpcr3_respond_2 { display:none; background-color:inherit; }
89
+ .wpcr3_div_2 { width:600px; }
90
+ .wpcr3_table_2 { text-align:left; width:100%; }
91
+ .wpcr3_table_2 td { text-align:left; }
92
+ .wpcr3_check_confirm { margin-top:10px;font-size:13px;margin-bottom:4px; }
93
+
94
+ .wpcr3_button_1 {
95
+ border: 1px solid;
96
+ border-color: #e6e6e6 #cccccc #cccccc #e6e6e6;
97
+ -moz-border-radius: 3px;
98
+ -webkit-border-radius: 3px;
99
+ border-radius: 3px;
100
+ background: #ffffff;
101
+ background: -moz-linear-gradient(top, #ffffff 0%, #c4c4c4 100%);
102
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#c4c4c4));
103
+ background: -webkit-linear-gradient(top, #ffffff 0%,#c4c4c4 100%);
104
+ background: -o-linear-gradient(top, #ffffff 0%,#c4c4c4 100%);
105
+ background: -ms-linear-gradient(top, #ffffff 0%,#c4c4c4 100%);
106
+ background: linear-gradient(to bottom, #ffffff 0%,#c4c4c4 100%);
107
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#c4c4c4',GradientType=0 );
108
+ color: #404040;
109
+ cursor:pointer;
110
+ display: inline-block;
111
+ font-size: 13px;
112
+ font-weight: normal;
113
+ outline: 0;
114
+ padding: 5px 12px 5px;
115
+ text-align: center;
116
+ text-decoration: none;
117
+ white-space: nowrap;
118
+ float:none;
119
+ height:auto;
120
+ text-indent:0;
121
+ margin-bottom: 15px;
122
+ }
123
+
124
+ .wpcr3_button_1:hover {
125
+ background: #dedede;
126
+ background: -moz-linear-gradient(top, #ffffff 0%, #b8b8b8 100%);
127
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#b8b8b8));
128
+ background: -webkit-linear-gradient(top, #ffffff 0%,#b8b8b8 100%);
129
+ background: -o-linear-gradient(top, #ffffff 0%,#b8b8b8 100%);
130
+ background: -ms-linear-gradient(top, #ffffff 0%,#b8b8b8 100%);
131
+ background: linear-gradient(to bottom, #ffffff 0%,#b8b8b8 100%);
132
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#b8b8b8',GradientType=1 );
133
+ border-color: #99ccff;
134
+ color: #333333;
135
+ cursor:pointer;
136
+ font-weight: normal;
137
+ }
138
+
139
+ .wpcr3_button_1:active, .wpcr3_button_1:focus {
140
+ background-position: 0 -25px;
141
+ background: #dedede;
142
+ background: -moz-linear-gradient(top, #ffffff 0%, #dedede 100%);
143
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#dedede));
144
+ background: -webkit-linear-gradient(top, #ffffff 0%,#dedede 100%);
145
+ background: -o-linear-gradient(top, #ffffff 0%,#dedede 100%);
146
+ background: -ms-linear-gradient(top, #ffffff 0%,#dedede 100%);
147
+ background: linear-gradient(to bottom, #ffffff 0%,#dedede 100%);
148
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dedede',GradientType=1 );
149
+ border-color: #8fc7ff #94c9ff #94c9ff #8fc7ff;
150
+ color:#1a1a1a;
151
+ }
152
+
153
+ .wpcr3_button_1.wpcr3_disabled {
154
+ opacity: 0.5;
155
+ }
156
+
157
+ .wpcr3_button_1.wpcr3_hide {
158
+ display:none !important;
159
+ }
160
+
161
+ .wpcr3_pagination {
162
+ clear:both;
163
+ padding:0px 0px 0px 0px;
164
+ position:relative;
165
+ font-size:11px;
166
+ line-height:13px;
167
+ }
168
+
169
+ .wpcr3_pagination_page {
170
+ float:left;
171
+ display:block;
172
+ line-height:30px;
173
+ padding-right:5px;
174
+ }
175
+
176
+ .wpcr3_pagination .wpcr3_a {
177
+ display:block;
178
+ float:left;
179
+ margin: 0px 1px 0px 1px;
180
+ padding:6px 10px 6px 10px;
181
+ line-height: 16px;
182
+ text-decoration:none;
183
+ width:auto;
184
+ color:#fff;
185
+ background:#555;
186
+ cursor:pointer;
187
+ }
188
+
189
+ .wpcr3_pagination .wpcr3_a:hover {
190
+ color:#fff;background: #3279BB;
191
+ }
192
+
193
+ .wpcr3_pagination .wpcr3_ls {
194
+ margin-right:1px;
195
+ }
196
+
197
+ .wpcr3_pagination .wpcr3_rs {
198
+ margin-left:1px;
199
+ }
200
+
201
+ .wpcr3_pagination .wpcr3_a.wpcr3_current {
202
+ background: #3279BB;color:#fff;cursor:default;
203
+ }
204
+
205
+ .wpcr3_pagination .wpcr3_a.wpcr3_disabled, .wpcr3_pagination .wpcr3_a.wpcr3_disabled:hover {
206
+ background:#ddd;color:#fff;cursor:default;
207
+ }
208
+
209
+ .wpcr3_clear , div.wpcr3_review .wpcr3_clear { clear:both !important; display:block !important; line-height:0px !important;; height:0px !important; }
210
+ .wpcr3_show, div.wpcr3_review .wpcr3_show { display:inline; }
211
+ .wpcr3_hide, div.wpcr3_review .wpcr3_hide { display:none !important; }
212
+ .wpcr3_fakehide { position:absolute !important;top:0 !important;left:-999em !important;height:1px !important;width:1px !important; }
213
+ .wpcr3_pb5 { padding-bottom:5px; }
css/wp-customer-reviews-generated.css.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define('DOING_AJAX', true);
3
+
4
+ $parse_uri = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
5
+ require_once($parse_uri[0].'wp-load.php');
6
+
7
+ $parse_uri = explode('wp-customer-reviews', $_SERVER['SCRIPT_FILENAME']);
8
+ require_once($parse_uri[0].'wp-customer-reviews/wp-customer-reviews-3.php');
9
+ $WPCustomerReviews3->css();
10
+ ?>
include/admin/tools/delete-all-reviews.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (function_exists("current_user_can") === false || current_user_can('manage_options') !== true) {
3
+ die("Access Denied");
4
+ }
5
+
6
+ // deletes all 3x reviews
7
+ if (!isset($_POST['wpcr3_confirm']) || $_POST['wpcr3_confirm'] !== 'YES') {
8
+ ?>
9
+ This will permanently delete all of your reviews.<br /><br />
10
+ To continue the deletion process, type YES in all caps below.<br /><br />
11
+ <input name="wpcr3_confirm" type="text" value="" />&nbsp;&nbsp;
12
+ <input name="wpcr3_debug_code" type="hidden" value="<?php echo $_POST['wpcr3_debug_code'] ?>" />
13
+ <input type="submit" value="Confirm" />
14
+ <?php
15
+ die();
16
+ }
17
+
18
+ $queryOpts = array(
19
+ 'nopaging' => true,
20
+ 'post_type' => 'wpcr3_review',
21
+ 'post_status' => 'publish,pending,draft,future,private,trash'
22
+ );
23
+ $posts = new WP_Query($queryOpts);
24
+ foreach ($posts->posts as $post) {
25
+ print "Deleting review $post->ID<br />";
26
+ wp_delete_post($post->ID, true);
27
+ }
28
+ ?>
include/admin/tools/reimport-2x.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (function_exists("current_user_can") === false || current_user_can('manage_options') !== true) {
3
+ die("Access Denied");
4
+ }
5
+
6
+ // imports 2x reviews
7
+ if (!isset($_POST['wpcr3_confirm']) || $_POST['wpcr3_confirm'] !== 'YES') {
8
+ ?>
9
+ This will re-import all reviews AND settings from v2.x, even if they were previously imported.<br /><br />
10
+ To continue the importing process, type YES in all caps below.<br /><br />
11
+ <input name="wpcr3_confirm" type="text" value="" />&nbsp;&nbsp;
12
+ <input name="wpcr3_debug_code" type="hidden" value="<?php echo $_POST['wpcr3_debug_code'] ?>" />
13
+ <input type="submit" value="Confirm" />
14
+ <?php
15
+ die();
16
+ }
17
+
18
+ // remove upgraded bit from 2x settings
19
+ $old_2x_options = get_option("wpcr_options");
20
+ $old_2x_options['migrated_to_3x'] = 0;
21
+ update_option('wpcr_options', $old_2x_options);
22
+
23
+ // remove 3x upgraded bit for all wp posts
24
+ $queryOpts = array(
25
+ 'nopaging' => true,
26
+ 'post_type' => 'any',
27
+ 'post_status' => 'publish,pending,draft,future,private,trash',
28
+ 'meta_query' => array(
29
+ array(
30
+ 'key' => 'wpcr_migrated_to_3x',
31
+ 'value' => '1',
32
+ 'compare' => '='
33
+ )
34
+ )
35
+ );
36
+ $migrated_posts = new WP_Query($queryOpts);
37
+ foreach ($migrated_posts->posts as $post) {
38
+ delete_post_meta($post->ID, 'wpcr_migrated_to_3x');
39
+ }
40
+
41
+ // run 2x-3x migrate script
42
+ include($this->getplugindir().'include/migrate/2x-3x.php');
43
+ $migrate_ok = wpcr3_migrate_2x_3x($this, 248);
44
+ ?>
include/admin/tools/remove-duplicates.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (function_exists("current_user_can") === false || current_user_can('manage_options') !== true) {
3
+ die("Access Denied");
4
+ }
5
+
6
+ // removes duplicate 3x reviews
7
+ // determines duplicate by name + email + reviewed page id + date
8
+ // keeps lowest page ids found
9
+ if (!isset($_POST['wpcr3_confirm']) || $_POST['wpcr3_confirm'] !== 'YES') {
10
+ ?>
11
+ This will attempt to de-dupe reviews. Duplicates are determined by comparing title + content + timestamp + reviewed page id<br /><br />
12
+ To continue the duplicate removal process, type YES in all caps below.<br /><br />
13
+ <input name="wpcr3_confirm" type="text" value="" />&nbsp;&nbsp;
14
+ <input name="wpcr3_debug_code" type="hidden" value="<?php echo $_POST['wpcr3_debug_code'] ?>" />
15
+ <input type="submit" value="Confirm" />
16
+ <?php
17
+ die();
18
+ }
19
+
20
+ $queryOpts = array(
21
+ 'nopaging' => true,
22
+ 'post_type' => $this->prefix.'_review',
23
+ 'post_status' => 'publish,pending,draft,future,private' // no trash
24
+ );
25
+ $posts = new WP_Query($queryOpts);
26
+
27
+ $unique_hashes = array();
28
+
29
+ foreach ($posts->posts as $post) {
30
+ $reviewed_post_id = get_post_meta($post->ID, $this->prefix.'_review_post' ,true);
31
+ $hash = "'{$post->post_date}'__'{$post->post_title}'__'{$post->post_content}'__'{$reviewed_post_id}'";
32
+ $hash = md5($hash);
33
+
34
+ if (!in_array($hash, $unique_hashes)) {
35
+ $unique_hashes[] = $hash;
36
+ continue;
37
+ }
38
+
39
+ // if we get here, we have a dupe
40
+ print "Deleting duplicate review $post->ID $post->title<br />";
41
+ wp_delete_post($post->ID, true);
42
+ }
43
+ ?>
include/admin/wp-customer-reviews-3-admin.php ADDED
@@ -0,0 +1,1395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WPCustomerReviewsAdmin3 extends WPCustomerReviews3
3
+ {
4
+ var $default_options = array();
5
+ var $settings_sections = array();
6
+ var $admin_init_ran = false;
7
+ var $meta_box_posts = array();
8
+ var $meta_box_reviews = array();
9
+
10
+ function __construct() {
11
+ }
12
+
13
+ function start_admin($parentClass) {
14
+ $this->setSharedVars($parentClass);
15
+ }
16
+
17
+ function check_admin_options_nonce() {
18
+ check_admin_referer("wpcr3_admin_options");
19
+ }
20
+
21
+ function my_output_settings_section($id) {
22
+ $submit_name = $this->prefix."_save_settings";
23
+
24
+ $params = array($submit_name);
25
+ $this->param($params);
26
+
27
+ if ($this->p->$submit_name == $id) {
28
+ $this->update_options($id);
29
+ }
30
+ ?>
31
+ <table class="form-table"><tbody>
32
+ <?php
33
+ foreach ($this->settings_sections[$id] as $settingObj) {
34
+ $this->my_output_setting($settingObj);
35
+ }
36
+ ?>
37
+ </tbody></table>
38
+ <input type="hidden" name="<?php echo $submit_name; ?>" value="<?php echo $id; ?>" />
39
+ <?php
40
+ submit_button();
41
+ }
42
+
43
+ function my_output_setting($settingObj) {
44
+ $options = $settingObj->options;
45
+ $options->hint = isset($options->hint) ? $options->hint : "";
46
+ $options->class = isset($options->class) ? $options->class : "";
47
+ $options->addmore = isset($options->addmore) && $options->addmore == "1" ? true : false;
48
+
49
+ $name = $this->prefix.'_option_'.$settingObj->name;
50
+ $value = $this->options[$settingObj->name];
51
+
52
+ echo '
53
+ <tr class="setting_'.$name.'">
54
+ <th scope="row">
55
+ <label title="'.$options->hint.'" for="'.$name.'">'.$settingObj->label.'</label>
56
+ <div style="font-size:10px;font-weight:normal;">'.$options->hint.'</div>
57
+ </th>
58
+ <td>
59
+ ';
60
+
61
+ if ($options->type === "text") {
62
+ echo ' <input class="'.$options->class.'" type="text" name="'.$name.'" value="'.$value.'" />';
63
+ } else if ($options->type === "select") {
64
+ echo ' <select class="'.$options->class.'" name="'.$name.'">';
65
+ foreach ($options->options as $opt) {
66
+ $selected = ($value == $opt->value) ? 'selected="selected"' : '';
67
+ echo ' <option '.$selected.' value="'.$opt->value.'">'.$opt->label.'</option>';
68
+ }
69
+ echo ' </select>';
70
+ } else if ($options->type === "multi_input_checkbox") {
71
+ echo ' <table class="table_multi_input_checkbox" style="border-right:1px solid #bbb;border-bottom:1px solid #ddd;">';
72
+ foreach ($options->options as $valObj) {
73
+ echo ' <tr><td>';
74
+ if (isset($options->editable_label) && $options->editable_label == "1") {
75
+ echo '<input class="'.$options->class.'" name="'.$name.'['.$valObj->value.'][label]" value="'.$value[$valObj->value]['label'].'" />';
76
+ } else {
77
+ echo $value[$valObj->value]['label'];
78
+ }
79
+ echo ' </td>';
80
+
81
+ foreach ($valObj->checkboxes as $cbObj) {
82
+ if ($cbObj->default == "-1") {
83
+ echo '<td></td>';
84
+ continue;
85
+ }
86
+ $cbObj->class = isset($cbObj->class) ? $cbObj->class : "";
87
+ $myValue = $value[$valObj->value][$cbObj->value];
88
+ $checked = ($myValue == "1") ? 'checked="checked"' : '';
89
+ echo ' <td><label><input class="'.$cbObj->class.'" '.$checked.' name="'.$name.'['.$valObj->value.']['.$cbObj->value.']" type="checkbox" value="1" /> '.$cbObj->label.'</label></td>';
90
+ }
91
+ echo ' <td style="font-size:10px;">'.$valObj->hint.'</td>';
92
+ echo ' </tr>';
93
+ }
94
+ if ($options->addmore) {
95
+ $need_pro = ($this->pro) ? "" : "need_pro";
96
+ echo ' <tr><td colspan="'.(count($valObj->checkboxes) + 2).'"><a class="addmore '.$need_pro.'" href="#">Add Another</a></td></tr>';
97
+ }
98
+ echo ' </table>';
99
+ }
100
+
101
+ echo '
102
+ </td>
103
+ </tr>
104
+ ';
105
+ }
106
+
107
+ function real_admin_init() {
108
+ $this->admin_init_ran = true;
109
+
110
+ add_action('admin_head', array(&$this, 'admin_head'));
111
+ add_action('admin_notices', array(&$this, 'admin_notices'));
112
+ add_action('save_post', array(&$this, 'admin_save_post'), 10, 3); // 3 arguments
113
+ add_action('manage_'.$this->prefix.'_review_posts_custom_column', array(&$this, 'admin_custom_review_column'), 10, 2); // 2 arguments
114
+ add_action('restrict_manage_posts', array(&$this, 'review_filter_list'));
115
+ add_action('load-edit.php', array(&$this, 'load_custom_filter'));
116
+ add_action('add_meta_boxes', array(&$this, 'my_add_meta_box'), 10, 2); // 2 arguments
117
+
118
+ add_action('wp_ajax_'.$this->prefix.'_enabled_posts', array(&$this, 'ajax_enabled_posts'));
119
+
120
+ add_filter('manage_edit-'.$this->prefix.'_review_columns', array(&$this, 'admin_filter_custom_review_columns') );
121
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), array(&$this, 'plugin_settings_link'));
122
+ add_filter('post_updated_messages', array(&$this, 'admin_post_updated_messages'));
123
+ add_filter('manage_edit-wpcr3_review_sortable_columns', array(&$this, 'review_sortable_columns'));
124
+ add_filter('request', array(&$this, 'review_sortable_columns_orderby'));
125
+
126
+ $this->enqueue_admin_stuff();
127
+
128
+ $params = array('action');
129
+ $this->param($params);
130
+
131
+ /* used for redirecting to settings page upon initial activation */
132
+ if (get_option($this->prefix.'_gotosettings', false)) {
133
+ delete_option($this->prefix.'_gotosettings');
134
+
135
+ $this->post_activate();
136
+
137
+ /* no auto redirect if upgrading */
138
+ if ($this->p->action === 'activate-plugin') { return false; }
139
+
140
+ $url = get_admin_url().'admin.php?page='.$this->prefix.'_options';
141
+ $this->redirect($url);
142
+ }
143
+
144
+ if ($this->options === false) {
145
+ $this->post_activate();
146
+ }
147
+
148
+ $this->create_settings();
149
+ $this->notice_ignore(); /* admin notices */
150
+ }
151
+
152
+ function post_activate() {
153
+ if ($this->pro !== true) {
154
+ unset($this->options['templates']);
155
+ update_option($this->options_name, $this->options);
156
+ }
157
+
158
+ $this->create_settings();
159
+ $this->check_migrate();
160
+
161
+ $this->notify_activate(1); // notify on initial activation, reactivation, upgrade
162
+ }
163
+
164
+ // generates new "-generated" CSS file based on template version
165
+ function generate_css() {
166
+ $can_write_css = $this->can_write_css();
167
+ if ($can_write_css["can_write"]) {
168
+ $css = $this->template('wp-customer-reviews-css');
169
+ file_put_contents($can_write_css["filename"], $css, LOCK_EX); // overwrites -generated.css
170
+ }
171
+ }
172
+
173
+ function load_template($file, $ext, $force) {
174
+ if ($this->options === false || !isset($this->options['templates'])) {
175
+ $force = true;
176
+ }
177
+
178
+ if ($force === true || array_key_exists($file, $this->options['templates']) === false) {
179
+ $rtn = file_get_contents($this->getplugindir().'include/templates/'.$file.'.'.$ext);
180
+ $rtn = preg_replace('/%---.*?---%/ims', '', $rtn);
181
+ } else {
182
+ $rtn = $this->options['templates'][$file];
183
+ }
184
+
185
+ return $rtn;
186
+ }
187
+
188
+ function update_db_version($new_version) {
189
+ $this->options['dbversion'] = $new_version;
190
+ update_option($this->options_name, $this->options);
191
+ return $this->options['dbversion'];
192
+ }
193
+
194
+ function merge_options() {
195
+ $default_options = array();
196
+
197
+ // begin: build options from settings_sections ( and get defaults )
198
+ foreach ($this->settings_sections as $section_id => $sectionArr) {
199
+ foreach ($sectionArr as $settingArr) {
200
+ $name = $settingArr->name;
201
+ $options = $settingArr->options;
202
+ if ($options->type === "text") {
203
+ $default_options[$name] = $options->default;
204
+ } else if ($options->type === "select") {
205
+ $default_options[$name] = $options->default;
206
+ } else if ($options->type === "multi_input_checkbox") {
207
+ $default_options[$name] = array();
208
+ foreach ($options->options as $valObj) {
209
+ $default_options[$name][$valObj->value] = array();
210
+ $default_options[$name][$valObj->value]['label'] = $valObj->label;
211
+ foreach ($valObj->checkboxes as $cbObj) {
212
+ $default_options[$name][$valObj->value][$cbObj->value] = $cbObj->default;
213
+ }
214
+ }
215
+ } else if ($options->type === "array") {
216
+ $default_options[$name] = array();
217
+ foreach ($options->options as $key => $val) {
218
+ $default_options[$name][$key] = $val;
219
+ }
220
+ }
221
+ }
222
+ }
223
+ // end: build options from settings_sections ( and get defaults )
224
+
225
+ $this->default_options = $default_options; // save for later, migrations, etc
226
+
227
+ // get current options from WP, if they do not exist yet, get $default_options
228
+ $this->options = get_option($this->options_name, $default_options);
229
+
230
+ // begin: magically easy options migrations to newer versions
231
+ $has_new = false;
232
+ foreach ($default_options as $col => $def_val) {
233
+ if (!isset($this->options[$col])) {
234
+ $this->options[$col] = $def_val;
235
+ $has_new = true;
236
+ }
237
+
238
+ // allows for associative arrays up to 2 depth [ "standard_fields" => [ "fname" => [ "ask" : "1" ] ] ]
239
+ if (is_array($def_val)) {
240
+ foreach ($def_val as $acol => $aval) {
241
+ if (!isset($this->options[$col][$acol])) {
242
+ $this->options[$col][$acol] = $aval;
243
+ $has_new = true;
244
+ }
245
+
246
+ if (is_array($aval)) {
247
+ foreach ($aval as $acol2 => $aval2) {
248
+ if (!isset($this->options[$col][$acol][$acol2])) {
249
+ $this->options[$col][$acol][$acol2] = $aval2;
250
+ $has_new = true;
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ }
257
+
258
+ if ($has_new) {
259
+ update_option($this->options_name, $this->options);
260
+ }
261
+ // end: magically easy options migrations to newer versions
262
+
263
+ $this->post_update_options();
264
+ }
265
+
266
+ function post_update_options() {
267
+ $this->generate_css();
268
+ }
269
+
270
+ function get_cleaned_dbversion() {
271
+ $current_dbversion = ($this->options !== false && isset($this->options['dbversion'])) ? $this->options['dbversion'] : 0;
272
+ $current_dbversion = intval(str_replace('.', '', $current_dbversion));
273
+ return $current_dbversion;
274
+ }
275
+
276
+ function check_migrate() {
277
+ $current_dbversion = $this->get_cleaned_dbversion();
278
+ $plugin_db_version = intval(str_replace('.', '', $this->plugin_version));
279
+
280
+ $this->merge_options();
281
+
282
+ if ($current_dbversion == $plugin_db_version) {
283
+ return;
284
+ }
285
+
286
+ if ($current_dbversion == 0) {
287
+ // check if we need to migrate from 2.x to 3.x
288
+ include_once($this->getplugindir().'include/migrate/2x-3x.php');
289
+ $migrate_ok = wpcr3_migrate_2x_3x($this, $current_dbversion);
290
+ } else {
291
+ // if we get here, we are upgrading 3.x to 3.x
292
+ include_once($this->getplugindir().'include/migrate/3x-3x.php');
293
+ $migrate_ok = wpcr3_migrate_3x_3x($this, $current_dbversion);
294
+ }
295
+
296
+ if ($migrate_ok === true) {
297
+ // done with all migrations, push dbversion to current version
298
+ $this->update_db_version($plugin_db_version);
299
+ }
300
+ }
301
+
302
+ function my_add_settings_section($id, $label, $type) {
303
+ $newSection = new stdClass();
304
+ $newSection->id = $id;
305
+ $newSection->label = $label;
306
+ $newSection->type = $type;
307
+ $this->settings_sections[$id] = array();
308
+ }
309
+
310
+ function my_add_setting($section_id, $name, $label, $options_json) {
311
+ $newSetting = new stdClass();
312
+ $newSetting->name = $name;
313
+ $newSetting->label = $label;
314
+ $newSetting->section_id = $section_id;
315
+ $newSetting->options = json_decode($options_json);
316
+ $this->settings_sections[$section_id][] = $newSetting;
317
+ }
318
+
319
+ function create_ask_require_show($label, $name, $ask, $require, $show, $rate, $has_rating, $hint) {
320
+ // pass -1 to ask,require,show to disable this checkbox from being output
321
+
322
+ $rtn = '
323
+ {
324
+ "label" : "'.$label.'",
325
+ "value" : "'.$name.'",
326
+ "hint" : "'.$hint.'",
327
+ "checkboxes" : [
328
+ { "label" : "Ask", "value" : "ask", "default" : "'.$ask.'" }
329
+ ,{ "label" : "Require", "value" : "require", "default" : "'.$require.'" }
330
+ ,{ "label" : "Show", "value" : "show", "default" : "'.$show.'" }
331
+ ';
332
+ if ($has_rating === 1) {
333
+ $rtn .= '
334
+ ,{ "label" : "Rate", "value" : "rate", "default" : "'.$rate.'", "class" : "need_pro" }
335
+ ';
336
+ }
337
+ $rtn .= '
338
+ ]
339
+ }
340
+ ';
341
+ return $rtn;
342
+ }
343
+
344
+ function create_settings() {
345
+ $this->settings_sections = array();
346
+
347
+ $options_yesno = '[
348
+ { "label" : "Yes", "value" : "1" },
349
+ { "label" : "No", "value" : "0" }
350
+ ]';
351
+
352
+ // Hidden Settings
353
+ $section_id = 'hidden_settings';
354
+ $this->my_add_settings_section($section_id, 'Hidden Settings', 'hidden');
355
+ $this->my_add_setting($section_id, 'act_email', 'Activation Email', '{ "type" : "text", "default" : "" }');
356
+ $this->my_add_setting($section_id, 'act_uniq', 'Activation ID', '{ "type" : "text", "default" : "" }');
357
+ $this->my_add_setting($section_id, 'activated', 'Activated', '{ "type" : "text", "default" : "1" }');
358
+ $this->my_add_setting($section_id, 'dbversion', 'Database Version', '{ "type" : "text", "default" : "0" }');
359
+
360
+ $templates = array();
361
+ foreach ($this->all_templates as $file => $ext) {
362
+ $templates[$file] = $this->load_template($file, $ext, false);
363
+ }
364
+ $templates = json_encode($templates);
365
+ $this->my_add_setting($section_id, 'templates', 'Templates', '{ "type" : "array", "options" : '.$templates.' }');
366
+
367
+ // Form Settings
368
+ $section_id = 'form_settings';
369
+ $this->my_add_settings_section($section_id, 'Form Settings', 'h3');
370
+
371
+ $this->my_add_setting($section_id, 'standard_fields', 'Standard fields on reviews', '
372
+ { "type": "multi_input_checkbox",
373
+ "hint" : "Choose which fields you want to ask for, require, and display on submitted reviews.",
374
+ "editable_label" : "1",
375
+ "options" : [
376
+ '.$this->create_ask_require_show( "Name", "fname", 1, 1, 1, 0, 0, '(English: Name)' ).',
377
+ '.$this->create_ask_require_show( "Email", "femail", 1, 1, -1, 0, 0, '(English: Email)' ).',
378
+ '.$this->create_ask_require_show( "Website", "fwebsite", 1, 0, 0, 0, 0, '(English: Website)' ).',
379
+ '.$this->create_ask_require_show( "Review Title", "ftitle", 1, 0, 1, 0, 0, '(English: Review Title)' ).'
380
+ ]
381
+ }'
382
+ );
383
+
384
+ $this->my_add_setting($section_id, 'custom_fields', 'Custom fields on reviews', '
385
+ { "hint" : "You can type in the names of any additional fields you would like here. <br /><br />Warning: If you change the field names, it will also change them on past reviews.",
386
+ "type": "multi_input_checkbox",
387
+ "addmore" : "1",
388
+ "editable_label" : "1",
389
+ "options" : [
390
+ '.$this->create_ask_require_show( "Field 1", "f1", 0, 0, 0, 0, 1, '' ).',
391
+ '.$this->create_ask_require_show( "Field 2", "f2", 0, 0, 0, 0, 1, '' ).',
392
+ '.$this->create_ask_require_show( "Field 3", "f3", 0, 0, 0, 0, 1, '' ).'
393
+ ]
394
+ }'
395
+ );
396
+
397
+ // Display Settings
398
+ $section_id = 'display_settings';
399
+ $this->my_add_settings_section($section_id, 'Display Settings', 'h3');
400
+ $this->my_add_setting($section_id, 'reviews_per_page', 'Reviews shown per page', '{ "type" : "text", "class" : "w40px", "default" : "10" }');
401
+ $this->my_add_setting($section_id, 'support_us', 'Support us', '{ "hint" : "Please support the developer! If yes, a \"Powered by WP Customer Reviews\" link will display below reviews.", "type" : "select", "options" : '.$options_yesno.', "default" : "0" }');
402
+ }
403
+
404
+ // adding menu items to admin must be done in admin_menu which gets executed BEFORE admin_init
405
+ function real_admin_menu() {
406
+ add_menu_page('Reviews', 'Reviews', 'edit_others_posts', $this->prefix.'_view_reviews', '', $this->getpluginurl() . 'css/star.png', '50.92'); // try to resolve issues with other plugins
407
+ add_submenu_page($this->prefix.'_view_reviews', 'WP Customer Reviews - Settings', 'Plugin Settings', 'manage_options', $this->options_url_slug, array(&$this, 'admin_options'));
408
+ }
409
+
410
+ function plugin_settings_link($links) {
411
+ $url = get_admin_url().'admin.php?page='.$this->options_url_slug;
412
+ array_unshift($links, "<a href='$url'>Settings</a>");
413
+ return $links;
414
+ }
415
+
416
+ function admin_head() {
417
+ global $post;
418
+ if ($post != '' && $post->post_type == $this->prefix.'_review') {
419
+ remove_action('media_buttons', 'media_buttons'); // do not allow media uploads for reviews
420
+ }
421
+ }
422
+
423
+ function redirect($url, $cookie = array()) {
424
+ $headers_sent = headers_sent();
425
+
426
+ if ($headers_sent == true) {
427
+ // use JS redirect and add cookie before redirect
428
+ // we do not html comment script blocks here - to prevent any issues with other plugins adding content to newlines, etc
429
+ $out = "<html><head><title>Redirecting...</title></head><body><div style='clear:both;text-align:center;padding:10px;'>" .
430
+ "Processing... Please wait..." .
431
+ "<script type='text/javascript'>";
432
+ foreach ($cookie as $col => $val) {
433
+ $val = preg_replace("/\r?\n/", "\\n", addslashes($val));
434
+ $out .= "document.cookie=\"$col=$val\";";
435
+ }
436
+ $out .= "window.location='$url';";
437
+ $out .= "</script>";
438
+ $out .= "</div></body></html>";
439
+ echo $out;
440
+ } else {
441
+ foreach ($cookie as $col => $val) {
442
+ setcookie($col, $val); // add cookie via headers
443
+ }
444
+ if (ob_get_level() > 0) {
445
+ @ob_end_clean();
446
+ }
447
+ wp_redirect($url); // a real redirect
448
+ }
449
+
450
+ exit();
451
+ }
452
+
453
+ /* begin - admin notices */
454
+ function admin_notices() {
455
+ $url = $_SERVER['REQUEST_URI'] . (strstr($_SERVER['REQUEST_URI'], "?") === false ? "?" : "&");
456
+ $notices = array(
457
+ "1" => array(
458
+ "text" => "WP Customer Reviews | Updated to v3 | <a href='admin.php?page=wpcr3_options&tab=tools'>Missing / Duplicate Reviews?</a>",
459
+ "enabled" => (get_option("wpcr_options") !== false) // only show if upgraded from 2x to 3x
460
+ )
461
+ );
462
+
463
+ foreach ($notices as $noticeKey => $notice) {
464
+ $preNoticeKey = $this->prefix."_admin_notice_".$noticeKey;
465
+ if (!isset($this->options[$preNoticeKey]) && $notice["enabled"] === true) {
466
+ echo "<div class='updated'><p>{$notice["text"]}&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href='{$url}{$preNoticeKey}=dismiss'>Dismiss</a></p></div>";
467
+ }
468
+ }
469
+ }
470
+
471
+ function notice_ignore() {
472
+ /* If user clicks to dismiss the notice, add to plugin settings */
473
+ foreach($this->p as $key => $val) {
474
+ if (strpos($key, $this->prefix."_admin_notice_") !== false) {
475
+ if ($val === 'dismiss') {
476
+ $this->options[$key] = "dismiss";
477
+ update_option($this->options_name, $this->options);
478
+ }
479
+ }
480
+ }
481
+ }
482
+ /* end - admin notices */
483
+
484
+ function admin_post_updated_messages($messages) {
485
+ global $post;
486
+ if ($post == '') { return $messages; }
487
+ if ($post->post_type === $this->prefix."_review") {
488
+ // remove "view post" links when adding/editing review post type
489
+ foreach ($messages["post"] as $i => $v) {
490
+ $messages["post"][$i] = trim(preg_replace("/<a.+?href.+?>.+?<\/a>/is","",$v));
491
+ }
492
+ }
493
+ return $messages;
494
+ }
495
+
496
+ function selected_label_function_500($metaValue) {
497
+ // metaValue is postID
498
+ return get_the_title($metaValue);
499
+ }
500
+
501
+ function my_add_meta_box($post_type, $post) {
502
+ $my_post_type = $this->prefix.'_review';
503
+
504
+ if ($post_type === $my_post_type && count($this->meta_box_reviews) === 0) {
505
+ $this->meta_box_reviews = array(
506
+ 'id' => $this->prefix.'-meta-box-reviews',
507
+ 'title' => '<img src="'.$this->getpluginurl().'css/star.png" />&nbsp;Review Details',
508
+ 'context' => 'normal',
509
+ 'priority' => 'high',
510
+ 'fields' => array(
511
+ array(
512
+ 'name' => 'Reviewed Post / Page',
513
+ 'desc' => '',
514
+ 'id' => $this->prefix.'_review_post',
515
+ 'type' => 'select2',
516
+ 'options' => array(), // populated by ajax select2
517
+ 'typeOptions' => array(
518
+ // passed by name for php4/wp3 support, does not support anonymous functions
519
+ 'selected_label_function' => "selected_label_function_500",
520
+ 'select2' => array(
521
+ "ajax" => array(
522
+ "url" => admin_url('admin-ajax.php') . '?action=wpcr3_enabled_posts',
523
+ "dataType" => 'json',
524
+ "delay" => 250 // 250ms debounce
525
+ ),
526
+ "placeholder" => '-- Select Post --',
527
+ "allowClear" => true
528
+ )
529
+ )
530
+ ),
531
+ array(
532
+ 'name' => 'Reviewer Name',
533
+ 'desc' => '',
534
+ 'id' => $this->prefix.'_review_name',
535
+ 'type' => 'text'
536
+ ),
537
+ array(
538
+ 'name' => 'Email Address',
539
+ 'desc' => '',
540
+ 'id' => $this->prefix.'_review_email',
541
+ 'type' => 'text'
542
+ ),
543
+ array(
544
+ 'name' => 'Website',
545
+ 'desc' => '',
546
+ 'id' => $this->prefix.'_review_website',
547
+ 'type' => 'text'
548
+ ),
549
+ array(
550
+ 'name' => 'Review Title',
551
+ 'desc' => '',
552
+ 'id' => $this->prefix.'_review_title',
553
+ 'type' => 'text'
554
+ ),
555
+ array(
556
+ 'name' => 'Rating',
557
+ 'desc' => '',
558
+ 'id' => $this->prefix.'_review_rating',
559
+ 'type' => 'select',
560
+ 'options' => array('1' => '1 star','2' => '2 stars','3' => '3 stars','4' => '4 stars','5' => '5 stars')
561
+ ),
562
+ array(
563
+ 'name' => 'Admin Response to Review',
564
+ 'desc' => '',
565
+ 'id' => $this->prefix.'_review_admin_response',
566
+ 'type' => 'textarea'
567
+ )
568
+ )
569
+ );
570
+
571
+ if (isset($this->options['custom_fields'])) {
572
+ $i = 0;
573
+ foreach ($this->options['custom_fields'] as $name => $fieldArr) {
574
+ $i++;
575
+ if ($fieldArr['ask'] == 1 || $fieldArr['show'] == 1) {
576
+ $this->meta_box_reviews['fields'][] = array(
577
+ 'name' => $fieldArr['label'],
578
+ 'desc' => 'Custom Field #'.$i,
579
+ 'id' => $this->prefix.'_'.$name,
580
+ 'type' => 'text'
581
+ );
582
+ }
583
+ }
584
+ }
585
+
586
+ // add for reviews
587
+ add_meta_box( $this->meta_box_reviews['id'], $this->meta_box_reviews['title'], array(&$this, 'show_meta_box_fields'), $this->prefix.'_review', $this->meta_box_reviews['context'], $this->meta_box_reviews['priority'], array('type' => 'meta_box_reviews') );
588
+ } else if (count($this->meta_box_posts) === 0) {
589
+ $this->meta_box_posts = array(
590
+ 'id' => $this->prefix.'-meta-box',
591
+ 'title' => '<img src="'.$this->getpluginurl().'css/star.png" />&nbsp;WP Customer Reviews',
592
+ 'context' => 'normal',
593
+ 'priority' => 'high',
594
+ 'fields' => array(
595
+ array(
596
+ 'name' => '<span style="font-weight:bold;">Enable WP Customer Reviews</span> for this page',
597
+ 'desc' => 'Reviews will be displayed below your page content by default. To insert reviews in the middle of your post, add [WPCR_INSERT] in the contents where you would like the reviews to be displayed.',
598
+ 'id' => $this->prefix.'_enable',
599
+ 'type' => 'checkbox'
600
+ ),
601
+ array(
602
+ 'name' => 'Hide review form',
603
+ 'desc' => 'If this option is checked, users will NOT be able to submit reviews.',
604
+ 'id' => $this->prefix.'_hideform',
605
+ 'type' => 'checkbox'
606
+ ),
607
+ array(
608
+ 'name' => 'Review Format',
609
+ 'desc' => 'Will visitors be reviewing a business or a product?',
610
+ 'id' => $this->prefix.'_format',
611
+ 'type' => 'select',
612
+ 'options' => array(
613
+ 'business' => 'Business',
614
+ 'product' => 'Product'
615
+ )
616
+ ),
617
+
618
+ array(
619
+ 'name' => 'Business Name',
620
+ 'desc' => '',
621
+ 'id' => $this->prefix.'_business_name',
622
+ 'type' => 'text'
623
+ ),
624
+ array(
625
+ 'name' => 'Street Address 1',
626
+ 'desc' => '',
627
+ 'id' => $this->prefix.'_business_street1',
628
+ 'type' => 'text'
629
+ ),
630
+ array(
631
+ 'name' => 'Street Address 2',
632
+ 'desc' => '(optional) Leave blank if this does not apply.',
633
+ 'id' => $this->prefix.'_business_street2',
634
+ 'type' => 'text'
635
+ ),
636
+ array(
637
+ 'name' => 'City / Locality',
638
+ 'desc' => '',
639
+ 'id' => $this->prefix.'_business_city',
640
+ 'type' => 'text'
641
+ ),
642
+ array(
643
+ 'name' => 'State / Region',
644
+ 'desc' => 'For USA, use 2 letters such as "CA"',
645
+ 'id' => $this->prefix.'_business_state',
646
+ 'type' => 'text'
647
+ ),
648
+ array(
649
+ 'name' => 'Postal Code',
650
+ 'desc' => '',
651
+ 'id' => $this->prefix.'_business_zip',
652
+ 'type' => 'text'
653
+ ),
654
+ array(
655
+ 'name' => 'Country',
656
+ 'desc' => 'Use the 2-letter or 3-letter country code such as "USA"',
657
+ 'id' => $this->prefix.'_business_country',
658
+ 'type' => 'text'
659
+ ),
660
+ array(
661
+ 'name' => 'Telephone',
662
+ 'desc' => 'Example: 520-555-5555 or (520) 555-5555',
663
+ 'id' => $this->prefix.'_business_phone',
664
+ 'type' => 'text'
665
+ ),
666
+ array(
667
+ 'name' => 'Website URL',
668
+ 'desc' => 'Example: http://www.gowebsolutions.com/',
669
+ 'id' => $this->prefix.'_business_url',
670
+ 'type' => 'text'
671
+ ),
672
+
673
+ array(
674
+ 'name' => 'Product Name',
675
+ 'desc' => '',
676
+ 'id' => $this->prefix.'_product_name',
677
+ 'type' => 'text'
678
+ ),
679
+ array(
680
+ 'name' => 'Manufacturer/Brand of Product',
681
+ 'desc' => '',
682
+ 'id' => $this->prefix.'_product_brand',
683
+ 'type' => 'text'
684
+ ),
685
+ array(
686
+ 'name' => 'Product ID',
687
+ 'desc' => 'ONE of the following formats: <b>asin:1234567890</b>, <b>isbn:1234567890</b>, <b>upc:1234567890123</b> , <b>sku:ABC123</b>, <b>mpn:ABC123</b>',
688
+ 'id' => $this->prefix.'_product_id',
689
+ 'type' => 'text'
690
+ )
691
+ )
692
+ );
693
+
694
+ $args = array('public' => true);
695
+ $post_types = get_post_types($args);
696
+ if (is_array($post_types) === false) {
697
+ $post_types = array();
698
+ }
699
+
700
+ unset($post_types['attachment']);
701
+ unset($post_types[$my_post_type]);
702
+
703
+ foreach ($post_types as $post_type) {
704
+ add_meta_box( $this->meta_box_posts['id'], $this->meta_box_posts['title'], array(&$this, 'show_meta_box_fields'), $post_type, $this->meta_box_posts['context'], $this->meta_box_posts['priority'], array('type' => 'meta_box_posts') );
705
+ }
706
+ }
707
+ }
708
+
709
+ function get_all_posts_pages($only_plugin_enabled_posts, $keyword, $skip, $limit) {
710
+ global $wpdb;
711
+
712
+ // using a direct query here because we only want specific fields, and this needs to be performant
713
+
714
+ $query = "
715
+ SELECT p.ID,p.post_title
716
+ FROM {$wpdb->posts} p
717
+ LEFT JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = '{$this->prefix}_enable' AND pm.meta_value = '1'
718
+ WHERE p.post_type NOT IN ('attachment')
719
+ AND p.post_status IN ('publish','pending','draft','future','private','trash')";
720
+
721
+ if ($only_plugin_enabled_posts) {
722
+ $query .= "
723
+ AND pm.meta_value = '1'";
724
+ }
725
+
726
+ if ($keyword !== "") {
727
+ $keyword = '%' . esc_sql($keyword) . '%';
728
+
729
+ $query .= "
730
+ AND p.post_title LIKE '{$keyword}'";
731
+ }
732
+
733
+ $query .= "
734
+ ORDER BY p.post_title ASC";
735
+
736
+ if ($skip !== false && $limit !== false) {
737
+ $skip = intval($skip);
738
+ $limit = intval($limit);
739
+
740
+ $query .= "
741
+ LIMIT $skip, $limit";
742
+ }
743
+
744
+ return $wpdb->get_results($query, OBJECT);
745
+ }
746
+
747
+ // update = false for wp 3.6 support
748
+ function admin_save_post($post_id, $post, $update = false) {
749
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // do nothing special if autosaving
750
+ if (defined('DOING_AJAX') && DOING_AJAX) { return $post_id; } // do nothing special if ajax
751
+ if (defined('DOING_CRON') && DOING_CRON) { return $post_id; } // do nothing special if cron
752
+ if (!current_user_can('edit_post', $post_id)) { return $post_id; } // do nothing special if user does not have permissions
753
+
754
+ $params = array('_wpnonce', 'bulk_edit');
755
+ $this->param($params);
756
+
757
+ if ($this->p->_wpnonce !== '' && $this->p->bulk_edit === '') {
758
+ // we need to call my_add_meta_box here, since it does not run on every page for performance reasons
759
+ $this->my_add_meta_box($post->post_type, $post);
760
+
761
+ // update meta if changed, delete it if not set or blank
762
+ $types = array('meta_box_posts','meta_box_reviews'); // $this->meta_box_posts, $this->meta_box_reviews
763
+ foreach ($types as $type) {
764
+ $my_type = $this->$type; // $this->meta_box_posts, $this->meta_box_reviews
765
+
766
+ // if meta boxes have not been added by our plugin for the current post_type, continue
767
+ if (count($my_type) === 0) { continue; }
768
+
769
+ foreach ($my_type['fields'] as $field) {
770
+ $old = get_post_meta($post_id, $field['id'], true);
771
+ if (isset($this->p->{$field['id']})) {
772
+ $new = $this->p->{$field['id']};
773
+ if ($new && $new != $old) {
774
+ update_post_meta($post_id, $field['id'], $new);
775
+ } elseif ($new == '' && $old) {
776
+ delete_post_meta($post_id, $field['id'], $old);
777
+ }
778
+ } else {
779
+ delete_post_meta($post_id, $field['id'], $old);
780
+ }
781
+ }
782
+ }
783
+ }
784
+
785
+ return $post_id;
786
+ }
787
+
788
+ /* start custom columns filters */
789
+ function admin_custom_review_column($column, $post_id) {
790
+ switch ($column) {
791
+ case $this->prefix.'_review_post':
792
+ $reviewed_post_id = get_post_meta($post_id, $this->prefix.'_review_post' ,true);
793
+ if ($reviewed_post_id !== "") {
794
+ $reviewed_post = get_post($reviewed_post_id);
795
+ $permalink = get_permalink($reviewed_post_id);
796
+ $not_published = ($reviewed_post->post_status !== "publish") ? "(Not Published)" : "";
797
+ echo "<a target='_blank' href='{$permalink}'>{$reviewed_post->post_title}</a> {$not_published}";
798
+ } else {
799
+ echo "Not Assigned";
800
+ }
801
+ break;
802
+ case $this->prefix.'_review_rating':
803
+ $stars = get_post_meta($post_id, $this->prefix.'_review_rating' ,true);
804
+ echo "{$stars} ";
805
+ echo (intval($stars) === 1) ? "star" : "stars";
806
+ break;
807
+ }
808
+ }
809
+
810
+ function admin_filter_custom_review_columns($columns) {
811
+ $columns[$this->prefix.'_review_post'] = 'Reviewed Post / Page';
812
+ $columns[$this->prefix.'_review_rating'] = 'Rating';
813
+ return $columns;
814
+ }
815
+
816
+ function review_sortable_columns($columns) {
817
+ //$columns[$this->prefix.'_review_post'] = $this->prefix.'_review_post';
818
+ $columns[$this->prefix.'_review_rating'] = $this->prefix.'_review_rating';
819
+ return $columns;
820
+ }
821
+
822
+ function review_sortable_columns_orderby($request) {
823
+ if ($request['post_type'] !== $this->prefix.'_review') {
824
+ return $request;
825
+ }
826
+
827
+ if (isset($request['orderby'])) {
828
+ $name = $this->prefix.'_review_rating';
829
+ if ($request['orderby'] === $name) {
830
+ $request = array_merge($request, array('meta_key' => $name, 'orderby' => 'meta_value_num'));
831
+ }
832
+ }
833
+
834
+ return $request;
835
+ }
836
+
837
+ // used for filtering on "All Reviews" page - step 1
838
+ function load_custom_filter() {
839
+ $screen = get_current_screen();
840
+ if ($screen->post_type !== $this->prefix.'_review') { return; }
841
+
842
+ $filterName = $name = $this->prefix."_reviews_post_filter";
843
+ if (!isset($_GET[$filterName]) || intval($_GET[$filterName]) === 0) { return; }
844
+
845
+ add_filter('posts_where' ,array(&$this, 'load_custom_filter_2'));
846
+ }
847
+
848
+ // used for filtering on "All Reviews" page - step 2
849
+ function load_custom_filter_2($where) {
850
+ global $wpdb;
851
+ $filterName = $name = $this->prefix."_reviews_post_filter";
852
+ $filterVal = intval($_GET[$filterName]);
853
+ $where .= " AND ID IN (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='{$this->prefix}_review_post' AND meta_value = {$filterVal})";
854
+ return $where;
855
+ }
856
+
857
+ function ajax_enabled_posts() {
858
+ header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
859
+ header("Cache-Control: post-check=0, pre-check=0", false);
860
+ header("Pragma: no-cache");
861
+ header('Content-type: application/json');
862
+
863
+ $this->param(array('term', 'page'));
864
+
865
+ $page = $this->p->page;
866
+ if ($page === "") { $page = 1; }
867
+ $page = intval($page);
868
+ $limit = 100;
869
+ $skip = ($page * $limit) - $limit;
870
+
871
+ $rtn = new stdClass();
872
+ $rtn->results = array();
873
+ $rtn->pagination = new stdClass();
874
+
875
+ $posts = $this->get_all_posts_pages(true, $this->p->term, $skip, $limit);
876
+ $rtn->pagination->more = (count($posts) === $limit);
877
+
878
+ foreach ($posts as $post) {
879
+ $tmp = new stdClass();
880
+ $tmp->id = $post->ID;
881
+ $tmp->text = $post->post_title;
882
+ $rtn->results[] = $tmp;
883
+ }
884
+ unset($posts);
885
+
886
+ die(json_encode($rtn));
887
+ }
888
+
889
+ function review_filter_list() {
890
+ $screen = get_current_screen();
891
+ if ($screen->post_type !== $this->prefix.'_review') { return; }
892
+
893
+ $filterName = "wpcr3_reviews_post_filter";
894
+
895
+ $this->param(array($filterName));
896
+ $getPostID = ($this->p->wpcr3_reviews_post_filter !== "") ? intval($this->p->wpcr3_reviews_post_filter) : "";
897
+ ?>
898
+ <select style="width:450px;" name="<?php echo $filterName; ?>" id="<?php echo $filterName;?>">
899
+ <option></option>
900
+ <?php if ($getPostID !== "") : ?>
901
+ <option selected="selected" value="<?php echo $getPostID; ?>"><?php echo get_the_title($getPostID); ?></option>
902
+ <?php endif; ?>
903
+ </select>
904
+ <script>
905
+ jQuery('#<?php echo $filterName; ?>').wpcr3_select({
906
+ ajax : {
907
+ url : '<?php echo admin_url('admin-ajax.php'); ?>?action=wpcr3_enabled_posts',
908
+ dataType : 'json',
909
+ delay : 250 // 250ms debounce
910
+ },
911
+ placeholder : 'All Posts / Pages',
912
+ allowClear : true
913
+ });
914
+ </script>
915
+ <?php
916
+ }
917
+ /* end custom columns filters */
918
+
919
+ function show_meta_box_fields($post, $args) {
920
+ $my_args = $args['args'];
921
+ $my_type = $this->{$my_args['type']}; // $this->meta_box_posts, $this->meta_box_reviews
922
+
923
+ echo '<table class="form-table">';
924
+
925
+ foreach ($my_type['fields'] as $field) {
926
+ $params = array('default');
927
+ $this->param($params, $field);
928
+
929
+ // get current post meta data
930
+ $meta = get_post_meta($post->ID, $field['id'], true);
931
+
932
+ echo '<tr>',
933
+ '<th style="width:30%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
934
+ '<td>';
935
+ switch ($field['type']) {
936
+ case 'text':
937
+ echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['default'], '" size="30" style="width:97%" />';
938
+ break;
939
+ case 'textarea':
940
+ echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['default'], '</textarea>';
941
+ break;
942
+ case 'select':
943
+ case 'select2':
944
+ echo '<select style="width:97%;" name="', $field['id'], '" id="', $field['id'], '">';
945
+
946
+ if ($field['type'] === 'select2') {
947
+ if (isset($field['typeOptions']['select2']['placeholder'])) {
948
+ echo '<option></option>';
949
+ }
950
+
951
+ if (isset($field['typeOptions']['selected_label_function'])) {
952
+ if ($meta) {
953
+ $selected_label_function = $field['typeOptions']['selected_label_function'];
954
+ // meta is postID
955
+ $post_title = call_user_func(array($this,$selected_label_function), $meta);
956
+ $field['options'] = array($meta => $post_title);
957
+ }
958
+ }
959
+ }
960
+
961
+ foreach ($field['options'] as $value => $label) {
962
+ echo '<option value="'.$value.'" ', $meta == $value ? ' selected="selected"' : '', '>', $label, '</option>';
963
+ }
964
+ echo '</select>';
965
+
966
+ if ($field['type'] === 'select2') {
967
+ ?>
968
+ <script>
969
+ jQuery('#<?php echo $field['id']; ?>').wpcr3_select(<?php echo json_encode($field['typeOptions']['select2']); ?>);
970
+ </script>
971
+ <?php
972
+ }
973
+
974
+ break;
975
+ case 'checkbox':
976
+ echo '<input value="1" type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
977
+ break;
978
+ }
979
+ echo '<div style="padding-top:5px;"><small>'.$field['desc'].'</small></div>';
980
+ echo '<td></tr>';
981
+ }
982
+
983
+ echo '</table>';
984
+ }
985
+
986
+ /* some admin styles can override normal styles for inplace edits */
987
+ function enqueue_admin_stuff() {
988
+ global $pagenow;
989
+
990
+ $pluginurl = $this->getpluginurl();
991
+
992
+ $params = array('page', 'post_type');
993
+ $this->param($params);
994
+
995
+ if ($pagenow === 'post.php' || $pagenow === 'post-new.php' || $this->p->post_type === "wpcr3_review" || $this->p->page == $this->options_url_slug) {
996
+ wp_register_script('wp-customer-reviews-admin', $pluginurl.'js/wp-customer-reviews-admin.js', array('jquery'), $this->plugin_version);
997
+ wp_enqueue_script('wp-customer-reviews-admin');
998
+
999
+ wp_register_style('wp-customer-reviews-admin', $pluginurl.'css/wp-customer-reviews-admin.css', array(), $this->plugin_version);
1000
+ wp_enqueue_style('wp-customer-reviews-admin');
1001
+ }
1002
+ }
1003
+
1004
+ /* v4 uuid */
1005
+ function gen_uuid() {
1006
+ return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
1007
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
1008
+ mt_rand( 0, 0xffff ),
1009
+ mt_rand( 0, 0x0fff ) | 0x4000,
1010
+ mt_rand( 0, 0x3fff ) | 0x8000,
1011
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
1012
+ );
1013
+ }
1014
+
1015
+ // this is used for notification of new releases and will not be shared with any third party.
1016
+ function notify_activate($act_flag) {
1017
+ // $act flag [ 1 = activation (includes reactivation/upgrade) , 2 = deactivation ]
1018
+
1019
+ if (!isset($this->options['act_uniq']) || $this->options['act_uniq'] == '') {
1020
+ $this->options['act_uniq'] = $this->gen_uuid();
1021
+ update_option($this->options_name, $this->options);
1022
+ }
1023
+
1024
+ if (function_exists('fsockopen') === false && function_exists('pfsockopen') === false && function_exists('stream_socket_client') === false) {
1025
+ return;
1026
+ }
1027
+
1028
+ /* TO DISABLE THIS FUNCTION, UNCOMMENT THE FOLLOWING LINE */
1029
+ /* return; */
1030
+
1031
+ global $wp_version;
1032
+ $request = 'plugin='.$this->prefix.'&doact='.$act_flag.'&email='.urlencode(stripslashes($this->options['act_email'])).'&version='.$this->plugin_version.'&support='.$this->options['support_us'].'&uuid='.$this->options['act_uniq'];
1033
+ $host = "www.gowebsolutions.com"; $port = 80; $wpurl = get_bloginfo('wpurl');
1034
+
1035
+ $http_request = "POST /plugin-activation/activate.php HTTP/1.0\r\n";
1036
+ $http_request .= "Host: www.gowebsolutions.com\r\n";
1037
+ $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
1038
+ $http_request .= "Content-Length: ".strlen($request)."\r\n";
1039
+ $http_request .= "Referer: $wpurl\r\n";
1040
+ $http_request .= "User-Agent: WordPress/$wp_version\r\n\r\n";
1041
+ $http_request .= $request;
1042
+
1043
+ $response = '';
1044
+ $ret = false;
1045
+
1046
+ if (function_exists('fsockopen')) {
1047
+ $fs = @fsockopen($host, $port, $errno, $errstr, 10);
1048
+ } else if (function_exists('pfsockopen')) {
1049
+ $fs = @pfsockopen($host, $port, $errno, $errstr, 10);
1050
+ } else if (function_exists('stream_socket_client')) {
1051
+ $fs = stream_socket_client("tcp://{$host}:{$port}", $errno, $errstr, 10);
1052
+ }
1053
+
1054
+ if ($fs !== false) {
1055
+ stream_set_timeout($fs, 10);
1056
+ fwrite($fs, $http_request);
1057
+ while (!feof($fs)) {
1058
+ $response .= fgets($fs, 1160);
1059
+ }
1060
+ fclose($fs);
1061
+ $response = explode("\r\n\r\n", $response, 2);
1062
+ }
1063
+
1064
+ // var_dump($response);exit();
1065
+ }
1066
+
1067
+ function update_options($id) {
1068
+ $this->security();
1069
+ $this->check_admin_options_nonce();
1070
+
1071
+ $default_options = $this->options;
1072
+
1073
+ foreach ($this->settings_sections[$id] as $settingArr) {
1074
+ $name = $settingArr->name;
1075
+ $options = $settingArr->options;
1076
+ $postName = $this->prefix."_option_".$name;
1077
+ $postVal = $this->p->$postName;
1078
+
1079
+ if ($options->type === "text") {
1080
+ $default_options[$name] = $postVal;
1081
+ } else if ($options->type === "select") {
1082
+ $default_options[$name] = $postVal;
1083
+ } else if ($options->type === "multi_input_checkbox") {
1084
+ $default_options[$name] = array();
1085
+ foreach ($options->options as $valObj) {
1086
+ $default_options[$name][$valObj->value] = array();
1087
+ if (isset($postVal[$valObj->value]['label'])) {
1088
+ $default_options[$name][$valObj->value]['label'] = $postVal[$valObj->value]['label'];
1089
+ }
1090
+ foreach ($valObj->checkboxes as $cbObj) {
1091
+ $postVal_cb = isset($postVal[$valObj->value][$cbObj->value]) ? "1" : "0";
1092
+ $default_options[$name][$valObj->value][$cbObj->value] = $postVal_cb;
1093
+ }
1094
+ }
1095
+ } else if ($options->type === "array") {
1096
+ $default_options[$name] = array();
1097
+ foreach ($options->options as $key => $val) {
1098
+ $default_options[$name][$key] = $postVal[$name][$key];
1099
+ }
1100
+ }
1101
+ }
1102
+
1103
+ // simple validation
1104
+ if (intval($default_options['reviews_per_page']) < 1) { $default_options['reviews_per_page'] = 10; }
1105
+
1106
+ $this->options = $default_options;
1107
+ update_option($this->options_name, $this->options);
1108
+
1109
+ $this->post_update_options();
1110
+
1111
+ add_settings_error($this->prefix.'_updateoptions', $this->prefix.'_updateoptions', 'Your settings have been saved.', 'updated');
1112
+ settings_errors($this->prefix.'_updateoptions');
1113
+ }
1114
+
1115
+ function security() {
1116
+ if (!current_user_can('manage_options')) {
1117
+ wp_die( __('You do not have sufficient permissions to access this page.') );
1118
+ }
1119
+ }
1120
+
1121
+ function tab_about() {
1122
+ ?>
1123
+ <div class="metabox-holder">
1124
+ <div class="postbox">
1125
+ <h3>About WP Customer Reviews</h3>
1126
+
1127
+ <div class="inside">
1128
+ <p>
1129
+ <?php if ($this->pro) : ?>
1130
+ Version: <strong><?php echo $this->plugin_version; ?> PRO</strong>
1131
+ <?php else: ?>
1132
+ Version: <strong><?php echo $this->plugin_version; ?> Lite <!--(<a class="boldBlue" target="_blank" href="<?php echo $this->prolink; ?>?from=about_upgrade">Upgrade to Pro</a>)--> </strong>
1133
+ <?php endif; ?>
1134
+ </p>
1135
+ <p>
1136
+ WP Customer Reviews allows your visitors to leave business and product reviews. Reviews are Microformat enabled and can help search engines index these reviews.
1137
+ </p>
1138
+ </div>
1139
+ <div class="inside bgblue">
1140
+ Plugin Homepage: <a target="_blank" href="<?php echo $this->url; ?>?from=about"><?php echo $this->url; ?></a><br /><br />
1141
+ Bug Report / Feature Request: <a target="_blank" href="mailto:wpcr@wpcr.freshdesk.com">wpcr@wpcr.freshdesk.com</a><br /><br />
1142
+ Community Support Forum: <a target="_blank" href="<?php echo $this->support_link; ?>"><?php echo $this->support_link; ?></a><br /><br />
1143
+ <div style="color:#BE5409;font-weight:bold;">
1144
+ If you like this plugin, please <a target="_blank" href="https://wordpress.org/support/plugin/wp-customer-reviews/reviews/">login and rate it 5 stars here</a>
1145
+ <?php if (!$this->pro) : ?>
1146
+ <!-- and consider purchasing the Pro version. -->
1147
+ <?php endif; ?>
1148
+ </div>
1149
+ </div>
1150
+ </div>
1151
+
1152
+ <div class="postbox">
1153
+ <h3>Support Us</h3>
1154
+ <div class="inside">
1155
+ <p style="color:#060;">
1156
+ If you would like to be notified of any major updates, please enter your email
1157
+ address below. We do not share your information with any third party.
1158
+ </p>
1159
+ <label for="email">Email Address: </label><input type="text" size="32" id="act_email" name="act_email" value="<?php echo $this->options["act_email"]; ?>" /> (optional)
1160
+ <p>
1161
+ Please support the developer! Can we display a small "Powered by WP Customer Reviews" link below reviews?
1162
+ </p>
1163
+ <label><input type="radio" name="activate" value="Yes" <?php if ($this->options["support_us"] == 1) { echo 'checked="checked"'; } ?> /> Yes</label>
1164
+ &nbsp;&nbsp;&nbsp;&nbsp;
1165
+ <label><input type="radio" name="activate" value="No" <?php if ($this->options["support_us"] == 0) { echo 'checked="checked"'; } ?> /> No</label>
1166
+ <br /><br />
1167
+ <p>
1168
+ <input type="submit" class="button-primary" value="Save Changes" name="support_submit" />
1169
+ </p>
1170
+ </div>
1171
+ </div>
1172
+ </div>
1173
+ <?php
1174
+ }
1175
+
1176
+ function tab_how_to_use() {
1177
+ ?>
1178
+ <style>
1179
+ .how-to-use .inside span { color:#00c;font-weight:bold; }
1180
+ .boldRed { color:#d00;font-weight:bold; }
1181
+ </style>
1182
+ <div class="metabox-holder how-to-use">
1183
+ <div class="postbox">
1184
+ <h3>How to use</h3>
1185
+ <div class="inside">
1186
+ <p class="boldBlue">
1187
+ When editing any post or page, scroll down to the setting block for WP Customer Reviews and enable it.<br />
1188
+ If you do not see this section, click on "Screen Options" (top-right) when editing a post and turn it on.
1189
+ </p>
1190
+ </div>
1191
+ <h3>Shortcodes ( use inside of the WordPress page editor )</h3>
1192
+ <div class="inside">
1193
+ <p>
1194
+ The following shortcodes can be used in the content of any page.
1195
+ </p>
1196
+ <p>
1197
+ [WPCR_SHOW
1198
+ POSTID="<span>ALL</span>"
1199
+ NUM="<span>5</span>"
1200
+ PAGINATE="<span>1</span>"
1201
+ PERPAGE="<span>5</span>"
1202
+ SHOWFORM="<span>1</span>"
1203
+ HIDEREVIEWS="<span>0</span>"
1204
+ HIDERESPONSE="<span>0</span>"
1205
+ SNIPPET="<span></span>"
1206
+ MORE="<span></span>"
1207
+ HIDECUSTOM="<span>0</span>"
1208
+ ]
1209
+ <br /><small>is available to show the latest reviews. Explanation below: <br />
1210
+ POSTID="<span>ALL</span>" to show recent reviews from ALL posts/pages or POSTID="123" to show recent reviews from post/page ID #123<br />
1211
+ NUM="<span>5</span>" will show a maximum of 5 reviews.<br />
1212
+ PAGINATE="<span>0</span>" will disable pagination of reviews.<br />
1213
+ PERPAGE="<span>10</span>" will show 10 reviews at a time.<br />
1214
+ SHOWFORM="<span>1</span>" will show the form to add a new review. This only works if POSTID is not set to "ALL".<br />
1215
+ HIDEREVIEWS="<span>1</span>" will hide the review output. Can be used to show the form only.<br />
1216
+ HIDERESPONSE="<span>1</span>" will hide the admin response to all reviews.<br />
1217
+ SNIPPET="<span>140</span>" will only show the first 140 characters of a review.<br />
1218
+ MORE="<span>view more</span>" will show "... view more" with a link to the review. Only displayed when the review has been trimmed using SNIPPET.<br />
1219
+ HIDECUSTOM="<span>1</span>" will hide all custom fields in the shortcode output.<br />
1220
+ </small>
1221
+ </p>
1222
+ </div>
1223
+ <h3>PHP Functions ( use in your theme/template files )</h3>
1224
+ <div class="inside">
1225
+ <p>
1226
+ To create a more advanced implementation, you can use any shortcode in your
1227
+ theme/template files. Any developer familiar with customizing WordPress themes/templates
1228
+ can assist.
1229
+ </p>
1230
+ <p>
1231
+ Example: &lt;?php echo do_shortcode('[WPCR_SHOW POSTID="ALL" NUM="3"]'); ?&gt;
1232
+ </p>
1233
+ </div>
1234
+ </div>
1235
+ </div>
1236
+ <?php
1237
+ }
1238
+
1239
+ function tab_form_settings() {
1240
+ $this->my_output_settings_section('form_settings');
1241
+ }
1242
+
1243
+ function tab_display_settings() {
1244
+ echo '<br /><strong>Tip: You can completely customize the display of the review form and reviews on the Customize Templates / CSS tab.</strong>';
1245
+ $this->my_output_settings_section('display_settings');
1246
+ }
1247
+
1248
+ function tab_templates() {
1249
+ echo '<br /><strong>This feature is available in the Pro version which will be announced soon.</strong>';
1250
+ }
1251
+
1252
+ function tab_tools() {
1253
+ $params = array("wpcr3_debug_code");
1254
+ $this->param($params);
1255
+
1256
+ ?>
1257
+ <div style="color:#c00;">
1258
+ <br />
1259
+ You should ALWAYS make a backup of your files and database before performing an action.<br />
1260
+ Using any of these codes is at your own risk and we cannot be held liable for unintended results or lost data.<br />
1261
+ </div>
1262
+
1263
+ <?php
1264
+ if ($this->p->wpcr3_debug_code !== "") {
1265
+ $this->check_admin_options_nonce();
1266
+
1267
+ $code = sanitize_text_field(str_replace(".", "", $this->p->wpcr3_debug_code));
1268
+ $file = $this->getplugindir().'include/admin/tools/'.$code.'.php';
1269
+
1270
+ if (file_exists($file)) {
1271
+ echo "<br />Running: <strong>{$code}</strong><br /><br />";
1272
+ include($file);
1273
+ echo "<br /><strong>{$code} DONE!</strong><br />";
1274
+ } else {
1275
+ echo "<br /><strong>{$code} is not valid</strong><br />";
1276
+ }
1277
+
1278
+ echo "<hr />";
1279
+ }
1280
+ ?>
1281
+
1282
+ <br />
1283
+ If you are having issues, we have provided fixes for some common scenarios, listed below.<br />
1284
+ <br />
1285
+ <table class="wp-list-table widefat fixed striped posts">
1286
+ <thead>
1287
+ <tr><th>Problem</th><th>Solution</th></tr>
1288
+ </thead>
1289
+ <tbody>
1290
+ <tr>
1291
+ <td>I upgraded from an earlier version and all/some of my reviews are missing!</td>
1292
+ <td>The 2x -> 3x migration script did not work properly. Enter this code below: <strong>reimport-2x</strong></td>
1293
+ </tr>
1294
+ <tr>
1295
+ <td>I have a lot of duplicate reviews that appeared after I upgraded!</td>
1296
+ <td>Enter this code below: <strong>remove-duplicates</strong></td>
1297
+ </tr>
1298
+ <tr>
1299
+ <td>For some reason, I need to permanently delete ALL of my reviews.</td>
1300
+ <td>Enter this code below: <strong>delete-all-reviews</strong></td>
1301
+ </tr>
1302
+ </tbody>
1303
+ </table>
1304
+ <br />
1305
+ If you have been given a code by support, enter it here.<br />
1306
+ <br />
1307
+ Support Code: <input name="wpcr3_debug_code" type="text" value="" />&nbsp;&nbsp;
1308
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="Submit" />
1309
+ <?php
1310
+ }
1311
+
1312
+ function admin_options() {
1313
+ $this->security();
1314
+
1315
+ $params = array('activate','act_email','clearopts','support_submit');
1316
+ $this->param($params);
1317
+
1318
+ if ($this->p->clearopts == 1 || $this->p->support_submit !== '') {
1319
+ $this->check_admin_options_nonce();
1320
+ }
1321
+
1322
+ // begin: clear options for debugging, reset to defaults
1323
+ if ($this->p->clearopts == 1) {
1324
+ // need to use &clearopts=1&_wpnonce=<nonce from "tab" form on page being viewed>
1325
+
1326
+ delete_option($this->options_name);
1327
+ $this->redirect("admin.php?page=".$this->options_url_slug);
1328
+ }
1329
+ // end: clear options for debugging, reset to defaults
1330
+
1331
+ // begin: activation
1332
+ if ($this->p->support_submit !== '') {
1333
+ $this->options['support_us'] = ($this->p->activate === 'Yes') ? 1 : 0;
1334
+ $this->options['act_email'] = $this->p->act_email;
1335
+ update_option($this->options_name, $this->options);
1336
+ $this->notify_activate(1);
1337
+ add_settings_error($this->prefix.'_activation', $this->prefix.'_activation', 'Thank you! You may now configure the plugin using the tabs below.', 'updated');
1338
+ settings_errors($this->prefix.'_activation');
1339
+ }
1340
+ // end: activation
1341
+
1342
+ $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'about';
1343
+ $func_name = 'tab_'.$active_tab;
1344
+ $slug = '?page='.$this->options_url_slug;
1345
+ ?>
1346
+ <style>
1347
+ .<?php echo $this->prefix; ?>_myplugin_options .metabox-holder .postbox {
1348
+ width:auto;
1349
+ }
1350
+ .<?php echo $this->prefix; ?>_myplugin_options .metabox-holder .postbox h3 {
1351
+ cursor:default;
1352
+ }
1353
+ .<?php echo $this->prefix; ?>_myplugin_options .metabox-holder .postbox .inside {
1354
+ margin:0;
1355
+ padding:10px;
1356
+ }
1357
+ .<?php echo $this->prefix; ?>_myplugin_options .metabox-holder .postbox .inside.bgblue {
1358
+ background:#eaf2fa;
1359
+ }
1360
+ .<?php echo $this->prefix; ?>_myplugin_options .metabox-holder .postbox .inside > p:first-child {
1361
+ margin-top:0;
1362
+ }
1363
+ </style>
1364
+
1365
+ <div class="wrap <?php echo $this->prefix; ?>_myplugin_options">
1366
+ <?php if ($this->pro) : ?>
1367
+ <h2>WP Customer Reviews PRO - Settings</h2>
1368
+ <?php else : ?>
1369
+ <h2>WP Customer Reviews Lite - Settings <!--<div class="need_pro"><a class="boldBlue" target="_blank" href="<?php echo $this->prolink; ?>?from=h2_upgrade">Upgrade to Pro</a></div>--> </h2>
1370
+ <?php endif; ?>
1371
+
1372
+ <h2 class="nav-tab-wrapper">
1373
+ <a href="<?php echo $slug;?>&tab=about" class="nav-tab <?php echo $active_tab == 'about' ? 'nav-tab-active' : ''; ?>">About</a>
1374
+ <a href="<?php echo $slug;?>&tab=how_to_use" class="nav-tab <?php echo $active_tab == 'how_to_use' ? 'nav-tab-active' : ''; ?>">How to use</a>
1375
+ <a href="<?php echo $slug;?>&tab=form_settings" class="nav-tab <?php echo $active_tab == 'form_settings' ? 'nav-tab-active' : ''; ?>">Review Form Settings</a>
1376
+ <a href="<?php echo $slug;?>&tab=display_settings" class="nav-tab <?php echo $active_tab == 'display_settings' ? 'nav-tab-active' : ''; ?>">Display Settings</a>
1377
+ <a href="<?php echo $slug;?>&tab=templates" class="nav-tab <?php echo $active_tab == 'templates' ? 'nav-tab-active' : ''; ?>">Customize Templates / CSS</a>
1378
+ <a href="<?php echo $slug;?>&tab=tools" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>">Tools</a>
1379
+ </h2>
1380
+
1381
+ <form method="POST" action="">
1382
+ <?php
1383
+ wp_nonce_field("wpcr3_admin_options");
1384
+
1385
+ if (method_exists($this, $func_name)) {
1386
+ $this->$func_name();
1387
+ }
1388
+ ?>
1389
+ </form>
1390
+
1391
+ </div>
1392
+ <?php
1393
+ }
1394
+ }
1395
+ ?>
include/ajax.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define('DOING_AJAX', true);
3
+
4
+ $parse_uri = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
5
+ require_once($parse_uri[0].'wp-load.php');
6
+
7
+ $parse_uri = explode('wp-customer-reviews', $_SERVER['SCRIPT_FILENAME']);
8
+ require_once($parse_uri[0].'wp-customer-reviews/wp-customer-reviews-3.php');
9
+ $WPCustomerReviews3->ajax();
10
+ ?>
include/goatee-php/wpcr-goatee.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Goatee is a ideological sibling of Mustache Templates.
4
+ It shares the basic syntax of Mustache, but implements a few new awesome features
5
+ which make templating much easier and removes some features which are unneccessary.
6
+
7
+ template tags documented at https://github.com/owenallenaz/Goatee
8
+
9
+ Ported from Javascript to PHP by Aaron Queen (https://github.com/bompus)
10
+
11
+ usage:
12
+ $html = '<div>{{name}}</div>';
13
+ $data = array('name' => 'Aaron');
14
+ $filled = Goatee::fill($html, $data); // filled should contain '<div>Aaron</div>'
15
+ */
16
+
17
+ class wpcr_Goatee {
18
+ private static function context($html) {
19
+ $html_len = strlen($html);
20
+ $rtn = new stdClass();
21
+ $rtn->tags = array();
22
+ $rtn->start = 0;
23
+ $rtn->inner = $html;
24
+ $rtn->innerStart = 0;
25
+ $rtn->innerEnd = $html_len;
26
+ $rtn->end = $html_len;
27
+ return $rtn;
28
+ }
29
+
30
+ private static function tag($label, $type, $start, $end, $innerStart, $innerEnd, $tags) {
31
+ $rtn = new stdClass();
32
+ $rtn->label = $label;
33
+ $rtn->type = $type;
34
+ $rtn->start = $start;
35
+ $rtn->end = $end;
36
+ $rtn->innerStart = $innerStart;
37
+ $rtn->innerEnd = $innerEnd;
38
+ $rtn->tags = $tags;
39
+ return $rtn;
40
+ }
41
+
42
+ public static function fill($html, $data) {
43
+ $currentHTML = $html;
44
+
45
+ $context = self::context($html);
46
+ $myContext = & $context;
47
+ $previousContexts = array();
48
+
49
+ $numMatched = preg_match_all('/\{\{([#!:%\/-]?)(.*?)\}\}/', $currentHTML, $matches, PREG_OFFSET_CAPTURE);
50
+ if ($numMatched === 0) {
51
+ return self::processTags($html, $context, array($data));
52
+ }
53
+
54
+ foreach ($matches[0] as $idx => $match) {
55
+ $match_type = & $matches[1][$idx][0];
56
+ $match_name = & $matches[2][$idx][0];
57
+ $match_len = strlen($match[0]);
58
+ $match_start = & $match[1];
59
+ $match_end = $match_start + $match_len;
60
+
61
+ if ($match_type !== '/') {
62
+ $myContext->tags[] = self::tag( $match_name, $match_type, $match_start, $match_end, $match_end, '', array() );
63
+
64
+ if ($match_type !== '' && $match_type !== '%') {
65
+ $previousContexts[] = $myContext;
66
+ $my_idx = count($myContext->tags) - 1;
67
+ $myContext = $myContext->tags[$my_idx];
68
+ }
69
+ } else {
70
+ $myContext->end = $match_end;
71
+ $myContext->innerEnd = $match_start;
72
+ $myContext->inner = substr($html, $myContext->innerStart, $myContext->innerEnd - $myContext->innerStart);
73
+ $my_idx = count($previousContexts) - 1;
74
+ $myContext = $previousContexts[$my_idx];
75
+ array_splice($previousContexts, $my_idx, 1);
76
+ }
77
+
78
+ $temp = str_repeat('~', $match_len);
79
+ $currentHTML = str_replace($match[0], $temp, $currentHTML);
80
+ }
81
+
82
+ return self::processTags($html, $context, array($data));
83
+ }
84
+
85
+ private static function processTags($html, $context, $data) {
86
+ $returnArray = array();
87
+ $last_data_idx = count($data) - 1;
88
+ $position = $context->innerStart;
89
+
90
+ foreach($context->tags as $idx => $tag) {
91
+ $returnArray[] = substr($html, $position, $tag->start - $position);
92
+ $position = $tag->end;
93
+
94
+ if ($tag->type === '-') {
95
+ if ($last_data_idx > 0) {
96
+ $newData = array_merge(array(), $data);
97
+ array_splice($newData, $last_data_idx, 1);
98
+ $returnArray[] = self::processTags($html, $tag, $newData);
99
+ }
100
+ continue;
101
+ }
102
+
103
+ $myData = false;
104
+ $myData_defined = false;
105
+ $label = $tag->label;
106
+ if ( is_array($data[$last_data_idx]) && isset($data[$last_data_idx][$label]) ) {
107
+ $myData_defined = true;
108
+ $myData = $data[$last_data_idx][$label];
109
+ } else if ( is_object($data[$last_data_idx]) && isset($data[$last_data_idx]->$label) ) {
110
+ $myData_defined = true;
111
+ $myData = $data[$last_data_idx]->$label;
112
+ }
113
+ $myData_type = gettype($myData);
114
+
115
+ if ($tag->type === '' || $tag->type === '%') {
116
+ if ($myData_defined === false) {
117
+ // do nothing
118
+ } else if ($myData_type === 'string' || $myData_type === 'integer' || $myData_type === 'double') {
119
+ // standard tags
120
+ if ($tag->type === '') {
121
+ $returnArray[] = $myData;
122
+ } else if ($tag->type === '%') {
123
+ $returnArray[] = htmlspecialchars($myData);
124
+ }
125
+ }
126
+ else if (
127
+ ( ($myData_type === 'array') && isset($myData['template']) && isset($myData['data']) ) ||
128
+ ( ($myData_type === 'object') && isset($myData->template) && isset($myData->data) )
129
+ ) {
130
+ // passing a template and data structure
131
+
132
+ $myData_data = ($myData_type === 'array') ? $myData['data'] : $myData->data;
133
+ $myData_template = ($myData_type === 'array') ? $myData['template'] : $myData->template;
134
+ $myData_date_type = gettype($myData_data);
135
+
136
+ // Is array loop over array
137
+ if ($myData_date_type === 'array') {
138
+ foreach($myData_data as $idx2 => $val2) {
139
+ $returnArray[] = self::fill($myData_template, array($idx2 => $val2));
140
+ }
141
+ } else {
142
+ $returnArray[] = self::fill($myData_template, $myData_data);
143
+ }
144
+ }
145
+ } else if ($tag->type === '#') {
146
+ if ($myData_defined === true) {
147
+ if ($myData_type === 'array') {
148
+ foreach ($myData as $idx3 => $val3) {
149
+ $newData = array_merge(array(), $data);
150
+ $newData[] = $val3;
151
+ $returnArray[] = self::processTags($html, $tag, $newData);
152
+ }
153
+ } else if ($myData_type === 'object' && count(get_object_vars($myData)) !== 0) {
154
+ $newData = array_merge(array(), $data);
155
+ $newData[] = $myData;
156
+ $returnArray[] = self::processTags($html, $tag, $newData);
157
+ }
158
+ }
159
+ } else if ($tag->type === ':') {
160
+ if (
161
+ $myData_defined === true &&
162
+ (
163
+ ($myData_type === 'string' && $myData !== '' && $myData !== 'false') ||
164
+ ($myData_type === 'array' && count($myData) > 0) ||
165
+ ($myData_type === 'object' && count(get_object_vars($myData)) !== 0) ||
166
+ ($myData_type === 'boolean' && $myData !== false) ||
167
+ ($myData_type === 'integer' || $myData_type === 'double')
168
+ )
169
+ ) {
170
+ $returnArray[] = self::processTags($html, $tag, $data);
171
+ }
172
+ } else if ($tag->type === '!') {
173
+ if (
174
+ $myData_defined === false ||
175
+ (
176
+ ($myData_type === 'string' && ($myData === '' || $myData === 'false')) ||
177
+ ($myData_type === 'array' && count($myData) === 0) ||
178
+ ($myData_type === 'object' && count(get_object_vars($myData)) === 0) ||
179
+ ($myData_type === 'boolean' && $myData === false)
180
+ )
181
+ ) {
182
+ $returnArray[] = self::processTags($html, $tag, $data);
183
+ }
184
+ }
185
+ }
186
+
187
+ if ($position < $context->end) {
188
+ $returnArray[] = substr($html, $position, $context->innerEnd - $position);
189
+ }
190
+
191
+ return implode('', $returnArray);
192
+ }
193
+
194
+ public static function unpreserve($html) {
195
+ return preg_replace('/\{\{\$/', '{{', $html);
196
+ }
197
+
198
+ public static function preserve($html) {
199
+ return preg_replace('/\{\{/', '{{$', $html);
200
+ }
201
+ }
202
+ ?>
include/migrate/2x-3x.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function wpcr3_migrate_2x_3x(&$this2, $current_dbversion) {
3
+ global $wpdb;
4
+
5
+ // if anything fails, RETURN FALSE
6
+
7
+ $old_2x_options = get_option("wpcr_options");
8
+ if ($old_2x_options === false) { return true; }
9
+ if (isset($old_2x_options['migrated_to_3x']) && $old_2x_options['migrated_to_3x'] == 1) { return true; }
10
+
11
+ // update 2x options so it does not migrate again
12
+ $old_2x_options['migrated_to_3x'] = 1;
13
+ update_option('wpcr_options', $old_2x_options);
14
+
15
+ $this2->options['act_email'] = $old_2x_options['act_email'];
16
+ $this2->options['act_uniq'] = $old_2x_options['act_uniq'];
17
+ $this2->options['support_us'] = $old_2x_options['support_us'];
18
+ $this2->options['reviews_per_page'] = $old_2x_options['reviews_per_page'];
19
+
20
+ if ($this2->options['activated'] == 0) {
21
+ $this2->options['activated'] = $old_2x_options['activate']; // "activate" -> "activated"
22
+ }
23
+
24
+ $new = new stdClass();
25
+
26
+ $new->type = $old_2x_options['hreview_type']; // "business" or "product" - all 2x reviews had to be the same type
27
+
28
+ $new->business_city = $old_2x_options['business_city'];
29
+ $new->business_country = $old_2x_options['business_country'];
30
+ $new->business_name = $old_2x_options['business_name'];
31
+ $new->business_phone = $old_2x_options['business_phone'];
32
+ $new->business_state = $old_2x_options['business_state'];
33
+ $new->business_street = $old_2x_options['business_street'];
34
+ $new->business_url = $old_2x_options['business_url'];
35
+ $new->business_zip = $old_2x_options['business_zip'];
36
+
37
+ $ask_fields = $old_2x_options['ask_fields'];
38
+ $new->ask_name = ($ask_fields["fname"] == 1); // boolean
39
+ $new->ask_email = ($ask_fields["femail"] == 1); // boolean
40
+ $new->ask_website = ($ask_fields["fwebsite"] == 1); // boolean
41
+ $new->ask_title = ($ask_fields["ftitle"] == 1); // boolean
42
+
43
+ $req_fields = $old_2x_options['require_fields'];
44
+ $new->req_name = ($req_fields["fname"] == 1); // boolean
45
+ $new->req_email = ($req_fields["femail"] == 1); // boolean
46
+ $new->req_website = ($req_fields["fwebsite"] == 1); // boolean
47
+ $new->req_title = ($req_fields["ftitle"] == 1); // boolean
48
+
49
+ $show_fields = $old_2x_options['show_fields'];
50
+ $new->show_name = ($show_fields["fname"] == 1); // boolean
51
+ $new->show_email = ($show_fields["femail"] == 1); // boolean
52
+ $new->show_website = ($show_fields["fwebsite"] == 1); // boolean
53
+ $new->show_title = ($show_fields["ftitle"] == 1); // boolean
54
+
55
+ $ask_custom = $old_2x_options['ask_custom'];
56
+ for ($i=0;$i<3;$i++) {
57
+ if (!isset($ask_custom[$i])) { $ask_custom[$i] = 0; }
58
+ }
59
+ $new->ask_custom_1 = ($ask_custom[0] == 1); // boolean
60
+ $new->ask_custom_2 = ($ask_custom[1] == 1); // boolean
61
+ $new->ask_custom_3 = ($ask_custom[2] == 1); // boolean
62
+
63
+ $req_custom = $old_2x_options['require_custom'];
64
+ for ($i=0;$i<3;$i++) {
65
+ if (!isset($req_custom[$i])) { $req_custom[$i] = 0; }
66
+ }
67
+ $new->req_custom_1 = ($req_custom[0] == 1); // boolean
68
+ $new->req_custom_2 = ($req_custom[1] == 1); // boolean
69
+ $new->req_custom_3 = ($req_custom[2] == 1); // boolean
70
+
71
+ $show_custom = $old_2x_options['show_custom'];
72
+ for ($i=0;$i<3;$i++) {
73
+ if (!isset($show_custom[$i])) { $show_custom[$i] = 0; }
74
+ }
75
+ $new->show_custom_1 = ($show_custom[0] == 1); // boolean
76
+ $new->show_custom_2 = ($show_custom[1] == 1); // boolean
77
+ $new->show_custom_3 = ($show_custom[2] == 1); // boolean
78
+
79
+ $field_custom = $old_2x_options['field_custom'];
80
+ for ($i=0;$i<3;$i++) {
81
+ if (!isset($field_custom[$i])) { $field_custom[$i] = 0; }
82
+ }
83
+ $new->field_custom_1 = $field_custom[0]; // field label
84
+ $new->field_custom_2 = $field_custom[1]; // field label
85
+ $new->field_custom_3 = $field_custom[2]; // field label
86
+
87
+ // begin: import reviews assigned to posts, update per-post wpcr meta
88
+
89
+ $post_ids = array();
90
+
91
+ // find posts that were automagically enabled with [WPCR_INSERT], but no checkbox enabled
92
+ $queryOpts = array(
93
+ 'nopaging' => true,
94
+ 'ignore_sticky_posts ' => true,
95
+ 'post_type' => 'any',
96
+ 'post_status' => 'publish,pending,draft,future,private,trash',
97
+ 'fields' => 'ids',
98
+ 's' => '[WPCR_INSERT]'
99
+ );
100
+ $res = new WP_Query($queryOpts);
101
+ $post_ids = array_merge($post_ids, $res->posts);
102
+
103
+ // find posts which are enabled via checkbox
104
+ $queryOpts = array(
105
+ 'nopaging' => true,
106
+ 'ignore_sticky_posts ' => true,
107
+ 'post_type' => 'any',
108
+ 'post_status' => 'publish,pending,draft,future,private,trash',
109
+ 'fields' => 'ids',
110
+ 'meta_query' => array(
111
+ array(
112
+ 'key' => 'wpcr_enable',
113
+ 'value' => '1',
114
+ 'compare' => '='
115
+ )
116
+ )
117
+ );
118
+ $res = new WP_Query($queryOpts);
119
+ $post_ids = array_merge($post_ids, $res->posts);
120
+
121
+ // begin: find posts which have 2x reviews associated with their post ID
122
+ // $reviews_2x will be re-used further down
123
+ $reviews_2x = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpcreviews ORDER BY page_id ASC, id ASC");
124
+ $assigned_page_ids = array();
125
+ foreach ($reviews_2x as $review) {
126
+ $assigned_page_ids[] = intval($review->page_id);
127
+ }
128
+ $assigned_page_ids = array_unique($assigned_page_ids);
129
+
130
+ if (count($assigned_page_ids)) {
131
+ $queryOpts = array(
132
+ 'nopaging' => true,
133
+ 'ignore_sticky_posts ' => true,
134
+ 'post_type' => 'any',
135
+ 'post_status' => 'publish,pending,draft,future,private,trash',
136
+ 'post__in' => $assigned_page_ids,
137
+ 'fields' => 'ids'
138
+ );
139
+ $res = new WP_Query($queryOpts);
140
+ $post_ids = array_merge($post_ids, $res->posts);
141
+ }
142
+ // end: find posts which have 2x reviews associated with their post ID
143
+
144
+ $post_ids = array_unique($post_ids);
145
+ foreach ($post_ids as $postid) {
146
+ $tmp = get_post_custom($postid);
147
+ $meta = new stdClass();
148
+ foreach ($tmp as $key => $metaArr) {
149
+ if (strpos($key, "wpcr_") !== false) {
150
+ $meta->$key = $metaArr[0];
151
+ }
152
+ }
153
+
154
+ if (isset($meta->wpcr_migrated_to_3x)) { continue; }
155
+
156
+ // update $postid with v3 options ( product vs business )
157
+
158
+ update_post_meta($postid, 'wpcr_migrated_to_3x', '1');
159
+ update_post_meta($postid, 'wpcr3_enable', '1');
160
+ update_post_meta($postid, 'wpcr3_format', $new->type);
161
+
162
+ if ($new->type === "business") {
163
+ update_post_meta($postid, 'wpcr3_business_name', $new->business_name);
164
+ update_post_meta($postid, 'wpcr3_business_street1', $new->business_street);
165
+ update_post_meta($postid, 'wpcr3_business_city', $new->business_city);
166
+ update_post_meta($postid, 'wpcr3_business_state', $new->business_state);
167
+ update_post_meta($postid, 'wpcr3_business_zip', $new->business_zip);
168
+ update_post_meta($postid, 'wpcr3_business_country', $new->business_country);
169
+ update_post_meta($postid, 'wpcr3_business_phone', $new->business_phone);
170
+ update_post_meta($postid, 'wpcr3_business_url', $new->business_url);
171
+ } else if ($new->type === "product") {
172
+ update_post_meta($postid, 'wpcr3_product_name', $meta->wpcr_product_name);
173
+ update_post_meta($postid, 'wpcr3_product_brand', $meta->wpcr_product_brand);
174
+ if ($meta->wpcr_product_upc != "") {
175
+ update_post_meta($postid, 'wpcr3_product_id', "upc:".$meta->wpcr_product_upc);
176
+ } else if ($meta->wpcr_product_sku != "") {
177
+ update_post_meta($postid, 'wpcr3_product_id', "sku:".$meta->wpcr_product_sku);
178
+ } else if ($meta->wpcr_product_model != "") {
179
+ update_post_meta($postid, 'wpcr3_product_id', "mpn:".$meta->wpcr_product_model);
180
+ }
181
+ }
182
+ }
183
+ // end: import per-post plugin settings
184
+
185
+ // begin: import reviews
186
+ foreach ($reviews_2x as $review) {
187
+ $status = 'publish';
188
+ if ($review->status == '0') { $status = 'pending'; }
189
+ else if ($review->status == '1') { $status = 'publish'; }
190
+ else if ($review->status == '2') { $status = 'trash'; }
191
+
192
+ $name = (strlen($review->reviewer_name) === 0) ? 'Anonymous' : $review->reviewer_name;
193
+ $datetime = date('m/d/Y h:i', strtotime($review->date_time));
194
+ $title = "{$name} @ {$datetime}";
195
+
196
+ $newpost = array(
197
+ 'post_author' => 1,
198
+ 'post_date' => $review->date_time,
199
+ 'post_content' => nl2br($review->review_text),
200
+ 'post_status' => $status,
201
+ 'post_title' => $title,
202
+ 'post_type' => 'wpcr3_review'
203
+ );
204
+ $newpostid = wp_insert_post($newpost, true);
205
+
206
+ update_post_meta($newpostid, 'wpcr3_review_post', $review->page_id);
207
+
208
+ update_post_meta($newpostid, 'wpcr3_review_name', $review->reviewer_name);
209
+ update_post_meta($newpostid, 'wpcr3_review_email', $review->reviewer_email);
210
+ update_post_meta($newpostid, 'wpcr3_review_ip', $review->reviewer_ip);
211
+ update_post_meta($newpostid, 'wpcr3_review_website', $review->reviewer_url);
212
+
213
+ update_post_meta($newpostid, 'wpcr3_review_title', $review->review_title);
214
+ update_post_meta($newpostid, 'wpcr3_review_rating', $review->review_rating);
215
+ update_post_meta($newpostid, 'wpcr3_review_admin_response', $review->review_response);
216
+
217
+ if (isset($review->custom_fields) && substr($review->custom_fields, 0, 2) === "a:") {
218
+ $custom_fields = unserialize($review->custom_fields);
219
+ $field_num = 0;
220
+ foreach ($custom_fields as $value) {
221
+ $field_num++;
222
+ update_post_meta($newpostid, "wpcr3_f{$field_num}", $value);
223
+ }
224
+ }
225
+ }
226
+ // end: import reviews
227
+
228
+ // update 3x options
229
+ update_option($this2->options_name, $this2->options);
230
+
231
+ return true;
232
+ }
233
+ ?>
include/migrate/3x-3x.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function wpcr3_migrate_3x_3x(&$this2, $current_dbversion) {
3
+ // if anything fails, RETURN FALSE
4
+
5
+ if ($this2->pro === false) {
6
+ // if Lite version, on every new plugin version we replace templates in the DB with default template files
7
+ // this is because templates are stored in the DB and there is no method for Lite users to edit them but they need to get updates.
8
+ $this2->options['templates'] = $this2->default_options['templates'];
9
+ update_option($this2->options_name, $this2->options);
10
+ }
11
+
12
+ /* example of upgrade to 3.0.1 which needs migration tasks */
13
+ if ($current_dbversion < 301) {
14
+ /*
15
+ TODO: perform any migration tasks
16
+ $current_dbversion = $this2->update_db_version(301);
17
+ */
18
+ }
19
+
20
+ /* example of upgrade to 3.0.3 which needs migration tasks */
21
+ if ($current_dbversion < 302) {
22
+ /*
23
+ TODO: perform any migration tasks
24
+ $current_dbversion = $this2->update_db_version(302);
25
+ */
26
+ }
27
+
28
+ return true;
29
+ }
30
+ ?>
include/templates/frontend_review_form.html ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+
7
+ {{:showform}}
8
+ <div class="wpcr3_respond_2">
9
+ <div class="wpcr3_div_2">
10
+ <table class="wpcr3_table_2">
11
+ <tbody>
12
+ <tr>
13
+ <td colspan="2">
14
+ <div class="wpcr3_leave_text">
15
+ Submit your review
16
+ </div>
17
+ </td>
18
+ </tr>
19
+ {{input_fields}}
20
+ {{rating_field}}
21
+ {{review_field}}
22
+ <tr>
23
+ <td colspan="2" class="wpcr3_check_confirm">
24
+ <div class="wpcr3_clear"></div>
25
+ <input type="hidden" name="wpcr3_postid" value="{{postid}}" />
26
+ <input type="text" class="wpcr3_fakehide wpcr3_fake_website" name="website" />
27
+ <input type="text" class="wpcr3_fakehide wpcr3_fake_url" name="url" />
28
+ <input type="checkbox" class="wpcr3_fakehide wpcr3_fconfirm1" name="wpcr3_fconfirm1" value="1" />
29
+ <label>
30
+ <input type="checkbox" name="wpcr3_fconfirm2" class="wpcr3_fconfirm2" value="1" />
31
+ &nbsp; Check this box to confirm you are human.
32
+ </label>
33
+ <input type="checkbox" class="wpcr3_fakehide wpcr3_fconfirm3" name="wpcr3_fconfirm3" checked="checked" value="1" />
34
+ </td>
35
+ </tr>
36
+ <tr>
37
+ <td colspan="2">
38
+ <div class="wpcr3_button_1 wpcr3_submit_btn">Submit</div>
39
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
40
+ <div class="wpcr3_button_1 wpcr3_cancel_btn">Cancel</div>
41
+ </td>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+ </div>
46
+ </div>
47
+ <div class="wpcr3_clear wpcr3_pb5"></div>
48
+ <div class="wpcr3_respond_3">
49
+ <p>
50
+ <div class="wpcr3_button_1 wpcr3_show_btn">
51
+ Create your own review
52
+ </div>
53
+ </p>
54
+ {{!found_posts}}
55
+ <p class="wpcr3_no_reviews">
56
+ There are no reviews yet. Be the first to leave yours!
57
+ </p>
58
+ {{/found_posts}}
59
+ </div>
60
+ <div class="wpcr3_dotline"></div>
61
+ {{/showform}}
include/templates/frontend_review_form_rating_field.html ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ <tr class="wpcr3_review_form_rating_field">
7
+ <td>
8
+ <label for="id_wpcr3_frating" class="comment-field">Rating: </label>
9
+ </td>
10
+ <td>
11
+ <div class="wpcr3_rating_stars">{{rating_stars}}</div>
12
+ <input style="display:none;" type="hidden" class="wpcr3_required wpcr3_frating" id="id_wpcr3_frating" name="wpcr3_frating" />
13
+ </td>
14
+ </tr>
include/templates/frontend_review_form_review_field.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ <tr class="wpcr3_review_form_review_field_label">
7
+ <td colspan="2">
8
+ <label for="id_wpcr3_ftext" class="comment-field">Review: </label>
9
+ </td>
10
+ </tr>
11
+ <tr class="wpcr3_review_form_review_field_textarea">
12
+ <td colspan="2">
13
+ <textarea class="wpcr3_required wpcr3_ftext" id="id_wpcr3_ftext" name="wpcr3_ftext" rows="8" cols="50">{{value}}</textarea>
14
+ </td>
15
+ </tr>
include/templates/frontend_review_form_text_field.html ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ <tr class="wpcr3_review_form_text_field">
7
+ <td>
8
+ <label for="{{name}}" class="comment-field">{{label}}: </label>
9
+ </td>
10
+ {{#test}}
11
+ test only
12
+ {{/test}}
13
+ <td>
14
+ <input maxlength="150" class="text-input {{class}}" type="text" id="{{name}}" name="{{name}}" value="{{value}}" />
15
+ </td>
16
+ </tr>
include/templates/frontend_review_holder.html ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ <div class='wpcr3_respond_1 {{classes}}' data-ajaxurl='{{ajaxurl}}' data-on-postid='{{on_postid}}' data-postid='{{postid}}'>
7
+ {{review_form}}
8
+ {{!hidereviews}}
9
+ <div class="wpcr3_reviews_holder">
10
+ {{reviews}}
11
+ </div>
12
+ {{pagination}}
13
+ {{/hidereviews}}
14
+ {{:power}}
15
+ <div class="wpcr3_clear wpcr3_power">
16
+ {{power}}
17
+ </div>
18
+ {{/power}}
19
+ </div>
include/templates/frontend_review_item.html ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ <div class="wpcr3_review_item">
7
+ {{:is_business}}
8
+ <div class="wpcr3_item wpcr3_business" itemscope itemtype="http://schema.org/LocalBusiness">
9
+ {{:aggregate}}
10
+ <div class="wpcr3_item_name">
11
+ {{:on_same_page}}
12
+ {{wpcr3_business_name}}
13
+ {{/on_same_page}}
14
+ {{!on_same_page}}
15
+ <a href="{{postLink}}">{{wpcr3_business_name}}</a>
16
+ {{/on_same_page}}
17
+ </div>
18
+ {{/aggregate}}
19
+ <meta itemprop="name" content="{{wpcr3_business_name}}" />
20
+ <meta itemprop="url" content="{{wpcr3_business_url}}" />
21
+ <meta itemprop="telephone" content="{{wpcr3_business_phone}}" />
22
+ <div class="wpcr3_hide" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
23
+ <meta itemprop="streetAddress" content="{{wpcr3_business_street1}}{{:wpcr3_business_street2}}{{wpcr3_business_street2}}{{/wpcr3_business_street2}}" />
24
+ <meta itemprop="addressLocality" content="{{wpcr3_business_city}}" />
25
+ <meta itemprop="addressRegion" content="{{wpcr3_business_state}}" />
26
+ <meta itemprop="postalCode" content="{{wpcr3_business_zip}}" />
27
+ </div>
28
+ {{aggregate}}
29
+ {{reviews}}
30
+ </div>
31
+ {{/is_business}}
32
+
33
+ {{:is_product}}
34
+ <div class="wpcr3_item wpcr3_product" itemscope itemtype="http://schema.org/Product">
35
+ {{:aggregate}}
36
+ <div class="wpcr3_item_name">
37
+ {{:on_same_page}}
38
+ {{wpcr3_product_name}}
39
+ {{/on_same_page}}
40
+ {{!on_same_page}}
41
+ <a href="{{postLink}}">{{wpcr3_product_name}}</a>
42
+ {{/on_same_page}}
43
+ </div>
44
+ {{/aggregate}}
45
+ <meta itemprop="name" content="{{wpcr3_product_name}}" />
46
+ <meta itemprop="brand" content="{{wpcr3_product_brand}}" />
47
+ <meta itemprop="productID" content="{{wpcr3_product_id}}" />
48
+ {{aggregate}}
49
+ {{reviews}}
50
+ </div>
51
+ {{/is_product}}
52
+ </div>
include/templates/frontend_review_item_aggregate.html ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ {{#aggregate}}
7
+ <div class="wpcr3_aggregateRating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
8
+ <meta itemprop="bestRating" content="5" />
9
+ <meta itemprop="worstRating" content="1" />
10
+ <meta itemprop="ratingValue" content="{{aggregate_rating}}" />
11
+ <meta itemprop="reviewCount" content="{{aggregate_count}}" />
12
+ <span class="wpcr3_aggregateRating_overallText">Average rating: </span>&nbsp;
13
+ <div class="wpcr3_aggregateRating_ratingValue">{{stars}}</div>&nbsp;
14
+ <span class="wpcr3_aggregateRating_reviewCount">{{aggregate_count}} reviews</span>
15
+ </div>
16
+ {{/aggregate}}
include/templates/frontend_review_item_reviews.html ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ {{#reviews}}
7
+ <div class="wpcr3_dotline"></div>
8
+ <div id="wpcr3_id_{{id}}" class="wpcr3_review" itemprop="review" itemscope itemtype="http://schema.org/Review">
9
+ <meta itemprop="author" content="{{wpcr3_review_name}}" />
10
+ <div class="wpcr3_hide" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
11
+ <meta itemprop="bestRating" content="5" />
12
+ <meta itemprop="worstRating" content="1" />
13
+ <meta itemprop="ratingValue" content="{{wpcr3_review_rating}}" />
14
+ </div>
15
+ <div class="wpcr3_review_ratingValue">{{stars}}</div>
16
+ <div class="wpcr3_review_datePublished" itemprop="datePublished">{{post_date}}</div>
17
+ <div class="wpcr3_review_author">by
18
+ <span class="wpcr3_caps">
19
+ {{:wpcr3_review_website}}
20
+ <a target="_blank" href="{{wpcr3_review_website}}">{{wpcr3_review_name}}</a>
21
+ {{/wpcr3_review_website}}
22
+ {{!wpcr3_review_website}}
23
+ {{wpcr3_review_name}}
24
+ {{/wpcr3_review_website}}
25
+ </span> on
26
+ <span class="wpcr3_item_name">
27
+ {{:on_same_page}}
28
+ {{item_name}}
29
+ {{/on_same_page}}
30
+ {{!on_same_page}}
31
+ <a href="{{postLink}}">{{item_name}}</a>
32
+ {{/on_same_page}}
33
+ </span>
34
+ </div>
35
+ <div class="wpcr3_clear"></div>
36
+ {{:wpcr3_review_title}}
37
+ <div class="wpcr3_review_title wpcr3_caps">{{wpcr3_review_title}}</div>
38
+ {{/wpcr3_review_title}}
39
+ <div class="wpcr3_clear"></div>
40
+ {{:wpcr3_custom_fields}}
41
+ <div class="wpcr3_review_customs">
42
+ {{#wpcr3_custom_fields}}
43
+ <div class="wpcr3_review_custom">
44
+ <span class="wpcr3_review_custom_label">{{label}}:</span> <span class="wpcr3_review_custom_value">{{value}}</span>
45
+ </div>
46
+ {{/wpcr3_custom_fields}}
47
+ </div>
48
+ <div class="wpcr3_clear"></div>
49
+ {{/wpcr3_custom_fields}}
50
+
51
+ <blockquote class="wpcr3_content" itemprop="reviewBody">
52
+ <p>
53
+ {{content}}
54
+ </p>
55
+ </blockquote>
56
+
57
+ {{:wpcr3_review_admin_response}}
58
+ <blockquote class="wpcr3_content wpcr3_admin_response">
59
+ <p>
60
+ {{wpcr3_review_admin_response}}
61
+ </p>
62
+ </blockquote>
63
+ {{/wpcr3_review_admin_response}}
64
+ </div>
65
+ {{/reviews}}
include/templates/frontend_review_pagination.html ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ %---
2
+ NOTICE: Changes made to this file do nothing.
3
+ Additionally, this file will be overwritten with each plugin update and/or activation.
4
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
5
+ ---%
6
+ <div data-page-opts="{{pageOpts}}" class="wpcr3_pagination">
7
+ <div class="wpcr3_pagination_page">Page {{onPage}} of {{numPages}}: </div>
8
+ <div data-page="1" class="wpcr3_a {{!hasPrev}}wpcr3_disabled{{/hasPrev}}">&laquo;</div>&nbsp;
9
+ <div data-page="{{prevPage}}" class="wpcr3_a wpcr3_ls {{!hasPrev}}wpcr3_disabled{{/hasPrev}}">&lsaquo;</div>&nbsp;
10
+ {{#pages}}
11
+ <div data-page="{{pageNum}}" class="wpcr3_a {{:current}}wpcr3_current{{/current}}">{{pageNum}}</div>
12
+ {{/pages}}
13
+ <div data-page="{{nextPage}}" class="wpcr3_a wpcr3_rs {{!hasNext}}wpcr3_disabled{{/hasNext}}">&rsaquo;</div>&nbsp;
14
+ <div data-page="{{numPages}}" class="wpcr3_a {{!hasNext}}wpcr3_disabled{{/hasNext}}">&raquo;</div>&nbsp;
15
+ </div>
16
+ <div class="wpcr3_clear"></div>
include/templates/frontend_review_rating_stars.html ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wpcr3_rating_style1">
2
+ {{:hoverable}}
3
+ <div class="wpcr3_rating_style1_status">
4
+ <div class="wpcr3_rating_style1_score">
5
+ <div class="wpcr3_rating_style1_score1">1</div>
6
+ <div class="wpcr3_rating_style1_score2">2</div>
7
+ <div class="wpcr3_rating_style1_score3">3</div>
8
+ <div class="wpcr3_rating_style1_score4">4</div>
9
+ <div class="wpcr3_rating_style1_score5">5</div>
10
+ </div>
11
+ </div>
12
+ {{/hoverable}}
13
+ <div class="wpcr3_rating_style1_base {{:hoverable}}wpcr3_hide{{/hoverable}}">
14
+ <div class="wpcr3_rating_style1_average" style="width:{{rating_width}}%;"></div>
15
+ </div>
16
+ </div>
include/templates/readme_templates.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ These are the default templates. These WILL be overwritten when the plugin upgrades.
2
+
3
+ If you need to make updates to any templates, you can update them in the plugin settings of WP Customer Reviews Pro.
include/templates/wp-customer-reviews-css.css ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ WARNING: If you edit anything here, it will be overwritten with each plugin update and/or activation.
3
+ If you have the Pro version, you can edit this file via plugin settings without it being overwritten.
4
+
5
+ You can also override any of these values in your theme CSS if you use !important or prepend with "body "
6
+ Example: body #wpcr3_respond_1 blockquote.description p { font-size:12px !important; font-weight:bold !important; }
7
+ */
8
+
9
+ .wpcr3_in_content { margin-bottom:30px; }
10
+ .wpcr3_in_content meta { display:none; }
11
+ .wpcr3_power { padding-top:30px !important; padding-bottom:30px !important; font-size:11px !important; }
12
+ .wpcr3_status_msg { color:#c00;font-weight:bold; }
13
+ .wpcr3_status_msg div { color:#c00;font-weight:bold;padding-bottom:15px;padding-top:15px; }
14
+ .wpcr3_caps { text-transform:capitalize; }
15
+
16
+ div.wpcr3_dotline, div.wpcr3_review div.wpcr3_dotline {
17
+ display:block !important; border-bottom:1px dotted #ccc !important;
18
+ margin-bottom:10px !important; clear:both !important;
19
+ }
20
+
21
+ .wpcr3_leave_text { font-weight:bold; font-size:1.1rem; }
22
+
23
+ div.wpcr3_aggregateRating { display:block !important; margin-bottom:30px; line-height:24px; font-size:0.8em; }
24
+ div.wpcr3_aggregateRating div.wpcr3_aggregateRating_ratingValue { display:inline-block !important; position:relative; top:2px; }
25
+
26
+ div.wpcr3_review_item div.wpcr3_item_name { font-size:0.8em; font-style:italic; }
27
+
28
+ div.wpcr3_review div, div.wpcr3_review span { display:inline-block !important; line-height:24px; }
29
+ div.wpcr3_review div.wpcr3_review_ratingValue { position:relative; top:2px; margin-right:5px; }
30
+ div.wpcr3_review div.wpcr3_review_title { font-size:0.8em; display:block !important; }
31
+ div.wpcr3_review blockquote.wpcr3_content { font-size:14px; font-weight:normal; display:block !important; padding-bottom:30px; }
32
+ div.wpcr3_review blockquote.wpcr3_content p { font-size:14px; font-weight:normal; display:inline !important; }
33
+ div.wpcr3_review blockquote.wpcr3_content.wpcr3_admin_response { margin-left:30px;color:#00c; }
34
+ div.wpcr3_review div.wpcr3_review_datePublished { font-size:0.9em; font-style:italic; }
35
+ div.wpcr3_review div.wpcr3_review_author { font-size:0.8em; font-style:italic; }
36
+ div.wpcr3_review div.wpcr3_review_customs { margin-bottom:5px; }
37
+ div.wpcr3_review div.wpcr3_review_custom { font-size:12px; float:left; margin-right:60px; }
38
+
39
+ .wpcr3_respond_2 { position:relative; }
40
+ .wpcr3_respond_2 label { display:inline-block; !important; }
41
+ .wpcr3_respond_2 .fconfirm2 { width:auto !important; }
42
+
43
+ .wpcr3_respond_2 input { }
44
+ .wpcr3_respond_2 input[type="text"] { min-width:200px; }
45
+ .wpcr3_respond_2 textarea { height:100px !important; min-width:500px; }
46
+ .wpcr3_respond_2 small { padding:0 !important; margin:0 !important; }
47
+ .wpcr3_respond_2 table, .wpcr3_respond_2 td { border:0 !important; border-style:none !important; }
48
+
49
+ .wpcr3_respond_2 .wpcr3_check_confirm label { margin:-2px 0px 0px 5px; }
50
+
51
+ .wpcr3_ad { background:#ffffff; }
52
+ .wpcr3_ad label { font-weight:bold; }
53
+
54
+ .wpcr3_respond_1, .wpcr3_respond_2 { margin:0 !important; padding:0 !important; clear:both !important; }
55
+ .wpcr3_respond_1 p, .wpcr3_respond_2 p {
56
+ margin:0 !important;
57
+ padding:0 !important;
58
+ line-height:120% !important;
59
+ margin-top:2px !important;
60
+ margin-bottom:2px !important;
61
+ }
62
+
63
+ .wpcr3_respond_1 .wpcr3_rating, .wpcr3_respond_2 .wpcr3_rating {
64
+ border:0 !important;
65
+ margin:0 !important;
66
+ padding:0 !important;
67
+ margin-left:0px !important;
68
+ margin-top:0px !important;
69
+ overflow:hidden;
70
+ height:16px;
71
+ }
72
+
73
+ div.wpcr3_rating_style1 { line-height:17px; display:inline-block; }
74
+ div.wpcr3_rating_style1 div { line-height:17px; }
75
+ div.wpcr3_rating_style1 * { border:0 none; margin:0; padding:0; line-height:17px; }
76
+ div.wpcr3_rating_style1_base { background:url(newstars.png) 0 0 no-repeat; width:85px; height:17px; line-height:17px; float:left; padding-right:4px; overflow:hidden; display:block; }
77
+ div.wpcr3_rating_style1_average { background:url(newstars.png) 0 -15px no-repeat; text-indent:-9999px; height:17px; line-height:17px; }
78
+ div.wpcr3_rating_style1_status { height:17px; line-height:17px; width:100px; overflow:hidden; position:relative; cursor:pointer; display:block; }
79
+ div.wpcr3_rating_style1_score { background:url(newstars.png) 0 0 no-repeat; width:85px; height:17px; line-height:17px; float:left; position:relative; }
80
+ div.wpcr3_rating_style1_score div { display:block; height:17px; float:left; text-indent:-9999px; position:absolute; overflow:hidden; line-height:17px; }
81
+ div.wpcr3_rating_style1_score div:hover { background:url(newstars.png) bottom right no-repeat; }
82
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score1 {width:20%; z-index:55;}
83
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score2 {width:40%; z-index:54;}
84
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score3 {width:60%; z-index:53;}
85
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score4 {width:80%; z-index:52;}
86
+ div.wpcr3_rating_style1_score div.wpcr3_rating_style1_score5 {width:100%; z-index:51;}
87
+
88
+ .wpcr3_respond_2 { display:none; background-color:inherit; }
89
+ .wpcr3_div_2 { width:600px; }
90
+ .wpcr3_table_2 { text-align:left; width:100%; }
91
+ .wpcr3_table_2 td { text-align:left; }
92
+ .wpcr3_check_confirm { margin-top:10px;font-size:13px;margin-bottom:4px; }
93
+
94
+ .wpcr3_button_1 {
95
+ border: 1px solid;
96
+ border-color: #e6e6e6 #cccccc #cccccc #e6e6e6;
97
+ -moz-border-radius: 3px;
98
+ -webkit-border-radius: 3px;
99
+ border-radius: 3px;
100
+ background: #ffffff;
101
+ background: -moz-linear-gradient(top, #ffffff 0%, #c4c4c4 100%);
102
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#c4c4c4));
103
+ background: -webkit-linear-gradient(top, #ffffff 0%,#c4c4c4 100%);
104
+ background: -o-linear-gradient(top, #ffffff 0%,#c4c4c4 100%);
105
+ background: -ms-linear-gradient(top, #ffffff 0%,#c4c4c4 100%);
106
+ background: linear-gradient(to bottom, #ffffff 0%,#c4c4c4 100%);
107
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#c4c4c4',GradientType=0 );
108
+ color: #404040;
109
+ cursor:pointer;
110
+ display: inline-block;
111
+ font-size: 13px;
112
+ font-weight: normal;
113
+ outline: 0;
114
+ padding: 5px 12px 5px;
115
+ text-align: center;
116
+ text-decoration: none;
117
+ white-space: nowrap;
118
+ float:none;
119
+ height:auto;
120
+ text-indent:0;
121
+ margin-bottom: 15px;
122
+ }
123
+
124
+ .wpcr3_button_1:hover {
125
+ background: #dedede;
126
+ background: -moz-linear-gradient(top, #ffffff 0%, #b8b8b8 100%);
127
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#b8b8b8));
128
+ background: -webkit-linear-gradient(top, #ffffff 0%,#b8b8b8 100%);
129
+ background: -o-linear-gradient(top, #ffffff 0%,#b8b8b8 100%);
130
+ background: -ms-linear-gradient(top, #ffffff 0%,#b8b8b8 100%);
131
+ background: linear-gradient(to bottom, #ffffff 0%,#b8b8b8 100%);
132
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#b8b8b8',GradientType=1 );
133
+ border-color: #99ccff;
134
+ color: #333333;
135
+ cursor:pointer;
136
+ font-weight: normal;
137
+ }
138
+
139
+ .wpcr3_button_1:active, .wpcr3_button_1:focus {
140
+ background-position: 0 -25px;
141
+ background: #dedede;
142
+ background: -moz-linear-gradient(top, #ffffff 0%, #dedede 100%);
143
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#dedede));
144
+ background: -webkit-linear-gradient(top, #ffffff 0%,#dedede 100%);
145
+ background: -o-linear-gradient(top, #ffffff 0%,#dedede 100%);
146
+ background: -ms-linear-gradient(top, #ffffff 0%,#dedede 100%);
147
+ background: linear-gradient(to bottom, #ffffff 0%,#dedede 100%);
148
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dedede',GradientType=1 );
149
+ border-color: #8fc7ff #94c9ff #94c9ff #8fc7ff;
150
+ color:#1a1a1a;
151
+ }
152
+
153
+ .wpcr3_button_1.wpcr3_disabled {
154
+ opacity: 0.5;
155
+ }
156
+
157
+ .wpcr3_button_1.wpcr3_hide {
158
+ display:none !important;
159
+ }
160
+
161
+ .wpcr3_pagination {
162
+ clear:both;
163
+ padding:0px 0px 0px 0px;
164
+ position:relative;
165
+ font-size:11px;
166
+ line-height:13px;
167
+ }
168
+
169
+ .wpcr3_pagination_page {
170
+ float:left;
171
+ display:block;
172
+ line-height:30px;
173
+ padding-right:5px;
174
+ }
175
+
176
+ .wpcr3_pagination .wpcr3_a {
177
+ display:block;
178
+ float:left;
179
+ margin: 0px 1px 0px 1px;
180
+ padding:6px 10px 6px 10px;
181
+ line-height: 16px;
182
+ text-decoration:none;
183
+ width:auto;
184
+ color:#fff;
185
+ background:#555;
186
+ cursor:pointer;
187
+ }
188
+
189
+ .wpcr3_pagination .wpcr3_a:hover {
190
+ color:#fff;background: #3279BB;
191
+ }
192
+
193
+ .wpcr3_pagination .wpcr3_ls {
194
+ margin-right:1px;
195
+ }
196
+
197
+ .wpcr3_pagination .wpcr3_rs {
198
+ margin-left:1px;
199
+ }
200
+
201
+ .wpcr3_pagination .wpcr3_a.wpcr3_current {
202
+ background: #3279BB;color:#fff;cursor:default;
203
+ }
204
+
205
+ .wpcr3_pagination .wpcr3_a.wpcr3_disabled, .wpcr3_pagination .wpcr3_a.wpcr3_disabled:hover {
206
+ background:#ddd;color:#fff;cursor:default;
207
+ }
208
+
209
+ .wpcr3_clear , div.wpcr3_review .wpcr3_clear { clear:both !important; display:block !important; line-height:0px !important;; height:0px !important; }
210
+ .wpcr3_show, div.wpcr3_review .wpcr3_show { display:inline; }
211
+ .wpcr3_hide, div.wpcr3_review .wpcr3_hide { display:none !important; }
212
+ .wpcr3_fakehide { position:absolute !important;top:0 !important;left:-999em !important;height:1px !important;width:1px !important; }
213
+ .wpcr3_pb5 { padding-bottom:5px; }
js/wp-customer-reviews-admin.js ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Select2 4.0.6-rc.1 ( renamed to wpcr3_select )
3
+ * https://wpcr3_select.github.io
4
+ *
5
+ * Released under the MIT license
6
+ * https://github.com/wpcr3_select/wpcr3_select/blob/master/LICENSE.md
7
+ */
8
+ !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,n){return void 0===n&&(n="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(n),n}:e(jQuery)}(function(e){var t=function(){if(e&&e.fn&&e.fn.wpcr3_select&&e.fn.wpcr3_select.amd)var t=e.fn.wpcr3_select.amd;var n,r,i;return t&&t.requirejs||(t?r=t:t={},function(e){var t,s,o,a,l={},c={},u={},p={},d=Object.prototype.hasOwnProperty,h=[].slice,f=/\.js$/;function g(e,t){return d.call(e,t)}function m(e,t){var n,r,i,s,o,a,l,c,p,d,h,g=t&&t.split("/"),m=u.map,_=m&&m["*"]||{};if(e){for(o=(e=e.split("/")).length-1,u.nodeIdCompat&&f.test(e[o])&&(e[o]=e[o].replace(f,"")),"."===e[0].charAt(0)&&g&&(e=g.slice(0,g.length-1).concat(e)),p=0;p<e.length;p++)if("."===(h=e[p]))e.splice(p,1),p-=1;else if(".."===h){if(0===p||1===p&&".."===e[2]||".."===e[p-1])continue;p>0&&(e.splice(p-1,2),p-=2)}e=e.join("/")}if((g||_)&&m){for(p=(n=e.split("/")).length;p>0;p-=1){if(r=n.slice(0,p).join("/"),g)for(d=g.length;d>0;d-=1)if((i=m[g.slice(0,d).join("/")])&&(i=i[r])){s=i,a=p;break}if(s)break;!l&&_&&_[r]&&(l=_[r],c=p)}!s&&l&&(s=l,a=c),s&&(n.splice(0,a,s),e=n.join("/"))}return e}function _(t,n){return function(){var r=h.call(arguments,0);return"string"!=typeof r[0]&&1===r.length&&r.push(null),s.apply(e,r.concat([t,n]))}}function v(e){return function(t){l[e]=t}}function y(n){if(g(c,n)){var r=c[n];delete c[n],p[n]=!0,t.apply(e,r)}if(!g(l,n)&&!g(p,n))throw new Error("No "+n);return l[n]}function w(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function $(e){return e?w(e):[]}o=function(e,t){var n,r,i=w(e),s=i[0],o=t[1];return e=i[1],s&&(n=y(s=m(s,o))),s?e=n&&n.normalize?n.normalize(e,(r=o,function(e){return m(e,r)})):m(e,o):(s=(i=w(e=m(e,o)))[0],e=i[1],s&&(n=y(s))),{f:s?s+"!"+e:e,n:e,pr:s,p:n}},a={require:function(e){return _(e)},exports:function(e){var t=l[e];return void 0!==t?t:l[e]={}},
9
+ module:function(e){return{id:e,uri:"",exports:l[e],config:function(e){return function(){return u&&u.config&&u.config[e]||{}}}(e)}}},t=function(t,n,r,i){var s,u,d,h,f,m,w,b=[],A=typeof r;if(m=$(i=i||t),"undefined"===A||"function"===A){for(n=!n.length&&r.length?["require","exports","module"]:n,f=0;f<n.length;f+=1)if("require"===(u=(h=o(n[f],m)).f))b[f]=a.require(t);else if("exports"===u)b[f]=a.exports(t),w=!0;else if("module"===u)s=b[f]=a.module(t);else if(g(l,u)||g(c,u)||g(p,u))b[f]=y(u);else{if(!h.p)throw new Error(t+" missing "+u);h.p.load(h.n,_(i,!0),v(u),{}),b[f]=l[u]}d=r?r.apply(l[t],b):void 0,t&&(s&&s.exports!==e&&s.exports!==l[t]?l[t]=s.exports:d===e&&w||(l[t]=d))}else t&&(l[t]=r)},n=r=s=function(n,r,i,l,c){if("string"==typeof n)return a[n]?a[n](r):y(o(n,$(r)).f);if(!n.splice){if((u=n).deps&&s(u.deps,u.callback),!r)return;r.splice?(n=r,r=i,i=null):n=e}return r=r||function(){},"function"==typeof i&&(i=l,l=c),l?t(e,n,r,i):setTimeout(function(){t(e,n,r,i)},4),s},s.config=function(e){return s(e)},n._defined=l,(i=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),g(l,e)||g(c,e)||(c[e]=[e,t,n])}).amd={jQuery:!0}}(),t.requirejs=n,t.require=r,t.define=i),t.define("almond",function(){}),t.define("jquery",[],function(){var t=e||$;return null==t&&console&&console.error&&console.error("wpcr3_select: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before wpcr3_select on your web page."),t}),t.define("wpcr3_select/utils",["jquery"],function(e){var t={};function n(e){var t=e.prototype,n=[];for(var r in t){"function"==typeof t[r]&&("constructor"!==r&&n.push(r))}return n}t.Extend=function(e,t){var n={}.hasOwnProperty;function r(){this.constructor=e}for(var i in t)n.call(t,i)&&(e[i]=t[i]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},t.Decorate=function(e,t){var r=n(t),i=n(e);function s(){
10
+ var n=Array.prototype.unshift,r=t.prototype.constructor.length,i=e.prototype.constructor;r>0&&(n.call(arguments,e.prototype.constructor),i=t.prototype.constructor),i.apply(this,arguments)}t.displayName=e.displayName,s.prototype=new function(){this.constructor=s};for(var o=0;o<i.length;o++){var a=i[o];s.prototype[a]=e.prototype[a]}for(var l=function(e){var n=function(){};e in s.prototype&&(n=s.prototype[e]);var r=t.prototype[e];return function(){return Array.prototype.unshift.call(arguments,n),r.apply(this,arguments)}},c=0;c<r.length;c++){var u=r[c];s.prototype[u]=l(u)}return s};var r=function(){this.listeners={}};r.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},r.prototype.trigger=function(e){var t=Array.prototype.slice,n=t.call(arguments,1);this.listeners=this.listeners||{},null==n&&(n=[]),0===n.length&&n.push({}),n[0]._type=e,e in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},r.prototype.invoke=function(e,t){for(var n=0,r=e.length;n<r;n++)e[n].apply(this,t)},t.Observable=r,t.generateChars=function(e){for(var t="",n=0;n<e;n++){t+=Math.floor(36*Math.random()).toString(36)}return t},t.bind=function(e,t){return function(){e.apply(t,arguments)}},t._convertData=function(e){for(var t in e){var n=t.split("-"),r=e;if(1!==n.length){for(var i=0;i<n.length;i++){var s=n[i];(s=s.substring(0,1).toLowerCase()+s.substring(1))in r||(r[s]={}),i==n.length-1&&(r[s]=e[t]),r=r[s]}delete e[t]}}return e},t.hasScroll=function(t,n){var r=e(n),i=n.style.overflowX,s=n.style.overflowY;return(i!==s||"hidden"!==s&&"visible"!==s)&&("scroll"===i||"scroll"===s||(r.innerHeight()<n.scrollHeight||r.innerWidth()<n.scrollWidth))},t.escapeMarkup=function(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},
11
+ t.appendMany=function(t,n){if("1.7"===e.fn.jquery.substr(0,3)){var r=e();e.map(n,function(e){r=r.add(e)}),n=r}t.append(n)},t.__cache={};var i=0;return t.GetUniqueElementId=function(e){var t=e.getAttribute("data-wpcr3_select-id");return null==t&&(e.id?(t=e.id,e.setAttribute("data-wpcr3_select-id",t)):(e.setAttribute("data-wpcr3_select-id",++i),t=i.toString())),t},t.StoreData=function(e,n,r){var i=t.GetUniqueElementId(e);t.__cache[i]||(t.__cache[i]={}),t.__cache[i][n]=r},t.GetData=function(n,r){var i=t.GetUniqueElementId(n);return r?t.__cache[i]&&null!=t.__cache[i][r]?t.__cache[i][r]:e(n).data(r):t.__cache[i]},t.RemoveData=function(e){var n=t.GetUniqueElementId(e);null!=t.__cache[n]&&delete t.__cache[n]},t}),t.define("wpcr3_select/results",["jquery","./utils"],function(e,t){function n(e,t,r){this.$element=e,this.data=r,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,t.Observable),n.prototype.render=function(){var t=e('<ul class="wpcr3_select-results__options" role="tree"></ul>');return this.options.get("multiple")&&t.attr("aria-multiselectable","true"),this.$results=t,t},n.prototype.clear=function(){this.$results.empty()},n.prototype.displayMessage=function(t){var n=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var r=e('<li role="treeitem" aria-live="assertive" class="wpcr3_select-results__option"></li>'),i=this.options.get("translations").get(t.message);r.append(n(i(t.args))),r[0].className+=" wpcr3_select-results__message",this.$results.append(r)},n.prototype.hideMessages=function(){this.$results.find(".wpcr3_select-results__message").remove()},n.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var r=e.results[n],i=this.option(r);t.push(i)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},n.prototype.position=function(e,t){
12
+ t.find(".wpcr3_select-results").append(e)},n.prototype.sort=function(e){return this.options.get("sorter")(e)},n.prototype.highlightFirstItem=function(){var e=this.$results.find(".wpcr3_select-results__option[aria-selected]"),t=e.filter("[aria-selected=true]");t.length>0?t.first().trigger("mouseenter"):e.first().trigger("mouseenter"),this.ensureHighlightVisible()},n.prototype.setClasses=function(){var n=this;this.data.current(function(r){var i=e.map(r,function(e){return e.id.toString()});n.$results.find(".wpcr3_select-results__option[aria-selected]").each(function(){var n=e(this),r=t.GetData(this,"data"),s=""+r.id;null!=r.element&&r.element.selected||null==r.element&&e.inArray(s,i)>-1?n.attr("aria-selected","true"):n.attr("aria-selected","false")})})},n.prototype.showLoading=function(e){this.hideLoading();var t={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},n=this.option(t);n.className+=" loading-results",this.$results.prepend(n)},n.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},n.prototype.option=function(n){var r=document.createElement("li");r.className="wpcr3_select-results__option";var i={role:"treeitem","aria-selected":"false"};for(var s in n.disabled&&(delete i["aria-selected"],i["aria-disabled"]="true"),null==n.id&&delete i["aria-selected"],null!=n._resultId&&(r.id=n._resultId),n.title&&(r.title=n.title),n.children&&(i.role="group",i["aria-label"]=n.text,delete i["aria-selected"]),i){var o=i[s];r.setAttribute(s,o)}if(n.children){var a=e(r),l=document.createElement("strong");l.className="wpcr3_select-results__group";e(l);this.template(n,l);for(var c=[],u=0;u<n.children.length;u++){var p=n.children[u],d=this.option(p);c.push(d)}var h=e("<ul></ul>",{class:"wpcr3_select-results__options wpcr3_select-results__options--nested"});h.append(c),a.append(l),a.append(h)}else this.template(n,r);return t.StoreData(r,"data",n),r},n.prototype.bind=function(n,r){var i=this,s=n.id+"-results"
13
+ ;this.$results.attr("id",s),n.on("results:all",function(e){i.clear(),i.append(e.data),n.isOpen()&&(i.setClasses(),i.highlightFirstItem())}),n.on("results:append",function(e){i.append(e.data),n.isOpen()&&i.setClasses()}),n.on("query",function(e){i.hideMessages(),i.showLoading(e)}),n.on("select",function(){n.isOpen()&&(i.setClasses(),i.highlightFirstItem())}),n.on("unselect",function(){n.isOpen()&&(i.setClasses(),i.highlightFirstItem())}),n.on("open",function(){i.$results.attr("aria-expanded","true"),i.$results.attr("aria-hidden","false"),i.setClasses(),i.ensureHighlightVisible()}),n.on("close",function(){i.$results.attr("aria-expanded","false"),i.$results.attr("aria-hidden","true"),i.$results.removeAttr("aria-activedescendant")}),n.on("results:toggle",function(){var e=i.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),n.on("results:select",function(){var e=i.getHighlightedResults();if(0!==e.length){var n=t.GetData(e[0],"data");"true"==e.attr("aria-selected")?i.trigger("close",{}):i.trigger("select",{data:n})}}),n.on("results:previous",function(){var e=i.getHighlightedResults(),t=i.$results.find("[aria-selected]"),n=t.index(e);if(!(n<=0)){var r=n-1;0===e.length&&(r=0);var s=t.eq(r);s.trigger("mouseenter");var o=i.$results.offset().top,a=s.offset().top,l=i.$results.scrollTop()+(a-o);0===r?i.$results.scrollTop(0):a-o<0&&i.$results.scrollTop(l)}}),n.on("results:next",function(){var e=i.getHighlightedResults(),t=i.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var r=t.eq(n);r.trigger("mouseenter");var s=i.$results.offset().top+i.$results.outerHeight(!1),o=r.offset().top+r.outerHeight(!1),a=i.$results.scrollTop()+o-s;0===n?i.$results.scrollTop(0):o>s&&i.$results.scrollTop(a)}}),n.on("results:focus",function(e){e.element.addClass("wpcr3_select-results__option--highlighted")}),n.on("results:message",function(e){i.displayMessage(e)}),e.fn.mousewheel&&this.$results.on("mousewheel",function(e){
14
+ var t=i.$results.scrollTop(),n=i.$results.get(0).scrollHeight-t+e.deltaY,r=e.deltaY>0&&t-e.deltaY<=0,s=e.deltaY<0&&n<=i.$results.height();r?(i.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):s&&(i.$results.scrollTop(i.$results.get(0).scrollHeight-i.$results.height()),e.preventDefault(),e.stopPropagation())}),this.$results.on("mouseup",".wpcr3_select-results__option[aria-selected]",function(n){var r=e(this),s=t.GetData(this,"data");"true"!==r.attr("aria-selected")?i.trigger("select",{originalEvent:n,data:s}):i.options.get("multiple")?i.trigger("unselect",{originalEvent:n,data:s}):i.trigger("close",{})}),this.$results.on("mouseenter",".wpcr3_select-results__option[aria-selected]",function(n){var r=t.GetData(this,"data");i.getHighlightedResults().removeClass("wpcr3_select-results__option--highlighted"),i.trigger("results:focus",{data:r,element:e(this)})})},n.prototype.getHighlightedResults=function(){return this.$results.find(".wpcr3_select-results__option--highlighted")},n.prototype.destroy=function(){this.$results.remove()},n.prototype.ensureHighlightVisible=function(){var e=this.getHighlightedResults();if(0!==e.length){var t=this.$results.find("[aria-selected]").index(e),n=this.$results.offset().top,r=e.offset().top,i=this.$results.scrollTop()+(r-n),s=r-n;i-=2*e.outerHeight(!1),t<=2?this.$results.scrollTop(0):(s>this.$results.outerHeight()||s<0)&&this.$results.scrollTop(i)}},n.prototype.template=function(t,n){var r=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),s=r(t,n);null==s?n.style.display="none":"string"==typeof s?n.innerHTML=i(s):e(n).append(s)},n}),t.define("wpcr3_select/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),t.define("wpcr3_select/selection/base",["jquery","../utils","../keys"],function(e,t,n){function r(e,t){this.$element=e,this.options=t,r.__super__.constructor.call(this)}
15
+ return t.Extend(r,t.Observable),r.prototype.render=function(){var n=e('<span class="wpcr3_select-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=t.GetData(this.$element[0],"old-tabindex")?this._tabindex=t.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),n.attr("title",this.$element.attr("title")),n.attr("tabindex",this._tabindex),this.$selection=n,n},r.prototype.bind=function(e,t){var r=this,i=(e.id,e.id+"-results");this.container=e,this.$selection.on("focus",function(e){r.trigger("focus",e)}),this.$selection.on("blur",function(e){r._handleBlur(e)}),this.$selection.on("keydown",function(e){r.trigger("keypress",e),e.which===n.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){r.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){r.update(e.data)}),e.on("open",function(){r.$selection.attr("aria-expanded","true"),r.$selection.attr("aria-owns",i),r._attachCloseHandler(e)}),e.on("close",function(){r.$selection.attr("aria-expanded","false"),r.$selection.removeAttr("aria-activedescendant"),r.$selection.removeAttr("aria-owns"),r.$selection.focus(),window.setTimeout(function(){r.$selection.focus()},0),r._detachCloseHandler(e)}),e.on("enable",function(){r.$selection.attr("tabindex",r._tabindex)}),e.on("disable",function(){r.$selection.attr("tabindex","-1")})},r.prototype._handleBlur=function(t){var n=this;window.setTimeout(function(){document.activeElement==n.$selection[0]||e.contains(n.$selection[0],document.activeElement)||n.trigger("blur",t)},1)},r.prototype._attachCloseHandler=function(n){e(document.body).on("mousedown.wpcr3_select."+n.id,function(n){var r=e(n.target).closest(".wpcr3_select");e(".wpcr3_select.wpcr3_select-container--open").each(function(){e(this);this!=r[0]&&t.GetData(this,"element").wpcr3_select("close")})})},r.prototype._detachCloseHandler=function(t){
16
+ e(document.body).off("mousedown.wpcr3_select."+t.id)},r.prototype.position=function(e,t){t.find(".selection").append(e)},r.prototype.destroy=function(){this._detachCloseHandler(this.container)},r.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},r}),t.define("wpcr3_select/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,r){function i(){i.__super__.constructor.apply(this,arguments)}return n.Extend(i,t),i.prototype.render=function(){var e=i.__super__.render.call(this);return e.addClass("wpcr3_select-selection--single"),e.html('<span class="wpcr3_select-selection__rendered"></span><span class="wpcr3_select-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},i.prototype.bind=function(e,t){var n=this;i.__super__.bind.apply(this,arguments);var r=e.id+"-container";this.$selection.find(".wpcr3_select-selection__rendered").attr("id",r).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",r),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),e.on("focus",function(t){e.isOpen()||n.$selection.focus()})},i.prototype.clear=function(){var e=this.$selection.find(".wpcr3_select-selection__rendered");e.empty(),e.removeAttr("title")},i.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},i.prototype.selectionContainer=function(){return e("<span></span>")},i.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".wpcr3_select-selection__rendered"),r=this.display(t,n);n.empty().append(r),n.attr("title",t.title||t.text)}else this.clear()},i}),t.define("wpcr3_select/selection/multiple",["jquery","./base","../utils"],function(e,t,n){function r(e,t){r.__super__.constructor.apply(this,arguments)}return n.Extend(r,t),
17
+ r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("wpcr3_select-selection--multiple"),e.html('<ul class="wpcr3_select-selection__rendered"></ul>'),e},r.prototype.bind=function(t,i){var s=this;r.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){s.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".wpcr3_select-selection__choice__remove",function(t){if(!s.options.get("disabled")){var r=e(this).parent(),i=n.GetData(r[0],"data");s.trigger("unselect",{originalEvent:t,data:i})}})},r.prototype.clear=function(){var e=this.$selection.find(".wpcr3_select-selection__rendered");e.empty(),e.removeAttr("title")},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return e('<li class="wpcr3_select-selection__choice"><span class="wpcr3_select-selection__choice__remove" role="presentation">&times;</span></li>')},r.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],r=0;r<e.length;r++){var i=e[r],s=this.selectionContainer(),o=this.display(i,s);s.append(o),s.attr("title",i.title||i.text),n.StoreData(s[0],"data",i),t.push(s)}var a=this.$selection.find(".wpcr3_select-selection__rendered");n.appendMany(a,t)}},r}),t.define("wpcr3_select/selection/placeholder",["../utils"],function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("wpcr3_select-selection__placeholder").removeClass("wpcr3_select-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(t.length>1||n)return e.call(this,t);this.clear();var r=this.createPlaceholder(this.placeholder)
18
+ ;this.$selection.find(".wpcr3_select-selection__rendered").append(r)},t}),t.define("wpcr3_select/selection/allowClear",["jquery","../keys","../utils"],function(e,t,n){function r(){}return r.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("wpcr3_select: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".wpcr3_select-selection__clear",function(e){r._handleClear(e)}),t.on("keypress",function(e){r._handleKeyboardClear(e,t)})},r.prototype._handleClear=function(e,t){if(!this.options.get("disabled")){var r=this.$selection.find(".wpcr3_select-selection__clear");if(0!==r.length){t.stopPropagation();var i=n.GetData(r[0],"data"),s=this.$element.val();this.$element.val(this.placeholder.id);var o={data:i};if(this.trigger("clear",o),o.prevented)this.$element.val(s);else{for(var a=0;a<i.length;a++)if(o={data:i[a]},this.trigger("unselect",o),o.prevented)return void this.$element.val(s);this.$element.trigger("change"),this.trigger("toggle",{})}}}},r.prototype._handleKeyboardClear=function(e,n,r){r.isOpen()||n.which!=t.DELETE&&n.which!=t.BACKSPACE||this._handleClear(n)},r.prototype.update=function(t,r){if(t.call(this,r),!(this.$selection.find(".wpcr3_select-selection__placeholder").length>0||0===r.length)){var i=e('<span class="wpcr3_select-selection__clear">&times;</span>');n.StoreData(i[0],"data",r),this.$selection.find(".wpcr3_select-selection__rendered").prepend(i)}},r}),t.define("wpcr3_select/selection/search",["jquery","../utils","../keys"],function(e,t,n){function r(e,t,n){e.call(this,t,n)}return r.prototype.render=function(t){var n=e('<li class="wpcr3_select-search wpcr3_select-search--inline"><input class="wpcr3_select-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>')
19
+ ;this.$searchContainer=n,this.$search=n.find("input");var r=t.call(this);return this._transferTabIndex(),r},r.prototype.bind=function(e,r,i){var s=this;e.call(this,r,i),r.on("open",function(){s.$search.trigger("focus")}),r.on("close",function(){s.$search.val(""),s.$search.removeAttr("aria-activedescendant"),s.$search.trigger("focus")}),r.on("enable",function(){s.$search.prop("disabled",!1),s._transferTabIndex()}),r.on("disable",function(){s.$search.prop("disabled",!0)}),r.on("focus",function(e){s.$search.trigger("focus")}),r.on("results:focus",function(e){s.$search.attr("aria-activedescendant",e.id)}),this.$selection.on("focusin",".wpcr3_select-search--inline",function(e){s.trigger("focus",e)}),this.$selection.on("focusout",".wpcr3_select-search--inline",function(e){s._handleBlur(e)}),this.$selection.on("keydown",".wpcr3_select-search--inline",function(e){if(e.stopPropagation(),s.trigger("keypress",e),s._keyUpPrevented=e.isDefaultPrevented(),e.which===n.BACKSPACE&&""===s.$search.val()){var r=s.$searchContainer.prev(".wpcr3_select-selection__choice");if(r.length>0){var i=t.GetData(r[0],"data");s.searchRemoveChoice(i),e.preventDefault()}}});var o=document.documentMode,a=o&&o<=11;this.$selection.on("input.searchcheck",".wpcr3_select-search--inline",function(e){a?s.$selection.off("input.search input.searchcheck"):s.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".wpcr3_select-search--inline",function(e){if(a&&"input"===e.type)s.$selection.off("input.search input.searchcheck");else{var t=e.which;t!=n.SHIFT&&t!=n.CTRL&&t!=n.ALT&&t!=n.TAB&&s.handleSearch(e)}})},r.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},r.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},r.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;(this.$search.attr("placeholder",""),e.call(this,t),
20
+ this.$selection.find(".wpcr3_select-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n)&&(this.$element.find("[data-wpcr3_select-tag]").length?this.$element.focus():this.$search.focus())},r.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var e=this.$search.val();this.trigger("query",{term:e})}this._keyUpPrevented=!1},r.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},r.prototype.resizeSearch=function(){this.$search.css("width","25px");var e="";""!==this.$search.attr("placeholder")?e=this.$selection.find(".wpcr3_select-selection__rendered").innerWidth():e=.75*(this.$search.val().length+1)+"em";this.$search.css("width",e)},r}),t.define("wpcr3_select/selection/eventRelay",["jquery"],function(e){function t(){}return t.prototype.bind=function(t,n,r){var i=this,s=["open","opening","close","closing","select","selecting","unselect","unselecting","clear","clearing"],o=["opening","closing","selecting","unselecting","clearing"];t.call(this,n,r),n.on("*",function(t,n){if(-1!==e.inArray(t,s)){n=n||{};var r=e.Event("wpcr3_select:"+t,{params:n});i.$element.trigger(r),-1!==e.inArray(t,o)&&(n.prevented=r.isDefaultPrevented())}})},t}),t.define("wpcr3_select/translation",["jquery","require"],function(e,t){function n(e){this.dict=e||{}}return n.prototype.all=function(){return this.dict},n.prototype.get=function(e){return this.dict[e]},n.prototype.extend=function(t){this.dict=e.extend({},t.all(),this.dict)},n._cache={},n.loadPath=function(e){if(!(e in n._cache)){var r=t(e);n._cache[e]=r}return new n(n._cache[e])},n}),t.define("wpcr3_select/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE",
21
+ "Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R",
22
+ "Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g",
23
+ "ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w",
24
+ "ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"}}),t.define("wpcr3_select/data/base",["../utils"],function(e){function t(e,n){t.__super__.constructor.call(this)}return e.Extend(t,e.Observable),t.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},t.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},t.prototype.bind=function(e,t){},t.prototype.destroy=function(){},t.prototype.generateResultId=function(t,n){var r=t.id+"-result-";return r+=e.generateChars(4),null!=n.id?r+="-"+n.id.toString():r+="-"+e.generateChars(4),r},t}),t.define("wpcr3_select/data/select",["./base","../utils","jquery"],function(e,t,n){function r(e,t){this.$element=e,this.options=t,r.__super__.constructor.call(this)}return t.Extend(r,e),r.prototype.current=function(e){var t=[],r=this;this.$element.find(":selected").each(function(){var e=n(this),i=r.item(e);t.push(i)}),e(t)},r.prototype.select=function(e){var t=this;if(e.selected=!0,n(e.element).is("option"))return e.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(r){var i=[];(e=[e]).push.apply(e,r);for(var s=0;s<e.length;s++){var o=e[s].id;-1===n.inArray(o,i)&&i.push(o)}t.$element.val(i),t.$element.trigger("change")});else{var r=e.id;this.$element.val(r),this.$element.trigger("change")}},r.prototype.unselect=function(e){var t=this;if(this.$element.prop("multiple")){if(e.selected=!1,n(e.element).is("option"))return e.element.selected=!1,
25
+ void this.$element.trigger("change");this.current(function(r){for(var i=[],s=0;s<r.length;s++){var o=r[s].id;o!==e.id&&-1===n.inArray(o,i)&&i.push(o)}t.$element.val(i),t.$element.trigger("change")})}},r.prototype.bind=function(e,t){var n=this;this.container=e,e.on("select",function(e){n.select(e.data)}),e.on("unselect",function(e){n.unselect(e.data)})},r.prototype.destroy=function(){this.$element.find("*").each(function(){t.RemoveData(this)})},r.prototype.query=function(e,t){var r=[],i=this;this.$element.children().each(function(){var t=n(this);if(t.is("option")||t.is("optgroup")){var s=i.item(t),o=i.matches(e,s);null!==o&&r.push(o)}}),t({results:r})},r.prototype.addOptions=function(e){t.appendMany(this.$element,e)},r.prototype.option=function(e){var r;e.children?(r=document.createElement("optgroup")).label=e.text:void 0!==(r=document.createElement("option")).textContent?r.textContent=e.text:r.innerText=e.text,void 0!==e.id&&(r.value=e.id),e.disabled&&(r.disabled=!0),e.selected&&(r.selected=!0),e.title&&(r.title=e.title);var i=n(r),s=this._normalizeItem(e);return s.element=r,t.StoreData(r,"data",s),i},r.prototype.item=function(e){var r={};if(null!=(r=t.GetData(e[0],"data")))return r;if(e.is("option"))r={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){r={text:e.prop("label"),children:[],title:e.prop("title")};for(var i=e.children("option"),s=[],o=0;o<i.length;o++){var a=n(i[o]),l=this.item(a);s.push(l)}r.children=s}return(r=this._normalizeItem(r)).element=e[0],t.StoreData(e[0],"data",r),r},r.prototype._normalizeItem=function(e){e!==Object(e)&&(e={id:e,text:e});return null!=(e=n.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&null!=this.container&&(e._resultId=this.generateResultId(this.container,e)),n.extend({},{selected:!1,disabled:!1},e)},r.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},r}),
26
+ t.define("wpcr3_select/data/array",["./select","../utils","jquery"],function(e,t,n){function r(e,t){var n=t.get("data")||[];r.__super__.constructor.call(this,e,t),this.addOptions(this.convertToOptions(n))}return t.Extend(r,e),r.prototype.select=function(e){var t=this.$element.find("option").filter(function(t,n){return n.value==e.id.toString()});0===t.length&&(t=this.option(e),this.addOptions(t)),r.__super__.select.call(this,e)},r.prototype.convertToOptions=function(e){var r=this,i=this.$element.find("option"),s=i.map(function(){return r.item(n(this)).id}).get(),o=[];function a(e){return function(){return n(this).val()==e.id}}for(var l=0;l<e.length;l++){var c=this._normalizeItem(e[l]);if(n.inArray(c.id,s)>=0){var u=i.filter(a(c)),p=this.item(u),d=n.extend(!0,{},c,p),h=this.option(d);u.replaceWith(h)}else{var f=this.option(c);if(c.children){var g=this.convertToOptions(c.children);t.appendMany(f,g)}o.push(f)}}return o},r}),t.define("wpcr3_select/data/ajax",["./array","../utils","jquery"],function(e,t,n){function r(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),r.__super__.constructor.call(this,e,t)}return t.Extend(r,e),r.prototype._applyDefaults=function(e){var t={data:function(e){return n.extend({},e,{q:e.term})},transport:function(e,t,r){var i=n.ajax(e);return i.then(t),i.fail(r),i}};return n.extend({},t,e,!0)},r.prototype.processResults=function(e){return e},r.prototype.query=function(e,t){var r=this;null!=this._request&&(n.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var i=n.extend({type:"GET"},this.ajaxOptions);function s(){var s=i.transport(i,function(i){var s=r.processResults(i,e);r.options.get("debug")&&window.console&&console.error&&(s&&s.results&&n.isArray(s.results)||console.error("wpcr3_select: The AJAX results did not return an array in the `results` key of the response.")),t(s)},function(){
27
+ "status"in s&&(0===s.status||"0"===s.status)||r.trigger("results:message",{message:"errorLoading"})});r._request=s}"function"==typeof i.url&&(i.url=i.url.call(this.$element,e)),"function"==typeof i.data&&(i.data=i.data.call(this.$element,e)),this.ajaxOptions.delay&&null!=e.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(s,this.ajaxOptions.delay)):s()},r}),t.define("wpcr3_select/data/tags",["jquery"],function(e){function t(t,n,r){var i=r.get("tags"),s=r.get("createTag");void 0!==s&&(this.createTag=s);var o=r.get("insertTag");if(void 0!==o&&(this.insertTag=o),t.call(this,n,r),e.isArray(i))for(var a=0;a<i.length;a++){var l=i[a],c=this._normalizeItem(l),u=this.option(c);this.$element.append(u)}}return t.prototype.query=function(e,t,n){var r=this;this._removeOldTags(),null!=t.term&&null==t.page?e.call(this,t,function e(i,s){for(var o=i.results,a=0;a<o.length;a++){var l=o[a],c=null!=l.children&&!e({results:l.children},!0);if((l.text||"").toUpperCase()===(t.term||"").toUpperCase()||c)return!s&&(i.data=o,void n(i))}if(s)return!0;var u=r.createTag(t);if(null!=u){var p=r.option(u);p.attr("data-wpcr3_select-tag",!0),r.addOptions([p]),r.insertTag(o,u)}i.results=o,n(i)}):e.call(this,t,n)},t.prototype.createTag=function(t,n){var r=e.trim(n.term);return""===r?null:{id:r,text:r}},t.prototype.insertTag=function(e,t,n){t.unshift(n)},t.prototype._removeOldTags=function(t){this._lastTag;this.$element.find("option[data-wpcr3_select-tag]").each(function(){this.selected||e(this).remove()})},t}),t.define("wpcr3_select/data/tokenizer",["jquery"],function(e){function t(e,t,n){var r=n.get("tokenizer");void 0!==r&&(this.tokenizer=r),e.call(this,t,n)}return t.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".wpcr3_select-search__field")},t.prototype.query=function(t,n,r){var i=this;n.term=n.term||"";var s=this.tokenizer(n,this.options,function(t){var n=i._normalizeItem(t)
28
+ ;if(!i.$element.find("option").filter(function(){return e(this).val()===n.id}).length){var r=i.option(n);r.attr("data-wpcr3_select-tag",!0),i._removeOldTags(),i.addOptions([r])}!function(e){i.trigger("select",{data:e})}(n)});s.term!==n.term&&(this.$search.length&&(this.$search.val(s.term),this.$search.focus()),n.term=s.term),t.call(this,n,r)},t.prototype.tokenizer=function(t,n,r,i){for(var s=r.get("tokenSeparators")||[],o=n.term,a=0,l=this.createTag||function(e){return{id:e.term,text:e.term}};a<o.length;){var c=o[a];if(-1!==e.inArray(c,s)){var u=o.substr(0,a),p=l(e.extend({},n,{term:u}));null!=p?(i(p),o=o.substr(a+1)||"",a=0):a++}else a++}return{term:o}},t}),t.define("wpcr3_select/data/minimumInputLength",[],function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),t.define("wpcr3_select/data/maximumInputLength",[],function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",this.maximumInputLength>0&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),t.define("wpcr3_select/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){var r=this;this.current(function(i){var s=null!=i?i.length:0;r.maximumSelectionLength>0&&s>=r.maximumSelectionLength?r.trigger("results:message",{message:"maximumSelected",args:{maximum:r.maximumSelectionLength}}):e.call(r,t,n)})},e}),t.define("wpcr3_select/dropdown",["jquery","./utils"],function(e,t){function n(e,t){
29
+ this.$element=e,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,t.Observable),n.prototype.render=function(){var t=e('<span class="wpcr3_select-dropdown"><span class="wpcr3_select-results"></span></span>');return t.attr("dir",this.options.get("dir")),this.$dropdown=t,t},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),t.define("wpcr3_select/dropdown/search",["jquery","../utils"],function(e,t){function n(){}return n.prototype.render=function(t){var n=t.call(this),r=e('<span class="wpcr3_select-search wpcr3_select-search--dropdown"><input class="wpcr3_select-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=r,this.$search=r.find("input"),n.prepend(r),n},n.prototype.bind=function(t,n,r){var i=this;t.call(this,n,r),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(t){e(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),n.on("open",function(){i.$search.attr("tabindex",0),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),n.on("close",function(){i.$search.attr("tabindex",-1),i.$search.val(""),i.$search.blur()}),n.on("focus",function(){n.isOpen()||i.$search.focus()}),n.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("wpcr3_select-search--hide"):i.$searchContainer.addClass("wpcr3_select-search--hide"))})},n.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},n.prototype.showSearch=function(e,t){return!0},n}),t.define("wpcr3_select/dropdown/hidePlaceholder",[],function(){function e(e,t,n,r){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),
30
+ e.call(this,t,n,r)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),r=t.length-1;r>=0;r--){var i=t[r];this.placeholder.id===i.id&&n.splice(r,1)}return n},e}),t.define("wpcr3_select/dropdown/infiniteScroll",["jquery"],function(e){function t(e,t,n,r){this.lastParams={},e.call(this,t,n,r),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return t.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},t.prototype.bind=function(t,n,r){var i=this;t.call(this,n,r),n.on("query",function(e){i.lastParams=e,i.loading=!0}),n.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var t=e.contains(document.documentElement,i.$loadingMore[0]);!i.loading&&t&&(i.$results.offset().top+i.$results.outerHeight(!1)+50>=i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)&&i.loadMore())})},t.prototype.loadMore=function(){this.loading=!0;var t=e.extend({},{page:1},this.lastParams);t.page++,this.trigger("query:append",t)},t.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},t.prototype.createLoadingMore=function(){var t=e('<li class="wpcr3_select-results__option wpcr3_select-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),n=this.options.get("translations").get("loadingMore");return t.html(n(this.lastParams)),t},t}),t.define("wpcr3_select/dropdown/attachBody",["jquery","../utils"],function(e,t){function n(t,n,r){this.$dropdownParent=r.get("dropdownParent")||e(document.body),t.call(this,n,r)}return n.prototype.bind=function(e,t,n){var r=this,i=!1;e.call(this,t,n),t.on("open",function(){r._showDropdown(),r._attachPositioningHandler(t),i||(i=!0,t.on("results:all",function(){
31
+ r._positionDropdown(),r._resizeDropdown()}),t.on("results:append",function(){r._positionDropdown(),r._resizeDropdown()}))}),t.on("close",function(){r._hideDropdown(),r._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},n.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},n.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("wpcr3_select"),t.addClass("wpcr3_select-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},n.prototype.render=function(t){var n=e("<span></span>"),r=t.call(this);return n.append(r),this.$dropdownContainer=n,n},n.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},n.prototype._attachPositioningHandler=function(n,r){var i=this,s="scroll.wpcr3_select."+r.id,o="resize.wpcr3_select."+r.id,a="orientationchange.wpcr3_select."+r.id,l=this.$container.parents().filter(t.hasScroll);l.each(function(){t.StoreData(this,"wpcr3_select-scroll-position",{x:e(this).scrollLeft(),y:e(this).scrollTop()})}),l.on(s,function(n){var r=t.GetData(this,"wpcr3_select-scroll-position");e(this).scrollTop(r.y)}),e(window).on(s+" "+o+" "+a,function(e){i._positionDropdown(),i._resizeDropdown()})},n.prototype._detachPositioningHandler=function(n,r){var i="scroll.wpcr3_select."+r.id,s="resize.wpcr3_select."+r.id,o="orientationchange.wpcr3_select."+r.id;this.$container.parents().filter(t.hasScroll).off(i),e(window).off(i+" "+s+" "+o)},n.prototype._positionDropdown=function(){var t=e(window),n=this.$dropdown.hasClass("wpcr3_select-dropdown--above"),r=this.$dropdown.hasClass("wpcr3_select-dropdown--below"),i=null,s=this.$container.offset();s.bottom=s.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=s.top,o.bottom=s.top+o.height;var a=this.$dropdown.outerHeight(!1),l=t.scrollTop(),c=t.scrollTop()+t.height(),u=l<s.top-a,p=c>s.bottom+a,d={left:s.left,top:o.bottom},h=this.$dropdownParent
32
+ ;"static"===h.css("position")&&(h=h.offsetParent());var f=h.offset();d.top-=f.top,d.left-=f.left,n||r||(i="below"),p||!u||n?!u&&p&&n&&(i="below"):i="above",("above"==i||n&&"below"!==i)&&(d.top=o.top-f.top-a),null!=i&&(this.$dropdown.removeClass("wpcr3_select-dropdown--below wpcr3_select-dropdown--above").addClass("wpcr3_select-dropdown--"+i),this.$container.removeClass("wpcr3_select-container--below wpcr3_select-container--above").addClass("wpcr3_select-container--"+i)),this.$dropdownContainer.css(d)},n.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},n.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},n}),t.define("wpcr3_select/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,r){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,r)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,r=0;r<t.length;r++){var i=t[r];i.children?n+=e(i.children):n++}return n}(t.data.results)<this.minimumResultsForSearch)&&e.call(this,t)},e}),t.define("wpcr3_select/dropdown/selectOnClose",["../utils"],function(e){function t(){}return t.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("close",function(e){r._handleSelectOnClose(e)})},t.prototype._handleSelectOnClose=function(t,n){if(n&&null!=n.originalwpcr3_selectEvent){var r=n.originalwpcr3_selectEvent;if("select"===r._type||"unselect"===r._type)return}var i=this.getHighlightedResults();if(!(i.length<1)){var s=e.GetData(i[0],"data");null!=s.element&&s.element.selected||null==s.element&&s.selected||this.trigger("select",{data:s})}},t}),t.define("wpcr3_select/dropdown/closeOnSelect",[],function(){function e(){}
33
+ return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("select",function(e){r._selectTriggered(e)}),t.on("unselect",function(e){r._selectTriggered(e)})},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&n.ctrlKey||this.trigger("close",{originalEvent:n,originalwpcr3_selectEvent:t})},e}),t.define("wpcr3_select/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return 1!=t&&(n+="s"),n},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),t.define("wpcr3_select/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(e,t,n,r,i,s,o,a,l,c,u,p,d,h,f,g,m,_,v,y,w,$,b,A,x,D,E,C,O){function S(){this.reset()}return S.prototype.apply=function(p){if(null==(p=e.extend(!0,{},this.defaults,p)).dataAdapter){if(null!=p.ajax?p.dataAdapter=f:null!=p.data?p.dataAdapter=h:p.dataAdapter=d,p.minimumInputLength>0&&(p.dataAdapter=c.Decorate(p.dataAdapter,_)),p.maximumInputLength>0&&(p.dataAdapter=c.Decorate(p.dataAdapter,v)),
34
+ p.maximumSelectionLength>0&&(p.dataAdapter=c.Decorate(p.dataAdapter,y)),p.tags&&(p.dataAdapter=c.Decorate(p.dataAdapter,g)),null==p.tokenSeparators&&null==p.tokenizer||(p.dataAdapter=c.Decorate(p.dataAdapter,m)),null!=p.query){var O=t(p.amdBase+"compat/query");p.dataAdapter=c.Decorate(p.dataAdapter,O)}if(null!=p.initSelection){var S=t(p.amdBase+"compat/initSelection");p.dataAdapter=c.Decorate(p.dataAdapter,S)}}if(null==p.resultsAdapter&&(p.resultsAdapter=n,null!=p.ajax&&(p.resultsAdapter=c.Decorate(p.resultsAdapter,A)),null!=p.placeholder&&(p.resultsAdapter=c.Decorate(p.resultsAdapter,b)),p.selectOnClose&&(p.resultsAdapter=c.Decorate(p.resultsAdapter,E))),null==p.dropdownAdapter){if(p.multiple)p.dropdownAdapter=w;else{var T=c.Decorate(w,$);p.dropdownAdapter=T}if(0!==p.minimumResultsForSearch&&(p.dropdownAdapter=c.Decorate(p.dropdownAdapter,D)),p.closeOnSelect&&(p.dropdownAdapter=c.Decorate(p.dropdownAdapter,C)),null!=p.dropdownCssClass||null!=p.dropdownCss||null!=p.adaptDropdownCssClass){var q=t(p.amdBase+"compat/dropdownCss");p.dropdownAdapter=c.Decorate(p.dropdownAdapter,q)}p.dropdownAdapter=c.Decorate(p.dropdownAdapter,x)}if(null==p.selectionAdapter){if(p.multiple?p.selectionAdapter=i:p.selectionAdapter=r,null!=p.placeholder&&(p.selectionAdapter=c.Decorate(p.selectionAdapter,s)),p.allowClear&&(p.selectionAdapter=c.Decorate(p.selectionAdapter,o)),p.multiple&&(p.selectionAdapter=c.Decorate(p.selectionAdapter,a)),null!=p.containerCssClass||null!=p.containerCss||null!=p.adaptContainerCssClass){var L=t(p.amdBase+"compat/containerCss");p.selectionAdapter=c.Decorate(p.selectionAdapter,L)}p.selectionAdapter=c.Decorate(p.selectionAdapter,l)}if("string"==typeof p.language)if(p.language.indexOf("-")>0){var j=p.language.split("-")[0];p.language=[p.language,j]}else p.language=[p.language];if(e.isArray(p.language)){var P=new u;p.language.push("en");for(var I=p.language,k=0;k<I.length;k++){var R=I[k],U={};try{U=u.loadPath(R)}catch(e){try{R=this.defaults.amdLanguageBase+R,
35
+ U=u.loadPath(R)}catch(e){p.debug&&window.console&&console.warn&&console.warn('wpcr3_select: The language file for "'+R+'" could not be automatically loaded. A fallback will be used instead.');continue}}P.extend(U)}p.translations=P}else{var M=u.loadPath(this.defaults.amdLanguageBase+"en"),H=new u(p.language);H.extend(M),p.translations=H}return p},S.prototype.reset=function(){function t(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return p[e]||e})}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:c.escapeMarkup,language:O,matcher:function n(r,i){if(""===e.trim(r.term))return i;if(i.children&&i.children.length>0){for(var s=e.extend(!0,{},i),o=i.children.length-1;o>=0;o--)null==n(r,i.children[o])&&s.children.splice(o,1);return s.children.length>0?s:n(r,s)}var a=t(i.text).toUpperCase(),l=t(r.term).toUpperCase();return a.indexOf(l)>-1?i:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},S.prototype.set=function(t,n){var r={};r[e.camelCase(t)]=n;var i=c._convertData(r);e.extend(!0,this.defaults,i)},new S}),t.define("wpcr3_select/options",["require","jquery","./defaults","./utils"],function(e,t,n,r){function i(t,i){if(this.options=t,null!=i&&this.fromElement(i),this.options=n.apply(this.options),i&&i.is("input")){var s=e(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=r.Decorate(this.options.dataAdapter,s)}}return i.prototype.fromElement=function(e){var n=["wpcr3_select"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),
36
+ null==this.options.language&&(e.prop("lang")?this.options.language=e.prop("lang").toLowerCase():e.closest("[lang]").prop("lang")&&(this.options.language=e.closest("[lang]").prop("lang"))),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),r.GetData(e[0],"wpcr3_selectTags")&&(this.options.debug&&window.console&&console.warn&&console.warn('wpcr3_select: The `data-wpcr3_select-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of wpcr3_select.'),r.StoreData(e[0],"data",r.GetData(e[0],"wpcr3_selectTags")),r.StoreData(e[0],"tags",!0)),r.GetData(e[0],"ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("wpcr3_select: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of wpcr3_select."),e.attr("ajax--url",r.GetData(e[0],"ajaxUrl")),r.StoreData(e[0],"ajax-Url",r.GetData(e[0],"ajaxUrl")));var i={};i=t.fn.jquery&&"1."==t.fn.jquery.substr(0,2)&&e[0].dataset?t.extend(!0,{},e[0].dataset,r.GetData(e[0])):r.GetData(e[0]);var s=t.extend(!0,{},i);for(var o in s=r._convertData(s))t.inArray(o,n)>-1||(t.isPlainObject(this.options[o])?t.extend(this.options[o],s[o]):this.options[o]=s[o]);return this},i.prototype.get=function(e){return this.options[e]},i.prototype.set=function(e,t){this.options[e]=t},i}),t.define("wpcr3_select/core",["jquery","./options","./utils","./keys"],function(e,t,n,r){var i=function(e,r){null!=n.GetData(e[0],"wpcr3_select")&&n.GetData(e[0],"wpcr3_select").destroy(),this.$element=e,this.id=this._generateId(e),r=r||{},this.options=new t(r,e),i.__super__.constructor.call(this);var s=e.attr("tabindex")||0;n.StoreData(e[0],"old-tabindex",s),e.attr("tabindex","-1")
37
+ ;var o=this.options.get("dataAdapter");this.dataAdapter=new o(e,this.options);var a=this.render();this._placeContainer(a);var l=this.options.get("selectionAdapter");this.selection=new l(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,a);var c=this.options.get("dropdownAdapter");this.dropdown=new c(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,a);var u=this.options.get("resultsAdapter");this.results=new u(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var p=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(e){p.trigger("selection:update",{data:e})}),e.addClass("wpcr3_select-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),n.StoreData(e[0],"wpcr3_select",this),e.data("wpcr3_select",this)};return n.Extend(i,n.Observable),i.prototype._generateId=function(e){return"wpcr3_select-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+n.generateChars(2):n.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},i.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},i.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var r=this._resolveWidth(e,"style");return null!=r?r:this._resolveWidth(e,"element")}if("element"==t){var i=e.outerWidth(!1);return i<=0?"auto":i+"px"}if("style"==t){var s=e.attr("style");if("string"!=typeof s)return null;for(var o=s.split(";"),a=0,l=o.length;a<l;a+=1){var c=o[a].replace(/\s/g,"").match(n);if(null!==c&&c.length>=1)return c[1]}return null}return t},i.prototype._bindAdapters=function(){
38
+ this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},i.prototype._registerDomEvents=function(){var t=this;this.$element.on("change.wpcr3_select",function(){t.dataAdapter.current(function(e){t.trigger("selection:update",{data:e})})}),this.$element.on("focus.wpcr3_select",function(e){t.trigger("focus",e)}),this._syncA=n.bind(this._syncAttributes,this),this._syncS=n.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var r=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=r?(this._observer=new r(function(n){e.each(n,t._syncA),e.each(n,t._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",t._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",t._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",t._syncS,!1))},i.prototype._registerDataEvents=function(){var e=this;this.dataAdapter.on("*",function(t,n){e.trigger(t,n)})},i.prototype._registerSelectionEvents=function(){var t=this,n=["toggle","focus"];this.selection.on("toggle",function(){t.toggleDropdown()}),this.selection.on("focus",function(e){t.focus(e)}),this.selection.on("*",function(r,i){-1===e.inArray(r,n)&&t.trigger(r,i)})},i.prototype._registerDropdownEvents=function(){var e=this;this.dropdown.on("*",function(t,n){e.trigger(t,n)})},i.prototype._registerResultsEvents=function(){var e=this;this.results.on("*",function(t,n){e.trigger(t,n)})},i.prototype._registerEvents=function(){var e=this;this.on("open",function(){e.$container.addClass("wpcr3_select-container--open")}),this.on("close",function(){e.$container.removeClass("wpcr3_select-container--open")}),this.on("enable",function(){e.$container.removeClass("wpcr3_select-container--disabled")}),
39
+ this.on("disable",function(){e.$container.addClass("wpcr3_select-container--disabled")}),this.on("blur",function(){e.$container.removeClass("wpcr3_select-container--focus")}),this.on("query",function(t){e.isOpen()||e.trigger("open",{}),this.dataAdapter.query(t,function(n){e.trigger("results:all",{data:n,query:t})})}),this.on("query:append",function(t){this.dataAdapter.query(t,function(n){e.trigger("results:append",{data:n,query:t})})}),this.on("keypress",function(t){var n=t.which;e.isOpen()?n===r.ESC||n===r.TAB||n===r.UP&&t.altKey?(e.close(),t.preventDefault()):n===r.ENTER?(e.trigger("results:select",{}),t.preventDefault()):n===r.SPACE&&t.ctrlKey?(e.trigger("results:toggle",{}),t.preventDefault()):n===r.UP?(e.trigger("results:previous",{}),t.preventDefault()):n===r.DOWN&&(e.trigger("results:next",{}),t.preventDefault()):(n===r.ENTER||n===r.SPACE||n===r.DOWN&&t.altKey)&&(e.open(),t.preventDefault())})},i.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},i.prototype._syncSubtree=function(e,t){var n=!1,r=this;if(!e||!e.target||"OPTION"===e.target.nodeName||"OPTGROUP"===e.target.nodeName){if(t)if(t.addedNodes&&t.addedNodes.length>0)for(var i=0;i<t.addedNodes.length;i++){t.addedNodes[i].selected&&(n=!0)}else t.removedNodes&&t.removedNodes.length>0&&(n=!0);else n=!0;n&&this.dataAdapter.current(function(e){r.trigger("selection:update",{data:e})})}},i.prototype.trigger=function(e,t){var n=i.__super__.trigger,r={open:"opening",close:"closing",select:"selecting",unselect:"unselecting",clear:"clearing"};if(void 0===t&&(t={}),e in r){var s=r[e],o={prevented:!1,name:e,args:t};if(n.call(this,s,o),o.prevented)return void(t.prevented=!0)}n.call(this,e,t)},i.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},i.prototype.open=function(){
40
+ this.isOpen()||this.trigger("query",{})},i.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},i.prototype.isOpen=function(){return this.$container.hasClass("wpcr3_select-container--open")},i.prototype.hasFocus=function(){return this.$container.hasClass("wpcr3_select-container--focus")},i.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("wpcr3_select-container--focus"),this.trigger("focus",{}))},i.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('wpcr3_select: The `wpcr3_select("enable")` method has been deprecated and will be removed in later wpcr3_select versions. Use $element.prop("disabled") instead.'),null!=e&&0!==e.length||(e=[!0]);var t=!e[0];this.$element.prop("disabled",t)},i.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('wpcr3_select: Data can no longer be set using `wpcr3_select("data")`. You should consider setting the value instead using `$element.val()`.');var e=[];return this.dataAdapter.current(function(t){e=t}),e},i.prototype.val=function(t){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('wpcr3_select: The `wpcr3_select("val")` method has been deprecated and will be removed in later wpcr3_select versions. Use $element.val() instead.'),null==t||0===t.length)return this.$element.val();var n=t[0];e.isArray(n)&&(n=e.map(n,function(e){return e.toString()})),this.$element.val(n).trigger("change")},i.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),
41
+ this._syncA=null,this._syncS=null,this.$element.off(".wpcr3_select"),this.$element.attr("tabindex",n.GetData(this.$element[0],"old-tabindex")),this.$element.removeClass("wpcr3_select-hidden-accessible"),this.$element.attr("aria-hidden","false"),n.RemoveData(this.$element[0]),this.$element.removeData("wpcr3_select"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},i.prototype.render=function(){var t=e('<span class="wpcr3_select wpcr3_select-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return t.attr("dir",this.options.get("dir")),this.$container=t,this.$container.addClass("wpcr3_select-container--"+this.options.get("theme")),n.StoreData(t[0],"element",this.$element),t},i}),t.define("jquery-mousewheel",["jquery"],function(e){return e}),t.define("jquery.wpcr3_select",["jquery","jquery-mousewheel","./wpcr3_select/core","./wpcr3_select/defaults","./wpcr3_select/utils"],function(e,t,n,r,i){if(null==e.fn.wpcr3_select){var s=["open","close","destroy"];e.fn.wpcr3_select=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var r=e.extend(!0,{},t);new n(e(this),r)}),this;if("string"==typeof t){var r,o=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=i.GetData(this,"wpcr3_select");null==e&&window.console&&console.error&&console.error("The wpcr3_select('"+t+"') method was called on an element that is not using wpcr3_select."),r=e[t].apply(e,o)}),e.inArray(t,s)>-1?this:r}throw new Error("Invalid arguments for wpcr3_select: "+t)}}return null==e.fn.wpcr3_select.defaults&&(e.fn.wpcr3_select.defaults=r),n}),{define:t.define,require:t.require}}(),n=t.require("jquery.wpcr3_select");return e.fn.wpcr3_select.amd=t,n});
42
+
43
+ (function($){
44
+ $(function() {
45
+
46
+ // begin: post meta fields
47
+ var metabox = $('#wpcr3-meta-box');
48
+
49
+ if (metabox.length) {
50
+ var jqfields = metabox.find('input,select,textarea');
51
+ var fields = {};
52
+ jqfields.each(function(i,v){
53
+ v = $(v), id = v.attr('id');
54
+ fields[id] = v;
55
+ });
56
+
57
+ var toggleAllFields = function(show) {
58
+ if (show) { jqfields.not("#wpcr3_enable").parents("tr").show(); }
59
+ else { jqfields.not("#wpcr3_enable").parents("tr").hide(); }
60
+ };
61
+
62
+ var toggleTypeFields = function(type) {
63
+ jqfields.removeAttr('disabled');
64
+ jqfields.filter("[id^=wpcr3_business_], [id^=wpcr3_product_]").parents("tr").hide();
65
+ if (type === "business") { jqfields.filter("[id^=wpcr3_business_]").parents("tr").show(); }
66
+ else if (type === "product") { jqfields.filter("[id^=wpcr3_product_]").parents("tr").show(); }
67
+ jqfields.not(":visible").attr('disabled','disabled');
68
+ };
69
+
70
+ fields.wpcr3_format.change(function(){
71
+ var t = $(this);
72
+ toggleTypeFields(t.val());
73
+ }).change();
74
+
75
+ fields.wpcr3_enable.change(function(){
76
+ var t = $(this), checked = t.is(":checked");
77
+ toggleAllFields(checked);
78
+ if (checked) {
79
+ fields.wpcr3_format.change();
80
+ }
81
+ }).change();
82
+ }
83
+ // end: post meta fields
84
+
85
+ // begin: plugin settings fields
86
+ var options = $('.wpcr3_myplugin_options');
87
+ if (options.length) {
88
+ $('.setting_wpcr3_option_custom_fields input.need_pro').click(function(e){
89
+ e.preventDefault();
90
+ $(this).removeAttr('checked');
91
+ alert('Rating custom fields is available in the pro version.');
92
+ });
93
+
94
+ $('.table_multi_input_checkbox a.addmore').click(function(e){
95
+ e.preventDefault(); var t = $(this);
96
+ if (t.hasClass('need_pro')) {
97
+ alert('Additional custom fields are available in the pro version.');
98
+ return false;
99
+ }
100
+ });
101
+ }
102
+ // end: plugin settings fields
103
+ });
104
+ })(jQuery);
105
+
106
+ function make_stars_from_rating(me) {
107
+ var w = '', html = me.html();
108
+ switch (html) {
109
+ case 'Rated 1 Star':
110
+ w = '20'; break;
111
+ case 'Rated 2 Stars':
112
+ w = '40'; break;
113
+ case 'Rated 3 Stars':
114
+ w = '60'; break;
115
+ case 'Rated 4 Stars':
116
+ w = '80'; break;
117
+ case 'Rated 5 Stars':
118
+ w = '100'; break;
119
+ }
120
+ me.html('<div class="sp_rating"><div class="base"><div class="average" style="width:'+w+'%"></div></div></div>');
121
+ }
js/wp-customer-reviews.js ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var wpcr3 = wpcr3 || {};
2
+ wpcr3.mousemove_total = 0;
3
+ wpcr3.keypress_total = 0;
4
+ wpcr3.mousemove_need = 5;
5
+ wpcr3.keypress_need = 5;
6
+
7
+ wpcr3.getPostUrl = function(elm) {
8
+ var ajaxurl = elm.attr("data-ajaxurl");
9
+ ajaxurl = JSON.parse(ajaxurl);
10
+ ajaxurl = ajaxurl.join('.').replace(/\|/g,'/')
11
+ return ajaxurl;
12
+ };
13
+
14
+ wpcr3.onhover = function() {
15
+ var $ = jQuery;
16
+ $(".wpcr3_respond_2 .wpcr3_rating_stars").unbind("click.wpcr3");
17
+ $(".wpcr3_respond_2 .wpcr3_rating_style1_base").addClass('wpcr3_hide');
18
+ $(".wpcr3_respond_2 .wpcr3_rating_style1_status").removeClass('wpcr3_hide');
19
+ };
20
+
21
+ wpcr3.set_hover = function() {
22
+ var $ = jQuery;
23
+ $(".wpcr3_frating").val("");
24
+ $(".wpcr3_respond_2 .wpcr3_rating_stars").unbind("click.wpcr3");
25
+ wpcr3.onhover();
26
+ };
27
+
28
+ wpcr3.showform = function() {
29
+ var $ = jQuery;
30
+ var t = $(this);
31
+ var parent = t.closest(".wpcr3_respond_1");
32
+
33
+ var btn1 = parent.find(".wpcr3_respond_3 .wpcr3_show_btn");
34
+ var resp2 = parent.find(".wpcr3_respond_2");
35
+ resp2.slideToggle(400, function() {
36
+ parent.find(".wpcr3_table_2").find("input:text:visible:first").focus();
37
+ if (resp2.is(":visible")) {
38
+ btn1.addClass('wpcr3_hide');
39
+ } else {
40
+ btn1.removeClass('wpcr3_hide');
41
+ }
42
+ });
43
+ };
44
+
45
+ wpcr3.ajaxPost = function(parent, data, cb) {
46
+ return jQuery.ajax({
47
+ type : "POST",
48
+ url : wpcr3.getPostUrl(parent),
49
+ data : data,
50
+ dataType : "json",
51
+ success : function(rtn) {
52
+ if (rtn.err.length) {
53
+ rtn.err = rtn.err.join('\n');
54
+ alert(rtn.err);
55
+ wpcr3.enableSubmit();
56
+ return cb(rtn.err);
57
+ }
58
+
59
+ return cb(null, rtn);
60
+ },
61
+ error : function(rtn) {
62
+ alert('An unknown error has occurred. E01');
63
+ wpcr3.enableSubmit();
64
+ }
65
+ });
66
+ };
67
+
68
+ wpcr3.submit = function(e) {
69
+ var $ = jQuery;
70
+ var t = $(this);
71
+ var parent = t.closest(".wpcr3_respond_1");
72
+ e.preventDefault();
73
+
74
+ var div2 = parent.find('.wpcr3_div_2'), submit = div2.find('.wpcr3_submit_btn');
75
+ var c1 = parent.find('.wpcr3_fconfirm1'), c2 = parent.find('.wpcr3_fconfirm2'), c3 = parent.find('.wpcr3_fconfirm3');
76
+ var fake_website = parent.find('.wpcr3_fake_website'), fake_url = parent.find('.wpcr3_fake_url');
77
+
78
+ if (submit.hasClass('wpcr3_disabled')) { return false; }
79
+
80
+ if (wpcr3.mousemove_total <= wpcr3.mousemove_need || wpcr3.keypress_total <= wpcr3.keypress_need) {
81
+ alert('You did not pass our human detection check. Code '+wpcr3.mousemove_total+','+wpcr3.keypress_total);
82
+ return false;
83
+ }
84
+
85
+ var c1_fail = (c1.is(':checked') === true), c2_fail = (c2.is(':checked') === false), c3_fail = (c3.is(':checked') === false);
86
+ var fake_fail = (fake_website.val().length > 0);
87
+ if (c1_fail || c3_fail || fake_fail) {
88
+ alert('You did not pass our bot detection check. Code '+c1_fail+','+c3_fail+','+fake_fail);
89
+ return false;
90
+ }
91
+ if (c2_fail) {
92
+ alert('You must check the box to confirm you are human.');
93
+ return false;
94
+ }
95
+
96
+ var fields = div2.find('input,textarea');
97
+
98
+ var req = [];
99
+ $.each(fields, function(i,v) {
100
+ v = $(v);
101
+ if (v.hasClass('wpcr3_required') && $.trim(v.val()).length === 0) {
102
+ var label = div2.find('label[for="'+v.attr('id')+'"]'), err = '';
103
+ if (label.length) {
104
+ err = $.trim(label.text().replace(':',''))+' is required.';
105
+ } else {
106
+ err = 'A required field has not been filled out.';
107
+ }
108
+ req.push(err);
109
+ }
110
+ });
111
+
112
+ if (req.length > 0) {
113
+ req = req.join("\n");
114
+ alert(req);
115
+ return false;
116
+ }
117
+
118
+ submit.addClass('wpcr3_disabled');
119
+
120
+ var postid = parent.attr("data-postid");
121
+ div2.find('.wpcr3_checkid').remove();
122
+ div2.append('<input type="hidden" name="wpcr3_checkid" class="wpcr3_checkid" value="'+postid+'" />');
123
+ div2.append('<input type="hidden" name="wpcr3_ajaxAct" class="wpcr3_checkid" value="form" />');
124
+ fields = div2.find('input,textarea');
125
+
126
+ var ajaxData = {};
127
+ fields.each(function(i, v) {
128
+ v = $(v), val = v.val();
129
+ if (v.attr('type') === 'checkbox' && v.is(':checked') === false) { val = '0'; }
130
+ ajaxData[v.attr('name')] = val;
131
+ });
132
+
133
+ wpcr3.ajaxPost(parent, ajaxData, function(err, rtn) {
134
+ if (err) { return; }
135
+
136
+ alert('Thank you! Your review has been received and will be posted soon.');
137
+ $(window).scrollTop(0);
138
+ wpcr3.clearFields();
139
+ parent.find(".wpcr3_cancel_btn").click();
140
+ });
141
+ };
142
+
143
+ wpcr3.clearFields = function() {
144
+ var $ = jQuery;
145
+ var div2 = $('.wpcr3_div_2'), fields = div2.find('input,textarea');;
146
+ wpcr3.enableSubmit();
147
+ fields.attr('autocomplete', 'off').not('[type="checkbox"], [type="hidden"]').val('');
148
+ };
149
+
150
+ wpcr3.enableSubmit = function() {
151
+ var $ = jQuery;
152
+ var div2 = $('.wpcr3_div_2'), submit = div2.find('.wpcr3_submit_btn');
153
+ submit.removeClass('wpcr3_disabled');
154
+ };
155
+
156
+ wpcr3.init = function() {
157
+ var $ = jQuery;
158
+
159
+ $(".wpcr3_respond_3 .wpcr3_show_btn, .wpcr3_respond_2 .wpcr3_cancel_btn").click(wpcr3.showform);
160
+
161
+ var evt_1 = 'mousemove.wpcr3 touchmove.wpcr3';
162
+ $(document).bind(evt_1, function() {
163
+ wpcr3.mousemove_total++; if (wpcr3.mousemove_total > wpcr3.mousemove_need) { $(document).unbind(evt_1); }
164
+ });
165
+
166
+ var evt_2 = 'keypress.wpcr3 keydown.wpcr3';
167
+ $(document).bind(evt_2, function() {
168
+ wpcr3.keypress_total++; if (wpcr3.keypress_total > wpcr3.keypress_need) { $(document).unbind(evt_2); }
169
+ });
170
+
171
+ $(".wpcr3_respond_2 .wpcr3_rating_style1_score > div").click(function(e) {
172
+ e.preventDefault();
173
+ e.stopImmediatePropagation();
174
+
175
+ var wpcr3_rating = $(this).html(), new_w = 20 * wpcr3_rating + "%";
176
+ $(".wpcr3_frating").val(wpcr3_rating);
177
+ $(".wpcr3_respond_2 .wpcr3_rating_style1_base").removeClass('wpcr3_hide');
178
+ $(".wpcr3_respond_2 .wpcr3_rating_style1_average").css("width",new_w);
179
+ $(".wpcr3_respond_2 .wpcr3_rating_style1_status").addClass('wpcr3_hide');
180
+
181
+ $(".wpcr3_respond_2 .wpcr3_rating_stars").unbind("mouseover.wpcr3").bind("click.wpcr3", wpcr3.set_hover);
182
+
183
+ return false;
184
+ });
185
+
186
+ $(".wpcr3_respond_2 .wpcr3_rating_stars").bind("mouseover.wpcr3", wpcr3.onhover);
187
+
188
+ var pagingCb = function(e) {
189
+ e.preventDefault();
190
+ var t = $(this);
191
+ if (t.hasClass("wpcr3_disabled")) { return false; }
192
+
193
+ var parent = t.parents(".wpcr3_respond_1:first");
194
+ var pager = t.parents(".wpcr3_pagination:first");
195
+ var reviews = parent.find(".wpcr3_reviews_holder");
196
+ var page = t.attr("data-page");
197
+ var pageOpts = pager.attr("data-page-opts");
198
+ var on_postid = parent.attr("data-on-postid");
199
+
200
+ var ajaxData = { ajaxAct : "pager", on_postid : on_postid, page : page, pageOpts : pageOpts };
201
+ wpcr3.ajaxPost(parent, ajaxData, function(err, rtn) {
202
+ if (err) { return; }
203
+
204
+ reviews.html(rtn.output);
205
+ pager.remove();
206
+ $('html,body').animate({
207
+ scrollTop : (reviews.offset().top - 100)
208
+ });
209
+ });
210
+ };
211
+
212
+ if ($("body").on !== undefined) {
213
+ $(".wpcr3_respond_1").on("click", ".wpcr3_pagination .wpcr3_a", pagingCb);
214
+ } else {
215
+ // support older versions of jQuery
216
+ $(".wpcr3_respond_1 .wpcr3_pagination .wpcr3_a").live("click", pagingCb);
217
+ }
218
+
219
+ var div2 = $('.wpcr3_div_2'), submit = div2.find('.wpcr3_submit_btn');
220
+ submit.click(wpcr3.submit);
221
+
222
+ wpcr3.clearFields();
223
+ };
224
+
225
+ jQuery(function() {
226
+ wpcr3.init();
227
+ });
license.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Go Web Solutions, http://www.gowebsolutions.com/
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
newstars.png DELETED
Binary file
readme.txt CHANGED
@@ -1,104 +1,172 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Customer Reviews ===
2
+ Contributors: bompus
3
+ Donate link: http://www.gowebsolutions.com/wp-customer-reviews/
4
+ Tags: business, google, hcard, schema.org, hproduct, hreview, microformat, microformats, mu, places, plugin, product, rating, ratings, rdfa, review, review box, review widget, reviews, seo, service, snippet, snippets, testimonial, testimonials, widget, wordpressmu, wpmu
5
+ Requires at least: 3.0.0
6
+ Tested up to: 4.9
7
+ Stable tag: 3.1.8
8
+ License: MIT
9
+ License URI: http://opensource.org/licenses/MIT
10
+
11
+ Allows your visitors to leave business / product reviews. Testimonials are in Microdata / Microformat and may display star ratings in search results.
12
+
13
+ == Description ==
14
+
15
+ 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 a product.
16
+
17
+ **Big News! Version 3 has been released.** [Click here for details](http://www.gowebsolutions.com/wp-customer-reviews/?from=wpcr3_directory_notice_1 "Click here for details")
18
+
19
+ * WP Multisite and Multiuser (WPMU / WPMS / Wordpress MU) compatible.
20
+ * All submissions are moderated, which means that YOU choose which reviews get shown.
21
+ * Reviews are displayed to visitors in a friendly format, but search engines see the Schema.org microformat.
22
+ * Multiple anti-spam measures to prevent automated spambots from submitting reviews.
23
+ * Completely customizable, including which fields to ask for, require, and show.
24
+ * Shortcodes available for inserting reviews and review form on any page or widget.
25
+ * Works with caching plugins and custom themes.
26
+ * Includes an external stylesheet so you can modify it to better fit your theme.
27
+ * Reviews can be edited by admin for content and date.
28
+ * Admin responses can be made and shown under each review.
29
+ * Support for adding your own custom fields.
30
+ * The plugin can be used on more than one page, and can be used on posts.
31
+ * Supports both `Business` and `Product` review types.
32
+ * Shows aggregate reviews microformat.
33
+ * Fast and lightweight, even including the star rating image. This plugin will not slow down your blog.
34
+ * Validates as valid XHTML 1.1 (W3C) and valid Microformats (Rich Snippets Testing Tool).
35
+ * And much more...
36
+
37
+ 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.
38
+
39
+ More information at: [**WP Customer Reviews**](http://www.gowebsolutions.com/wp-customer-reviews/)
40
+
41
+ == Installation ==
42
+
43
+ 1. Upload contents of compressed file (wp-customer-reviews) to the `/wp-content/plugins/` directory.
44
+ 2. Activate the plugin through the `Plugins` menu in WordPress admin.
45
+ 3. Create a WordPress page to be used specifically for gathering reviews or testimonials.
46
+ 4. Go into settings for WP Customer Reviews and configure the plugin.
47
+
48
+ == Screenshots ==
49
+
50
+ 1. Front-end display
51
+ 2. Submit a review (1)
52
+ 3. Submit a review (2)
53
+ 4. Admin moderation (1)
54
+ 5. Admin moderation (2)
55
+ 6. Plugin settings
56
+ 7. Submit form settings
57
+ 8. Display settings
58
+ 9. Enabling a page for Business reviews
59
+ 10. Enabling a page for Product reviews
60
+
61
+ == Frequently Asked Questions ==
62
+ * Bug Report / Feature Requests: **Submit from Plugin Settings page**
63
+ * [**Community Support Forum**](http://wordpress.org/tags/wp-customer-reviews?forum_id=10)
64
+
65
+ == Changelog ==
66
+
67
+ = 3.1.9 =
68
+ * 04/02/2018
69
+ * [Update] Allow HIDEREVIEWS=0 to be used in shortcode without needing the (unreleased) Pro version
70
+
71
+ = 3.1.8 =
72
+ * 03/30/2018
73
+ * [Bugfix] Compatibility with PHP 4.3+, apparently people still use PHP 4.3.x and 4.4.x
74
+
75
+ = 3.1.7 =
76
+ * 03/27/2018
77
+ * [Bugfix] To prevent conflicts with other plugins, we renamed our usage of select2 to wpcr3_select2, and are loading it locally instead of via a CDN.
78
+
79
+ = 3.1.6 =
80
+ * 03/24/2018
81
+ * [Update] Significant performance improvements when logged in or using WP admin. Blogs with many review-enabled posts should notice significantly faster page load times.
82
+ * [Bugfix] "Enable WP Customer Reviews for this page" form should now properly initialize when adding new posts. Previously, it only worked properly on existing posts.
83
+
84
+ = 3.1.5 =
85
+ * 11/16/2017
86
+ * [Update] compatible with WP 4.9
87
+
88
+ = 3.1.4 =
89
+ * 10/16/2017
90
+ * [Bugfix] Fixed validation issue which broke AMP
91
+
92
+ = 3.1.3 =
93
+ * 05/31/2017
94
+ * [Bugfix] css typo bug fix
95
+ * [Update] compatible with WP 4.8
96
+
97
+ = 3.1.2 =
98
+ * 04/21/2016
99
+ * [Update] Made activation process simpler
100
+ * [Update] Images losslessly compressed
101
+
102
+ = 3.1.1 =
103
+ * 04/19/2016
104
+ * [Bugfix] Fixed possible issues with WordPress 3.6
105
+
106
+ = 3.1.0 =
107
+ * 04/09/2016
108
+ * [Bugfix] Fixed possible issue with PHP 7.0
109
+
110
+ = 3.0.9 =
111
+ * 04/05/2016
112
+ * [Security] Prevented CSRF and XSS in admin tools.
113
+
114
+ = 3.0.8 =
115
+ * 01/04/2016
116
+ * [Bugfix] Fixed the appearance of a security hole with admin tools. Malicious action was not possible.
117
+ * [Bugfix] Fixed deprecation warning with wpseo_pre_analysis_post_content (Yoast SEO).
118
+
119
+ = 3.0.7 =
120
+ * 11/15/2015
121
+ * [Bugfix] In some installations, ajax requests were still failing. We are reverting to using admin-ajax once again.
122
+
123
+ = 3.0.6 =
124
+ * 11/12/2015
125
+ * [Bugfix] In some installations, a dynamic CSS file could not be written upon plugin activation.
126
+ * [Bugfix] In some installations, ajax requests to admin-ajax were failing. We are trying a new method.
127
+ * [Bugfix] In some installations, the number of reviews displayed for "Average Rating" was inflated.
128
+ * [Bugfix] Email notifications for new reviews were missing a timestamp in the subject line.
129
+ * [Bugfix] When using [WPCR_SHOW POSTID="123"] shortcode on the page ID 123, reviews would output twice.
130
+ * [Bugfix] When a page had 0 reviews, the average rating would show 2.5 stars instead of 0.
131
+ * [Feature] Added PAGINATE and PERPAGE as shortcode options.
132
+
133
+ = 3.0.5 =
134
+ * 10/19/2015
135
+ * [Bugfix] JavaScript will now work with older versions of jQuery
136
+
137
+ = 3.0.4 =
138
+ * 10/18/2015
139
+ * [Bugfix] Fixed post/page saving issue
140
+
141
+ = 3.0.3 =
142
+ * 10/18/2015
143
+ * [Bugfix] Fix for broken JavaScript
144
+
145
+ = 3.0.2 =
146
+ * 10/18/2015
147
+ * [Bugfix] Shortcode copied/pasted itno WP visual editor should now work better
148
+ * [Bugfix] Migrating from 2.x would sometimes duplicate imported reviews ( see "Tools" settings tab for fix )
149
+ * [Bugfix] Migrating from 2.x would sometimes skip importing reviews ( see "Tools" settings tab for fix )
150
+ * [Bugfix] When paginating reviews on the front-end, "reviewed on" page links would sometimes be not linked
151
+ * [Bugfix] Relaxed the human detection anti-spam rules a bit
152
+ * [Bugfix] Fixed "failed the spambot check" issue when WP back-end is SSL, but front-end is not
153
+ * [Bugfix] Fixed some PHP error notices
154
+ * [Bugfix] JavaScript will now work with older versions of jQuery
155
+ * [Update] "Tools" tab added to plugin settings. This will contain various methods for managing/fixing review data.
156
+ * [Update] When adding reviews manually in WP admin, the WP post title now matches user-added reviews
157
+ * [Update] You can now edit the WP post title of reviews
158
+
159
+ = 3.0.1 =
160
+ * 09/29/2015
161
+ * [Update] Enabled for custom post types
162
+ * [Update] Upgrading from 2.x should go smoother for some people
163
+
164
+ = 3.0.0 =
165
+ * 09/10/2015
166
+ * [Update] Complete code cleanup and rewrite
167
+ * [Update] Complete overhaul of settings and management interface
168
+
169
+ == Upgrade Notice ==
170
+
171
+ = 3.0.0 =
172
+ A complete overhaul of the codebase and management interface
red_pen.png DELETED
Binary file
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
screenshot-5.png DELETED
Binary file
star.png DELETED
Binary file
wp-customer-reviews-3.php ADDED
@@ -0,0 +1,1078 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: WP Customer Reviews
4
+ * Plugin URI: http://www.gowebsolutions.com/wp-customer-reviews/
5
+ * Description: Allows your visitors to leave business / product reviews. Testimonials are in Microdata / Microformat and may display star ratings in search results.
6
+ * Version: 3.1.8.1
7
+ * Author: Go Web Solutions
8
+ * Author URI: http://www.gowebsolutions.com/
9
+ * Text Domain: wp-customer-reviews
10
+ * License: MIT
11
+ *
12
+ * Copyright (c) 2017 Go Web Solutions
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in
22
+ * all copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ * THE SOFTWARE.
31
+ *
32
+ */
33
+
34
+ class WPCustomerReviews3 {
35
+ var $debug = false;
36
+ var $prefix = 'wpcr3';
37
+ var $dashname = 'wp-customer-reviews-3';
38
+ var $url = 'http://www.gowebsolutions.com/wp-customer-reviews/';
39
+ var $support_link = 'http://wordpress.org/tags/wp-customer-reviews?forum_id=10';
40
+ var $prolink = 'http://www.gowebsolutions.com/wp-customer-reviews/';
41
+ var $plugin_info = false;
42
+ var $plugin_version = '0.0.0';
43
+ var $adminClass = false;
44
+ var $proClass = false;
45
+ var $pro = false;
46
+ var $force_active_page = false;
47
+ var $options = array();
48
+ var $options_name = 'wpcr3_options';
49
+ var $options_url_slug = 'wpcr3_options';
50
+ var $p = '';
51
+ var $all_templates = array(
52
+ 'frontend_review_holder' => 'html',
53
+ 'frontend_review_form' => 'html',
54
+ 'frontend_review_form_text_field' => 'html',
55
+ 'frontend_review_form_rating_field' => 'html',
56
+ 'frontend_review_form_review_field' => 'html',
57
+ 'frontend_review_item' => 'html',
58
+ 'frontend_review_item_aggregate' => 'html',
59
+ 'frontend_review_item_reviews' => 'html',
60
+ 'frontend_review_pagination' => 'html',
61
+ 'frontend_review_rating_stars' => 'html',
62
+ 'wp-customer-reviews-css' => 'css'
63
+ );
64
+
65
+ function __construct() {
66
+ }
67
+
68
+ function start() {
69
+ $this->debug = (isset($_SERVER) && isset($_SERVER['SERVER_NAME']) && stripos($_SERVER['SERVER_NAME'], 'wptest.bomp') !== FALSE);
70
+
71
+ if ($this->debug === true || $this->remote_debug()) {
72
+ restore_error_handler();
73
+ error_reporting(E_ALL);
74
+ ini_set('error_reporting', E_ALL);
75
+ ini_set('html_errors', TRUE);
76
+ ini_set('display_errors', TRUE);
77
+ }
78
+
79
+ register_activation_hook(__FILE__, array(&$this, 'activate'));
80
+ register_deactivation_hook(__FILE__, array(&$this, 'deactivate'));
81
+
82
+ // we use priority 11 to allow v2 and v3 to coexist
83
+ add_action('init', array(&$this, 'init'), 11);
84
+ }
85
+
86
+ function remote_debug() {
87
+ return isset($_GET['wpcr3_debug']);
88
+ }
89
+
90
+ function plugin_get_info() {
91
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php');
92
+ return get_plugin_data( __FILE__ );
93
+ }
94
+
95
+ function include_goatee() {
96
+ if (!defined('HAS_'.$this->prefix.'_GOATEE')) {
97
+ define('HAS_'.$this->prefix.'_GOATEE', 1);
98
+ include_once($this->getplugindir() . 'include/goatee-php/wpcr-goatee.php'); // include Goatee templating functions
99
+ }
100
+ }
101
+
102
+ function include_pro() {
103
+ if (!defined('HAS_'.$this->prefix.'_PRO')) {
104
+ $pro_file = $this->getplugindir() . '../wp-customer-reviews-pro-activation/wp-customer-reviews-3-pro-inc.php';
105
+ $pro_exists = file_exists($pro_file);
106
+ if ($pro_exists === false) { return; }
107
+
108
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php');
109
+ if (is_plugin_active("wp-customer-reviews-pro-activation/wp-customer-reviews-3-pro.php") === false) { return; }
110
+
111
+ define('HAS_'.$this->prefix.'_PRO', 1);
112
+ include_once($pro_file); // include pro functions
113
+ $this->proClass = new WPCustomerReviews3Pro();
114
+ $this->proClass->start_pro($this);
115
+ }
116
+ }
117
+
118
+ // forward to pro class
119
+ function pro_function() {
120
+ if (!$this->pro) { die("Pro Function called without pro loaded."); }
121
+ $args = func_get_args();
122
+ $function = array_shift($args);
123
+ return call_user_func_array(array($this->proClass,$function), $args);
124
+ }
125
+
126
+ function include_admin() {
127
+ if (!defined('HAS_'.$this->prefix.'_ADMIN')) {
128
+ define('HAS_'.$this->prefix.'_ADMIN', 1);
129
+ include_once($this->getplugindir() . 'include/admin/wp-customer-reviews-3-admin.php'); // include admin functions
130
+ $this->adminClass = new WPCustomerReviewsAdmin3();
131
+ $this->adminClass->start_admin($this);
132
+ }
133
+ }
134
+
135
+ // forward to admin class
136
+ function admin_function() {
137
+ $this->include_admin();
138
+ $args = func_get_args();
139
+ $function = array_shift($args);
140
+ return call_user_func_array(array($this->adminClass,$function), $args);
141
+ }
142
+
143
+ function admin_menu() {
144
+ $this->admin_function('real_admin_menu');
145
+ }
146
+
147
+ function admin_init() {
148
+ $this->admin_function('real_admin_init');
149
+ }
150
+
151
+ // if $this->p->$key does not exist, set it to empty string
152
+ function param($keys, &$object = "") {
153
+ if (!is_array($keys)) { $keys = array($keys); }
154
+ if ($object === "") { $object = $this->p; }
155
+ foreach ($keys as $key) {
156
+ if (is_object($object)) {
157
+ if (!isset($object->$key)) {
158
+ $object->$key = '';
159
+ }
160
+ } else if (is_array($object)) {
161
+ if (!array_key_exists($key, $object)) {
162
+ $object[$key] = '';
163
+ }
164
+ }
165
+ }
166
+ }
167
+
168
+ function get_options() {
169
+ $this->options = get_option($this->options_name);
170
+ }
171
+
172
+ function make_p_obj() {
173
+ $this->p = new stdClass();
174
+
175
+ foreach ($_GET as $c => $val) {
176
+ if (is_array($val)) {
177
+ $this->p->$c = $val;
178
+ } else {
179
+ $this->p->$c = trim(stripslashes($val));
180
+ }
181
+ }
182
+
183
+ foreach ($_POST as $c => $val) {
184
+ if (is_array($val)) {
185
+ $this->p->$c = $val;
186
+ } else {
187
+ $this->p->$c = trim(stripslashes($val));
188
+ }
189
+ }
190
+ }
191
+
192
+ function is_active_page() {
193
+ global $post;
194
+
195
+ // if using WPCR_SHOW, we always force the page active so reviews will output
196
+ if ($this->force_active_page === 'shortcode_show') { return $this->force_active_page; }
197
+
198
+ if ($this->remote_debug()) {
199
+ $debug = "\n <div style='display:none;'>";
200
+ $debug .= "\n wpcr3_info is_active_page() post={$post->ID} is_active_page=";
201
+ $debug .= "".print_r(is_singular(), true);
202
+ $debug .= ",".print_r(is_single(), true);
203
+ $debug .= ",".print_r(is_page(), true);
204
+ $debug .= "\n </div>";
205
+ print $debug;
206
+ }
207
+
208
+ // not on a single post/page, do not output
209
+ if (!is_singular()) { return 0; }
210
+
211
+ $enabled_post = get_post_meta($post->ID, $this->prefix.'_enable', true);
212
+ if ($enabled_post) { return 'enabled'; }
213
+
214
+ return 0;
215
+ }
216
+
217
+ // run after each shortcode has finished
218
+ function reset_active_page() {
219
+ $this->force_active_page = false;
220
+ }
221
+
222
+ function rand_string($length) {
223
+ $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
224
+ $str = '';
225
+
226
+ $size = strlen($chars);
227
+ for ($i = 0; $i < $length; $i++) {
228
+ $str .= $chars[rand(0, $size - 1)];
229
+ }
230
+
231
+ return $str;
232
+ }
233
+
234
+ function get_aggregate_reviews($postid) {
235
+ global $wpdb;
236
+
237
+ $query = $wpdb->prepare("
238
+ SELECT
239
+ COUNT(*) AS aggregate_count, AVG(tmp1.rating) AS aggregate_rating
240
+ FROM
241
+ (
242
+ SELECT pm4.meta_value AS rating
243
+ FROM {$wpdb->prefix}posts p1
244
+ INNER JOIN {$wpdb->prefix}postmeta pm1 ON pm1.meta_key = 'wpcr3_enable' AND pm1.meta_value = '1' AND pm1.post_id = p1.id
245
+ INNER JOIN {$wpdb->prefix}postmeta pm2 ON pm2.meta_key = 'wpcr3_review_post' AND pm2.meta_value = p1.id
246
+ INNER JOIN {$wpdb->prefix}posts p2 ON p2.id = pm2.post_id AND p2.post_status = 'publish' AND p2.post_type = 'wpcr3_review'
247
+ INNER JOIN {$wpdb->prefix}postmeta pm4 ON pm4.post_id = p2.id AND pm4.meta_key = 'wpcr3_review_rating' AND pm4.meta_value IS NOT NULL AND pm4.meta_value != '0'
248
+ WHERE
249
+ p1.id = %d
250
+ GROUP BY p2.id
251
+ ) tmp1
252
+ ", intval($postid));
253
+
254
+ $results = $wpdb->get_results($query);
255
+
256
+ $rtn = new stdClass();
257
+
258
+ if (count($results)) {
259
+ $rtn->aggregate_count = $results[0]->aggregate_count;
260
+ $rtn->aggregate_rating = $results[0]->aggregate_rating;
261
+ if ($rtn->aggregate_count == 0) { $rtn->aggregate_rating = 0; }
262
+ $rtn->stars = $this->get_rating_template($rtn->aggregate_rating, false);
263
+ }
264
+
265
+ return $rtn;
266
+ }
267
+
268
+ // filters show reviews only display for posts that have wpcr enabled on them AND are published
269
+ function reviews_attached_to_enabled_published_posts($where) {
270
+ global $wpdb;
271
+ $where .= "
272
+ AND {$wpdb->prefix}posts.id IN (
273
+ SELECT DISTINCT p2.id FROM {$wpdb->prefix}posts p2
274
+ INNER JOIN {$wpdb->prefix}postmeta pm2 ON pm2.meta_key = 'wpcr3_review_post' AND pm2.post_id = p2.id
275
+ INNER JOIN {$wpdb->prefix}posts p3 ON p3.id = pm2.meta_value AND p3.post_status = 'publish'
276
+ INNER JOIN {$wpdb->prefix}postmeta pm3 ON pm3.meta_key = 'wpcr3_enable' AND pm3.meta_value = '1'
277
+ WHERE p2.post_type = 'wpcr3_review'
278
+ )
279
+ ";
280
+ return $where;
281
+ }
282
+
283
+ function get_reviews($postid, $thispage, $opts) {
284
+ $queryOpts = array(
285
+ 'orderby' => 'date',
286
+ 'order' => 'DESC',
287
+ 'showposts' => min($opts->perpage, $opts->num),
288
+ 'post_type' => $this->prefix.'_review',
289
+ 'post_status' => 'publish',
290
+ 'paged' => $thispage
291
+ );
292
+
293
+ if ($postid != -1) {
294
+ // if $postid is not -1 (all reviews from all posts), need to filter by meta value for post id
295
+ $meta_query = array('relation' => 'AND');
296
+ $meta_query[] = array(
297
+ 'key' => "{$this->prefix}_review_post",
298
+ 'value' => $postid,
299
+ 'compare' => '='
300
+ );
301
+ $queryOpts['meta_query'] = $meta_query;
302
+ }
303
+
304
+ add_filter('posts_where', array(&$this, 'reviews_attached_to_enabled_published_posts'));
305
+ $reviews = new WP_Query($queryOpts);
306
+ remove_filter('posts_where', array(&$this, 'reviews_attached_to_enabled_published_posts'));
307
+
308
+ $rtn = new stdClass();
309
+ $rtn->reviews = array();
310
+ $rtn->found_posts = $reviews->found_posts;
311
+
312
+ foreach ($reviews->posts as $post) {
313
+ $review = $this->get_post_custom_single($post->ID);
314
+
315
+ $review['id'] = $post->ID;
316
+ $review['stars'] = $this->get_rating_template($review[$this->prefix.'_review_rating'], false);
317
+
318
+ $params = array($this->prefix.'_review_name', $this->prefix.'_review_title', $this->prefix.'_review_website', $this->prefix.'_review_admin_response');
319
+ $this->param($params, $review);
320
+
321
+ if ($this->options['standard_fields']['fname']['show'] == 0 || $review[$this->prefix.'_review_name'] == '') {
322
+ $review[$this->prefix.'_review_name'] = 'Anonymous';
323
+ }
324
+
325
+ if ($this->options['standard_fields']['ftitle']['show'] == 0) {
326
+ $review[$this->prefix.'_review_title'] = '';
327
+ }
328
+
329
+ if ($this->options['standard_fields']['fwebsite']['show'] == 0) {
330
+ $review[$this->prefix.'_review_website'] = '';
331
+ }
332
+
333
+ $review[$this->prefix.'_custom_fields'] = array();
334
+
335
+ if ($opts->hidecustom == 0) {
336
+ foreach($this->options['custom_fields'] as $name => $fieldArr) {
337
+ $params = array($this->prefix.'_'.$name);
338
+ $this->param($params, $review);
339
+ $value = trim($review[$this->prefix.'_'.$name]);
340
+ if ($fieldArr['show'] == 1 && strlen($value)) {
341
+ $review[$this->prefix.'_custom_fields'][] = array(
342
+ 'label' => $fieldArr['label'],
343
+ 'value' => $value
344
+ );
345
+ }
346
+ }
347
+ }
348
+
349
+ $review[$this->prefix.'_review_admin_response'] = nl2br($review[$this->prefix.'_review_admin_response']);
350
+
351
+ if ($opts->hideresponse == 1) {
352
+ unset($review[$this->prefix.'_review_admin_response']);
353
+ }
354
+
355
+ $rtn->reviews[] = $review;
356
+ }
357
+
358
+ return $rtn;
359
+ }
360
+
361
+ function iso8601($time=false) {
362
+ if ($time === false) { $time = time(); }
363
+ $date = date('Y-m-d\TH:i:sO', $time);
364
+ return (substr($date, 0, strlen($date) - 2) . ':' . substr($date, -2));
365
+ }
366
+
367
+ function pagination($opts, $thispage, $total_results) {
368
+ $rtn = false;
369
+ $thispage = intval($thispage);
370
+ if ($thispage == 0) { $thispage = 1; }
371
+ $pages = intval(ceil($total_results / $opts->perpage));
372
+
373
+ if ($pages > 1) {
374
+ $rtn = array();
375
+ $rtn['pageOpts'] = htmlspecialchars(json_encode($opts), ENT_QUOTES);
376
+ $rtn['onPage'] = $thispage;
377
+ $rtn['numPages'] = $pages;
378
+ $rtn['pages'] = array();
379
+ $rtn['prevPage'] = max(1, $thispage - 1);
380
+ $rtn['nextPage'] = min($pages, $thispage + 1);
381
+
382
+ $range = 2;
383
+ $showitems = ($range * 2) + 1;
384
+
385
+ $rtn['hasPrev'] = false;
386
+ if ($thispage !== 1) {
387
+ $rtn['hasPrev'] = true;
388
+ }
389
+
390
+ for ($i = 1; $i <= $pages; $i++) {
391
+ if ($i === $thispage) {
392
+ $tmp = array();
393
+ $tmp['pageNum'] = $i;
394
+ $tmp['current'] = true;
395
+ $rtn['pages'][] = $tmp;
396
+ } else if (!($i >= ($thispage + $range + 1) || $i <= ($thispage - $range - 1)) || $pages <= $showitems) {
397
+ $tmp = array();
398
+ $tmp['pageNum'] = $i;
399
+ $tmp['current'] = false;
400
+ $rtn['pages'][] = $tmp;
401
+ }
402
+ }
403
+
404
+ $rtn['hasNext'] = false;
405
+ if ($thispage !== $pages) {
406
+ $rtn['hasNext'] = true;
407
+ }
408
+ }
409
+
410
+ return $rtn;
411
+ }
412
+
413
+ function get_meta_or_default($metaArr, $key, $default) {
414
+ return (isset($metaArr[$key])) ? $metaArr[$key] : $default;
415
+ }
416
+
417
+ function get_post_custom_single($postid) {
418
+ $post = get_post($postid);
419
+ $meta = get_post_custom($postid);
420
+
421
+ $out = array();
422
+ foreach ($meta as $key => $valArr) {
423
+ if ($key === "") { continue; }
424
+ $out[$key] = $valArr[0];
425
+ }
426
+
427
+ if ($post->post_type !== $this->prefix.'_review') {
428
+ $format = $this->get_meta_or_default($out, $this->prefix.'_format', "Blank Format");
429
+ if ($format === 'business') {
430
+ $out['is_business'] = true;
431
+ } else if ($format === 'product') {
432
+ $out['is_product'] = true;
433
+ }
434
+ }
435
+
436
+ $out['content'] = $post->post_content;
437
+
438
+ $post_date = explode(" ",$post->post_date);
439
+ $out['post_date'] = $post_date[0];
440
+ $out['post_date'] = date("M j, Y", strtotime($out['post_date']));
441
+
442
+ return $out;
443
+ }
444
+
445
+ function inject_parent_info($reviews, $postid, $parentData, $opts) {
446
+ foreach($reviews as &$review) {
447
+ $format = $this->get_meta_or_default($parentData, $this->prefix.'_format', "Blank Format");
448
+ if ($format === 'business') {
449
+ $review['is_business'] = true;
450
+ $review['item_name'] = $this->get_meta_or_default($parentData, $this->prefix.'_business_name', "Blank Business Name");
451
+ } else if ($format === 'product') {
452
+ $review['is_product'] = true;
453
+ $review['item_name'] = $this->get_meta_or_default($parentData, $this->prefix.'_product_name', "Blank Product Name");
454
+ }
455
+ $review['postLink'] = get_permalink($postid);
456
+ $review['on_same_page'] = ($opts->on_postid == $postid);
457
+
458
+ if ($opts->snippet > 0) {
459
+ $review['content'] = $this->trim_text_to_word($review, $opts);
460
+ }
461
+ }
462
+
463
+ return $reviews;
464
+ }
465
+
466
+ function output_reviews_show($opts) {
467
+ global $post;
468
+
469
+ // required: showform, num, postid, classes, showsupport
470
+ // optional: hidecustom, hideresponse, snippet, morelink, thispage, ajax, hidereviews, on_postid (internal), wrapper (internal)
471
+
472
+ $params = array('morelink', 'classes', 'on_postid', 'wrapper');
473
+ $this->param($params, $opts);
474
+
475
+ $intArr = array('postid', 'num', 'paginate', 'perpage', 'hidecustom', 'snippet', 'showform', 'hidereviews', 'hideresponse', 'ajax', 'thispage', 'on_postid', 'wrapper');
476
+ foreach ($intArr as $key) {
477
+ $opts->$key = isset($opts->$key) ? $this->strip_trim_intval($opts->$key) : 0;
478
+ }
479
+
480
+ if ($opts->num < 1) { $opts->num = 9999; }
481
+ if ($opts->thispage < 1) { $opts->thispage = 1; }
482
+ if ($opts->perpage < 1) { $opts->perpage = intval($this->options['reviews_per_page']); }
483
+
484
+ $postid = $opts->postid;
485
+ $thispage = $opts->thispage;
486
+
487
+ if ($opts->num > 0 && $opts->num < $opts->perpage) {
488
+ $opts->perpage = $opts->num;
489
+ }
490
+
491
+ if ($opts->ajax == 1) {
492
+ $opts->showform = 0;
493
+ }
494
+
495
+ $this->include_goatee();
496
+
497
+ $tmp = $this->get_reviews($postid, $thispage, $opts);
498
+ $found_posts = $tmp->found_posts;
499
+ $reviews = $tmp->reviews;
500
+ $page_count = count($reviews);
501
+
502
+ $ajaxurl_arr = json_encode(explode(".",str_replace('/','|',$this->getAjaxURL())));
503
+
504
+ $on_postid = $opts->on_postid;
505
+ if (isset($post)) {
506
+ $on_postid = $post->ID;
507
+ }
508
+
509
+ $main_data = array(
510
+ 'classes' => $opts->classes,
511
+ 'review_form' => '',
512
+ 'reviews' => '',
513
+ 'power' => '',
514
+ 'hidereviews' => ($opts->hidereviews == 1),
515
+ 'ajaxurl' => $ajaxurl_arr,
516
+ 'postid' => $postid,
517
+ 'on_postid' => $on_postid
518
+ );
519
+
520
+ $got_post_meta = array();
521
+
522
+ $data['found_posts'] = $found_posts;
523
+
524
+ $pagination = "";
525
+ if ($opts->hidereviews == 0) {
526
+ if ($found_posts > $opts->perpage && $opts->paginate === 1) {
527
+ $pagination = $this->pagination($opts, $thispage, $found_posts);
528
+ $pagination = wpcr_Goatee::fill($this->options['templates']['frontend_review_pagination'], $pagination);
529
+ }
530
+ }
531
+
532
+ if ($opts->showsupport == 1 && $this->options['support_us'] == 1) {
533
+ $main_data['power'] = 'Powered by <strong><a target="_blank" href="'.$this->url.'">'.$this->plugin_info['Name'].'</a></strong>';
534
+ }
535
+
536
+ $main_data['pagination'] = $pagination;
537
+
538
+ if ($postid > 0) {
539
+ // if viewing reviews of a single post id
540
+ $got_post_meta[$postid] = $this->get_post_custom_single($postid);
541
+ $data = &$got_post_meta[$postid];
542
+
543
+ $params = array($this->prefix.'_hideform');
544
+ $this->param($params, $data);
545
+
546
+ $showform = ($opts->showform == 1 && $data[$this->prefix.'_hideform'] != 1);
547
+ $main_data['review_form'] = $this->show_reviews_form($postid, $found_posts, $showform);
548
+
549
+ $reviews = $this->inject_parent_info($reviews, $postid, $data, $opts);
550
+
551
+ $data['on_same_page'] = ($opts->on_postid == $postid);
552
+
553
+ $data['reviews'] = array(
554
+ 'template' => $this->options['templates']['frontend_review_item_reviews'],
555
+ 'data' => array(
556
+ 'reviews' => $reviews
557
+ )
558
+ );
559
+
560
+ $data['aggregate'] = array(
561
+ 'template' => $this->options['templates']['frontend_review_item_aggregate'],
562
+ 'data' => array(
563
+ 'aggregate' => $this->get_aggregate_reviews($postid)
564
+ )
565
+ );
566
+
567
+ $main_data['reviews'] .= wpcr_Goatee::fill($this->options['templates']['frontend_review_item'], $data);
568
+ } else {
569
+ // we are in a shortcode/widget that is showing reviews for multiple posts
570
+ // so we need to fill $got_post_meta with the post meta related to each $review
571
+ foreach ($reviews as $review) {
572
+ $review_of_postid = intval($review[$this->prefix.'_review_post']);
573
+
574
+ if (!array_key_exists($review_of_postid, $got_post_meta)) {
575
+ $got_post_meta[$review_of_postid] = $this->get_post_custom_single($review_of_postid);
576
+ }
577
+
578
+ $data = &$got_post_meta[$review_of_postid];
579
+
580
+ $tmpReviews = array($review);
581
+ $tmpReview = $this->inject_parent_info($tmpReviews, $review_of_postid, $data, $opts);
582
+ $review = $tmpReview[0];
583
+
584
+ // 1. no aggregate shown for multiple businesses/products as it would confuse crawlers which one to show in SERPs
585
+ // 2. no form shown for showing "all" reviews because we don't know what post to bind the form to
586
+
587
+ if ($opts->hidereviews == 0) {
588
+ $data['reviews'] = array(
589
+ 'template' => $this->options['templates']['frontend_review_item_reviews'],
590
+ 'data' => array(
591
+ 'reviews' => array($review)
592
+ )
593
+ );
594
+ }
595
+
596
+ $main_data['reviews'] .= wpcr_Goatee::fill($this->options['templates']['frontend_review_item'], $data);
597
+ }
598
+ }
599
+
600
+ // Useful info: http://wordpress.stackexchange.com/a/39928 ( faster way to get meta values for many posts )
601
+ // Useful info: http://stackoverflow.com/a/18422969 ( outputting multiple ratings for one item )
602
+
603
+ $reviews_content = wpcr_Goatee::fill($this->options['templates']['frontend_review_holder'], $main_data);
604
+ $reviews_content = preg_replace('/\n\r|\r\n|\n|\r|\t/', '', $reviews_content); // minify to prevent automatic line breaks, not removing double spaces
605
+
606
+ if ($opts->wrapper === 1) {
607
+ $data_attr = $this->get_data_attr_wrapper($postid);
608
+ $reviews_content = "<div {$data_attr}>".$reviews_content."</div>";
609
+ }
610
+
611
+ return $reviews_content;
612
+ }
613
+
614
+ // stripts html then trims text, but does not break up a word
615
+ function trim_text_to_word($review, $opts) {
616
+ $text = $review['content'];
617
+ $text = str_replace("<br", " <br", $text);
618
+ $text = trim(strip_tags($text));
619
+ $len = $opts->snippet;
620
+
621
+ if (strlen($text) > $len) {
622
+ preg_match('/^.{0,'.$len.'}(?:.*?)\b/siu', $text, $matches);
623
+ $text = $matches[0] . "... ";
624
+ if (strlen(trim($opts->morelink)) > 0) {
625
+ $postLink = $review['postLink']."#wpcr3_id_".$review['id'];
626
+ $text .= "<a href='{$postLink}'>$opts->morelink</a>";
627
+ }
628
+ }
629
+ return $text;
630
+ }
631
+
632
+ function print_filters_for($hook = '') {
633
+ global $wp_filter;
634
+ if( empty( $hook ) || !isset( $wp_filter[$hook] ) ) { return; }
635
+ print '<pre>';
636
+ print_r( $wp_filter[$hook] );
637
+ print '</pre>';
638
+ }
639
+
640
+ function get_data_attr_wrapper($postid) {
641
+ return "data-wpcr3-content=\"{$postid}\"";
642
+ }
643
+
644
+ /*
645
+ function do_the_content_wpseo($original_content) {
646
+ return $this->do_the_content($original_content, 'wpseo');
647
+ }
648
+ */
649
+
650
+ function do_the_content($original_content, $fix = "wp") {
651
+ global $post;
652
+
653
+ if ($this->remote_debug()) {
654
+ $debug = "\n<div style='display:none;'>wpcr3_info top_start</div>\n";
655
+ $debug .= "\n<div style='display:none;'>wpcr3_info fix={$fix}</div>\n";
656
+ $debug .= "\n<div style='display:none;'>wpcr3_info original_content={$original_content}</div>\n";
657
+ $debug .= "\n<div style='display:none;'>wpcr3_info top_end</div>\n";
658
+ print $debug;
659
+ }
660
+
661
+ if (!isset($post) || !isset($post->ID) || intval($post->ID) == 0) {
662
+ // we need a post object to do anything useful
663
+
664
+ if ($this->remote_debug()) {
665
+ $debug = "\n<div style='display:none;'>wpcr3_info no post id fix={$fix}</div>\n";
666
+ $debug .= "\n<div style='display:none;'>wpcr3_info above returned from filter 1</div>\n";
667
+ print $debug;
668
+ }
669
+
670
+ return $original_content;
671
+ }
672
+
673
+ $postid = $post->ID;
674
+ $data_attr = $this->get_data_attr_wrapper($postid);
675
+ $already_ran = (strpos($original_content, $data_attr) !== FALSE) ? 1 : 0;
676
+
677
+ if ($this->remote_debug()) {
678
+ $debug = "\n <div style='display:none;'>";
679
+ $debug .= "\n wpcr3_info postid={$postid} fix={$fix} already_ran={$already_ran} strlen=".strlen($original_content);
680
+ $debug .= "\n </div>";
681
+ print $debug;
682
+ }
683
+
684
+ // return original content if reviews should not display for this post
685
+ $is_active_page = $this->is_active_page();
686
+
687
+ if ($this->remote_debug()) {
688
+ $debug = "\n <div style='display:none;'>wpcr3_info post={$post->ID} fix={$fix} already_ran={$already_ran} is_active_page={$is_active_page}</div> \n";
689
+ $debug .= "\n <div style='display:none;'>wpcr3_info above returned from filter 2</div> \n";
690
+ print $debug;
691
+ }
692
+
693
+ if ($already_ran === 1 || $is_active_page === 0) {
694
+ return $original_content;
695
+ }
696
+
697
+ if ($this->remote_debug()) {
698
+ $debug = "\n <div style='display:none;'>wpcr3_info on_active_page post={$post->ID} fix={$fix} is_active_page={$is_active_page}</div> \n";
699
+ $debug .= "\n <div style='display:none;'>wpcr3_info above returned from filter 3</div> \n";
700
+ print $debug;
701
+ }
702
+
703
+ $this->reset_active_page();
704
+
705
+ $hideform = get_post_meta($post->ID, $this->prefix.'_hideform', true);
706
+ $showform = ($hideform !== "1");
707
+
708
+ $opts = new stdClass();
709
+ $opts->showform = $showform;
710
+ $opts->showsupport = $this->options['support_us'];
711
+ $opts->postid = $postid;
712
+ $opts->perpage = $this->options['reviews_per_page'];
713
+ $opts->paginate = 1;
714
+ $opts->classes = $this->prefix."_in_content";
715
+ $opts->wrapper = 1;
716
+
717
+ $reviews_content = $this->output_reviews_show($opts);
718
+ $original_content .= $reviews_content;
719
+ return $original_content;
720
+ }
721
+
722
+ function get_rating_template($rating, $enable_hover) {
723
+ $data = array(
724
+ 'hoverable' => $enable_hover,
725
+ 'stars' => $rating,
726
+ 'rating_width' => 20 * $rating // 20% for each star if having 5 stars
727
+ );
728
+ return wpcr_Goatee::fill($this->options['templates']['frontend_review_rating_stars'], $data);
729
+ }
730
+
731
+ function get_form_field($name, $fieldArr) {
732
+ $posted_name = $this->prefix.'_'.$name;
733
+
734
+ $params = array($posted_name);
735
+ $this->param($params);
736
+
737
+ $required = ($fieldArr['require'] == 1);
738
+ $data = array(
739
+ 'name' => $this->prefix.'_'.$name,
740
+ 'label' => $fieldArr['label'],
741
+ 'required' => $required ? '*' : '',
742
+ 'class' => $required ? $this->prefix.'_required' : '',
743
+ 'value' => $this->p->$posted_name
744
+ );
745
+ $field = wpcr_Goatee::fill($this->options['templates']['frontend_review_form_text_field'], $data);
746
+ return $field;
747
+ }
748
+
749
+ function get_rating_field() {
750
+ $data = array(
751
+ 'rating_stars' => $this->get_rating_template(0, true)
752
+ );
753
+ $field = wpcr_Goatee::fill($this->options['templates']['frontend_review_form_rating_field'], $data);
754
+ return $field;
755
+ }
756
+
757
+ function get_review_field() {
758
+ $posted_name = $this->prefix.'_ftext';
759
+
760
+ $params = array($posted_name);
761
+ $this->param($params);
762
+
763
+ $data = array(
764
+ 'value' => $this->p->$posted_name
765
+ );
766
+ $field = wpcr_Goatee::fill($this->options['templates']['frontend_review_form_review_field'], $data);
767
+ return $field;
768
+ }
769
+
770
+ // currently, because of how JS "wpcr3" object works, we can only display one form on a single page. To fix, we would need to make "wpcr3" a "new wpcr3();"
771
+ function show_reviews_form($postid, $found_posts, $showform) {
772
+ $input_fields = '';
773
+
774
+ foreach($this->options['standard_fields'] as $name => $fieldArr) {
775
+ if ($fieldArr["ask"] == 1) {
776
+ $input_fields .= $this->get_form_field($name, $fieldArr);
777
+ }
778
+ }
779
+
780
+ foreach($this->options['custom_fields'] as $name => $fieldArr) {
781
+ if ($fieldArr["ask"] == 1) {
782
+ $input_fields .= $this->get_form_field($name, $fieldArr);
783
+ }
784
+ }
785
+
786
+ $has_required_fields = strpos($input_fields, $this->prefix.'_required') !== false;
787
+ $rating_field = $this->get_rating_field();
788
+ $review_field = $this->get_review_field();
789
+
790
+ $data = array(
791
+ 'input_fields' => $input_fields,
792
+ 'rating_field' => $rating_field,
793
+ 'review_field' => $review_field,
794
+ 'has_required_fields' => $has_required_fields,
795
+ 'postid' => $postid,
796
+ 'found_posts' => $found_posts,
797
+ 'showform' => $showform
798
+ );
799
+
800
+ return wpcr_Goatee::fill($this->options['templates']['frontend_review_form'], $data);
801
+ }
802
+
803
+ function generateTitle($fname) {
804
+ $fname = (strlen($fname) === 0) ? 'Anonymous' : $fname;
805
+ $datetime = date('m/d/Y h:i');
806
+ return "{$fname} @ {$datetime}";
807
+ }
808
+
809
+ function css() {
810
+ header('Content-type: text/css');
811
+ die($this->template('wp-customer-reviews-css'));
812
+ }
813
+
814
+ function ajax() {
815
+ header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
816
+ header("Cache-Control: post-check=0, pre-check=0", false);
817
+ header("Pragma: no-cache");
818
+ header('Content-type: application/json');
819
+
820
+ $rtn = new stdClass();
821
+ $rtn->err = array();
822
+ $rtn->success = false;
823
+
824
+ $posted = new stdClass();
825
+ foreach ($this->p as $k => $v) {
826
+ $k = str_replace($this->prefix.'_', '', $k);
827
+ $posted->$k = trim(strip_tags($v));
828
+ }
829
+
830
+ $params = array('checkid', 'postid', 'on_postid', 'fname', 'femail', 'ajaxAct', 'page', 'pageOpts');
831
+ $this->param($params, $posted);
832
+
833
+ $cookieName = $this->prefix.'_checkid';
834
+
835
+ if ($posted->ajaxAct === 'cookie') {
836
+ setcookie($cookieName, $posted->postid);
837
+ } else if ($posted->ajaxAct === 'form') {
838
+ if ($posted->checkid != $posted->postid) { $rtn->err[] = 'You have failed the spambot check. Code 1'; }
839
+
840
+ // if (!isset($_COOKIE[$cookieName])) { $rtn->err[] = 'You have failed the spambot check. Code 2'; }
841
+ // if ($posted->checkid != $_COOKIE[$cookieName]) { $rtn->err[] = 'You have failed the spambot check. Code 3'; }
842
+
843
+ if ($posted->fconfirm1 != '0') { $rtn->err[] = 'You have failed the spambot check. Code 4'; }
844
+ if ($posted->fconfirm2 != '1') { $rtn->err[] = 'You have failed the spambot check. Code 5'; }
845
+ if ($posted->fconfirm3 != '1') { $rtn->err[] = 'You have failed the spambot check. Code 6'; }
846
+ if ($posted->url != '') { $rtn->err[] = 'You have failed the spambot check. Code 7'; }
847
+ if ($posted->website != '') { $rtn->err[] = 'You have failed the spambot check. Code 8'; }
848
+ if ($posted->femail != '' && filter_var($posted->femail, FILTER_VALIDATE_EMAIL) == false) { $rtn->err[] = 'Please enter a valid email address.'; }
849
+
850
+ // remove the cookie
851
+ setcookie($cookieName, "", time()-3600);
852
+
853
+ if (count($rtn->err)) { die(json_encode($rtn)); } // die here if we failed any spambot checks
854
+
855
+ // passed all spambot checks, continue
856
+
857
+ $title = $this->generateTitle($posted->fname);
858
+
859
+ $newpost = array(
860
+ 'post_author' => 1,
861
+ 'post_date' => date('Y-m-d H:i:s'),
862
+ 'post_content' => nl2br($posted->ftext),
863
+ 'post_status' => 'pending',
864
+ 'post_title' => $title,
865
+ 'post_type' => $this->prefix.'_review'
866
+ );
867
+ $newpostid = wp_insert_post($newpost, true);
868
+
869
+ update_post_meta($newpostid, $this->prefix.'_review_ip', $_SERVER['REMOTE_ADDR']);
870
+
871
+ if (isset($posted->postid)) { update_post_meta($newpostid, $this->prefix.'_review_post', $posted->postid); }
872
+ if (isset($posted->fname)) { update_post_meta($newpostid, $this->prefix.'_review_name', $posted->fname); }
873
+ if (isset($posted->femail)) { update_post_meta($newpostid, $this->prefix.'_review_email', $posted->femail); }
874
+ if (isset($posted->frating)) { update_post_meta($newpostid, $this->prefix.'_review_rating', $posted->frating); }
875
+ if (isset($posted->ftitle)) { update_post_meta($newpostid, $this->prefix.'_review_title', $posted->ftitle); }
876
+ if (isset($posted->fwebsite)) { update_post_meta($newpostid, $this->prefix.'_review_website', $posted->fwebsite); }
877
+
878
+ foreach($this->options['custom_fields'] as $name => $fieldArr) {
879
+ if ($fieldArr['ask'] == 1 && isset($posted->$name)) {
880
+ update_post_meta($newpostid, $this->prefix.'_'.$name, $posted->$name);
881
+ }
882
+ }
883
+
884
+ $datetime = date('m/d/Y h:i');
885
+ @wp_mail(get_bloginfo('admin_email'), "WP Customer Reviews: New Review Posted on {$datetime}", "A new review has been posted on ".get_bloginfo('name')." via WP Customer Reviews. \n\nYou will need to approve this review before it will appear on your site.");
886
+ } else if ($posted->ajaxAct === "pager") {
887
+ $opts = json_decode($posted->pageOpts);
888
+ $opts->thispage = $posted->page;
889
+ $opts->ajax = 1;
890
+ $opts->showsupport = 0;
891
+ $opts->on_postid = $posted->on_postid;
892
+ $rtn->output = $this->output_reviews_show($opts);
893
+ }
894
+
895
+ $rtn->success = true;
896
+ die(json_encode($rtn));
897
+ }
898
+
899
+ function getAjaxURL() {
900
+ return admin_url('admin-ajax.php').'?action=wpcr3-ajax';
901
+ //return $this->getpluginurl()."include/ajax.php";
902
+ }
903
+
904
+ // used in extended classes to grab already-set information we care about from main class
905
+ function setSharedVars($parentClass) {
906
+ $this->plugin_info = &$parentClass->plugin_info; // array by &reference
907
+ $this->plugin_version = $this->plugin_info["Version"];
908
+ $this->pro = $parentClass->pro;
909
+
910
+ $this->options = &$parentClass->options; // array by &reference
911
+ $this->p = $parentClass->p; // object is already by &reference
912
+ }
913
+
914
+ function can_write_css() {
915
+ $filename = $this->getplugindir().'css/wp-customer-reviews-generated.css';
916
+ return array("filename" => $filename, "can_write" => is_writeable($filename));
917
+ }
918
+
919
+ function init() {
920
+ $this->include_pro();
921
+
922
+ add_action('admin_menu', array(&$this, 'admin_menu')); // adding menu items to admin must be done in admin_menu which gets executed BEFORE admin_init
923
+ add_action('admin_init', array(&$this, 'admin_init'));
924
+ add_filter('the_content', array(&$this, 'do_the_content'), 15); // prio 15 makes sure this hits after wptexturize and other garbage that likes to destroy our output
925
+
926
+ // "Wordpress SEO - Yoast" hijacks the_content and breaks all kinds of plugins
927
+ // luckily they provide a filter to fix it
928
+ // add_filter('wpseo_pre_analysis_post_content', array(&$this, 'do_the_content_wpseo'), 15);
929
+
930
+ // $this->print_filters_for('the_content'); exit();
931
+
932
+ add_action('wp_ajax_'.$this->prefix.'-ajax', array(&$this, 'ajax'));
933
+ add_action('wp_ajax_nopriv_'.$this->prefix.'-ajax', array(&$this, 'ajax'));
934
+
935
+ $this->plugin_info = $this->plugin_get_info();
936
+ $this->plugin_version = $this->plugin_info["Version"];
937
+
938
+ $this->make_p_obj(); // make P variables object
939
+ $this->get_options(); // populate the options array
940
+ $this->create_post_type();
941
+
942
+ // remove any existing shortcode to allow v2 and v3 to coexist
943
+ remove_shortcode('WPCR_INSERT');
944
+ remove_shortcode('WPCR_SHOW');
945
+
946
+ add_shortcode('WPCR_INSERT', array(&$this, 'shortcode_insert'));
947
+ add_shortcode('WPCR_SHOW', array(&$this, 'shortcode_show'));
948
+ add_shortcode('WPCR_HCARD', array(&$this, 'shortcode_hcard')); // deprecated, returns blank
949
+
950
+ // we insert styles/scripts in init because some themes are horrible
951
+
952
+ $can_write_css = $this->can_write_css();
953
+ if ($can_write_css["can_write"] === true) {
954
+ wp_register_style('wp-customer-reviews-3-frontend', $this->getpluginurl() . 'css/wp-customer-reviews-generated.css', array(), $this->plugin_version);
955
+ } else {
956
+ wp_register_style('wp-customer-reviews-3-frontend', $this->getpluginurl() . 'css/wp-customer-reviews-generated.css.php', array(), $this->plugin_version);
957
+ }
958
+
959
+ wp_register_style('wp-customer-reviews-3-frontend', $this->getpluginurl() . 'css/wp-customer-reviews-generated.css', array(), $this->plugin_version);
960
+ wp_register_script('wp-customer-reviews-3-frontend', $this->getpluginurl() . 'js/wp-customer-reviews.js', array('jquery'), $this->plugin_version);
961
+ wp_enqueue_style('wp-customer-reviews-3-frontend');
962
+ wp_enqueue_script('wp-customer-reviews-3-frontend');
963
+ }
964
+
965
+ function create_post_type() {
966
+ $defaults1 = array(
967
+ 'labels' => array(),
968
+ 'public' => false,
969
+ 'exclude_from_search' => true,
970
+ 'publicly_queryable' => false,
971
+ 'show_in_nav_menus' => false,
972
+ 'show_ui' => true,
973
+ 'show_in_menu' => $this->prefix.'_view_reviews',
974
+ 'menu_position' => 25,
975
+ 'show_in_admin_bar' => false,
976
+ 'has_archive' => false,
977
+ 'rewrite' => false,
978
+ 'supports' => array('title'),
979
+ 'map_meta_cap' => true
980
+ );
981
+
982
+ $defaults2 = $defaults1;
983
+ $defaults2['labels'] = array(
984
+ 'name' => 'WP Customer Reviews',
985
+ 'singular_name' => 'Review',
986
+ 'menu_name' => 'All Reviews',
987
+ 'add_new_item' => 'Add New Customer Review',
988
+ 'edit_item' => 'Edit Customer Review',
989
+ 'new_item' => 'New Customer Review',
990
+ 'view_item' => 'View Customer Review',
991
+ 'search_items' => 'Search Customer Reviews',
992
+ 'not_found' => 'No Reviews Found',
993
+ 'not_found_in_trash' => 'No Reviews Found in Trash'
994
+ );
995
+ $defaults2['supports'] = array('title', 'editor');
996
+ $err = register_post_type($this->prefix.'_review', $defaults2);
997
+ }
998
+
999
+ function shortcode_insert() {
1000
+ $this->force_active_page = 'shortcode_insert';
1001
+ return $this->do_the_content('', 'shortcode_insert');
1002
+ }
1003
+
1004
+ function strip_trim($val) {
1005
+ return trim(strip_tags($val));
1006
+ }
1007
+
1008
+ function strip_trim_intval($val) {
1009
+ return intval($this->strip_trim($val));
1010
+ }
1011
+
1012
+ function shortcode_show($atts) {
1013
+ $attArr = shortcode_atts(array(
1014
+ 'postid' => 'all', 'num' => 5, 'paginate' => 1, 'perpage' => 5, 'hidecustom' => 0, 'snippet' => 0,
1015
+ 'more' => '', 'showform' => 1, 'hidereviews' => 0, 'hideresponse' => 0
1016
+ ), $atts);
1017
+
1018
+ $opts = new stdClass();
1019
+ foreach ($attArr as $key => $val) {
1020
+ $opts->$key = $val;
1021
+ }
1022
+
1023
+ $opts->postid = $this->strip_trim($opts->postid);
1024
+
1025
+ if (strtolower($opts->postid) == 'all') { $opts->postid = -1; } // -1 queries all reviews
1026
+ $opts->morelink = $opts->more;
1027
+
1028
+ $intArr = array('postid', 'num', 'paginate', 'perpage', 'hidecustom', 'snippet', 'showform', 'hidereviews', 'hideresponse');
1029
+ foreach ($intArr as $key) {
1030
+ $opts->$key = isset($opts->$key) ? $this->strip_trim_intval($opts->$key) : 0;
1031
+ }
1032
+
1033
+ if ($opts->postid === -1) { $opts->showform = 0; } // do not show form if postid is "all"
1034
+ $opts->showsupport = 0;
1035
+ if ($opts->showform == 1) { $opts->showsupport = 1; }
1036
+
1037
+ $opts->wrapper = 1;
1038
+
1039
+ return $this->output_reviews_show($opts);
1040
+ }
1041
+
1042
+ // deprecated, returns blank
1043
+ function shortcode_hcard($atts) {
1044
+ return '';
1045
+ }
1046
+
1047
+ function activate() {
1048
+ add_option($this->prefix.'_gotosettings', true); // used for redirecting to settings page upon initial activation
1049
+ }
1050
+
1051
+ function deactivate() {
1052
+ // do not fire on upgrading plugin or upgrading WP - only on true manual deactivation
1053
+ if (isset($this->p->action) && $this->p->action == 'deactivate') {
1054
+ $this->admin_function('notify_activate', 2);
1055
+ }
1056
+ }
1057
+
1058
+ function template($name) {
1059
+ return $this->options['templates'][$name];
1060
+ }
1061
+
1062
+ function getpluginurl() {
1063
+ return trailingslashit(plugins_url(basename(dirname(__FILE__))));
1064
+ }
1065
+
1066
+ function getplugindir() {
1067
+ return trailingslashit(WP_PLUGIN_DIR . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
1068
+ }
1069
+ }
1070
+
1071
+ function start_wpcr3() {
1072
+ $WPCustomerReviews3 = new WPCustomerReviews3();
1073
+ $WPCustomerReviews3->start();
1074
+ return $WPCustomerReviews3;
1075
+ }
1076
+
1077
+ $WPCustomerReviews3 = start_wpcr3();
1078
+ ?>
wp-customer-reviews-admin.css DELETED
@@ -1,49 +0,0 @@
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 DELETED
@@ -1,777 +0,0 @@
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 DELETED
@@ -1,1224 +0,0 @@
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 DELETED
@@ -1,191 +0,0 @@
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 DELETED
@@ -1,151 +0,0 @@
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 DELETED
@@ -1,1344 +0,0 @@
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
- ?>