WP Review - Version 3.0

Version Description

  • Major security updates
  • New AJAXified Tab widget for Popular and Recent reviews, try it, you gonna love it.
  • Language file updated fully.
  • Added a nonce (a security token) to ensure that the user actually voted from the review
  • More developer possibilities
  • Added filters for developers. Using a filter is much better than a function for setting the default colors.
  • Compatible with WordPress 3.9 Beta
  • Plugin will support the widget customizer coming up in WordPress 3.9
Download this release

Release Info

Developer MyThemeShop
Plugin Icon 128x128 WP Review
Version 3.0
Comparing to
See all releases

Code changes from version 2.0 to 3.0

admin/activation.php CHANGED
@@ -23,14 +23,4 @@ die(var_dump($e));*/
23
}
24
mts_create_review_tables();
25
26
- // set default colors
27
- $defaultColors = array(
28
- 'review_color' => '#1e73be',
29
- 'font_color' => '#555555',
30
- 'bg_color1' => '#e7e7e7',
31
- 'bg_color2' => '#ffffff',
32
- 'border_color' => '#e7e7e7'
33
- );
34
- wp_review_set_default_colors($defaultColors);
35
-
36
?>
23
}
24
mts_create_review_tables();
25
26
?>
admin/admin.php CHANGED
File without changes
admin/metaboxes.php CHANGED
@@ -86,16 +86,19 @@ function wp_review_render_meta_box_review_options( $post ) {
86
87
/* Retrieve an existing value from the database. */
88
$type = get_post_meta( $post->ID, 'wp_review_type', true );
89
?>
90
91
<p class="wp-review-field">
92
<label for="wp_review_type"><?php _e( 'Review Type', 'wp-review' ); ?></label>
93
<select name="wp_review_type" id="wp_review_type">
94
<option value=""><?php _e( 'No Review', 'wp-review' ) ?></option>
95
- <option value="star" <?php selected( $type, 'star' ); ?>><?php _e( 'Star', 'wp-review' ) ?></option>
96
- <option value="point" <?php selected( $type, 'point' ); ?>><?php _e( 'Point', 'wp-review' ) ?></option>
97
- <option value="percentage" <?php selected( $type, 'percentage' ); ?>><?php _e( 'Percentage', 'wp-review' ) ?></option>
98
</select>
99
</p>
100
101
<?php
@@ -107,9 +110,22 @@ function wp_review_render_meta_box_review_options( $post ) {
107
* @since 1.0
108
*/
109
function wp_review_render_meta_box_item( $post ) {
110
- global $post;
111
- $defaultColors = get_option('wp_review_default_colors');
112
-
113
/* Add an nonce field so we can check for it later. */
114
wp_nonce_field( basename( __FILE__ ), 'wp-review-item-nonce' );
115
@@ -121,15 +137,26 @@ function wp_review_render_meta_box_item( $post ) {
121
$bgcolor1 = get_post_meta( $post->ID, 'wp_review_bgcolor1', true );
122
$bgcolor2 = get_post_meta( $post->ID, 'wp_review_bgcolor2', true );
123
$bordercolor = get_post_meta( $post->ID, 'wp_review_bordercolor', true );
124
- if( $color == '' ) $color = $defaultColors['review_color'];
125
- if( $fontcolor == '' ) $fontcolor = $defaultColors['font_color'];
126
- if( $bgcolor1 == '' ) $bgcolor1 = $defaultColors['bg_color1'];
127
- if( $bgcolor2 == '' ) $bgcolor2 = $defaultColors['bg_color2'];
128
- if( $bordercolor == '' ) $bordercolor = $defaultColors['border_color'];
129
-
130
?>
131
132
- <p class="wp-review-field">
133
<label for="wp_review_location"><?php _e( 'Review Location', 'wp-review' ); ?></label>
134
<select name="wp_review_location" id="wp_review_location">
135
<option value="bottom" <?php selected( $location, 'bottom' ); ?>><?php _e( 'After Content', 'wp-review' ) ?></option>
@@ -144,27 +171,27 @@ function wp_review_render_meta_box_item( $post ) {
144
<span><?php _e('Copy &amp; paste this shortcode in the content.', 'wp-review') ?></span>
145
</p>
146
147
- <p class="wp-review-field">
148
<label for="wp_review_color"><?php _e( 'Review Color', 'wp-review' ); ?></label>
149
<input type="text" class="wp-review-color" name="wp_review_color" value="<?php echo $color; ?>" />
150
</p>
151
152
- <p class="wp-review-field">
153
<label for="wp_review_fontcolor"><?php _e( 'Font Color', 'wp-review' ); ?></label>
154
<input type="text" class="wp-review-color" name="wp_review_fontcolor" id ="wp_review_fontcolor" value="<?php echo $fontcolor; ?>" />
155
</p>
156
157
- <p class="wp-review-field">
158
<label for="wp_review_bgcolor1"><?php _e( 'Heading Background Color', 'wp-review' ); ?></label>
159
<input type="text" class="wp-review-color" name="wp_review_bgcolor1" id ="wp_review_bgcolor1" value="<?php echo $bgcolor1; ?>" />
160
</p>
161
162
- <p class="wp-review-field">
163
<label for="wp_review_bgcolor2"><?php _e( 'Background Color', 'wp-review' ); ?></label>
164
<input type="text" class="wp-review-color" name="wp_review_bgcolor2" id="wp_review_bgcolor2" value="<?php echo $bgcolor2; ?>" />
165
</p>
166
167
- <p class="wp-review-field">
168
<label for="wp_review_bordercolor"><?php _e( 'Border Color', 'wp-review' ); ?></label>
169
<input type="text" class="wp-review-color" name="wp_review_bordercolor" id="wp_review_bordercolor" value="<?php echo $bordercolor; ?>" />
170
</p>
@@ -181,7 +208,7 @@ function wp_review_render_meta_box_item( $post ) {
181
</thead>
182
183
<tbody>
184
- <?php if ( $items ) : ?>
185
186
<?php foreach ( $items as $item ) { ?>
187
@@ -190,7 +217,7 @@ function wp_review_render_meta_box_item( $post ) {
190
<input type="text" class="widefat" name="wp_review_item_title[]" value="<?php if( !empty( $item['wp_review_item_title'] ) ) echo esc_attr( $item['wp_review_item_title'] ); ?>" />
191
</td>
192
<td>
193
- <input type="text" class="widefat review-star" name="wp_review_item_star[]" value="<?php if ( !empty ($item['wp_review_item_star'] ) ) echo $item['wp_review_item_star']; ?>" />
194
</td>
195
<td><a class="button remove-row" href="#"><?php _e( 'Delete', 'wp-review' ); ?></a></td>
196
</tr>
@@ -201,7 +228,7 @@ function wp_review_render_meta_box_item( $post ) {
201
202
<tr>
203
<td><input type="text" class="widefat" name="wp_review_item_title[]" /></td>
204
- <td><input type="text" class="widefat review-star" name="wp_review_item_star[]" /></td>
205
<td><a class="button remove-row" href="#"><?php _e( 'Delete', 'wp-review' ); ?></a></td>
206
</tr>
207
@@ -210,7 +237,7 @@ function wp_review_render_meta_box_item( $post ) {
210
<!-- empty hidden one for jQuery -->
211
<tr class="empty-row screen-reader-text">
212
<td><input type="text" class="widefat" name="wp_review_item_title[]" /></td>
213
- <td><input type="text" class="widefat" name="wp_review_item_star[]" /></td>
214
<td><a class="button remove-row" href="#"><?php _e( 'Delete', 'wp-review' ); ?></a></td>
215
</tr>
216
86
87
/* Retrieve an existing value from the database. */
88
$type = get_post_meta( $post->ID, 'wp_review_type', true );
89
+
90
+ $available_types = apply_filters('wp_review_metabox_types', array('star' => __('Star', 'wp-review'), 'point' => __('Point', 'wp-review'), 'percentage' => __('Percentage', 'wp-review')));
91
?>
92
93
<p class="wp-review-field">
94
<label for="wp_review_type"><?php _e( 'Review Type', 'wp-review' ); ?></label>
95
<select name="wp_review_type" id="wp_review_type">
96
<option value=""><?php _e( 'No Review', 'wp-review' ) ?></option>
97
+ <?php foreach ($available_types as $available_type => $label) { ?>
98
+ <option value="<?php echo $available_type; ?>" <?php selected( $type, $available_type ); ?>><?php echo $label; ?></option>
99
+ <?php } ?>
100
</select>
101
+ <span id="wp_review_id_hint">Review ID: <strong><?php echo $post->ID; ?></strong></span>
102
</p>
103
104
<?php
110
* @since 1.0
111
*/
112
function wp_review_render_meta_box_item( $post ) {
113
+ $defaultColors = apply_filters('wp_review_default_colors', array(
114
+ 'color' => '#1e73be',
115
+ 'fontcolor' => '#555555',
116
+ 'bgcolor1' => '#e7e7e7',
117
+ 'bgcolor2' => '#ffffff',
118
+ 'bordercolor' => '#e7e7e7'
119
+ ));
120
+ $defaultLocation = apply_filters('wp_review_default_location', 'bottom');
121
+
122
+ $defaultCriteria = apply_filters('wp_review_default_criteria', array());
123
+ $defaultItems = array();
124
+ foreach ($defaultCriteria as $item) {
125
+ $defaultItems[] = array( 'wp_review_item_title' => $item, 'wp_review_item_star' => '');
126
+ }
127
+
128
+
129
/* Add an nonce field so we can check for it later. */
130
wp_nonce_field( basename( __FILE__ ), 'wp-review-item-nonce' );
131
137
$bgcolor1 = get_post_meta( $post->ID, 'wp_review_bgcolor1', true );
138
$bgcolor2 = get_post_meta( $post->ID, 'wp_review_bgcolor2', true );
139
$bordercolor = get_post_meta( $post->ID, 'wp_review_bordercolor', true );
140
+ if ( $items == '' ) $items = $defaultItems;
141
+ if( $color == '' ) $color = $defaultColors['color'];
142
+ if( $location == '' ) $location = $defaultLocation;
143
+ if( $fontcolor == '' ) $fontcolor = $defaultColors['fontcolor'];
144
+ if( $bgcolor1 == '' ) $bgcolor1 = $defaultColors['bgcolor1'];
145
+ if( $bgcolor2 == '' ) $bgcolor2 = $defaultColors['bgcolor2'];
146
+ if( $bordercolor == '' ) $bordercolor = $defaultColors['bordercolor'];
147
+
148
+ $fields = array(
149
+ 'location' => true,
150
+ 'color' => true,
151
+ 'fontcolor' => true,
152
+ 'bgcolor1' => true,
153
+ 'bgcolor2' => true,
154
+ 'bordercolor' => true
155
+ );
156
+ $displayed_fields = apply_filters('wp_review_metabox_item_fields', $fields);
157
?>
158
159
+ <p class="wp-review-field"<?php if (empty($displayed_fields['location'])) echo ' style="display: none;"'; ?>>
160
<label for="wp_review_location"><?php _e( 'Review Location', 'wp-review' ); ?></label>
161
<select name="wp_review_location" id="wp_review_location">
162
<option value="bottom" <?php selected( $location, 'bottom' ); ?>><?php _e( 'After Content', 'wp-review' ) ?></option>
171
<span><?php _e('Copy &amp; paste this shortcode in the content.', 'wp-review') ?></span>
172
</p>
173
174
+ <p class="wp-review-field"<?php if (empty($displayed_fields['color'])) echo ' style="display: none;"'; ?>>
175
<label for="wp_review_color"><?php _e( 'Review Color', 'wp-review' ); ?></label>
176
<input type="text" class="wp-review-color" name="wp_review_color" value="<?php echo $color; ?>" />
177
</p>
178
179
+ <p class="wp-review-field"<?php if (empty($displayed_fields['fontcolor'])) echo ' style="display: none;"'; ?>>
180
<label for="wp_review_fontcolor"><?php _e( 'Font Color', 'wp-review' ); ?></label>
181
<input type="text" class="wp-review-color" name="wp_review_fontcolor" id ="wp_review_fontcolor" value="<?php echo $fontcolor; ?>" />
182
</p>
183
184
+ <p class="wp-review-field"<?php if (empty($displayed_fields['bgcolor1'])) echo ' style="display: none;"'; ?>>
185
<label for="wp_review_bgcolor1"><?php _e( 'Heading Background Color', 'wp-review' ); ?></label>
186
<input type="text" class="wp-review-color" name="wp_review_bgcolor1" id ="wp_review_bgcolor1" value="<?php echo $bgcolor1; ?>" />
187
</p>
188
189
+ <p class="wp-review-field"<?php if (empty($displayed_fields['bgcolor2'])) echo ' style="display: none;"'; ?>>
190
<label for="wp_review_bgcolor2"><?php _e( 'Background Color', 'wp-review' ); ?></label>
191
<input type="text" class="wp-review-color" name="wp_review_bgcolor2" id="wp_review_bgcolor2" value="<?php echo $bgcolor2; ?>" />
192
</p>
193
194
+ <p class="wp-review-field"<?php if (empty($displayed_fields['bordercolor'])) echo ' style="display: none;"'; ?>>
195
<label for="wp_review_bordercolor"><?php _e( 'Border Color', 'wp-review' ); ?></label>
196
<input type="text" class="wp-review-color" name="wp_review_bordercolor" id="wp_review_bordercolor" value="<?php echo $bordercolor; ?>" />
197
</p>
208
</thead>
209
210
<tbody>
211
+ <?php if ( !empty($items) ) : ?>
212
213
<?php foreach ( $items as $item ) { ?>
214
217
<input type="text" class="widefat" name="wp_review_item_title[]" value="<?php if( !empty( $item['wp_review_item_title'] ) ) echo esc_attr( $item['wp_review_item_title'] ); ?>" />
218
</td>
219
<td>
220
+ <input type="text" min="1" step="1" autocomplete="off" class="widefat review-star" name="wp_review_item_star[]" value="<?php if ( !empty ($item['wp_review_item_star'] ) ) echo $item['wp_review_item_star']; ?>" />
221
</td>
222
<td><a class="button remove-row" href="#"><?php _e( 'Delete', 'wp-review' ); ?></a></td>
223
</tr>
228
229
<tr>
230
<td><input type="text" class="widefat" name="wp_review_item_title[]" /></td>
231
+ <td><input type="text" min="1" step="1" autocomplete="off" class="widefat review-star" name="wp_review_item_star[]" /></td>
232
<td><a class="button remove-row" href="#"><?php _e( 'Delete', 'wp-review' ); ?></a></td>
233
</tr>
234
237
<!-- empty hidden one for jQuery -->
238
<tr class="empty-row screen-reader-text">
239
<td><input type="text" class="widefat" name="wp_review_item_title[]" /></td>
240
+ <td><input type="text" min="1" step="1" autocomplete="off" class="widefat" name="wp_review_item_star[]" /></td>
241
<td><a class="button remove-row" href="#"><?php _e( 'Delete', 'wp-review' ); ?></a></td>
242
</tr>
243
assets/css/admin.css CHANGED
@@ -45,4 +45,7 @@
45
}
46
#wp_review_shortcode_hint {
47
width: 94px;
48
}
45
}
46
#wp_review_shortcode_hint {
47
width: 94px;
48
+ }
49
+ #wp_review_id_hint {
50
+ margin-left: 8px;
51
}
assets/css/wp-review-ie7.css CHANGED
File without changes
assets/css/wp-review-tab-widget.css ADDED
@@ -0,0 +1,179 @@
1
+ .wp_review_tab_widget_content {
2
+ position: relative;
3
+ border: 1px solid #E4E4E4;
4
+ }
5
+ .wp_review_tab_widget_content img {
6
+ max-width: 100%;
7
+ height: auto;
8
+ }
9
+ .wp_review_tab_widget_content a {
10
+ color: #444;
11
+ }
12
+ .wp_review_tab_widget_content ul.wp-review-tabs li {
13
+ list-style: none;
14
+ display: block;
15
+ width: 50%;
16
+ float: left;
17
+ text-align: center;
18
+ margin: 0;
19
+ padding: 0 !important;
20
+ }
21
+ .wp_review_tab_widget_content ul.has-1-tabs li {
22
+ width: 100%;
23
+ float: none;
24
+ margin: 0 auto;
25
+ }
26
+ .wp_review_tab_widget_content ul.has-2-tabs li {
27
+
28
+ }
29
+ .wp_review_tab_widget_content ul.has-3-tabs li {
30
+ width: 33.33%;
31
+ }
32
+ .wp_review_tab_widget_content ul.has-4-tabs li {
33
+ width: 50%;
34
+ }
35
+ .wp_review_tab_widget_content .tab_title a {
36
+ display: block;
37
+ background: #f0f0f0;
38
+ border-left: 1px solid #E4E4E4;
39
+ border-bottom: 1px solid #E4E4E4;
40
+ padding: 2px 0 4px;
41
+ line-height: 2.4;
42
+ text-decoration: none;
43
+ position: relative;
44
+ font-weight: bold;
45
+ }
46
+ .wp_review_tab_widget_content .tab_title:first-child a {
47
+ margin-left: 0;
48
+ border-left: 0;
49
+ }
50
+ .wp_review_tab_widget_content .tab_title.selected a {
51
+ background: #fff;
52
+ border-bottom: 1px solid #fff;
53
+ }
54
+
55
+
56
+ .wp_review_tab_widget_content .inside {
57
+ background: #fff;
58
+ padding-top: 10px;
59
+ }
60
+ .wp_review_tab_widget_content .tab-content li {
61
+ list-style-type: none;
62
+ float: left;
63
+ width: 100%;
64
+ -moz-box-sizing: border-box;
65
+ box-sizing: border-box;
66
+ margin: 0 0 15px 0;
67
+ padding: 0px 15px 10px 15px;
68
+ border-bottom: 1px solid #E4E4E4;
69
+ text-align: left;
70
+ color: #444;
71
+ background: none;
72
+ position: relative;
73
+ }
74
+ .wp_review_tab_widget_content .tab-content li:last-child {
75
+ border: none;
76
+ margin-bottom: 0;
77
+ }
78
+ .wp_review_tab_widget_content .tab-content li:first-child {
79
+ padding-top: 5px;
80
+ }
81
+
82
+ .wp_review_tab_thumb_small {
83
+ float: left;
84
+ margin-right: 12px;
85
+ padding-top: 4px;
86
+ width: 65px;
87
+ height: 65px;
88
+ overflow: hidden;
89
+ }
90
+ .wp_review_tab_thumb_large {
91
+ float: none;
92
+ max-width: 100%;
93
+ display: inline-block;
94
+ margin-bottom: 4px;
95
+ position: relative;
96
+ }
97
+ .wp_review_tab_widget_content .entry-title {
98
+ font-weight: bold;
99
+ margin: 0;
100
+ padding: 0;
101
+ }
102
+ .wp_review_tab_widget_content .wp-review-tab-postmeta {
103
+ color: #999;
104
+ font-size: 13px;
105
+ float: right;
106
+ margin-top: 5px;
107
+ }
108
+ .wp_review_tab_widget_content .wp-post-image {
109
+ margin: 0 !important;
110
+ }
111
+
112
+
113
+
114
+ /* Pagination */
115
+ .wp_review_tab_widget_content .wp-review-tab-pagination {
116
+ margin: 0;
117
+ width: 100%;
118
+ padding-top: 0;
119
+ padding-bottom: 15px;
120
+ float: left;
121
+ }
122
+ .wp_review_tab_widget_content .wp-review-tab-pagination a {
123
+ margin: 0 15px;
124
+ }
125
+ .wp-review-tab-pagination a.next {
126
+ float: right;
127
+ }
128
+
129
+ /* Loading... */
130
+ .wp-review-tab-loading:after {
131
+ content: "";
132
+ display: block;
133
+ position: absolute;
134
+ top: 0;
135
+ right: 0;
136
+ bottom: 0;
137
+ left: 0;
138
+ background-color: rgba(255,255,255,0.8);
139
+ }
140
+ .clear {
141
+ clear: both;
142
+ }
143
+
144
+ /* Rating... */
145
+ .wp_review_tab_widget_content .review-total-only {
146
+
147
+ }
148
+ .review-total-only.small-thumb {
149
+ font-size: 15px;
150
+ font-weight: bold;
151
+ padding: 0 4px;
152
+ margin-top: 4px;
153
+ float: left;
154
+ }
155
+ .review-total-only.small-thumb.review-type-star {
156
+ background: none;
157
+ padding: 0;
158
+ }
159
+ .review-total-only.large-thumb {
160
+ position: absolute;
161
+ top: 0; right: 15px;
162
+ }
163
+ li:first-child .review-total-only.large-thumb {
164
+ top: 5px;
165
+ right: 15px;
166
+ display: block;
167
+ }
168
+ .review-total-only.small-thumb .review-result-wrapper i {
169
+ color: #444 !important;
170
+ }
171
+ .wp_review_tab_widget_content .has-4-tabs .tab_title.selected a {
172
+ border-bottom: 1px solid #E4E4E4;
173
+ }
174
+ .wp_review_tab_widget_content .has-4-tabs .tab_title:nth-child(3) a {
175
+ border-left: 0;
176
+ }
177
+ .title-right {
178
+ overflow: hidden;
179
+ }
assets/css/wp-review.css CHANGED
@@ -1,417 +1,419 @@
1
- /*
2
- Plugin: WP Review
3
- Created By: MyThemeShop.com
4
- */
5
- .review-wrapper {
6
- border: 1px solid #e7e7e7;
7
- margin-bottom: 1.5em;
8
- overflow: hidden;
9
- }
10
-
11
- .review-title {
12
- background-color: #f6f6f6;
13
- border-bottom: 1px solid #e7e7e7;
14
- margin: 0;
15
- padding: 10px;
16
- }
17
-
18
- .review-wrapper .review-list {
19
- margin: 0;
20
- list-style: none;
21
- padding: 0;
22
- }
23
-
24
- .review-list li {
25
- border-bottom: 1px solid #e7e7e7;
26
- padding: 10px;
27
- position: relative;
28
- list-style: none;
29
- }
30
-
31
- .review-list li:nth-child(even) {
32
- background-color: #fafafa;
33
- }
34
-
35
- .review-list li:last-child {
36
- border-bottom: 1px solid #e7e7e7;
37
- }
38
-
39
- .review-summary-title {
40
- margin-bottom: 5px;
41
- }
42
-
43
- .review-desc {
44
- float: left;
45
- width: 75%;
46
- padding: 2%;
47
- -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
48
- }
49
-
50
- .review-desc p:last-child {
51
- margin-bottom: 0;
52
- }
53
-
54
- .review-result-wrapper i {
55
- font-style: normal;
56
- font-size: 16px;
57
- }
58
-
59
- .review-result {
60
- position: absolute;
61
- top: 0;
62
- left: 0;
63
- height: 22px;
64
- overflow: hidden;
65
- white-space: nowrap;
66
- }
67
-
68
- .review-total-wrapper {
69
- float: right;
70
- margin: 0;
71
- margin-right: 0;
72
- padding-right: 0;
73
- position: relative;
74
- -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
75
- margin-right: 20px;
76
- }
77
-
78
- .review-total-wrapper span.review-total-box {
79
- border-top: 0;
80
- border-bottom: 0;
81
- border-left: 0;
82
- border-right: 0;
83
- display: block;
84
- font-size: 40px;
85
- font-weight: 700;
86
- text-align: right;
87
- margin: 0;
88
- padding: 35px 0 20px;
89
- width: 100%;
90
- -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
91
- }
92
- .review-total-wrapper span.review-total-box small{font-size: 12px; display: block;}
93
- /*.review-total-wrapper span.review-total-box.hidden{display: none;}*/
94
- .percentage-icon {
95
- font-size: 22px;
96
- position: relative;
97
- top: -14px;
98
- }
99
-
100
- .review-total-star {
101
- position: relative;
102
- margin-top: 5px;
103
- margin: 5px auto 15px auto;
104
- float: right;
105
- }
106
-
107
- .review-total-star.allowed-to-rate{margin-top:-10px;}
108
-
109
- .review-total-star.allowed-to-rate.has-not-rated-yet a{cursor: pointer;}
110
-
111
- .review-total-star.allowed-to-rate.has-not-rated-yet:hover .review-result {opacity: 0; filter: alpha(opacity=0); display:none}
112
- .review-total-star.allowed-to-rate.has-not-rated-yet a:hover > i{opacity: 1; filter: alpha(opacity=1);}
113
- .review-total-star.allowed-to-rate a.hovered i{opacity: 1; filter: alpha(opacity=1);}
114
- .mts-review-wait-msg{display: none;}
115
-
116
- .review-total {
117
- position: absolute;
118
- top: 0px;
119
- left: 0px;
120
- height: 16px;
121
- z-index: 99;
122
- text-indent: -9999px;
123
- }
124
-
125
- .review-star {
126
- position: absolute;
127
- right: 20px;
128
- top: 10px;
129
- }
130
-
131
-
132
-
133
- /**
134
- * Bar & Percentage Point
135
- */
136
- .bar-point .review-star,
137
- .percentage-point .review-star {
138
- position: relative;
139
- margin: 6px 0;
140
- top: 0;
141
- right: 0;
142
- }
143
-
144
- .bar-point .review-result-wrapper,
145
- .percentage-point .review-result-wrapper {
146
- background: rgba(0,0,0,0.1) 0 -24px repeat-x;
147
- width: 100%;
148
- height: 22px;
149
- }
150
-
151
- .bar-point .review-result,
152
- .percentage-point .review-result {
153
- position: absolute;
154
- top: 0px;
155
- left: 0px;
156
- height: 22px;
157
- z-index: 99;
158
- text-indent: -9999px;
159
- }
160
-
161
- .review-total-star.allowed-to-rate .review-result-wrapper{background: none;}
162
- /**
163
- * Twenty series themes compatibilty
164
- */
165
- .entry-content .review-title,
166
- #content .review-title {
167
- margin: 0;
168
- }
169
-
170
- .entry-content .review-wrapper li {
171
- margin: 0;
172
- }
173
-
174
- .entry-content .review-summary-title,
175
- #content .review-summary-title {
176
- margin-bottom: 5px;
177
- }
178
-
179
- #content .review-list {
180
- margin: 0;
181
- }
182
-
183
- #content .review-desc p:last-child {
184
- margin-bottom: 0;
185
- }
186
-
187
- /**
188
- * Basic styling for wp_review_display_total
189
- */
190
- .review-total-only {
191
- padding: 3px 10px;
192
- background: rgba(0, 0, 0, 0.6);
193
- color:#fff;
194
- font-size:13px;
195
- display: inline-block;
196
- }
197
- .review-total-only .percentage-icon {
198
- font-size: inherit;
199
- top: 0;
200
- }
201
- .review-total-only .review-type-star {
202
- font-size:12px;
203
- padding: 3px 6px;
204
- }
205
- .review-total-only .review-total-star {
206
- font-size:12px;
207
- margin: 0;
208
- }
209
- .review-total-only .review-result-wrapper i {
210
- color: #FFF !important;
211
- opacity: 0.50;
212
- filter: alpha(opacity=50);
213
- }
214
- .review-total-only .review-result-wrapper .review-result i {
215
- opacity: 1;
216
- filter: alpha(opacity=100);
217
- }
218
-
219
- /**
220
- * Users review area
221
- */
222
- .user-review-area{ border-top: 1px solid #e7e7e7; /*border: none;*/ margin-top: -1.5em; overflow: hidden; padding: 10px; position: relative; clear: both;}
223
- .user-total-wrapper{float: left; margin:0; }
224
- .review-total-star.allowed-to-rate{float: right; margin:0;margin-right: 10px;}
225
- .user-total-wrapper .user-review-title{/*font-size: 20px;*/ font-weight: bold;margin:0;}
226
- .user-total-wrapper #mts-user-reviews-total{/*font-size: 20px;*/}
227
- /*.user-total-wrapper small{font-size:16px;}*/
228
- /*#review.review-wrapper{float: left; width: 45%;}*/
229
-
230
- /**
231
- * Font icon
232
- */
233
- @font-face {
234
- font-family: 'font-star';
235
- src: url('../fonts/font-star.eot?75880836');
236
- src: url('../fonts/font-star.eot?75880836#iefix') format('embedded-opentype'),
237
- url('../fonts/font-star.woff?75880836') format('woff'),
238
- url('../fonts/font-star.ttf?75880836') format('truetype'),
239
- url('../fonts/font-star.svg?75880836#font-star') format('svg');
240
- font-weight: normal;
241
- font-style: normal;
242
- }
243
-
244
- [class^="mts-icon-"]:before, [class*=" mts-icon-"]:before {
245
- font-family: "font-star";
246
- font-style: normal;
247
- font-weight: normal;
248
- speak: none;
249
- display: inline-block;
250
- text-decoration: inherit;
251
- width: 1em;
252
- margin-right: 0;
253
- text-align: center;
254
- font-variant: normal;
255
- text-transform: none;
256
- line-height: 1em;
257
- margin-left: 2px;
258
- }
259
-
260
- .mts-icon-star:before { content: '\e800'; }
261
-
262
- @font-face {
263
- font-family: 'font-loader';
264
- src: url('../fonts/font-loader.eot?75880836');
265
- src: url('../fonts/font-loader.eot?75880836#iefix') format('embedded-opentype'),
266
- url('../fonts/font-loader.woff?75880836') format('woff'),
267
- url('../fonts/font-loader.ttf?75880836') format('truetype'),
268
- url('../fonts/font-loader.svg?75880836#font-loader') format('svg');
269
- font-weight: normal;
270
- font-style: normal;
271
- }
272
-
273
- [class*="mts-icon-loader"]:before {
274
- font-family: "font-loader";
275
- font-style: normal;
276
- font-weight: normal;
277
- speak: none;
278
-
279
- display: inline-block;
280
- text-decoration: inherit;
281
- width: 1em;
282
- margin-right: .2em;
283
- text-align: center;
284
- /* opacity: .8; */
285
-
286
- /* For safety - reset parent styles, that can break glyph codes*/
287
- font-variant: normal;
288
- text-transform: none;
289
-
290
- /* fix buttons height, for twitter bootstrap */
291
- line-height: 1em;
292
-
293
- /* Animation center compensation - margins should be symmetric */
294
- /* remove if not needed */
295
- margin-left: .2em;
296
-
297
- /* you can be more comfortable with increased icons size */
298
- /* font-size: 120%; */
299
-
300
- /* Uncomment for 3D effect */
301
- /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
302
- }
303
-
304
-
305
-
306
-
307
- /*
308
- Spin Animation For Loader
309
- */
310
-
311
-
312
- .mts-icon-loader:before { content: '\e800'; } /* '' */
313
-
314
- .animate-spin {
315
- -moz-animation: spin 1s infinite linear;
316
- -o-animation: spin 1s infinite linear;
317
- -webkit-animation: spin 1s infinite linear;
318
- animation: spin 1s infinite linear;
319
- display: inline-block;
320
- }
321
- @-moz-keyframes spin {
322
- 0% {
323
- -moz-transform: rotate(0deg);
324
- -o-transform: rotate(0deg);
325
- -webkit-transform: rotate(0deg);
326
- transform: rotate(0deg);
327
- }
328
-
329
- 100% {
330
- -moz-transform: rotate(359deg);
331
- -o-transform: rotate(359deg);
332
- -webkit-transform: rotate(359deg);
333
- transform: rotate(359deg);
334
- }
335
- }
336
- @-webkit-keyframes spin {
337
- 0% {
338
- -moz-transform: rotate(0deg);
339
- -o-transform: rotate(0deg);
340
- -webkit-transform: rotate(0deg);
341
- transform: rotate(0deg);
342
- }
343
-
344
- 100% {
345
- -moz-transform: rotate(359deg);
346
- -o-transform: rotate(359deg);
347
- -webkit-transform: rotate(359deg);
348
- transform: rotate(359deg);
349
- }
350
- }
351
- @-o-keyframes spin {
352
- 0% {
353
- -moz-transform: rotate(0deg);
354
- -o-transform: rotate(0deg);
355
- -webkit-transform: rotate(0deg);
356
- transform: rotate(0deg);
357
- }
358
-
359
- 100% {
360
- -moz-transform: rotate(359deg);
361
- -o-transform: rotate(359deg);
362
- -webkit-transform: rotate(359deg);
363
- transform: rotate(359deg);
364
- }
365
- }
366
- @-ms-keyframes spin {
367
- 0% {
368
- -moz-transform: rotate(0deg);
369
- -o-transform: rotate(0deg);
370
- -webkit-transform: rotate(0deg);
371
- transform: rotate(0deg);
372
- }
373
-
374
- 100% {
375
- -moz-transform: rotate(359deg);
376
- -o-transform: rotate(359deg);
377
- -webkit-transform: rotate(359deg);
378
- transform: rotate(359deg);
379
- }
380
- }
381
- @keyframes spin {
382
- 0% {
383
- -moz-transform: rotate(0deg);
384
- -o-transform: rotate(0deg);
385
- -webkit-transform: rotate(0deg);
386
- transform: rotate(0deg);
387
- }
388
-
389
- 100% {
390
- -moz-transform: rotate(359deg);
391
- -o-transform: rotate(359deg);
392
- -webkit-transform: rotate(359deg);
393
- transform: rotate(359deg);
394
- }
395
- }
396
-
397
- /*-----------------------------------------------------*/
398
- /* Responsvie
399
- /*-----------------------------------------------------*/
400
- @media screen and (max-width:1040px) {
401
- .review-desc { width: 71%;}
402
- /*.review-total-wrapper { width: 26.8%; }*/
403
- }
404
-
405
- @media screen and (max-width:860px) {
406
- .review-desc { width: 66%;}
407
- /*.review-total-wrapper { width: 31.8%; }*/
408
- }
409
- @media screen and (max-width:470px) {
410
- .review-desc { padding: 4%; width: 100%;}
411
- .review-total-wrapper { width: 100%; margin-right: 0;}
412
- .review-total-wrapper span.review-total-box { padding: 10px 0 20px; text-align: left; padding-left: 10px;}
413
- .review-total-star { position: absolute; right: 20px; top: 5px;}
414
- .user-total-wrapper{width: 96%;}
415
- .review-total-star.allowed-to-rate{position: relative; right: auto;left: 0;float: left;}
416
-
417
}
1
+ /*
2
+ Plugin: WP Review
3
+ Created By: MyThemeShop.com
4
+ */
5
+ .review-wrapper {
6
+ border: 1px solid #e7e7e7;
7
+ margin-bottom: 1.5em;
8
+ overflow: hidden;
9
+ clear: both;
10
+ }
11
+
12
+ .review-title {
13
+ background-color: #f6f6f6;
14
+ border-bottom: 1px solid #e7e7e7;
15
+ margin: 0;
16
+ padding: 10px;
17
+ }
18
+
19
+ .review-wrapper .review-list {
20
+ margin: 0;
21
+ list-style: none;
22
+ padding: 0;
23
+ }
24
+
25
+ .review-list li {
26
+ border-bottom: 1px solid #e7e7e7;
27
+ padding: 10px 15px;
28
+ position: relative;
29
+ list-style: none;
30
+ }
31
+
32
+ .review-list li:nth-child(even) {
33
+ background-color: #fafafa;
34
+ }
35
+
36
+ .review-list li:last-child {
37
+ border-bottom: 1px solid #e7e7e7;
38
+ }
39
+
40
+ .review-summary-title {
41
+ margin-bottom: 5px;
42
+ }
43
+
44
+ .review-desc {
45
+ float: left;
46
+ width: 75%;
47
+ padding: 10px 15px;
48
+ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
49
+ }
50
+
51
+ .review-desc p:last-child {
52
+ margin-bottom: 0;
53
+ }
54
+
55
+ .review-result-wrapper i {
56
+ font-style: normal;
57
+ font-size: 16px;
58
+ }
59
+
60
+ .review-result {
61
+ position: absolute;
62
+ top: 0;
63
+ left: 0;
64
+ height: 22px;
65
+ overflow: hidden;
66
+ white-space: nowrap;
67
+ }
68
+
69
+ .review-total-wrapper {
70
+ float: right;
71
+ margin: 0;
72
+ margin-right: 0;
73
+ padding-right: 0;
74
+ position: relative;
75
+ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
76
+ margin-right: 15px;
77
+ }
78
+
79
+ .review-total-wrapper span.review-total-box {
80
+ border-top: 0;
81
+ border-bottom: 0;
82
+ border-left: 0;
83
+ border-right: 0;
84
+ display: block;
85
+ font-size: 40px;
86
+ font-weight: 700;
87
+ text-align: right;
88
+ margin: 0;
89
+ padding: 35px 0 20px;
90
+ width: 100%;
91
+ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
92
+ }
93
+ .review-total-wrapper span.review-total-box small{font-size: 12px; display: block;}
94
+ /*.review-total-wrapper span.review-total-box.hidden{display: none;}*/
95
+ .percentage-icon {
96
+ font-size: 22px;
97
+ position: relative;
98
+ top: -14px;
99
+ }
100
+
101
+ .review-total-star {
102
+ position: relative;
103
+ margin-top: 5px;
104
+ margin: 5px auto 15px auto;
105
+ float: right;
106
+ }
107
+
108
+ .review-total-star.allowed-to-rate{margin-top:-10px;}
109
+
110
+ .review-total-star.allowed-to-rate.has-not-rated-yet a{cursor: pointer;}
111
+
112
+ .review-total-star.allowed-to-rate.has-not-rated-yet:hover .review-result {opacity: 0; filter: alpha(opacity=0); display:none}
113
+ .review-total-star.allowed-to-rate.has-not-rated-yet a:hover > i{opacity: 1; filter: alpha(opacity=1);}
114
+ .review-total-star.allowed-to-rate a.hovered i{opacity: 1; filter: alpha(opacity=1);}
115
+ .mts-review-wait-msg{display: none;}
116
+
117
+ .review-total {
118
+ position: absolute;
119
+ top: 0px;
120
+ left: 0px;
121
+ height: 16px;
122
+ z-index: 99;
123
+ text-indent: -9999px;
124
+ }
125
+
126
+ .review-star {
127
+ position: absolute;
128
+ right: 15px;
129
+ top: 10px;
130
+ }
131
+
132
+
133
+
134
+ /**
135
+ * Bar & Percentage Point
136
+ */
137
+ .bar-point .review-star,
138
+ .percentage-point .review-star {
139
+ position: relative;
140
+ margin: 6px 0;
141
+ top: 0;
142
+ right: 0;
143
+ }
144
+
145
+ .bar-point .review-result-wrapper,
146
+ .percentage-point .review-result-wrapper {
147
+ background: rgba(0,0,0,0.1) 0 -24px repeat-x;
148
+ width: 100%;
149
+ height: 22px;
150
+ }
151
+
152
+ .bar-point .review-result,
153
+ .percentage-point .review-result {
154
+ position: absolute;
155
+ top: 0px;
156
+ left: 0px;
157
+ height: 22px;
158
+ z-index: 99;
159
+ text-indent: -9999px;
160
+ }
161
+
162
+ .review-total-star.allowed-to-rate .review-result-wrapper{background: none;}
163
+ /**
164
+ * Twenty series themes compatibilty
165
+ */
166
+ .entry-content .review-title,
167
+ #content .review-title {
168
+ margin: 0;
169
+ }
170
+
171
+ .entry-content .review-wrapper li {
172
+ margin: 0;
173
+ }
174
+
175
+ .entry-content .review-summary-title,
176
+ #content .review-summary-title {
177
+ margin-bottom: 5px;
178
+ }
179
+
180
+ #content .review-list {
181
+ margin: 0;
182
+ }
183
+
184
+ #content .review-desc p:last-child {
185
+ margin-bottom: 0;
186
+ }
187
+
188
+ /**
189
+ * Basic styling for wp_review_display_total
190
+ */
191
+ .review-total-only {
192
+ padding: 3px 10px;
193
+ background: rgba(0, 0, 0, 0.6);
194
+ color:#fff;
195
+ font-size:13px;
196
+
197
+ display: inline-block;
198
+ }
199
+ .review-total-only .percentage-icon {
200
+ font-size: inherit;
201
+ top: 0;
202
+ }
203
+ .review-total-only .review-type-star {
204
+ font-size:12px;
205
+ padding: 3px 6px;
206
+ }
207
+ .review-total-only .review-total-star {
208
+ font-size:12px;
209
+ margin: 0;
210
+ }
211
+ .review-total-only .review-result-wrapper i {
212
+ color: #FFF !important;
213
+ opacity: 0.50;
214
+ filter: alpha(opacity=50);
215
+ }
216
+ .review-total-only .review-result-wrapper .review-result i {
217
+ opacity: 1;
218
+ filter: alpha(opacity=100);
219
+ }
220
+
221
+ /**
222
+ * Users review area
223
+ */
224
+ .user-review-area{ border-top: 1px solid #e7e7e7; margin-top: -1.5em; overflow: hidden; padding: 10px 15px; position: relative; clear: both;}
225
+ .user-total-wrapper{float: left; margin:0; }
226
+ .review-total-star.allowed-to-rate{float: right; margin:0;}
227
+ .user-total-wrapper .user-review-title{/*font-size: 20px;*/ font-weight: bold;margin:0;}
228
+ .user-total-wrapper #mts-user-reviews-total{/*font-size: 20px;*/}
229
+ /*.user-total-wrapper small{font-size:16px;}*/
230
+ /*#review.review-wrapper{float: left; width: 45%;}*/
231
+
232
+ /**
233
+ * Font icon
234
+ */
235
+ @font-face {
236
+ font-family: 'font-star';
237
+ src: url('../fonts/font-star.eot?75880836');
238
+ src: url('../fonts/font-star.eot?75880836#iefix') format('embedded-opentype'),
239
+ url('../fonts/font-star.woff?75880836') format('woff'),
240
+ url('../fonts/font-star.ttf?75880836') format('truetype'),
241
+ url('../fonts/font-star.svg?75880836#font-star') format('svg');
242
+ font-weight: normal;
243
+ font-style: normal;
244
+ }
245
+
246
+ [class^="mts-icon-"]:before, [class*=" mts-icon-"]:before {
247
+ font-family: "font-star";
248
+ font-style: normal;
249
+ font-weight: normal;
250
+ speak: none;
251
+ display: inline-block;
252
+ text-decoration: inherit;
253
+ width: 1em;
254
+ margin-right: 0;
255
+ text-align: center;
256
+ font-variant: normal;
257
+ text-transform: none;
258
+ line-height: 1em;
259
+ margin-left: 2px;
260
+ }
261
+
262
+ .mts-icon-star:before { content: '\e800'; }
263
+
264
+ @font-face {
265
+ font-family: 'font-loader';
266
+ src: url('../fonts/font-loader.eot?75880836');
267
+ src: url('../fonts/font-loader.eot?75880836#iefix') format('embedded-opentype'),
268
+ url('../fonts/font-loader.woff?75880836') format('woff'),
269
+ url('../fonts/font-loader.ttf?75880836') format('truetype'),
270
+ url('../fonts/font-loader.svg?75880836#font-loader') format('svg');
271
+ font-weight: normal;
272
+ font-style: normal;
273
+ }
274
+
275
+ [class*="mts-icon-loader"]:before {
276
+ font-family: "font-loader";
277
+ font-style: normal;
278
+ font-weight: normal;
279
+ speak: none;
280
+
281
+ display: inline-block;
282
+ text-decoration: inherit;
283
+ width: 1em;
284
+ margin-right: .2em;
285
+ text-align: center;
286
+ /* opacity: .8; */
287
+
288
+ /* For safety - reset parent styles, that can break glyph codes*/
289
+ font-variant: normal;
290
+ text-transform: none;
291
+
292
+ /* fix buttons height, for twitter bootstrap */
293
+ line-height: 1em;
294
+
295
+ /* Animation center compensation - margins should be symmetric */
296
+ /* remove if not needed */
297
+ margin-left: .2em;
298
+
299
+ /* you can be more comfortable with increased icons size */
300
+ /* font-size: 120%; */
301
+
302
+ /* Uncomment for 3D effect */
303
+ /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
304
+ }
305
+
306
+
307
+
308
+
309
+ /*
310
+ Spin Animation For Loader
311
+ */
312
+
313
+
314
+ .mts-icon-loader:before { content: '\e800'; } /* '' */
315
+
316
+ .animate-spin {
317
+ -moz-animation: spin 1s infinite linear;
318
+ -o-animation: spin 1s infinite linear;
319
+ -webkit-animation: spin 1s infinite linear;
320
+ animation: spin 1s infinite linear;
321
+ display: inline-block;
322
+ }
323
+ @-moz-keyframes spin {
324
+ 0% {
325
+ -moz-transform: rotate(0deg);
326
+ -o-transform: rotate(0deg);
327
+ -webkit-transform: rotate(0deg);
328
+ transform: rotate(0deg);
329
+ }
330
+
331
+ 100% {
332
+ -moz-transform: rotate(359deg);
333
+ -o-transform: rotate(359deg);
334
+ -webkit-transform: rotate(359deg);
335
+ transform: rotate(359deg);
336
+ }
337
+ }
338
+ @-webkit-keyframes spin {
339
+ 0% {
340
+ -moz-transform: rotate(0deg);
341
+ -o-transform: rotate(0deg);
342
+ -webkit-transform: rotate(0deg);
343
+ transform: rotate(0deg);
344
+ }
345
+
346
+ 100% {
347
+ -moz-transform: rotate(359deg);
348
+ -o-transform: rotate(359deg);
349
+ -webkit-transform: rotate(359deg);
350
+ transform: rotate(359deg);
351
+ }
352
+ }
353
+ @-o-keyframes spin {
354
+ 0% {
355
+ -moz-transform: rotate(0deg);
356
+ -o-transform: rotate(0deg);
357
+ -webkit-transform: rotate(0deg);
358
+ transform: rotate(0deg);
359
+ }
360
+
361
+ 100% {
362
+ -moz-transform: rotate(359deg);
363
+ -o-transform: rotate(359deg);
364
+ -webkit-transform: rotate(359deg);
365
+ transform: rotate(359deg);
366
+ }
367
+ }
368
+ @-ms-keyframes spin {
369
+ 0% {
370
+ -moz-transform: rotate(0deg);
371
+ -o-transform: rotate(0deg);
372
+ -webkit-transform: rotate(0deg);
373
+ transform: rotate(0deg);
374
+ }
375
+
376
+ 100% {
377
+ -moz-transform: rotate(359deg);
378
+ -o-transform: rotate(359deg);
379
+ -webkit-transform: rotate(359deg);
380
+ transform: rotate(359deg);
381
+ }
382
+ }
383
+ @keyframes spin {
384
+ 0% {
385
+ -moz-transform: rotate(0deg);
386
+ -o-transform: rotate(0deg);
387
+ -webkit-transform: rotate(0deg);
388
+ transform: rotate(0deg);
389
+ }
390
+
391
+ 100% {
392
+ -moz-transform: rotate(359deg);
393
+ -o-transform: rotate(359deg);
394
+ -webkit-transform: rotate(359deg);
395
+ transform: rotate(359deg);
396
+ }
397
+ }
398
+
399
+ /*-----------------------------------------------------*/
400
+ /* Responsvie
401
+ /*-----------------------------------------------------*/
402
+ @media screen and (max-width:1040px) {
403
+ .review-desc { width: 71%;}
404
+ /*.review-total-wrapper { width: 26.8%; }*/
405
+ }
406
+
407
+ @media screen and (max-width:860px) {
408
+ .review-desc { width: 66%;}
409
+ /*.review-total-wrapper { width: 31.8%; }*/
410
+ }
411
+ @media screen and (max-width:470px) {
412
+ .review-desc { padding: 4%; width: 100%;}
413
+ .review-total-wrapper { width: 100%; margin-right: 0;}
414
+ .review-total-wrapper span.review-total-box { padding: 10px 0 20px; text-align: left; padding-left: 10px;}
415
+ .review-total-star { position: absolute; right: 20px; top: 5px;}
416
+ .user-total-wrapper{width: 96%;}
417
+ .review-total-star.allowed-to-rate{position: relative; right: auto;left: 0;float: left;}
418
+
419
}
assets/fonts/font-loader.eot CHANGED
File without changes
assets/fonts/font-loader.svg CHANGED
File without changes
assets/fonts/font-loader.ttf CHANGED
File without changes
assets/fonts/font-loader.woff CHANGED
File without changes
assets/fonts/font-star.eot CHANGED
File without changes
assets/fonts/font-star.svg CHANGED
File without changes
assets/fonts/font-star.ttf CHANGED
File without changes
assets/fonts/font-star.woff CHANGED
File without changes
assets/images/bigthumb.png DELETED
Binary file
assets/images/largethumb.png ADDED
Binary file
assets/images/smallthumb.png CHANGED
Binary file
assets/js/admin.js CHANGED
@@ -27,6 +27,7 @@ $(document).ready(function() {
27
$('#wp-review-metabox-desc').hide();
28
$('#wp-review-metabox-userReview').hide();
29
$('#wp_review_shortcode_hint_field').hide();
30
31
$('#wp_review_type').on( 'change', function() {
32
@@ -34,6 +35,7 @@ $(document).ready(function() {
34
$('#wp-review-metabox-heading').toggle( $(this).val() != '' );
35
$('#wp-review-metabox-desc').toggle( $(this).val() != '' );
36
$('#wp-review-metabox-userReview').toggle( $(this).val() != '' );
37
38
if ( $(this).val() == 'point' ) {
39
$('.dynamic-text').text('Points (1-10)');
@@ -74,6 +76,10 @@ $(document).ready(function() {
74
$('#wp-review-metabox-userReview').show();
75
}
76
77
$('#wp_review_location').on('change', function() {
78
$('#wp_review_shortcode_hint_field').toggle($(this).val() == 'custom');
79
});
27
$('#wp-review-metabox-desc').hide();
28
$('#wp-review-metabox-userReview').hide();
29
$('#wp_review_shortcode_hint_field').hide();
30
+ $('#wp_review_id_hint').hide();
31
32
$('#wp_review_type').on( 'change', function() {
33
35
$('#wp-review-metabox-heading').toggle( $(this).val() != '' );
36
$('#wp-review-metabox-desc').toggle( $(this).val() != '' );
37
$('#wp-review-metabox-userReview').toggle( $(this).val() != '' );
38
+ $('#wp_review_id_hint').toggle( $(this).val() != '' );
39
40
if ( $(this).val() == 'point' ) {
41
$('.dynamic-text').text('Points (1-10)');
76
$('#wp-review-metabox-userReview').show();
77
}
78
79
+ if ( $('#wp_review_type option:selected').val() != '' ) {
80
+ $('#wp_review_id_hint').show();
81
+ }
82
+
83
$('#wp_review_location').on('change', function() {
84
$('#wp_review_shortcode_hint_field').toggle($(this).val() == 'custom');
85
});
assets/js/main.js CHANGED
@@ -12,12 +12,12 @@ jQuery(document).ready(function($){
12
$('.review-total-star.allowed-to-rate .review-result-wrapper').hide();
13
$('.mts-review-wait-msg').show();
14
var blogID = $('#blog_id').val();
15
- var userIP = $('#mts-userIP').val();
16
var post_id = $('#post_id').val();
17
var user_id = $('#user_id').val();
18
var review = $(this).attr('data-input-value');
19
$.ajax ({
20
- data: {action: 'mts_review_get_review', post_id: post_id, user_id: user_id, ip: userIP, review: review},
21
type: 'post',
22
url: ajaxurl,
23
success: function( response ){
12
$('.review-total-star.allowed-to-rate .review-result-wrapper').hide();
13
$('.mts-review-wait-msg').show();
14
var blogID = $('#blog_id').val();
15
+ var token = $('#token').val();
16
var post_id = $('#post_id').val();
17
var user_id = $('#user_id').val();
18
var review = $(this).attr('data-input-value');
19
$.ajax ({
20
+ data: {action: 'mts_review_get_review', post_id: post_id, user_id: user_id, nonce: token, review: review},
21
type: 'post',
22
url: ajaxurl,
23
success: function( response ){
assets/js/wp-review-tab-widget-admin.js ADDED
@@ -0,0 +1,27 @@
1
+ jQuery(document).on('click', function(e) {
2
+ var $this = jQuery(e.target);
3
+ var $form = $this.closest('.wp_review_tab_options_form');
4
+
5
+ if ($this.is('.wp_review_tab_enable_toprated')) {
6
+ $form.find('.wp_review_tab_toprated_order').slideToggle($this.is(':checked'));
7
+ $form.find('.wp_review_tab_toprated_title').slideToggle($this.is(':checked'));
8
+ } else if ($this.is('.wp_review_tab_enable_recent')) {
9
+ $form.find('.wp_review_tab_recent_order').slideToggle($this.is(':checked'));
10
+ $form.find('.wp_review_tab_recent_title').slideToggle($this.is(':checked'));
11
+ } else if ($this.is('.wp_review_tab_enable_mostvoted')) {
12
+ $form.find('.wp_review_tab_mostvoted_order').slideToggle($this.is(':checked'));
13
+ $form.find('.wp_review_tab_mostvoted_title').slideToggle($this.is(':checked'));
14
+ } else if ($this.is('.wp_review_tab_enable_custom')) {
15
+ $form.find('.wp_review_tab_custom_order').slideToggle($this.is(':checked'));
16
+ $form.find('.wp_review_tab_custom_title').slideToggle($this.is(':checked'));
17
+ $form.find('.wp_review_tab_custom_reviews').slideToggle($this.is(':checked'));
18
+ } else if ($this.is('.wp_review_tab_order_header')) {
19
+ e.preventDefault();
20
+ $form.find('.wp_review_tab_order').slideToggle();
21
+ $form.find('.wp_review_tab_titles').slideUp();
22
+ } else if ($this.is('.wp_review_tab_titles_header')) {
23
+ e.preventDefault();
24
+ $form.find('.wp_review_tab_titles').slideToggle();
25
+ $form.find('.wp_review_tab_order').slideUp();
26
+ }
27
+ });
assets/js/wp-review-tab-widget.js ADDED
@@ -0,0 +1,63 @@
1
+ function wp_review_tab_loadTabContent(tab_name, page_num, container, args_obj) {
2
+
3
+ var container = jQuery(container);
4
+ var tab_content = container.find('#'+tab_name+'-tab-content');
5
+
6
+ // only load content if it wasn't already loaded
7
+ var isLoaded = tab_content.data('loaded');
8
+
9
+ if (!isLoaded || page_num != 1) {
10
+ if (!container.hasClass('wp-review-tab-loading')) {
11
+ container.addClass('wp-review-tab-loading');
12
+
13
+ tab_content.load(wp_review_tab.ajax_url, {
14
+ action: 'wp_review_tab_widget_content',
15
+ tab: tab_name,
16
+ page: page_num,
17
+ args: args_obj
18
+ }, function() {
19
+ container.removeClass('wp-review-tab-loading');
20
+ tab_content.data('loaded', 1).hide().fadeIn().siblings().hide();
21
+ }
22
+ );
23
+ }
24
+ } else {
25
+ tab_content.fadeIn().siblings().hide();
26
+ }
27
+ }
28
+
29
+ jQuery(document).ready(function() {
30
+ jQuery('.wp_review_tab_widget_content').each(function() {
31
+ var $this = jQuery(this);
32
+ var widget_id = this.id;
33
+ var args = $this.data('args');
34
+
35
+ // load tab content on click
36
+ $this.find('.wp-review-tabs a').click(function(e) {
37
+ e.preventDefault();
38
+ jQuery(this).parent().addClass('selected').siblings().removeClass('selected');
39
+ var tab_name = this.id.slice(0, -4); // -tab
40
+ wp_review_tab_loadTabContent(tab_name, 1, $this, args);
41
+ });
42
+
43
+ // pagination
44
+ $this.on('click', '.wp-review-tab-pagination a', function(e) {
45
+ e.preventDefault();
46
+ var $this_a = jQuery(this);
47
+ var tab_name = $this_a.closest('.tab-content').attr('id').slice(0, -12); // -tab-content
48
+ var page_num = parseInt($this_a.closest('.tab-content').children('.page_num').val());
49
+
50
+ if ($this_a.hasClass('next')) {
51
+ wp_review_tab_loadTabContent(tab_name, page_num + 1, $this, args);
52
+ } else {
53
+ $this.find('#'+tab_name+'-tab-content').data('loaded', 0);
54
+ wp_review_tab_loadTabContent(tab_name, page_num - 1, $this, args);
55
+ }
56
+
57
+ });
58
+
59
+ // load first tab now
60
+ $this.find('.wp-review-tabs a').first().click();
61
+ });
62
+
63
+ });
includes/enqueue.php CHANGED
File without changes
includes/functions.php CHANGED
@@ -1,482 +1,499 @@
1
- <?php
2
- ob_start();
3
- /**
4
- * WP Review
5
- *
6
- * @since 2.0
7
- * @copyright Copyright (c) 2013, MyThemesShop
8
- * @author MyThemesShop
9
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
- */
11
-
12
- /* Display the meta box data below 'the_content' hook. */
13
- add_filter( 'the_content', 'wp_review_inject_data' );
14
-
15
- /* Custom review color. */
16
- add_action( 'wp_head', 'wp_review_color_output', 20 );
17
-
18
- /* Get review with Ajax */
19
- add_action('wp_ajax_mts_review_get_review', 'mts_review_get_review');
20
- add_action('wp_ajax_nopriv_mts_review_get_review', 'mts_review_get_review');
21
-
22
- /* Show with shortcode */
23
- add_shortcode('wp-review', 'wp_review_get_data');
24
- add_shortcode('wp-review-total', 'wp_review_total_shortcode');
25
-
26
- // image sizes for the widgets
27
- //add_image_size( 'wp_review_big', 320, 200, true );
28
- //add_image_size( 'wp_review_small', 65, 65, true );
29
-
30
- /**
31
- * Set new default colors for the WP Review meta boxes.
32
- * Passed array doesn't have to contain all values,
33
- * it is possible to change values separately, eg.
34
- * wp_review_set_default_colors( array( 'font_color' => '#222222' ) );
35
- *
36
- * To be used in themes & plugins.
37
- *
38
- * @since 1.0
39
- *
40
- */
41
- function wp_review_set_default_colors( $colors = array() ) {
42
- $current_colors = get_option('wp_review_default_colors', $defaultColors);
43
- $colors = wp_parse_args($colors, $current_colors);
44
- update_option('wp_review_default_colors', $colors);
45
- }
46
-
47
-
48
- /**
49
- * Get the meta box data.
50
- *
51
- * @since 1.0
52
- *
53
- */
54
- function wp_review_get_data() {
55
- global $post;
56
- global $blog_id;
57
-
58
- /* Retrieve the meta box data. */
59
- $heading = get_post_meta( $post->ID, 'wp_review_heading', true );
60
- $desc = get_post_meta( $post->ID, 'wp_review_desc', true );
61
- $items = get_post_meta( $post->ID, 'wp_review_item', true );
62
- $type = get_post_meta( $post->ID, 'wp_review_type', true );
63
- $total = get_post_meta( $post->ID, 'wp_review_total', true );
64
- $allowUsers = get_post_meta( $post->ID, 'wp_review_userReview', true );
65
-
66
- /* Define a custom class for bar type. */
67
- $class = '';
68
- if ( 'point' == $type ) {
69
- $class = 'bar-point';
70
- } elseif ( 'percentage' == $type ) {
71
- $class = 'percentage-point';
72
- }
73
- $post_types = get_post_types( array('public' => true), 'names' );
74
- $excluded_post_types = array('attachment');
75
- $allowed_post_types = array();
76
- foreach ($post_types as $i => $post_type) {
77
- if (!in_array($post_type, $excluded_post_types)) {
78
- $allowed_post_types[] = $post_type;
79
- }
80
- }
81
-
82
- /**
83
- * Add the custom data from the meta box to the main query an
84
- * make sure the hook only apply on single post.
85
- */
86
- if ( $type != '' && is_singular($allowed_post_types) && is_main_query() ) {
87
-
88
-
89
- $review = '<div id="review" class="review-wrapper ' . $class . '" >';
90
-
91
- /* Review title. */
92
- if( $heading != '' ){
93
- $review .= '<h5 class="review-title">' . __( $heading ) . '</h5>';
94
- }
95
-
96
-
97
- /* Review item. */
98
- if ( $items ) {
99
- $review .= '<ul class="review-list">';
100
- foreach( $items as $item ) {
101
-
102
- $item['wp_review_item_title'] = ( !empty( $item['wp_review_item_title'] ) ) ? $item['wp_review_item_title'] : '';
103
- $item['wp_review_item_star'] = ( !empty( $item['wp_review_item_star'] ) ) ? $item['wp_review_item_star'] : '';
104
-
105
- if ( 'star' == $type ) {
106
- $result = $item['wp_review_item_star'] * 20;
107
- $bestresult = '<meta itemprop="best" content="5"/>';
108
- $best = '5';
109
- } elseif( 'point' == $type ) {
110
- $result = $item['wp_review_item_star'] * 10;
111
- $bestresult = '<meta itemprop="best" content="10"/>';
112
- $best = '10';
113
- } else {
114
- $result = $item['wp_review_item_star'] * 100 / 100;
115
- $bestresult = '<meta itemprop="best" content="100"/>';
116
- $best = '100';
117
- }
118
-
119
- $review .= '<li>';
120
-
121
- if ( 'point' == $type ) {
122
- $review .= '<span>' . wp_kses_post( $item['wp_review_item_title'] ) . ' - ' . $item['wp_review_item_star'] . '</span>';
123
- } elseif( 'percentage' == $type ) {
124
- $review .= '<span>' . wp_kses_post( $item['wp_review_item_title'] ) . ' - ' . $item['wp_review_item_star'] . '%' . '</span>';
125
- } else {
126
- $review .= '<span>' . wp_kses_post( $item['wp_review_item_title'] ) . '</span>';
127
- }
128
-
129
- $review .= '<div class="review-star">';
130
- $review .= '<div class="review-result-wrapper">';
131
-
132
- if ( 'star' == $type ) {
133
- $review .= '<i class="mts-icon-star"></i>';
134
- $review .= '<i class="mts-icon-star"></i>';
135
- $review .= '<i class="mts-icon-star"></i>';
136
- $review .= '<i class="mts-icon-star"></i>';
137
- $review .= '<i class="mts-icon-star"></i>';
138
- $review .= '<div class="review-result" style="width:' . $result . '%;">';
139
- $review .= '<i class="mts-icon-star"></i>';
140
- $review .= '<i class="mts-icon-star"></i>';
141
- $review .= '<i class="mts-icon-star"></i>';
142
- $review .= '<i class="mts-icon-star"></i>';
143
- $review .= '<i class="mts-icon-star"></i>';
144
- $review .= '</div><!-- .review-result -->';
145
- } elseif ( 'point' == $type ) {
146
- $review .= '<div class="review-result" style="width:' . $result . '%;">' . $item['wp_review_item_star'] . '</div>';
147
- } else {
148
- $review .= '<div class="review-result" style="width:' . $result . '%;">' . $item['wp_review_item_star'] . '</div>';
149
- }
150
-
151
- $review .= '</div><!-- .review-result-wrapper -->';
152
- $review .= '</div><!-- .review-star -->';
153
- $review .= '</li>';
154
-
155
- }
156
- $review .= '</ul>';
157
- }
158
-
159
- /* Review description. */
160
- if ( $desc ) {
161
- $review .= '<div class="review-desc" >';
162
- $review .= '<p class="review-summary-title"><strong>' . __( 'Summary', 'mts-review' ) . '</strong></p>';
163
- $review .= wp_kses_post( wpautop( $desc ) );
164
- $review .= '</div><!-- .review-desc -->';
165
-
166
- }//**END IF HAS DESCRIPTION**
167
- if( $total != '' ){
168
- $review .= '<div class="review-total-wrapper"> ';
169
-
170
- if ( 'percentage' == $type ) {
171
- $review .= '<span class="review-total-box"><span itemprop="review">' . $total . '</span> <i class="percentage-icon">%</i>' . '</span>';
172
- } elseif ( 'point' == $type ) {
173
- $review .= '<span class="review-total-box" itemprop="review">' . $total . '/'.__('10','mts-review').'</span></span>';
174
- } else {
175
- $review .= '<span class="review-total-box" itemprop="review">' . $total . '</span></span>';
176
- }
177
-
178
- if ( 'star' == $type ) {
179
- $review .= '<div class="review-total-star">';
180
- $review .= '<div class="review-result-wrapper">';
181
- $review .= '<i class="mts-icon-star"></i>';
182
- $review .= '<i class="mts-icon-star"></i>';
183
- $review .= '<i class="mts-icon-star"></i>';
184
- $review .= '<i class="mts-icon-star"></i>';
185
- $review .= '<i class="mts-icon-star"></i>';
186
- $review .= '<div class="review-result" style="width:' . $total*20 . '%;">';
187
- $review .= '<i class="mts-icon-star"></i>';
188
- $review .= '<i class="mts-icon-star"></i>';
189
- $review .= '<i class="mts-icon-star"></i>';
190
- $review .= '<i class="mts-icon-star"></i>';
191
- $review .= '<i class="mts-icon-star"></i>';
192
- $review .= '</div><!-- .review-result -->';
193
- $review .= '</div><!-- .review-result-wrapper -->';
194
- $review .= '</div><!-- .review-star -->';
195
- }
196
-
197
- $review .= '</div>';
198
-
199
-
200
- $review .= '<div itemscope="itemscope" itemtype="http://data-vocabulary.org/Review">
201
- <meta itemprop="itemreviewed" content="'.__( $heading ).'">
202
-
203
- <span itemprop="rating" itemscope="itemscope"itemtype="http://data-vocabulary.org/Rating">
204
- <meta itemprop="value" content="'.$total.'">
205
- <meta itemprop="best" content="'.$best.'">
206
- </span>
207
- <span itemprop="reviewer" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
208
- <meta itemprop="name" content="'. get_the_author() .'">
209
- </span>
210
- </div>';
211
- }
212
-
213
- /**
214
- * USERS REVIEW AREA
215
- */
216
-
217
- if( is_array( $allowUsers ) && $allowUsers[0] == 1 ){
218
- $allowedClass = 'allowed-to-rate';
219
- $hasNotRatedClass = 'has-not-rated-yet';
220
- $postReviews = mts_get_post_reviews( $post->ID );
221
- $userTotal = $postReviews[0]->reviewsAvg;
222
- $usersReviewsCount = $postReviews[0]->reviewsNum;
223
-
224
- $review .= '<div style="clear: both;"></div>';
225
-
226
- $review .= '<div class="user-review-area">';
227
-
228
- //$ip = $_SERVER['REMOTE_ADDR'];
229
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
230
- $ip = $_SERVER['HTTP_CLIENT_IP'];
231
- } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
232
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
233
- } else {
234
- $ip = $_SERVER['REMOTE_ADDR'];
235
- }
236
- $user_id = '';
237
- if ( is_user_logged_in() ) { $user_id = get_current_user_id(); }
238
- //echo $blog_id;
239
- $review .= '<input type="hidden" id="blog_id" value="'.$blog_id.'">';
240
- $review .= '<input type="hidden" id="post_id" value="'.$post->ID.'">';
241
- $review .= '<input type="hidden" id="user_id" value="'.$user_id.'">';
242
- $review .= '<input type="hidden" id="mts-userIP" value="'.$ip.'">';
243
-
244
- if( $userTotal == '' ) $userTotal = '0.0';
245
- $review .= '<div class="user-total-wrapper"><span class="user-review-title">'.__('User Rating','mts-review').': </span><span class="review-total-box"><span id="mts-user-reviews-total">' . $userTotal . '</span> ';
246
- $review.= '<small>(<span id="mts-user-reviews-counter" >'.$usersReviewsCount.'</span> '.__('votes', 'mts-review').')</small></span></div>';
247
-
248
- if( hasPreviousReview( $post->ID, $user_id, $ip )) {
249
- $hasNotRatedClass = '';
250
- }
251
-
252
- $review .= '<div class="review-total-star '.$allowedClass.' '.$hasNotRatedClass.'" >';
253
- $review .='<div class="mts-review-wait-msg"><span class="animate-spin mts-icon-loader"></span>'.__('Sending','mts-review').'</div>';
254
- $review .= '<div class="review-result-wrapper">';
255
- $review .= '<a data-input-value="1" title="1/5"><i class="mts-icon-star"></i></a>';
256
- $review .= '<a data-input-value="2" title="2/5"><i class="mts-icon-star"></i></a>';
257
- $review .= '<a data-input-value="3" title="3/5"><i class="mts-icon-star"></i></a>';
258
- $review .= '<a data-input-value="4" title="4/5"><i class="mts-icon-star"></i></a>';
259
- $review .= '<a data-input-value="5" title="5/5"><i class="mts-icon-star"></i></a>';
260
- $review .= '<div class="review-result" style="width:' . $userTotal*20 . '%;">';
261
- $review .= '<i class="mts-icon-star"></i>';
262
- $review .= '<i class="mts-icon-star"></i>';
263
- $review .= '<i class="mts-icon-star"></i>';
264
- $review .= '<i class="mts-icon-star" style=""></i>';
265
- $review .= '<i class="mts-icon-star"></i>';
266
- $review .= '</div><!-- .review-result -->';
267
- $review .= '</div><!-- .review-result-wrapper -->';
268
- $review .= '</div><!-- .review-star -->';
269
- $review .= '<input type="hidden" id="mts-review-user-rate" value="" />';
270
-
271
- $review .= '</div>';
272
-
273
- $review .= '<div itemscope itemtype="http://schema.org/Review">
274
- <div itemprop="reviewRating" itemscope itemtype="http://schema.org/AggregateRating">
275
- <meta itemprop="ratingValue" content="'.$userTotal.'" />
276
- <meta itemprop="bestRating" content="5"/>
277
- <meta itemprop="ratingCount" content="'.$usersReviewsCount.'" />
278
- </div>
279
- </div>';
280
-
281
- }//**END IF USERS ALLOWED TO RATE**
282
-
283
-
284
- $review .= '</div><!-- #review -->';
285
-
286
- return $review;
287
- } else {
288
- return '';
289
- }
290
- }
291
-
292
- function wp_review_inject_data( $content ) {
293
- global $post;
294
- $location = get_post_meta( $post->ID, 'wp_review_location', true );
295
- if (empty($location) || $location == 'custom') {
296
- return $content;
297
- }
298
-
299
- $review = wp_review_get_data();
300
- if ( 'bottom' == $location ) {
301
- return $content .= $review;
302
- } elseif ( 'top' == $location ) {
303
- return $review .= $content;
304
- } else {
305
- return $content;
306
- }
307
- }
308
-
309
- /**
310
- * Retrieve only total rating.
311
- * To be used on archive pages, etc.
312
- *
313
- * @since 1.0
314
- *
315
- */
316
- function wp_review_show_total($echo = true, $class = 'review-total-only') {
317
- global $post;
318
- $type = get_post_meta( $post->ID, 'wp_review_type', true );
319
- $total = get_post_meta( $post->ID, 'wp_review_total', true );
320
- $review = '';
321
-
322
- if (!empty($type) && !empty($total)) {
323
- wp_enqueue_style( 'wp_review-style', trailingslashit( WP_REVIEW_ASSETS ) . 'css/wp-review.css', array(), '1.0', 'all' );
324
-
325
- $review = '<div class="review-type-'.$type.' '.esc_attr($class).'"> ';
326
-
327
- if ( 'percentage' == $type ) {
328
- $review .= '<span class="review-total-box"><span itemprop="review">' . $total . '</span> <i class="percentage-icon">%</i>' . '</span>';
329
- } elseif ( 'point' == $type ) {
330
- $review .= '<span class="review-total-box" itemprop="review">' . $total . '</span>/'.__('10','mts-review').'</span>';
331
- } else {
332
- // star
333
- $review .= '<div class="review-total-star">';
334
- $review .= '<div class="review-result-wrapper">';
335
- $review .= '<i class="mts-icon-star"></i>';
336
- $review .= '<i class="mts-icon-star"></i>';
337
- $review .= '<i class="mts-icon-star"></i>';
338
- $review .= '<i class="mts-icon-star"></i>';
339
- $review .= '<i class="mts-icon-star"></i>';
340
- $review .= '<div class="review-result" style="width:' . $total*22 . '%;">';
341
- $review .= '<i class="mts-icon-star"></i>';
342
- $review .= '<i class="mts-icon-star"></i>';
343
- $review .= '<i class="mts-icon-star"></i>';
344
- $review .= '<i class="mts-icon-star"></i>';
345
- $review .= '<i class="mts-icon-star"></i>';
346
- $review .= '</div><!-- .review-result -->';
347
- $review .= '</div><!-- .review-result-wrapper -->';
348
- $review .= '</div><!-- .review-star -->';
349
- }
350
-
351
- $review .= '</div>';
352
- }
353
-
354
- if ($echo)
355
- echo $review;
356
- else
357
- return $review;
358
- }
359
- function wp_review_total_shortcode($atts, $content) {
360
- if (empty($atts['class']))
361
- $atts['class'] = 'review-total-only review-total-shortcode';
362
-
363
- return wp_review_show_total(false, $atts['class']);
364
- }
365
-
366
- function mts_get_post_reviews( $post_id ){
367
- if( is_numeric( $post_id ) && $post_id > 0 ){
368
- global $wpdb;
369
- global $blog_id;
370
- $table_name = $wpdb->prefix . MTS_WP_REVIEW_DB_TABLE;
371
- if (function_exists('is_multisite') && is_multisite()) {$table_name = $wpdb->base_prefix . MTS_WP_REVIEW_DB_TABLE;}
372
- $reviews = $wpdb->get_results( $wpdb->prepare("SELECT ROUND( AVG(rate) ,1 ) as reviewsAvg, COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d'", $blog_id, $post_id) );
373
- return $reviews;
374
- }
375
- }
376
-
377
-
378
- /**
379
- * Star review color
380
- *
381
- * @since 1.0
382
- */
383
- function wp_review_color_output() {
384
- global $post;
385
-
386
- /* Retrieve the meta box data. */
387
- if(is_singular()) {
388
- $color = get_post_meta( $post->ID, 'wp_review_color', true );
389
- $type = get_post_meta( $post->ID, 'wp_review_type', true );
390
- $fontcolor = get_post_meta( $post->ID, 'wp_review_fontcolor', true );
391
- $bgcolor1 = get_post_meta( $post->ID, 'wp_review_bgcolor1', true );
392
- $bgcolor2 = get_post_meta( $post->ID, 'wp_review_bgcolor2', true );
393
- $bordercolor = get_post_meta( $post->ID, 'wp_review_bordercolor', true );
394
- $total = get_post_meta( $post->ID, 'wp_review_total', true );
395
-
396
- if( !$color ) $color = '#333333';
397
-
398
- if( $color ) {
399
- echo '<style type="text/css">';
400
-
401
- if ( 'star' == $type ) { ?>
402
-
403
- .review-result-wrapper .review-result i { color: <?php echo $color; ?>; opacity: 1; filter: alpha(opacity=100); }
404
- .review-result-wrapper i{ color: <?php echo $color; ?>; opacity: 0.50; filter: alpha(opacity=50); }
405
-
406
- <?php } elseif ( 'point' == $type ) { ?>
407
-
408
- .bar-point .review-result { background-color: <?php echo $color; ?>; }
409
-
410
- <?php } else { ?>
411
-
412
- .percentage-point .review-result { background-color: <?php echo $color; ?>; }
413
-
414
- <?php }
415
- ?>
416
- .review-wrapper, .review-title, .review-desc p{ color: <?php echo $fontcolor; ?>;}
417
- .review-list li, .review-wrapper{ background: <?php echo $bgcolor2; ?>;}
418
- .review-title, .review-list li:nth-child(2n){background: <?php echo $bgcolor1; ?>;}
419
-
420
- .bar-point .allowed-to-rate .review-result, .percentage-point .allowed-to-rate .review-result{background: none;}
421
- .review-total-star.allowed-to-rate a i { color: <?php echo $color; ?>; opacity: 0.50; filter: alpha(opacity=50); }
422
- .bar-point .allowed-to-rate .review-result, .percentage-point .allowed-to-rate .review-result{text-indent:0;}
423
- .bar-point .allowed-to-rate .review-result i, .percentage-point .allowed-to-rate .review-result i, .mts-user-review-star-container .selected i { color: <?php echo $color; ?>; opacity: 1; filter: alpha(opacity=100); }
424
- .review-wrapper, .review-title, .review-list li, .review-list li:last-child, .user-review-area{border-color: <?php echo $bordercolor; ?>;}
425
- <?php
426
- if( $total == '' ){?>
427
- .user-review-area{border: 1px solid <?php echo $bordercolor; ?>; margin-top: 0px;}
428
- .review-desc{width: 100%;}
429
- .review-wrapper{border: none; overflow: visible;}
430
- <?php }
431
- echo '</style>';
432
- }
433
- }
434
- }
435
-
436
- /**
437
- *Check if user has reviewed this post previously
438
- */
439
- function hasPreviousReview( $post_id, $user_id, $ip ){
440
- if( is_numeric( $post_id ) && $post_id > 0 ){
441
- global $wpdb;
442
- global $blog_id;
443
- $table_name = $wpdb->prefix . MTS_WP_REVIEW_DB_TABLE;
444
- if (function_exists('is_multisite') && is_multisite()) {$table_name = $wpdb->base_prefix . MTS_WP_REVIEW_DB_TABLE;}
445
- if( is_numeric( $user_id ) && $user_id > 0 ){
446
- $prevRates = $wpdb->get_row( $wpdb->prepare("SELECT COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d' AND user_id = '%d'", $blog_id, $post_id, $user_id) );
447
- if( $prevRates->reviewsNum > 0 ) return true; else return false;
448
- }
449
- elseif( $ip != '' ){
450
- $prevRates = $wpdb->get_row( $wpdb->prepare("SELECT COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d' AND user_ip = '%s' AND user_id = '0'", $blog_id, $post_id, $ip) );
451
- if( $prevRates->reviewsNum > 0 ) return true; else return false;
452
- }
453
- else return false;
454
- }
455
- return false;
456
- }
457
-
458
-
459
- /**
460
- *Get review with Ajax
461
- */
462
- function mts_review_get_review(){
463
- global $wpdb;
464
-
465
- $table_name = $wpdb->prefix . MTS_WP_REVIEW_DB_TABLE;
466
- if (function_exists('is_multisite') && is_multisite()) {$table_name = $wpdb->base_prefix . MTS_WP_REVIEW_DB_TABLE;}
467
-
468
- global $blog_id;
469
- $post_id = $_POST['post_id'];
470
- $user_id = $_POST['user_id'];
471
- $uip = $_POST['ip'];
472
- $data = $_POST['review'];
473
-
474
- if( $rows_affected = $wpdb->insert( $table_name, array('blog_id' => $blog_id, 'post_id' => $post_id, 'user_id' => $user_id, 'user_ip' => $uip, 'rate' => $data, 'date' => current_time('mysql')) ) ){
475
- $reviews = $wpdb->get_row( $wpdb->prepare("SELECT ROUND( AVG(rate) ,1 ) as reviewsAvg, COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d'", $blog_id, $post_id) );
476
- echo $reviews->reviewsAvg.'|'.$reviews->reviewsNum;
477
- }
478
- else echo 'MTS_REVIEW_DB_ERROR';
479
- exit;
480
- }
481
-
482
?>
1
+ <?php
2
+ ob_start();
3
+ /**
4
+ * WP Review
5
+ *
6
+ * @since 2.0
7
+ * @copyright Copyright (c) 2013, MyThemesShop
8
+ * @author MyThemesShop
9
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
+ */
11
+
12
+ /* Display the meta box data below 'the_content' hook. */
13
+ add_filter( 'the_content', 'wp_review_inject_data' );
14
+
15
+ /* Custom review color. */
16
+ add_action( 'wp_head', 'wp_review_color_output', 20 );
17
+
18
+ /* Get review with Ajax */
19
+ add_action('wp_ajax_mts_review_get_review', 'mts_review_get_review');
20
+ add_action('wp_ajax_nopriv_mts_review_get_review', 'mts_review_get_review');
21
+
22
+ /* Show with shortcode */
23
+ add_shortcode('wp-review', 'wp_review_get_data');
24
+ add_shortcode('wp-review-total', 'wp_review_total_shortcode');
25
+
26
+ // image sizes for the widgets
27
+ add_image_size( 'wp_review_large', 320, 200, true );
28
+ add_image_size( 'wp_review_small', 65, 65, true );
29
+
30
+ /**
31
+ * Get the meta box data.
32
+ *
33
+ * @since 1.0
34
+ *
35
+ */
36
+ function wp_review_get_data() {
37
+ global $post;
38
+ global $blog_id;
39
+
40
+ /* Retrieve the meta box data. */
41
+ $heading = get_post_meta( $post->ID, 'wp_review_heading', true );
42
+ $desc = get_post_meta( $post->ID, 'wp_review_desc', true );
43
+ $items = get_post_meta( $post->ID, 'wp_review_item', true );
44
+ $type = get_post_meta( $post->ID, 'wp_review_type', true );
45
+ $total = get_post_meta( $post->ID, 'wp_review_total', true );
46
+ $allowUsers = get_post_meta( $post->ID, 'wp_review_userReview', true );
47
+
48
+ /* Define a custom class for bar type. */
49
+ $class = '';
50
+ if ( 'point' == $type ) {
51
+ $class = 'bar-point';
52
+ } elseif ( 'percentage' == $type ) {
53
+ $class = 'percentage-point';
54
+ }
55
+ $post_types = get_post_types( array('public' => true), 'names' );
56
+ $excluded_post_types = array('attachment');
57
+ $allowed_post_types = array();
58
+ foreach ($post_types as $i => $post_type) {
59
+ if (!in_array($post_type, $excluded_post_types)) {
60
+ $allowed_post_types[] = $post_type;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Add the custom data from the meta box to the main query an
66
+ * make sure the hook only apply on single post.
67
+ */
68
+ if ( $type != '' && is_singular($allowed_post_types) && is_main_query() ) {
69
+
70
+
71
+ $review = '<div id="review" class="review-wrapper ' . $class . '" >';
72
+
73
+ /* Review title. */
74
+ if( $heading != '' ){
75
+ $review .= '<h5 class="review-title">' . __( $heading ) . '</h5>';
76
+ }
77
+
78
+
79
+ /* Review item. */
80
+ if ( $items ) {
81
+ $review .= '<ul class="review-list">';
82
+ foreach( $items as $item ) {
83
+
84
+ $item['wp_review_item_title'] = ( !empty( $item['wp_review_item_title'] ) ) ? $item['wp_review_item_title'] : '';
85
+ $item['wp_review_item_star'] = ( !empty( $item['wp_review_item_star'] ) ) ? $item['wp_review_item_star'] : '';
86
+
87
+ if ( 'star' == $type ) {
88
+ $result = $item['wp_review_item_star'] * 20;
89
+ $bestresult = '<meta itemprop="best" content="5"/>';
90
+ $best = '5';
91
+ } elseif( 'point' == $type ) {
92
+ $result = $item['wp_review_item_star'] * 10;
93
+ $bestresult = '<meta itemprop="best" content="10"/>';
94
+ $best = '10';
95
+ } else {
96
+ $result = $item['wp_review_item_star'] * 100 / 100;
97
+ $bestresult = '<meta itemprop="best" content="100"/>';
98
+ $best = '100';
99
+ }
100
+
101
+ $review .= '<li>';
102
+
103
+ if ( 'point' == $type ) {
104
+ $review .= '<span>' . wp_kses_post( $item['wp_review_item_title'] ) . ' - ' . $item['wp_review_item_star'] . '/10</span>';
105
+ } elseif( 'percentage' == $type ) {
106
+ $review .= '<span>' . wp_kses_post( $item['wp_review_item_title'] ) . ' - ' . $item['wp_review_item_star'] . '%' . '</span>';
107
+ } else {
108
+ $review .= '<span>' . wp_kses_post( $item['wp_review_item_title'] ) . '</span>';
109
+ }
110
+
111
+ $review .= '<div class="review-star">';
112
+ $review .= '<div class="review-result-wrapper">';
113
+
114
+ if ( 'star' == $type ) {
115
+ $review .= '<i class="mts-icon-star"></i>';
116
+ $review .= '<i class="mts-icon-star"></i>';
117
+ $review .= '<i class="mts-icon-star"></i>';
118
+ $review .= '<i class="mts-icon-star"></i>';
119
+ $review .= '<i class="mts-icon-star"></i>';
120
+ $review .= '<div class="review-result" style="width:' . $result . '%;">';
121
+ $review .= '<i class="mts-icon-star"></i>';
122
+ $review .= '<i class="mts-icon-star"></i>';
123
+ $review .= '<i class="mts-icon-star"></i>';
124
+ $review .= '<i class="mts-icon-star"></i>';
125
+ $review .= '<i class="mts-icon-star"></i>';
126
+ $review .= '</div><!-- .review-result -->';
127
+ } elseif ( 'point' == $type ) {
128
+ $review .= '<div class="review-result" style="width:' . $result . '%;">' . $item['wp_review_item_star'] . '/10</div>';
129
+ } else {
130
+ $review .= '<div class="review-result" style="width:' . $result . '%;">' . $item['wp_review_item_star'] . '</div>';
131
+ }
132
+
133
+ $review .= '</div><!-- .review-result-wrapper -->';
134
+ $review .= '</div><!-- .review-star -->';
135
+ $review .= '</li>';
136
+
137
+ }
138
+ $review .= '</ul>';
139
+ }
140
+
141
+ /* Review description. */
142
+ if ( $desc ) {
143
+ $review .= '<div class="review-desc" >';
144
+ $review .= '<p class="review-summary-title"><strong>' . __( 'Summary', 'mts-review' ) . '</strong></p>';
145
+ $review .= do_shortcode ( shortcode_unautop( wp_kses_post( wpautop( $desc ) ) ) );
146
+ $review .= '</div><!-- .review-desc -->';
147
+
148
+ }//**END IF HAS DESCRIPTION**
149
+ if( $total != '' ){
150
+ $review .= '<div class="review-total-wrapper"> ';
151
+
152
+ if ( 'percentage' == $type ) {
153
+ $review .= '<span class="review-total-box"><span itemprop="review">' . $total . '</span> <i class="percentage-icon">%</i>' . '</span>';
154
+ }
155
+
156
+ if ( 'point' == $type ) {
157
+ $review .= '<span class="review-total-box" itemprop="review">' . $total . '/10</span></span>';
158
+ }
159
+
160
+ if ( 'star' == $type ) {
161
+ $review .= '<div class="review-total-star">';
162
+ $review .= '<div class="review-result-wrapper">';
163
+ $review .= '<i class="mts-icon-star"></i>';
164
+ $review .= '<i class="mts-icon-star"></i>';
165
+ $review .= '<i class="mts-icon-star"></i>';
166
+ $review .= '<i class="mts-icon-star"></i>';
167
+ $review .= '<i class="mts-icon-star"></i>';
168
+ $review .= '<div class="review-result" style="width:' . $total*20 . '%;">';
169
+ $review .= '<i class="mts-icon-star"></i>';
170
+ $review .= '<i class="mts-icon-star"></i>';
171
+ $review .= '<i class="mts-icon-star"></i>';
172
+ $review .= '<i class="mts-icon-star"></i>';
173
+ $review .= '<i class="mts-icon-star"></i>';
174
+ $review .= '</div><!-- .review-result -->';
175
+ $review .= '</div><!-- .review-result-wrapper -->';
176
+ $review .= '</div><!-- .review-star -->';
177
+ }
178
+
179
+ $review .= '</div>';
180
+
181
+
182
+ $review .= '<div itemscope="itemscope" itemtype="http://data-vocabulary.org/Review">
183
+ <meta itemprop="itemreviewed" content="'.__( $heading ).'">
184
+
185
+ <span itemprop="rating" itemscope="itemscope"itemtype="http://data-vocabulary.org/Rating">
186
+ <meta itemprop="value" content="'.$total.'">
187
+ <meta itemprop="best" content="'.$best.'">
188
+ </span>
189
+ <span itemprop="reviewer" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
190
+ <meta itemprop="name" content="'. get_the_author() .'">
191
+ </span>
192
+ </div>';
193
+ }
194
+
195
+ /**
196
+ * USERS REVIEW AREA
197
+ */
198
+
199
+ if( is_array( $allowUsers ) && $allowUsers[0] == 1 ){
200
+ $allowedClass = 'allowed-to-rate';
201
+ $hasNotRatedClass = 'has-not-rated-yet';
202
+ $postReviews = mts_get_post_reviews( $post->ID );
203
+ $userTotal = $postReviews[0]->reviewsAvg;
204
+ $usersReviewsCount = $postReviews[0]->reviewsNum;
205
+
206
+ $review .= '<div style="clear: both;"></div>';
207
+
208
+ $review .= '<div class="user-review-area">';
209
+ //$ip = $_SERVER['REMOTE_ADDR'];
210
+ if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
211
+ $ip = $_SERVER['HTTP_CLIENT_IP'];
212
+ } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
213
+ $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
214
+ } else {
215
+ $ip = $_SERVER['REMOTE_ADDR'];
216
+ }
217
+
218
+ $user_id = '';
219
+ if ( is_user_logged_in() ) { $user_id = get_current_user_id(); }
220
+ //echo $blog_id;
221
+ $review .= '<input type="hidden" id="blog_id" value="'.$blog_id.'">';
222
+ $review .= '<input type="hidden" id="post_id" value="'.$post->ID.'">';
223
+ $review .= '<input type="hidden" id="user_id" value="'.$user_id.'">';
224
+ $review .= '<input type="hidden" id="token" value="'.wp_create_nonce( "wp-review-security" ).'">';
225
+
226
+
227
+ if( $userTotal == '' ) $userTotal = '0.0';
228
+ $review .= '<div class="user-total-wrapper"><span class="user-review-title">'.__('User Rating','mts-review').': </span><span class="review-total-box"><span id="mts-user-reviews-total">' . $userTotal . '</span> ';
229
+ $review.= '<small>(<span id="mts-user-reviews-counter" >'.$usersReviewsCount.'</span> '.__('votes', 'mts-review').')</small></span></div>';
230
+
231
+ if( hasPreviousReview( $post->ID, $user_id, $ip )) {
232
+ $hasNotRatedClass = '';
233
+ }
234
+
235
+ $review .= '<div class="review-total-star '.$allowedClass.' '.$hasNotRatedClass.'" >';
236
+ $review .='<div class="mts-review-wait-msg"><span class="animate-spin mts-icon-loader"></span>'.__('Sending','mts-review').'</div>';
237
+ $review .= '<div class="review-result-wrapper">';
238
+ $review .= '<a data-input-value="1" title="1/5"><i class="mts-icon-star"></i></a>';
239
+ $review .= '<a data-input-value="2" title="2/5"><i class="mts-icon-star"></i></a>';
240
+ $review .= '<a data-input-value="3" title="3/5"><i class="mts-icon-star"></i></a>';
241
+ $review .= '<a data-input-value="4" title="4/5"><i class="mts-icon-star"></i></a>';
242
+ $review .= '<a data-input-value="5" title="5/5"><i class="mts-icon-star"></i></a>';
243
+ $review .= '<div class="review-result" style="width:' . $userTotal*20 . '%;">';
244
+ $review .= '<i class="mts-icon-star"></i>';
245
+ $review .= '<i class="mts-icon-star"></i>';
246
+ $review .= '<i class="mts-icon-star"></i>';
247
+ $review .= '<i class="mts-icon-star" style=""></i>';
248
+ $review .= '<i class="mts-icon-star"></i>';
249
+ $review .= '</div><!-- .review-result -->';
250
+ $review .= '</div><!-- .review-result-wrapper -->';
251
+ $review .= '</div><!-- .review-star -->';
252
+ $review .= '<input type="hidden" id="mts-review-user-rate" value="" />';
253
+
254
+ $review .= '</div>';
255
+
256
+ $review .= '<div itemscope itemtype="http://schema.org/Review">
257
+ <div itemprop="reviewRating" itemscope itemtype="http://schema.org/AggregateRating">
258
+ <meta itemprop="ratingValue" content="'.$userTotal.'" />
259
+ <meta itemprop="bestRating" content="5"/>
260
+ <meta itemprop="ratingCount" content="'.$usersReviewsCount.'" />
261
+ </div>
262
+ </div>';
263
+
264
+ }//**END IF USERS ALLOWED TO RATE**
265
+
266
+
267
+ $review .= '</div><!-- #review -->';
268
+
269
+ return $review;
270
+ } else {
271
+ return '';
272
+ }
273
+ }
274
+
275
+ function wp_review_inject_data( $content ) {
276
+ global $post;
277
+ $location = get_post_meta( $post->ID, 'wp_review_location', true );
278
+ $location = apply_filters('wp_review_location', $location, $post->ID);
279
+ if (empty($location) || $location == 'custom') {
280
+ return $content;
281
+ }
282
+ $review = wp_review_get_data();
283
+ if ( 'bottom' == $location ) {
284
+ global $multipage, $numpages, $page;
285
+ if( $multipage ) {
286
+ if ($page == $numpages) {
287
+ return $content .= $review;
288
+ } else {
289
+ return $content;
290
+ }
291
+ } else {
292
+ return $content .= $review;
293
+ }
294
+ } elseif ( 'top' == $location ) {
295
+ return $review .= $content;
296
+ } else {
297
+ return $content;
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Retrieve only total rating.
303
+ * To be used on archive pages, etc.
304
+ *
305
+ * @since 1.0
306
+ *
307
+ */
308
+ function wp_review_show_total($echo = true, $class = 'review-total-only') {
309
+ global $post;
310
+ $type = get_post_meta( $post->ID, 'wp_review_type', true );
311
+ $total = get_post_meta( $post->ID, 'wp_review_total', true );
312
+ $review = '';
313
+
314
+ if (!empty($type) && !empty($total)) {
315
+ wp_enqueue_style( 'wp_review-style', trailingslashit( WP_REVIEW_ASSETS ) . 'css/wp-review.css', array(), '1.0', 'all' );
316
+
317
+ $review = '<div class="review-type-'.$type.' '.esc_attr($class).'"> ';
318
+
319
+ if ( 'percentage' == $type ) {
320
+ $review .= '<span class="review-total-box"><span itemprop="review">' . $total . '</span> <i class="percentage-icon">%</i>' . '</span>';
321
+ } elseif ( 'point' == $type ) {
322
+ $review .= '<span class="review-total-box" itemprop="review">' . $total . '/10</span></span>';
323
+ } else {
324
+ // star
325
+ $review .= '<div class="review-total-star">';
326
+ $review .= '<div class="review-result-wrapper">';
327
+ $review .= '<i class="mts-icon-star"></i>';
328
+ $review .= '<i class="mts-icon-star"></i>';
329
+ $review .= '<i class="mts-icon-star"></i>';
330
+ $review .= '<i class="mts-icon-star"></i>';
331
+ $review .= '<i class="mts-icon-star"></i>';
332
+ $review .= '<div class="review-result" style="width:' . $total*20 . '%;">';
333
+ $review .= '<i class="mts-icon-star"></i>';
334
+ $review .= '<i class="mts-icon-star"></i>';
335
+ $review .= '<i class="mts-icon-star"></i>';
336
+ $review .= '<i class="mts-icon-star"></i>';
337
+ $review .= '<i class="mts-icon-star"></i>';
338
+ $review .= '</div><!-- .review-result -->';
339
+ $review .= '</div><!-- .review-result-wrapper -->';
340
+ $review .= '</div><!-- .review-star -->';
341
+ }
342
+
343
+ $review .= '</div>';
344
+ }
345
+
346
+ if ($echo)
347
+ echo $review;
348
+ else
349
+ return $review;
350
+ }
351
+ function wp_review_total_shortcode($atts, $content) {
352
+ if (empty($atts['class']))
353
+ $atts['class'] = 'review-total-only review-total-shortcode';
354
+
355
+ return wp_review_show_total(false, $atts['class']);
356
+ }
357
+
358
+ function mts_get_post_reviews( $post_id ){
359
+ if( is_numeric( $post_id ) && $post_id > 0 ){
360
+ global $wpdb;
361
+ global $blog_id;
362
+ $table_name = $wpdb->prefix . MTS_WP_REVIEW_DB_TABLE;
363
+ if (function_exists('is_multisite') && is_multisite()) {$table_name = $wpdb->base_prefix . MTS_WP_REVIEW_DB_TABLE;}
364
+ $reviews = $wpdb->get_results( $wpdb->prepare("SELECT ROUND( AVG(rate) ,1 ) as reviewsAvg, COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d'", $blog_id, $post_id) );
365
+ return $reviews;
366
+ }
367
+ }
368
+
369
+
370
+ /**
371
+ * Star review color
372
+ *
373
+ * @since 1.0
374
+ */
375
+ function wp_review_color_output() {
376
+ global $post;
377
+
378
+ /* Retrieve the meta box data. */
379
+ if(is_singular()) {
380
+ $colors = array();
381
+ $colors['color'] = get_post_meta( $post->ID, 'wp_review_color', true );
382
+ $colors['type'] = get_post_meta( $post->ID, 'wp_review_type', true );
383
+ $colors['fontcolor'] = get_post_meta( $post->ID, 'wp_review_fontcolor', true );
384
+ $colors['bgcolor1'] = get_post_meta( $post->ID, 'wp_review_bgcolor1', true );
385
+ $colors['bgcolor2'] = get_post_meta( $post->ID, 'wp_review_bgcolor2', true );
386
+ $colors['bordercolor'] = get_post_meta( $post->ID, 'wp_review_bordercolor', true );
387
+ $colors['total'] = get_post_meta( $post->ID, 'wp_review_total', true );
388
+
389
+ // Filter for changing colors
390
+ // Post ID gets passed as well
391
+ // Usage:
392
+ // add_filter( 'wp_review_colors', $function_to_add, 10, 2 );
393
+ $colors = apply_filters('wp_review_colors', $colors, $post->ID);
394
+ extract($colors, EXTR_SKIP);
395
+
396
+ if( !$color ) $color = '#333333';
397
+
398
+ if( $color ) {
399
+ echo '<style type="text/css">';
400
+
401
+ if ( 'star' == $type ) { ?>
402
+
403
+ .review-result-wrapper .review-result i { color: <?php echo $color; ?>; opacity: 1; filter: alpha(opacity=100); }
404
+ .review-result-wrapper i{ color: <?php echo $color; ?>; opacity: 0.50; filter: alpha(opacity=50); }
405
+
406
+ <?php } elseif ( 'point' == $type ) { ?>
407
+
408
+ .bar-point .review-result { background-color: <?php echo $color; ?>; }
409
+
410
+ <?php } else { ?>
411
+
412
+ .percentage-point .review-result { background-color: <?php echo $color; ?>; }
413
+
414
+ <?php }
415
+ ?>
416
+ .review-wrapper, .review-title, .review-desc p{ color: <?php echo $fontcolor; ?>;}
417
+ .review-list li, .review-wrapper{ background: <?php echo $bgcolor2; ?>;}
418
+ .review-title, .review-list li:nth-child(2n){background: <?php echo $bgcolor1; ?>;}
419
+
420
+ .bar-point .allowed-to-rate .review-result, .percentage-point .allowed-to-rate .review-result{background: none;}
421
+ .review-total-star.allowed-to-rate a i { color: <?php echo $color; ?>; opacity: 0.50; filter: alpha(opacity=50); }
422
+ .bar-point .allowed-to-rate .review-result, .percentage-point .allowed-to-rate .review-result{text-indent:0;}
423
+ .bar-point .allowed-to-rate .review-result i, .percentage-point .allowed-to-rate .review-result i, .mts-user-review-star-container .selected i { color: <?php echo $color; ?>; opacity: 1; filter: alpha(opacity=100); }
424
+ .review-wrapper, .review-title, .review-list li, .review-list li:last-child, .user-review-area{border-color: <?php echo $bordercolor; ?>;}
425
+ <?php
426
+ if( $total == '' ){?>
427
+ .user-review-area{border: 1px solid <?php echo $bordercolor; ?>; margin-top: 0px;}
428
+ .review-desc{width: 100%;}
429
+ .review-wrapper{border: none; overflow: visible;}
430
+ <?php }
431
+ echo '</style>';
432
+ }
433
+ }
434
+ }
435
+
436
+ /**
437
+ *Check if user has reviewed this post previously
438
+ */
439
+ function hasPreviousReview( $post_id, $user_id, $ip ){
440
+ if( is_numeric( $post_id ) && $post_id > 0 ){
441
+ global $wpdb;
442
+ global $blog_id;
443
+ $table_name = $wpdb->prefix . MTS_WP_REVIEW_DB_TABLE;
444
+ if (function_exists('is_multisite') && is_multisite()) {$table_name = $wpdb->base_prefix . MTS_WP_REVIEW_DB_TABLE;}
445
+ if( is_numeric( $user_id ) && $user_id > 0 ){
446
+ $prevRates = $wpdb->get_row( $wpdb->prepare("SELECT COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d' AND user_id = '%d'", $blog_id, $post_id, $user_id) );
447
+ if( $prevRates->reviewsNum > 0 ) return true; else return false;
448
+ }
449
+ elseif( $ip != '' ){
450
+ $prevRates = $wpdb->get_row( $wpdb->prepare("SELECT COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d' AND user_ip = '%s' AND user_id = '0'", $blog_id, $post_id, $ip) );
451
+ if( $prevRates->reviewsNum > 0 ) return true; else return false;
452
+ }
453
+ else return false;
454
+ }
455
+ return false;
456
+ }
457
+
458
+
459
+ /**
460
+ *Get review with Ajax
461
+ */
462
+ function mts_review_get_review(){
463
+ // security
464
+ check_ajax_referer( 'wp-review-security', 'nonce' );
465
+
466
+ global $wpdb;
467
+
468
+ $table_name = $wpdb->prefix . MTS_WP_REVIEW_DB_TABLE;
469
+ if (function_exists('is_multisite') && is_multisite()) {$table_name = $wpdb->base_prefix . MTS_WP_REVIEW_DB_TABLE;}
470
+
471
+ global $blog_id;
472
+ $post_id = intval($_POST['post_id']);
473
+ $user_id = intval($_POST['user_id']);
474
+
475
+ //$ip = $_SERVER['REMOTE_ADDR'];
476
+ if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
477
+ $uip = $_SERVER['HTTP_CLIENT_IP'];
478
+ } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
479
+ $uip = $_SERVER['HTTP_X_FORWARDED_FOR'];
480
+ } else {
481
+ $uip = $_SERVER['REMOTE_ADDR'];
482
+ }
483
+
484
+ if (!hasPreviousReview($post_id, $user_id, $uip)) {
485
+ $data = intval($_POST['review']);
486
+
487
+ if( $rows_affected = $wpdb->insert( $table_name, array('blog_id' => $blog_id, 'post_id' => $post_id, 'user_id' => $user_id, 'user_ip' => $uip, 'rate' => $data, 'date' => current_time('mysql')) ) ){
488
+ $reviews = $wpdb->get_row( $wpdb->prepare("SELECT ROUND( AVG(rate) ,1 ) as reviewsAvg, COUNT(id) as reviewsNum FROM $table_name WHERE blog_id = '%d' AND post_id = '%d'", $blog_id, $post_id) );
489
+ echo $reviews->reviewsAvg.'|'.$reviews->reviewsNum;
490
+ } else {
491
+ echo 'MTS_REVIEW_DB_ERROR';
492
+ }
493
+ } else {
494
+ echo 'MTS_REVIEW_DB_ERROR';
495
+ }
496
+ exit;
497
+ }
498
+
499
?>
includes/widget.php ADDED
@@ -0,0 +1,472 @@