WP Product Review Lite - Version 2.9.6

Version Description

Download this release

Release Info

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

Code changes from version 2.9.5 to 2.9.6

CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
 
 
 
 
2
- Release 2.9.6
3
 
4
 
5
 
6
- Added amazon integration support
1
 
2
+
3
+
4
+
5
+
6
 
7
 
8
 
 
admin/functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
- require( plugin_dir_path ( __FILE__ ) . 'inc/config.php' );
4
- require( plugin_dir_path ( __FILE__) . 'inc/adminOptionsValidator.php' );
5
- require( plugin_dir_path ( __FILE__ ) . 'inc/adminSanitizer.php' );
6
- require( plugin_dir_path ( __FILE__ ) . 'inc/render.php' );
7
- require( plugin_dir_path ( __FILE__ ) . 'inc/loader.php' );
1
  <?php
2
 
3
+ require( plugin_dir_path( __FILE__ ) . 'inc/config.php' );
4
+ require( plugin_dir_path( __FILE__ ) . 'inc/adminOptionsValidator.php' );
5
+ require( plugin_dir_path( __FILE__ ) . 'inc/adminSanitizer.php' );
6
+ require( plugin_dir_path( __FILE__ ) . 'inc/render.php' );
7
+ require( plugin_dir_path( __FILE__ ) . 'inc/loader.php' );
admin/inc/adminOptionsValidator.php CHANGED
@@ -1,206 +1,194 @@
1
  <?php
2
 
3
- class cwpposOptionsValidator {
4
- public function __construct(){
5
-
6
- $sanitizer = new cwpposSanitizer();
7
- add_filter( 'cwppos_sanitize_color', array($sanitizer,'sanitize_hex'),10,2);
8
- add_filter( 'cwppos_sanitize_textarea', array($sanitizer,'sanitize_textarea'),10,2);
9
- add_filter( 'cwppos_sanitize_array', array($sanitizer,'sanitize_array'),10,3);
10
- add_filter( 'cwppos_sanitize_enum', array($sanitizer,'sanitize_enum'),10,3);
11
- add_filter( 'cwppos_sanitaze_typography', array($sanitizer,'sanitize_typography'),10,2);
12
- add_filter( 'cwppos_sanitize_url', array($sanitizer,'sanitize_imageurl'),10,2);
13
- add_filter( 'cwppos_sanitize_number', array($sanitizer,'sanitize_number'),10,2);
14
- add_filter( 'cwppos_sanitize_background', array($sanitizer,'sanitize_background'),10,2);
15
- add_filter( 'cwppos_sanitize_textarea_html', array($sanitizer,'sanitize_html'),10,2);
16
- add_filter( 'cwppos_sanitize_change_icon', array($sanitizer, 'sanitize_change_icon'), 10, 2);
17
- }
18
- public function validate_defaults(){
19
- $ninput = array();
20
- $defaults = $this->get_default_options();
21
- foreach($defaults as $k=>$i){
22
- switch($i['type']){
23
- case "textarea":
24
- case "editor":
25
 
26
- case "input_text":
27
- $ninput[$k] = apply_filters("cwppos_sanitize_textarea",$i['default']);
28
  break;
29
- case "textarea_html":
30
- $ninput[$k] = apply_filters("cwppos_sanitize_textarea_html",$i['default']);
31
  break;
32
 
33
- case "radio":
34
- case "select":
35
- $ninput[$k] = apply_filters("cwppos_sanitize_enum",$i['default'],$k);
36
 
37
  break;
38
- case "color":
39
 
40
- $ninput[$k] = apply_filters("cwppos_sanitize_color",$i['default']);
41
  break;
42
- case "image":
43
 
44
- $ninput[$k] = apply_filters("cwppos_sanitize_url",$i['default']);
45
  break;
46
- case "background":
47
 
48
- $ninput[$k] = apply_filters("cwppos_sanitize_background",$i['default']);
49
  break;
50
- case "typography":
51
 
52
- $ninput[$k] = apply_filters("cwppos_sanitize_typography",$i['default']);
53
  break;
54
- case "input_number":
55
 
56
- $ninput[$k] = apply_filters("cwppos_sanitize_number",$i['default']);
57
  break;
58
- case "checkbox":
59
- case "multiselect":
60
- $ninput[$k] = apply_filters("cwppos_sanitize_array",$i['default'],$k);
61
  break;
62
 
63
- case "change_icon":
64
- $ninput[$k] = apply_filters("cwppos_sanitize_change_icon",$i['default'],$k);
65
  break;
66
 
67
- }
68
  }
69
- return $ninput;
70
  }
71
- public function validate($input){
72
-
73
- $ninput = array();
74
 
75
- $options = $this->get_options_data();
76
 
 
77
 
78
- foreach($input as $k=>$i){
79
- switch($options[$k]['type']){
80
- case "textarea":
81
- case "editor":
82
 
83
- case "input_text":
84
- $ninput[$k] = apply_filters("cwppos_sanitize_textarea",$i,$options[$k]['default']);
85
 
86
  break;
87
- case "textarea_html":
88
- $ninput[$k] = apply_filters("cwppos_sanitize_textarea_html",$i,$options[$k]['default']);
89
  break;
90
- case "radio":
91
- case "select":
92
- $ninput[$k] = apply_filters("cwppos_sanitize_enum",$i,$k,$options[$k]['default']);
93
 
94
  break;
95
- case "color":
96
- $ninput[$k] = apply_filters("cwppos_sanitize_color",$i,$options[$k]['default']);
97
  break;
98
- case "image":
99
 
100
- $ninput[$k] = apply_filters("cwppos_sanitize_url",$i,$options[$k]['default']);
101
  break;
102
- case "background":
103
 
104
- $ninput[$k] = apply_filters("cwppos_sanitize_background",$i,$options[$k]['default']);
105
  break;
106
- case "typography":
107
 
108
- $ninput[$k] = apply_filters("cwppos_sanitize_typography",$i,$options[$k]['default']);
109
  break;
110
- case "input_number":
111
 
112
- $ninput[$k] = apply_filters("cwppos_sanitize_number",$i,$options[$k]['default']);
113
  break;
114
- case "checkbox":
115
- case "multiselect":
116
- $ninput[$k] = apply_filters("cwppos_sanitize_array",$i,$k,$options[$k]['default']);
117
  break;
118
 
119
- case "change_icon":
120
- $ninput[$k] = apply_filters("cwppos_sanitize_change_icon",$i,$k,$options[$k]['default']);
121
  break;
122
 
123
- }
124
  }
125
- return $ninput;
126
  }
127
- public function get_default_options(){
128
- $structure = cwpposConfig::$structure;
129
- $options = cwppos_get_config_defaults($structure);
130
- $data = array();
131
- foreach($structure as $k=>$fields){
132
-
133
- if($fields['type'] == 'tab'){
134
-
135
-
136
- foreach ($fields['options'] as $r=>$field){
137
-
138
- if($field['type'] == 'group'){
139
-
140
- foreach($field['options'] as $m=>$gfield){
141
- if($gfield["type"]!='title')
142
- $data[$gfield['id']] = array(
143
- "default"=>$options[$gfield['id']],
144
- "type"=>$gfield['type']
145
- );
146
- }
147
-
148
- }else{
149
- if($field["type"]!='title')
150
-
151
- $data[$field['id']] = array(
152
- "default"=>$options[$field['id']],
153
- "type"=>$field['type']
154
- );
155
- }
156
-
157
- }
158
-
159
- }
160
-
161
  }
162
- return $data;
163
  }
164
- public function get_options_data($options = 0){
165
- $structure = cwpposConfig::$structure;
166
- $defaults = cwppos_get_config_defaults($structure);
167
- $option = get_option(cwppos_config("menu_slug"));
168
- $options = array_merge($defaults,is_array($option) ? $option : array() );
169
-
170
- $data = array();
171
- foreach($structure as $k=>$fields){
172
-
173
- if($fields['type'] == 'tab'){
174
-
175
-
176
- foreach ($fields['options'] as $r=>$field){
177
-
178
- if($field['type'] == 'group'){
179
-
180
- foreach($field['options'] as $m=>$gfield){
181
- if($gfield["type"]!='title')
182
- $data[$gfield['id']] = array(
183
- "default"=>$options[$gfield['id']],
184
- "type"=>$gfield['type']
185
- );
186
- }
187
-
188
- }else{
189
- if($field["type"]!='title')
190
-
191
- $data[$field['id']] = array(
192
- "default"=>$options[$field['id']],
193
- "type"=>$field['type']
194
- );
195
- }
196
-
197
- }
198
-
199
- }
200
-
201
  }
202
- return $data;
203
  }
204
- //adauga aici noile functii pentru submeniu daca pagina este in meniul principal
205
-
206
- }
 
1
  <?php
2
 
3
+ class cwpposOptionsValidator {
4
+ public function __construct() {
5
+
6
+ $sanitizer = new cwpposSanitizer();
7
+ add_filter( 'cwppos_sanitize_color', array( $sanitizer, 'sanitize_hex' ),10,2 );
8
+ add_filter( 'cwppos_sanitize_textarea', array( $sanitizer, 'sanitize_textarea' ),10,2 );
9
+ add_filter( 'cwppos_sanitize_array', array( $sanitizer, 'sanitize_array' ),10,3 );
10
+ add_filter( 'cwppos_sanitize_enum', array( $sanitizer, 'sanitize_enum' ),10,3 );
11
+ add_filter( 'cwppos_sanitaze_typography', array( $sanitizer, 'sanitize_typography' ),10,2 );
12
+ add_filter( 'cwppos_sanitize_url', array( $sanitizer, 'sanitize_imageurl' ),10,2 );
13
+ add_filter( 'cwppos_sanitize_number', array( $sanitizer, 'sanitize_number' ),10,2 );
14
+ add_filter( 'cwppos_sanitize_background', array( $sanitizer, 'sanitize_background' ),10,2 );
15
+ add_filter( 'cwppos_sanitize_textarea_html', array( $sanitizer, 'sanitize_html' ),10,2 );
16
+ add_filter( 'cwppos_sanitize_change_icon', array( $sanitizer, 'sanitize_change_icon' ), 10, 2 );
17
+ }
18
+ public function validate_defaults() {
19
+ $ninput = array();
20
+ $defaults = $this->get_default_options();
21
+ foreach ( $defaults as $k => $i ) {
22
+ switch ( $i['type'] ) {
23
+ case 'textarea':
24
+ case 'editor':
25
 
26
+ case 'input_text':
27
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_textarea',$i['default'] );
28
  break;
29
+ case 'textarea_html':
30
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_textarea_html',$i['default'] );
31
  break;
32
 
33
+ case 'radio':
34
+ case 'select':
35
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_enum',$i['default'],$k );
36
 
37
  break;
38
+ case 'color':
39
 
40
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_color',$i['default'] );
41
  break;
42
+ case 'image':
43
 
44
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_url',$i['default'] );
45
  break;
46
+ case 'background':
47
 
48
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_background',$i['default'] );
49
  break;
50
+ case 'typography':
51
 
52
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_typography',$i['default'] );
53
  break;
54
+ case 'input_number':
55
 
56
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_number',$i['default'] );
57
  break;
58
+ case 'checkbox':
59
+ case 'multiselect':
60
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_array',$i['default'],$k );
61
  break;
62
 
63
+ case 'change_icon':
64
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_change_icon',$i['default'],$k );
65
  break;
66
 
 
67
  }
 
68
  }
69
+ return $ninput;
70
+ }
71
+ public function validate( $input ) {
72
 
73
+ $ninput = array();
74
 
75
+ $options = $this->get_options_data();
76
 
77
+ foreach ( $input as $k => $i ) {
78
+ switch ( $options[ $k ]['type'] ) {
79
+ case 'textarea':
80
+ case 'editor':
81
 
82
+ case 'input_text':
83
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_textarea',$i,$options[ $k ]['default'] );
84
 
85
  break;
86
+ case 'textarea_html':
87
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_textarea_html',$i,$options[ $k ]['default'] );
88
  break;
89
+ case 'radio':
90
+ case 'select':
91
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_enum',$i,$k,$options[ $k ]['default'] );
92
 
93
  break;
94
+ case 'color':
95
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_color',$i,$options[ $k ]['default'] );
96
  break;
97
+ case 'image':
98
 
99
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_url',$i,$options[ $k ]['default'] );
100
  break;
101
+ case 'background':
102
 
103
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_background',$i,$options[ $k ]['default'] );
104
  break;
105
+ case 'typography':
106
 
107
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_typography',$i,$options[ $k ]['default'] );
108
  break;
109
+ case 'input_number':
110
 
111
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_number',$i,$options[ $k ]['default'] );
112
  break;
113
+ case 'checkbox':
114
+ case 'multiselect':
115
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_array',$i,$k,$options[ $k ]['default'] );
116
  break;
117
 
118
+ case 'change_icon':
119
+ $ninput[ $k ] = apply_filters( 'cwppos_sanitize_change_icon',$i,$k,$options[ $k ]['default'] );
120
  break;
121
 
 
122
  }
 
123
  }
124
+ return $ninput;
125
+ }
126
+ public function get_default_options() {
127
+ $structure = cwpposConfig::$structure;
128
+ $options = cwppos_get_config_defaults( $structure );
129
+ $data = array();
130
+ foreach ( $structure as $k => $fields ) {
131
+
132
+ if ( $fields['type'] == 'tab' ) {
133
+
134
+ foreach ( $fields['options'] as $r => $field ) {
135
+
136
+ if ( $field['type'] == 'group' ) {
137
+
138
+ foreach ( $field['options'] as $m => $gfield ) {
139
+ if ( $gfield['type'] != 'title' ) {
140
+ $data[ $gfield['id'] ] = array(
141
+ 'default' => $options[ $gfield['id'] ],
142
+ 'type' => $gfield['type'],
143
+ ); }
144
+ }
145
+ } else {
146
+ if ( $field['type'] != 'title' ) {
147
+
148
+ $data[ $field['id'] ] = array(
149
+ 'default' => $options[ $field['id'] ],
150
+ 'type' => $field['type'],
151
+ ); }
152
+ }
153
+ }
 
 
 
 
154
  }
 
155
  }
156
+ return $data;
157
+ }
158
+ public function get_options_data( $options = 0 ) {
159
+ $structure = cwpposConfig::$structure;
160
+ $defaults = cwppos_get_config_defaults( $structure );
161
+ $option = get_option( cwppos_config( 'menu_slug' ) );
162
+ $options = array_merge( $defaults,is_array( $option ) ? $option : array() );
163
+
164
+ $data = array();
165
+ foreach ( $structure as $k => $fields ) {
166
+
167
+ if ( $fields['type'] == 'tab' ) {
168
+
169
+ foreach ( $fields['options'] as $r => $field ) {
170
+
171
+ if ( $field['type'] == 'group' ) {
172
+
173
+ foreach ( $field['options'] as $m => $gfield ) {
174
+ if ( $gfield['type'] != 'title' ) {
175
+ $data[ $gfield['id'] ] = array(
176
+ 'default' => $options[ $gfield['id'] ],
177
+ 'type' => $gfield['type'],
178
+ ); }
179
+ }
180
+ } else {
181
+ if ( $field['type'] != 'title' ) {
182
+
183
+ $data[ $field['id'] ] = array(
184
+ 'default' => $options[ $field['id'] ],
185
+ 'type' => $field['type'],
186
+ ); }
187
+ }
188
+ }
 
 
 
 
189
  }
 
190
  }
191
+ return $data;
192
+ }
193
+ // adauga aici noile functii pentru submeniu daca pagina este in meniul principal
194
+ }
admin/inc/adminSanitizer.php CHANGED
@@ -1,146 +1,139 @@
1
  <?php
2
- class cwpposSanitizer{
3
-
4
- public function sanitize_hex($hex,$default=''){
5
-
6
- if ( $this->validate_hex( $hex ) ) {
7
- return $hex;
8
- }
9
- return $default;
10
-
11
- }
12
- public function sanitize_textarea($input,$default=''){
13
- $output = esc_html(esc_attr(wp_kses_data($input)));
14
-
15
- return $output;
16
-
17
- }
18
- public function sanitize_html($input,$default=''){
19
- $output = wp_kses_data($input);
20
- return $output;
21
-
22
- }
23
- public function sanitize_number($input,$default = 0){
24
- $number = floatval($input);
25
- if(empty($number)) return $default;
26
- return $number;
27
- }
28
- public function sanitize_imageurl($input,$default = ''){
29
-
30
- $filetype = wp_check_filetype($input);
31
- if ( $filetype["ext"] ) {
32
- return $input;
33
- }
34
- $filetype = wp_check_filetype($default);
35
- if ( $filetype["ext"] ) {
36
- return $default;
37
- }
38
- return '';
39
- }
40
- public function sanitize_background($input,$default = array("bgcolor"=>"","bgimage"=>"","bgrepeat"=>"no-repeat","bgposition"=>"center center","bgattachment"=>"scroll")){
41
- $render = new cwpposRenderView();
42
- $repeat = $render->get_bg_repeat();
43
- $repeat = array_keys($repeat);
44
- $position = $render->get_bg_position();
45
- $position = array_keys($position);
46
- $att = $render->get_bg_attachment();
47
- $att = array_keys($att);
48
- $input['bgcolor'] = apply_filters("pos_sanitize_color",$input['bgcolor'],$default['bgcolor']);
49
- $input['bgimage'] = apply_filters("pos_sanitize_url",$input['bgimage'],$default['bgimage']);
50
- if(!in_array($input['bgrepeat'],$repeat))
51
- $input['bgrepeat'] = $default['bgrepeat'];
52
- if(!in_array($input['bgposition'],$position))
53
- $input['bgposition'] = $default['bgposition'];
54
- if(!in_array($input['bgattachment'],$repeat))
55
- $input['bgattachment'] = $default['bgattachment'];
56
- return $input;
57
  }
58
- public function sanitize_typography($input,$default = array("color"=>"","size"=>12,"style"=>"normal","font"=>"arial")){
59
- $render = new cwpposRenderView();
60
- $fonts = $render->get_fonts();
61
- $fonts = array_keys($fonts);
62
- $styles = $render->get_font_styles();
63
- $styles = array_keys($styles);
64
- $sizes = $render->get_font_sizes();
65
- $input['color'] = apply_filters("cwppos_sanitize_color",$input['color'],$default['color']);
66
- if(!in_array($input['size'],$sizes))
67
- $input['size'] = $default['size'];
68
- if(!in_array($input['style'],$styles))
69
- $input['style'] = $default['style'];
70
- if(!in_array($input['font'],$fonts))
71
- $input['font'] = $default['font'];
72
- return $input;
 
 
 
 
 
 
 
 
 
73
  }
74
- public function get_config_option($name){
75
- $structure = cwpposConfig::$structure;
76
- foreach($structure as $k=>$fields){
77
-
78
- if($fields['type'] == 'tab'){
79
-
80
-
81
- foreach ($fields['options'] as $r=>$field){
82
-
83
- if($field['type'] == 'group'){
84
-
85
- foreach($field['options'] as $m=>$gfield){
86
- if($gfield["type"]!='title' && $gfield["id"] == $name)
87
- return $gfield['options'];
88
- }
89
-
90
- }else{
91
- if($field["type"]!='title' && $field['id'] == $name)
92
- return $field['options'];
93
- }
94
-
95
- }
96
-
97
- }
98
-
99
- }
100
-
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- public function sanitize_change_icon($input, $name, $default= array()) {
104
- return wp_kses_data($input);
105
- }
106
 
107
- public function sanitize_array($input,$name, $default = array()){
108
-
109
- $options = $this->get_config_option($name);
110
- if ( is_array( $input ) ) {
111
- foreach( $input as $key => $value ) {
112
-
113
- $output[$key] = sanitize_text_field ($value) ;
 
 
 
 
114
  }
115
- $kop = array_keys($options);
116
- $dif = array_diff($output,$kop);
117
-
118
- if(empty($dif))
119
- return $output;
120
- return $default;
121
  }
122
- return $default;
123
  }
124
- public function sanitize_enum($input,$name, $default = ''){
125
- $options = $this->get_config_option($name);
126
-
127
- if(in_array($input,array_keys($options)))
128
- return apply_filters("cwppos_sanitize_textarea",$input);
129
- return $default;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
- public function validate_hex($hex){
132
- $hex = trim( $hex );
133
- if ( 0 === strpos( $hex, '#' ) ) {
134
- $hex = substr( $hex, 1 );
135
- }
136
- elseif ( 0 === strpos( $hex, '%23' ) ) {
137
- $hex = substr( $hex, 3 );
138
- }
139
- if ( 0 === preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) {
140
- return false;
141
- }
142
- else {
143
- return true;
144
- }
 
 
 
 
 
 
145
  }
146
- }
 
1
  <?php
2
+ class cwpposSanitizer {
3
+
4
+ public function sanitize_hex( $hex, $default = '' ) {
5
+
6
+ if ( $this->validate_hex( $hex ) ) {
7
+ return $hex;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
+ return $default;
10
+
11
+ }
12
+ public function sanitize_textarea( $input, $default = '' ) {
13
+ $output = esc_html( esc_attr( wp_kses_data( $input ) ) );
14
+
15
+ return $output;
16
+
17
+ }
18
+ public function sanitize_html( $input, $default = '' ) {
19
+ $output = wp_kses_data( $input );
20
+ return $output;
21
+
22
+ }
23
+ public function sanitize_number( $input, $default = 0 ) {
24
+ $number = floatval( $input );
25
+ if ( empty( $number ) ) { return $default; }
26
+ return $number;
27
+ }
28
+ public function sanitize_imageurl( $input, $default = '' ) {
29
+
30
+ $filetype = wp_check_filetype( $input );
31
+ if ( $filetype['ext'] ) {
32
+ return $input;
33
  }
34
+ $filetype = wp_check_filetype( $default );
35
+ if ( $filetype['ext'] ) {
36
+ return $default;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
+ return '';
39
+ }
40
+ public function sanitize_background( $input, $default = array( 'bgcolor' => '', 'bgimage' => '', 'bgrepeat' => 'no-repeat', 'bgposition' => 'center center', 'bgattachment' => 'scroll' ) ) {
41
+ $render = new cwpposRenderView();
42
+ $repeat = $render->get_bg_repeat();
43
+ $repeat = array_keys( $repeat );
44
+ $position = $render->get_bg_position();
45
+ $position = array_keys( $position );
46
+ $att = $render->get_bg_attachment();
47
+ $att = array_keys( $att );
48
+ $input['bgcolor'] = apply_filters( 'pos_sanitize_color',$input['bgcolor'],$default['bgcolor'] );
49
+ $input['bgimage'] = apply_filters( 'pos_sanitize_url',$input['bgimage'],$default['bgimage'] );
50
+ if ( ! in_array( $input['bgrepeat'],$repeat ) ) {
51
+ $input['bgrepeat'] = $default['bgrepeat']; }
52
+ if ( ! in_array( $input['bgposition'],$position ) ) {
53
+ $input['bgposition'] = $default['bgposition']; }
54
+ if ( ! in_array( $input['bgattachment'],$repeat ) ) {
55
+ $input['bgattachment'] = $default['bgattachment']; }
56
+ return $input;
57
+ }
58
+ public function sanitize_typography( $input, $default = array( 'color' => '', 'size' => 12, 'style' => 'normal', 'font' => 'arial' ) ) {
59
+ $render = new cwpposRenderView();
60
+ $fonts = $render->get_fonts();
61
+ $fonts = array_keys( $fonts );
62
+ $styles = $render->get_font_styles();
63
+ $styles = array_keys( $styles );
64
+ $sizes = $render->get_font_sizes();
65
+ $input['color'] = apply_filters( 'cwppos_sanitize_color',$input['color'],$default['color'] );
66
+ if ( ! in_array( $input['size'],$sizes ) ) {
67
+ $input['size'] = $default['size']; }
68
+ if ( ! in_array( $input['style'],$styles ) ) {
69
+ $input['style'] = $default['style']; }
70
+ if ( ! in_array( $input['font'],$fonts ) ) {
71
+ $input['font'] = $default['font']; }
72
+ return $input;
73
+ }
74
+ public function get_config_option( $name ) {
75
+ $structure = cwpposConfig::$structure;
76
+ foreach ( $structure as $k => $fields ) {
77
 
78
+ if ( $fields['type'] == 'tab' ) {
 
 
79
 
80
+ foreach ( $fields['options'] as $r => $field ) {
81
+
82
+ if ( $field['type'] == 'group' ) {
83
+
84
+ foreach ( $field['options'] as $m => $gfield ) {
85
+ if ( $gfield['type'] != 'title' && $gfield['id'] == $name ) {
86
+ return $gfield['options']; }
87
+ }
88
+ } else {
89
+ if ( $field['type'] != 'title' && $field['id'] == $name ) {
90
+ return $field['options']; }
91
  }
 
 
 
 
 
 
92
  }
93
+ }
94
  }
95
+
96
+ }
97
+
98
+ public function sanitize_change_icon( $input, $name, $default = array() ) {
99
+ return wp_kses_data( $input );
100
+ }
101
+
102
+ public function sanitize_array( $input, $name, $default = array() ) {
103
+
104
+ $options = $this->get_config_option( $name );
105
+ if ( is_array( $input ) ) {
106
+ foreach ( $input as $key => $value ) {
107
+
108
+ $output[ $key ] = sanitize_text_field( $value );
109
+ }
110
+ $kop = array_keys( $options );
111
+ $dif = array_diff( $output,$kop );
112
+
113
+ if ( empty( $dif ) ) {
114
+ return $output; }
115
+ return $default;
116
  }
117
+ return $default;
118
+ }
119
+ public function sanitize_enum( $input, $name, $default = '' ) {
120
+ $options = $this->get_config_option( $name );
121
+
122
+ if ( in_array( $input,array_keys( $options ) ) ) {
123
+ return apply_filters( 'cwppos_sanitize_textarea',$input ); }
124
+ return $default;
125
+ }
126
+ public function validate_hex( $hex ) {
127
+ $hex = trim( $hex );
128
+ if ( 0 === strpos( $hex, '#' ) ) {
129
+ $hex = substr( $hex, 1 );
130
+ } elseif ( 0 === strpos( $hex, '%23' ) ) {
131
+ $hex = substr( $hex, 3 );
132
+ }
133
+ if ( 0 === preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) {
134
+ return false;
135
+ } else {
136
+ return true;
137
  }
138
+ }
139
+ }
admin/inc/config.php CHANGED
@@ -1,575 +1,324 @@
1
- <?php
2
-
3
- class cwpposConfig{
4
-
5
- public static $admin_page_menu_name ;
6
-
7
- public static $admin_page_title ;
8
-
9
- public static $admin_page_header ;
10
-
11
- public static $admin_template_directory ;
12
-
13
- public static $admin_template_directory_uri ;
14
-
15
- public static $admin_uri ;
16
-
17
- public static $admin_path ;
18
-
19
- public static $menu_slug ;
20
-
21
- public static $structure;
22
-
23
- public static $review_categories_array;
24
-
25
- public static $categories_array;
26
-
27
- public static $shortname;
28
-
29
- public static $all_review_categories_array;
30
-
31
- public static $all_categories_array;
32
-
33
- public static $categories_ids;
34
-
35
-
36
-
37
- public static function init(){
38
-
39
- self::$admin_page_menu_name = "Product Review";
40
-
41
- self::$admin_page_title = "WP Product Review Options";
42
-
43
- self::$admin_page_header = "WP Product Review Options";
44
-
45
- self::$shortname = "cwppos";
46
-
47
- self::$admin_template_directory_uri = plugins_url ( '../layout', __FILE__ );
48
-
49
- self::$admin_template_directory = plugins_url ('../layout', __FILE__ );
50
-
51
- self::$admin_uri = plugins_url ( '../' , __FILE__ );
52
-
53
- self::$admin_path = plugins_url ( '../', __FILE__ );
54
-
55
- self::$menu_slug = "cwppos_options";
56
-
57
- self::$all_categories_array = array();
58
-
59
- self::$all_review_categories_array = array();
60
-
61
- self::$categories_array = array();
62
-
63
-
64
-
65
- self::$structure = array(
66
- array(
67
-
68
- "type"=>"tab",
69
-
70
- "name"=>"General settings",
71
-
72
- "options"=>array(
73
-
74
- array(
75
-
76
- "type"=>"select",
77
-
78
- "name"=>"Position of the review box",
79
-
80
- "description"=>"You can choose manually and use : <?php echo cwppos_show_review('postid'); ?> or you can get the Product in post add-on and use :[P_REVIEW post_id=3067 visual='full']",
81
-
82
- "id"=>"cwppos_show_reviewbox",
83
-
84
- "options"=>array("yes"=>"After content","no"=>"Before content","manual"=>"Manually"),
85
-
86
- "default"=>"yes"
87
-
88
- ),
89
- array(
90
-
91
- "type"=>"select",
92
-
93
- "name"=>"Show review comment",
94
-
95
- "description"=>"Activate comment review user",
96
-
97
- "id"=>"cwppos_show_userreview",
98
-
99
- "options"=>array("yes"=>"Yes","no"=>"No"),
100
-
101
- "default"=>"no"
102
-
103
- ),
104
-
105
- array(
106
-
107
- "type"=>"select",
108
-
109
- "name"=>"Visitor Review Influence",
110
-
111
- "description"=>"Select how much visitors rating will affect the main one.",
112
-
113
- "id"=>"cwppos_infl_userreview",
114
-
115
- "options"=>array("0"=>"No influence","10"=>"10%","20"=>"20%","30"=>"30%","40"=>"40%","50"=>"50%","60"=>"60%","70"=>"70%","80"=>"80%","90"=>"90%","100"=>"100%"),
116
-
117
- "default"=>"0"
118
-
119
- ),
120
-
121
- array(
122
- "type" => "change_icon",
123
- "name" => "Change Default Rating Icon",
124
- "description" => "Choose which icon would you like to use for the rating bar.",
125
- "id" => "cwppos_change_bar_icon",
126
- "default" => ""
127
- ),
128
-
129
- array(
130
-
131
- "type"=>"select",
132
-
133
- "name"=>"Number of options/pros/cons",
134
-
135
- "description"=>"You can select the default number of options / pros/ cons (3-10)",
136
-
137
- "id"=>"cwppos_option_nr",
138
-
139
- "options"=>array(3=>"3",4=>"4",5=>"5",6=>"6",7=>"7",8=>"8",9=>"9",10=>"10"),
140
-
141
- "default"=>5
142
-
143
- ),
144
-
145
-
146
- array(
147
-
148
- "type"=>"input_text",
149
-
150
- "name"=>"Content width",
151
-
152
- "description"=>"Write your content width in pixels in this format : 600 if you want to limit the review box width.",
153
-
154
- "id"=>"cwppos_widget_size",
155
-
156
- "default"=>""
157
-
158
- ),
159
- array(
160
-
161
- "type"=>"select",
162
-
163
- "name"=>"Disable Lighbox images",
164
-
165
- "description"=>"Disable lightbox effect on product images (increase loading speed)",
166
-
167
- "id"=>"cwppos_lighbox",
168
- "options"=>array("yes"=>"Yes","no"=>"No"),
169
-
170
- "default"=>"no"
171
-
172
- ),
173
- array(
174
-
175
- "type"=>"select",
176
-
177
- "name"=>"Disable Font Awesome",
178
-
179
- "description"=>"Disable Font Awesome for websites that already are including it (increase loading speed)",
180
-
181
- "id"=>"cwppos_fontawesome",
182
- "options"=>array("yes"=>"Yes","no"=>"No"),
183
-
184
- "default"=>"no"
185
-
186
- ),
187
-
188
-
189
-
190
-
191
-
192
- )
193
-
194
- ),
195
-
196
- array(
197
-
198
- "type"=>"tab",
199
-
200
- "name"=>"Rating colors",
201
-
202
- "options"=>array(
203
-
204
-
205
-
206
- array(
207
-
208
- "type"=>"title",
209
-
210
- "name"=>"Rating Colors"
211
-
212
- ) ,
213
-
214
-
215
-
216
- array(
217
-
218
- "type"=>"color",
219
-
220
- "name"=>"Rating options default color",
221
-
222
- "description"=>"Select the color to be used by default on rating.",
223
-
224
- "id"=>"cwppos_rating_default",
225
-
226
- "default"=>"#E1E2E0"
227
-
228
- ),
229
-
230
- array(
231
-
232
- "type"=>"color",
233
-
234
- "name"=>"Rating chart default color",
235
-
236
- "description"=>"Select the color to be used by default on rating chart.",
237
-
238
- "id"=>"cwppos_rating_chart_default",
239
-
240
- "default"=>"#ebebeb"
241
-
242
- ),
243
-
244
- array(
245
-
246
- "type"=>"color",
247
-
248
- "name"=>"Weak rating",
249
-
250
- "description"=>"Select the color to be used when the rating is weak. ( < 2.5)",
251
-
252
- "id"=>"cwppos_rating_weak",
253
-
254
- "default"=>"#FF7F66"
255
-
256
- ),
257
-
258
-
259
-
260
- array(
261
-
262
- "type"=>"color",
263
-
264
- "name"=>"Not bad rating",
265
-
266
- "description"=>"Select the color to be used when the rating is not bad. ( > 2.5 and < 5)",
267
-
268
- "id"=>"cwppos_rating_notbad",
269
-
270
- "default"=>"#FFCE55"
271
-
272
- ),
273
-
274
-
275
-
276
- array(
277
-
278
- "type"=>"color",
279
-
280
- "name"=>"Good rating",
281
-
282
- "description"=>"Select the color to be used when the rating is good. ( >5 and <7.5)",
283
-
284
- "id"=>"cwppos_rating_good",
285
-
286
- "default"=>"#50C1E9"
287
-
288
- ),
289
-
290
-
291
-
292
- array(
293
-
294
- "type"=>"color",
295
-
296
- "name"=>"Very good rating",
297
-
298
- "description"=>"Select the color to be used when the rating is very good. ( 7.5 < and <10)",
299
-
300
- "id"=>"cwppos_rating_very_good",
301
-
302
- "default"=>"#8DC153"
303
-
304
- )
305
-
306
-
307
-
308
- )
309
-
310
- ) ,
311
-
312
- array(
313
-
314
- "type"=>"tab",
315
-
316
- "name"=>"Typography",
317
-
318
- "options"=>array(
319
-
320
-
321
-
322
- array(
323
-
324
- "type"=>"title",
325
-
326
- "name"=>"Typography options"
327
-
328
- ) ,
329
-
330
-
331
-
332
- array(
333
-
334
- "type"=>"color",
335
-
336
- "name"=>"Font color",
337
-
338
- "description"=>"Select the color to be used on the font.",
339
-
340
- "id"=>"cwppos_font_color",
341
-
342
- "default"=>"#3D3D3D"
343
-
344
- ),
345
-
346
- array(
347
-
348
- "type"=>"color",
349
-
350
- "name"=>"'Pros' text color",
351
-
352
- "description"=>"Select the color to be used on the 'Pros' text.",
353
-
354
- "id"=>"cwppos_pros_color",
355
-
356
- "default"=>"#8DC153"
357
-
358
- ),
359
-
360
- array(
361
-
362
- "type"=>"color",
363
-
364
- "name"=>"'Cons' text color",
365
-
366
- "description"=>"Select the color to be used on the 'Cons' text.",
367
-
368
- "id"=>"cwppos_cons_color",
369
-
370
- "default"=>"#C15353"
371
-
372
- ),
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
- array(
381
-
382
- "type"=>"input_text",
383
-
384
- "name"=>"Pros text",
385
-
386
- "description"=>"Specify text for pros heading",
387
-
388
- "id"=>"cwppos_pros_text",
389
-
390
- "default"=>"Pros"
391
-
392
- ),
393
-
394
-
395
-
396
-
397
-
398
- array(
399
-
400
- "type"=>"input_text",
401
-
402
- "name"=>"Cons text",
403
-
404
- "description"=>"Specify text for cons heading",
405
-
406
- "id"=>"cwppos_cons_text",
407
-
408
- "default"=>"Cons"
409
-
410
- ),
411
-
412
- array(
413
- "type"=>"color",
414
- "name"=>"Review box border",
415
- "description"=>"Select the border color to be used on the review box",
416
- "id"=>"cwppos_reviewboxbd_color",
417
- "default"=>"#3BAEDA"
418
- ),
419
-
420
- array(
421
- "type"=>"input_text",
422
- "name"=>"Review box border width",
423
- "description"=>"Select the width in pixels of the top border of the review box",
424
- "id"=>"cwppos_reviewboxbd_width",
425
- "default"=>"5"
426
- )
427
-
428
-
429
-
430
- )
431
-
432
- ) ,
433
-
434
- array(
435
-
436
- "type"=>"tab",
437
-
438
- "name"=>"Buy button",
439
-
440
- "options"=>array(
441
-
442
-
443
-
444
- array(
445
-
446
- "type"=>"title",
447
-
448
- "name"=>"Buy button options"
449
-
450
- ) ,
451
-
452
- array(
453
-
454
- "type"=>"select",
455
-
456
- "name"=>"Show button icon",
457
-
458
- "description"=>"Show icon on the cart icon on button.",
459
-
460
- "id"=>"cwppos_show_icon",
461
-
462
- "options"=>array("yes"=>"Yes","no"=>"No"),
463
-
464
- "default"=>"yes"
465
-
466
- ),
467
-
468
- array(
469
-
470
- "type"=>"color",
471
-
472
- "name"=>"Button border",
473
-
474
- "description"=>"Select the border color to be used on the buy button for the default state",
475
-
476
- "id"=>"cwppos_buttonbd_color",
477
-
478
- "default"=>"#3BAEDA"
479
-
480
- ),
481
-
482
- array(
483
-
484
- "type"=>"color",
485
-
486
- "name"=>"Button border hover",
487
-
488
- "description"=>"Select the border color to be used on the buy button for the hover state",
489
-
490
- "id"=>"cwppos_buttonbh_color",
491
-
492
- "default"=>"#3BAEDA"
493
-
494
- ),
495
-
496
- array(
497
-
498
- "type"=>"color",
499
-
500
- "name"=>"Button background",
501
-
502
- "description"=>"Select the background color to be used on the buy button for the default state",
503
-
504
- "id"=>"cwppos_buttonbkd_color",
505
-
506
- "default"=>"#ffffff"
507
-
508
- ),
509
-
510
- array(
511
-
512
- "type"=>"color",
513
-
514
- "name"=>"Button background hover",
515
-
516
- "description"=>"Select the background color to be used on the buy button for the hover state",
517
-
518
- "id"=>"cwppos_buttonbkh_color",
519
-
520
- "default"=>"#3BAEDA"
521
-
522
- ),
523
-
524
- array(
525
-
526
- "type"=>"color",
527
-
528
- "name"=>"Button text color",
529
-
530
- "description"=>"Select the text color to be used on the buy button for the default state",
531
-
532
- "id"=>"cwppos_buttontxtd_color",
533
-
534
- "default"=>"#3BAEDA"
535
-
536
- ),
537
-
538
- array(
539
-
540
- "type"=>"color",
541
-
542
- "name"=>"Button text color hover",
543
-
544
- "description"=>"Select the text color to be used on the buy button for the hover state",
545
-
546
- "id"=>"cwppos_buttontxth_color",
547
-
548
- "default"=>"#FFFFFF"
549
-
550
- )
551
-
552
-
553
-
554
- )
555
-
556
- )
557
-
558
-
559
-
560
-
561
-
562
- );
563
-
564
-
565
-
566
-
567
-
568
-
569
-
570
- }
571
-
572
-
573
-
574
- }
575
-
1
+ <?php
2
+
3
+ class cwpposConfig {
4
+
5
+ public static $admin_page_menu_name;
6
+
7
+ public static $admin_page_title;
8
+
9
+ public static $admin_page_header;
10
+
11
+ public static $admin_template_directory;
12
+
13
+ public static $admin_template_directory_uri;
14
+
15
+ public static $admin_uri;
16
+
17
+ public static $admin_path;
18
+
19
+ public static $menu_slug;
20
+
21
+ public static $structure;
22
+
23
+ public static $review_categories_array;
24
+
25
+ public static $categories_array;
26
+
27
+ public static $shortname;
28
+
29
+ public static $all_review_categories_array;
30
+
31
+ public static $all_categories_array;
32
+
33
+ public static $categories_ids;
34
+
35
+ public static $pro_page_menu_name;
36
+
37
+ public static $pro_page_title;
38
+
39
+ public static function init() {
40
+ self::$admin_page_menu_name = 'Product Review';
41
+ self::$admin_page_title = 'WP Product Review Options';
42
+ self::$admin_page_header = 'WP Product Review Options';
43
+ self::$shortname = 'cwppos';
44
+ self::$admin_template_directory_uri = plugins_url( '../layout', __FILE__ );
45
+ self::$admin_template_directory = plugins_url( '../layout', __FILE__ );
46
+ self::$admin_uri = plugins_url( '../', __FILE__ );
47
+ self::$admin_path = plugins_url( '../', __FILE__ );
48
+ self::$menu_slug = 'cwppos_options';
49
+ self::$all_categories_array = array();
50
+ self::$all_review_categories_array = array();
51
+ self::$categories_array = array();
52
+ self::$pro_page_menu_name = 'Premium Features';
53
+ self::$pro_page_title = 'Go Premium';
54
+ self::$structure = array(
55
+ array(
56
+ 'type' => 'tab',
57
+ 'name' => 'General settings',
58
+ 'options' => array(
59
+ array(
60
+ 'type' => 'select',
61
+ 'name' => 'Position of the review box',
62
+ 'description' => "You can choose manually and use : <?php echo cwppos_show_review('postid'); ?> or you can get the Product in post add-on and use :[P_REVIEW post_id=3067 visual='full']",
63
+ 'id' => 'cwppos_show_reviewbox',
64
+ 'options' => array(
65
+ 'yes' => 'After content',
66
+ 'no' => 'Before content',
67
+ 'manual' => 'Manually',
68
+ ),
69
+ 'default' => 'yes',
70
+ ),
71
+ array(
72
+ 'type' => 'select',
73
+ 'name' => 'Show review comment',
74
+ 'description' => 'Activate comment review user',
75
+ 'id' => 'cwppos_show_userreview',
76
+ 'options' => array( 'yes' => 'Yes', 'no' => 'No' ),
77
+ 'default' => 'no',
78
+ ),
79
+ array(
80
+ 'type' => 'select',
81
+ 'name' => 'Visitor Review Influence',
82
+ 'description' => 'Select how much visitors rating will affect the main one.',
83
+ 'id' => 'cwppos_infl_userreview',
84
+ 'options' => array(
85
+ '0' => 'No influence',
86
+ '10' => '10%',
87
+ '20' => '20%',
88
+ '30' => '30%',
89
+ '40' => '40%',
90
+ '50' => '50%',
91
+ '60' => '60%',
92
+ '70' => '70%',
93
+ '80' => '80%',
94
+ '90' => '90%',
95
+ '100' => '100%',
96
+ ),
97
+ 'default' => '0',
98
+ ),
99
+ array(
100
+ 'type' => 'change_icon',
101
+ 'name' => 'Change Default Rating Icon',
102
+ 'description' => 'Choose which icon would you like to use for the rating bar.',
103
+ 'id' => 'cwppos_change_bar_icon',
104
+ 'default' => '',
105
+ ),
106
+ array(
107
+ 'type' => 'select',
108
+ 'name' => 'Number of options/pros/cons',
109
+ 'description' => 'You can select the default number of options / pros/ cons (3-10)',
110
+ 'id' => 'cwppos_option_nr',
111
+ 'options' => array(
112
+ 3 => '3',
113
+ 4 => '4',
114
+ 5 => '5',
115
+ 6 => '6',
116
+ 7 => '7',
117
+ 8 => '8',
118
+ 9 => '9',
119
+ 10 => '10',
120
+ ),
121
+ 'default' => 5,
122
+ ),
123
+ array(
124
+ 'type' => 'input_text',
125
+ 'name' => 'Content width',
126
+ 'description' => 'Write your content width in pixels in this format : 600 if you want to limit the review box width.',
127
+ 'id' => 'cwppos_widget_size',
128
+ 'default' => '',
129
+ ),
130
+ array(
131
+ 'type' => 'select',
132
+ 'name' => 'Disable Lighbox images',
133
+ 'description' => 'Disable lightbox effect on product images (increase loading speed)',
134
+ 'id' => 'cwppos_lighbox',
135
+ 'options' => array( 'yes' => 'Yes', 'no' => 'No' ),
136
+ 'default' => 'no',
137
+ ),
138
+ array(
139
+ 'type' => 'select',
140
+ 'name' => 'Disable Font Awesome',
141
+ 'description' => 'Disable Font Awesome for websites that already are including it (increase loading speed)',
142
+ 'id' => 'cwppos_fontawesome',
143
+ 'options' => array( 'yes' => 'Yes', 'no' => 'No' ),
144
+ 'default' => 'no',
145
+ ),
146
+ ),
147
+ ),
148
+ array(
149
+ 'type' => 'tab',
150
+ 'name' => 'Rating colors',
151
+ 'options' => array(
152
+ array(
153
+ 'type' => 'title',
154
+ 'name' => 'Rating Colors',
155
+ ),
156
+ array(
157
+ 'type' => 'color',
158
+ 'name' => 'Rating options default color',
159
+ 'description' => 'Select the color to be used by default on rating.',
160
+ 'id' => 'cwppos_rating_default',
161
+ 'default' => '#E1E2E0',
162
+ ),
163
+ array(
164
+ 'type' => 'color',
165
+ 'name' => 'Rating chart default color',
166
+ 'description' => 'Select the color to be used by default on rating chart.',
167
+ 'id' => 'cwppos_rating_chart_default',
168
+ 'default' => '#ebebeb',
169
+ ),
170
+ array(
171
+ 'type' => 'color',
172
+ 'name' => 'Weak rating',
173
+ 'description' => 'Select the color to be used when the rating is weak. ( < 2.5)',
174
+ 'id' => 'cwppos_rating_weak',
175
+ 'default' => '#FF7F66',
176
+ ),
177
+ array(
178
+ 'type' => 'color',
179
+ 'name' => 'Not bad rating',
180
+ 'description' => 'Select the color to be used when the rating is not bad. ( > 2.5 and < 5)',
181
+ 'id' => 'cwppos_rating_notbad',
182
+ 'default' => '#FFCE55',
183
+ ),
184
+ array(
185
+ 'type' => 'color',
186
+ 'name' => 'Good rating',
187
+ 'description' => 'Select the color to be used when the rating is good. ( >5 and <7.5)',
188
+ 'id' => 'cwppos_rating_good',
189
+ 'default' => '#50C1E9',
190
+ ),
191
+ array(
192
+ 'type' => 'color',
193
+ 'name' => 'Very good rating',
194
+ 'description' => 'Select the color to be used when the rating is very good. ( 7.5 < and <10)',
195
+ 'id' => 'cwppos_rating_very_good',
196
+ 'default' => '#8DC153',
197
+ ),
198
+ ),
199
+ ),
200
+ array(
201
+ 'type' => 'tab',
202
+ 'name' => 'Typography',
203
+ 'options' => array(
204
+ array(
205
+ 'type' => 'title',
206
+ 'name' => 'Typography options',
207
+ ),
208
+ array(
209
+ 'type' => 'color',
210
+ 'name' => 'Font color',
211
+ 'description' => 'Select the color to be used on the font.',
212
+ 'id' => 'cwppos_font_color',
213
+ 'default' => '#3D3D3D',
214
+ ),
215
+ array(
216
+ 'type' => 'color',
217
+ 'name' => "'Pros' text color",
218
+ 'description' => "Select the color to be used on the 'Pros' text.",
219
+ 'id' => 'cwppos_pros_color',
220
+ 'default' => '#8DC153',
221
+ ),
222
+ array(
223
+ 'type' => 'color',
224
+ 'name' => "'Cons' text color",
225
+ 'description' => "Select the color to be used on the 'Cons' text.",
226
+ 'id' => 'cwppos_cons_color',
227
+ 'default' => '#C15353',
228
+ ),
229
+ array(
230
+ 'type' => 'input_text',
231
+ 'name' => 'Pros text',
232
+ 'description' => 'Specify text for pros heading',
233
+ 'id' => 'cwppos_pros_text',
234
+ 'default' => 'Pros',
235
+ ),
236
+ array(
237
+ 'type' => 'input_text',
238
+ 'name' => 'Cons text',
239
+ 'description' => 'Specify text for cons heading',
240
+ 'id' => 'cwppos_cons_text',
241
+ 'default' => 'Cons',
242
+ ),
243
+ array(
244
+ 'type' => 'color',
245
+ 'name' => 'Review box border',
246
+ 'description' => 'Select the border color to be used on the review box',
247
+ 'id' => 'cwppos_reviewboxbd_color',
248
+ 'default' => '#3BAEDA',
249
+ ),
250
+ array(
251
+ 'type' => 'input_text',
252
+ 'name' => 'Review box border width',
253
+ 'description' => 'Select the width in pixels of the top border of the review box',
254
+ 'id' => 'cwppos_reviewboxbd_width',
255
+ 'default' => '5',
256
+ ),
257
+ ),
258
+ ),
259
+ array(
260
+ 'type' => 'tab',
261
+ 'name' => 'Buy button',
262
+ 'options' => array(
263
+ array(
264
+ 'type' => 'title',
265
+ 'name' => 'Buy button options',
266
+ ),
267
+ array(
268
+ 'type' => 'select',
269
+ 'name' => 'Show button icon',
270
+ 'description' => 'Show icon on the cart icon on button.',
271
+ 'id' => 'cwppos_show_icon',
272
+ 'options' => array( 'yes' => 'Yes', 'no' => 'No' ),
273
+ 'default' => 'yes',
274
+ ),
275
+ array(
276
+ 'type' => 'color',
277
+ 'name' => 'Button border',
278
+ 'description' => 'Select the border color to be used on the buy button for the default state',
279
+ 'id' => 'cwppos_buttonbd_color',
280
+ 'default' => '#3BAEDA',
281
+ ),
282
+ array(
283
+ 'type' => 'color',
284
+ 'name' => 'Button border hover',
285
+ 'description' => 'Select the border color to be used on the buy button for the hover state',
286
+ 'id' => 'cwppos_buttonbh_color',
287
+ 'default' => '#3BAEDA',
288
+ ),
289
+ array(
290
+ 'type' => 'color',
291
+ 'name' => 'Button background',
292
+ 'description' => 'Select the background color to be used on the buy button for the default state',
293
+ 'id' => 'cwppos_buttonbkd_color',
294
+ 'default' => '#ffffff',
295
+ ),
296
+ array(
297
+ 'type' => 'color',
298
+ 'name' => 'Button background hover',
299
+ 'description' => 'Select the background color to be used on the buy button for the hover state',
300
+ 'id' => 'cwppos_buttonbkh_color',
301
+ 'default' => '#3BAEDA',
302
+ ),
303
+ array(
304
+ 'type' => 'color',
305
+ 'name' => 'Button text color',
306
+ 'description' => 'Select the text color to be used on the buy button for the default state',
307
+ 'id' => 'cwppos_buttontxtd_color',
308
+ 'default' => '#3BAEDA',
309
+ ),
310
+ array(
311
+ 'type' => 'color',
312
+ 'name' => 'Button text color hover',
313
+ 'description' => 'Select the text color to be used on the buy button for the hover state',
314
+ 'id' => 'cwppos_buttontxth_color',
315
+ 'default' => '#FFFFFF',
316
+ ),
317
+ ),
318
+ ),
319
+ );
320
+
321
+ }
322
+
323
+ }
324
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/inc/loader.php CHANGED
@@ -1,419 +1,414 @@
1
  <?php
2
 
3
-
4
 
5
  add_action( 'admin_menu', 'cwppos_options_add_page' );
6
-
7
- function cwppos_options_add_page() {
8
-
9
  $render = new cwpposRenderView();
10
- add_menu_page( __( cwppos_config("admin_page_title"), 'cwppos' ), __( cwppos_config("admin_page_menu_name"), 'cwppos' ), 'manage_options', cwppos_config("menu_slug"), array($render,'show'), "dashicons-star-half" ,'99.87414' );
 
 
 
11
  }
12
-
13
- function cwppos_config($config_name, $echo = 0){
14
-
15
- $return = '';
 
 
 
 
16
  cwpposConfig::init();
17
- $return = cwpposConfig::$$config_name;
18
- if($echo)
19
- echo $return;
20
- else
21
- return $return;
22
  }
23
 
24
- function cwppos_get_options(){
25
- $error = cwppos_check_config();
26
- if(!empty($error)) return false;
27
- $options = get_option(cwppos_config("menu_slug"));
28
- $default = cwpposConfig::$structure;
29
  }
30
 
31
- function cwppos_check_element($field,$tab){
32
  $errors = array();
33
- $group_fields = array("type","name","options");
34
- $input_text = array("type","name","description","id","default");
35
- $input_number = array_merge($input_text,array("max","min","step"));
36
- $select = $mselect = $checkbox = $radio = array_merge($input_text,array("options"));
37
-
38
  $textarea = $editor = $color = $image = $typo = $bg = $input_text;
39
-
40
- switch($field['type']){
41
- case 'input_text':
42
-
43
- $keys = array_keys($field);
44
- $dif = array_diff($input_text,$keys);
45
- if(!empty($dif)){
46
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
47
- break;
48
- }
49
-
50
- break;
51
- case 'input_number':
52
-
53
- $keys = array_keys($field);
54
- $dif = array_diff($input_number,$keys);
55
-
56
- if(!empty($dif)){
57
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
58
- break;
59
- }
60
-
61
- break;
62
- case 'textarea':
63
-
64
- $keys = array_keys($field);
65
- $dif = array_diff($input_text,$keys);
66
- if(!empty($dif)){
67
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
68
- break;
69
- }
70
-
71
- break;
72
- case 'textarea_html':
73
-
74
- $keys = array_keys($field);
75
- $dif = array_diff($input_text,$keys);
76
- if(!empty($dif)){
77
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
78
- break;
79
- }
80
-
81
- break;
82
- case 'editor':
83
-
84
- $keys = array_keys($field);
85
- $dif = array_diff($input_text,$keys);
86
- if(!empty($dif)){
87
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
88
- break;
89
- }
90
-
91
- break;
92
- case 'color':
93
-
94
- $keys = array_keys($field);
95
- $dif = array_diff($input_text,$keys);
96
- if(!empty($dif)){
97
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
98
- break;
99
- }
100
-
101
- break;
102
- case 'image':
103
-
104
- $keys = array_keys($field);
105
- $dif = array_diff($input_text,$keys);
106
- if(!empty($dif)){
107
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
108
- break;
109
- }
110
-
111
- break;
112
- case 'typography':
113
-
114
- $keys = array_keys($field);
115
- $dif = array_diff($input_text,$keys);
116
- if(!empty($dif)){
117
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
118
- break;
119
- }
120
- $defaults = array("font","color","style","size");
121
- $kkeys = array_keys($field['default']);
122
-
123
- $ddif = array_diff($defaults,$kkeys);
124
- if(!empty($ddif)){
125
- $errors[] = "You have not added the ".implode(",",$ddif)." keys for the ".$field['nume']." in tab ".$tab." on option no.: ".$r;
126
- break;
127
- }
128
-
129
- break;
130
- case 'background':
131
-
132
- $keys = array_keys($field);
133
- $dif = array_diff($input_text,$keys);
134
- if(!empty($dif)){
135
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
136
- break;
137
- }
138
- $defaults = array("bgcolor","bgimage","bgposition","bgrepeat","bgattachment");
139
- $kkeys = array_keys($field['default']);
140
- $ddif = array_diff($defaults,$kkeys);
141
-
142
- if(!empty($ddif)){
143
- $errors[] = "You have not added the ".implode(",",$ddif)." keys for the ".$field['name']." in tab ".$tab." tab ";
144
- break;
145
- }
146
-
147
- break;
148
- case 'input_number':
149
- $keys = array_keys($field);
150
- $dif = array_diff($input_number,$keys);
151
- if(!empty($dif)){
152
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
153
- break;
154
- }
155
- break;
156
- case 'select':
157
- $keys = array_keys($field);
158
- $dif = array_diff($select,$keys);
159
- if(!empty($dif)){
160
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
161
- break;
162
- }
163
- $no = array();
164
- foreach($field['options'] as $ov=>$op){
165
- $no[esc_attr($ov)] = esc_html($op);
166
- }
167
- $kno = array_keys($no);
168
- if(!in_array($field['default'],$kno)){
169
- $errors[] = "The default value for the select ".$field['name']." in tab ".$tab." is not in the allowed values. ";
170
- break;
171
- }
172
- break;
173
- case 'radio':
174
- $keys = array_keys($field);
175
- $dif = array_diff($select,$keys);
176
- if(!empty($dif)){
177
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
178
- break;
179
- }
180
- $no = array();
181
- foreach($field['options'] as $ov=>$op){
182
- $no[esc_attr($ov)] = esc_html($op);
183
- }
184
- $kno = array_keys($no);
185
- if(!in_array($field['default'],$kno)){
186
- $errors[] = "The default value for the radio ".$field['name']." in tab ".$tab." is not in the allowed values. ";
187
- break;
188
- }
189
- break;
190
- case 'multiselect':
191
- $keys = array_keys($field);
192
- $dif = array_diff($select,$keys);
193
- if(!empty($dif)){
194
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
195
- break;
196
- }
197
- if(!is_array($field['default'])) {
198
-
199
- $errors[] = "The default value for the multiselect ".$field['name']." in tab ".$tab." must be an array. ";
200
- break;
201
- }
202
- $no = array();
203
- foreach($field['options'] as $ov=>$op){
204
- $no[esc_attr($ov)] = esc_html($op);
205
- }
206
- $kno = array_keys($no);
207
- $ddif = array_diff($field['default'],$kno);
208
-
209
- if(!empty($ddif)) {
210
-
211
- $errors[] = "The default values for the multiselect ".$field['name']." in tab ".$tab." are not in the allowed values (".implode(",",$ddif).") ";
212
- break;
213
- }
214
-
215
- break;
216
- case 'checkbox':
217
- $keys = array_keys($field);
218
- $dif = array_diff($select,$keys);
219
- if(!empty($dif)){
220
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$tab." tab on .: ".$field['name'];
221
- break;
222
- }
223
- if(!is_array($field['default'])) {
224
-
225
- $errors[] = "The default value for the checkbox ".$field['name']." in tab ".$tab." must be an array. ";
226
- break;
227
- }
228
- $no = array();
229
- foreach($field['options'] as $ov=>$op){
230
- $no[esc_attr($ov)] = esc_html($op);
231
- }
232
- $kno = array_keys($no);
233
- $ddif = array_diff($field['default'],$kno);
234
-
235
- if(!empty($ddif)) {
236
-
237
- $errors[] = "The default values for the checkbox ".$field['name']." in tab ".$tab." are not in the allowed values (".implode(",",$ddif).") ";
238
- break;
239
- }
240
-
241
- break;
242
-
243
-
244
- }
245
  return $errors;
246
  }
247
-
248
 
249
- function cwppos_check_config(){
 
250
  $errors = array();
251
  $config = cwpposConfig::$structure;
252
 
253
- $tab_fields = array("type","name","options");
254
- $titles = array("name","type");
255
- $title = array_merge($titles,array("default"));
256
- foreach($config as $k=>$fields){
 
 
 
257
 
 
 
 
 
258
 
259
- $keys = array_keys($fields);
260
- $dif = array_diff($tab_fields,$keys);
261
 
262
- if(!empty($dif)){
263
- $errors[] = "You have not added the ".implode(",",$dif)." keys for first level item on key : ". $k;
264
- break;
265
- }
266
-
267
- if($fields['type'] == 'tab'){
268
-
269
- }else{
270
- $errors[] = "All first level items from structure must be tabs";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  break;
272
- }
273
- foreach ($fields['options'] as $r=>$field){
274
- $keys = array_keys($field);
275
-
276
- $dif = array_diff($titles,$keys);
277
- if(!empty($dif)){
278
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$fields['name']." tab on option no.: ".$r;
279
- break;
280
- }
281
- if(!isset($field['default']) && ( $field['type'] != 'title' && $field['type'] != 'group' ) ){
282
- $errors[] = "You have not added the default key for the ".$fields['name']." tab on option no.: ".$r;
283
- break;
284
-
285
- }
286
- if($field['type'] == 'group'){
287
- if(!isset($field['options'])){
288
- $errors[] = "You have not added the option key for the ".$field['name']." group in ".$fields['name']." tab on option no.: ".$r;
289
- break;
290
- }
291
- if(empty($field['options'])){
292
- $errors[] = "The option array is empty for the ".$field['name']." group in ".$fields['name']." tab on option no.: ".$r;
293
- break;
294
-
295
- }
296
- foreach($field['options'] as $m=>$gfield){
297
- $keys = array_keys($gfield);
298
- $dif = array_diff($title,$keys);
299
- if(!empty($dif)){
300
- $errors[] = "You have not added the ".implode(",",$dif)." keys for the ".$fields['name']." tab on option no.: ".$m;
301
- break;
302
- }
303
-
304
- $errors = array_merge(cwppos_check_element($gfield,$fields['name'] ),$errors);
305
- }
306
- }else{
307
- $errors = array_merge(cwppos_check_element($field,$fields['name'] ),$errors) ;
308
- }
309
  }
310
- if(!empty($errors)) break;
311
-
312
- }
 
 
 
 
 
 
313
 
314
  return $errors;
315
- }
316
 
317
- function cwppos_get_config_defaults($structure){
318
  $defaults = array();
319
- foreach($structure as $k=>$fields){
320
-
321
- if($fields['type'] == 'tab'){
322
-
323
-
324
- foreach ($fields['options'] as $r=>$field){
325
-
326
- if($field['type'] == 'group'){
327
-
328
- foreach($field['options'] as $m=>$gfield){
329
- if($gfield["type"]!='title')
330
- $defaults[$gfield['id']] = $gfield['default'];
331
- }
332
-
333
- }else{
334
- if($field["type"]!='title')
335
- $defaults[$field['id']] = $field['default'];
336
- }
337
-
338
- }
339
-
340
- }
341
-
342
  }
343
  return $defaults;
344
  }
345
 
346
  function cwppos_admin_notice() {
347
 
348
- $errors = cwppos_check_config();
349
- if(!empty($errors)) {
350
- foreach($errors as $error){
351
  ?>
352
  <div id="message" class="error"> <p><strong><?php echo $error; ?></strong></p></div>
353
 
354
- <?php
355
  }
356
  }
357
  }
358
 
359
- function cwppos_check_options(){
360
- $option = get_option(cwppos_config("menu_slug"));
361
- if($option === false) cwppos_add_options();
362
  }
363
 
364
 
365
- function cwppos_add_options(){
366
- /* $errors = cwppos_check_config();
 
367
  if(!empty($errors)) return false; */
368
  $validator = new cwpposOptionsValidator();
369
- $option = get_option(cwppos_config("menu_slug"));
370
  $structure = cwpposConfig::$structure;
371
- $defaults = cwppos_get_config_defaults($structure);
372
  $defaults = $validator->validate_defaults();
373
- $options = array_merge($defaults,is_array($option) ? $option : array() );
374
 
375
-
376
- if(!is_array($option))
377
- add_option(cwppos_config("menu_slug"),$options,"","no");
378
- else
379
- update_option(cwppos_config("menu_slug"),$options);
380
- if(function_exists("register_setting")){
381
- register_setting( cwppos_config("menu_slug"), cwppos_config("menu_slug"), array($validator,"validate") );
382
- }
383
  }
384
 
385
 
386
  function cwppos_load_defaults_callback() {
387
  $errors = cwppos_check_config();
388
- if(!empty($errors)) return false;
389
- delete_option(cwppos_config("menu_slug"));
390
  $validator = new cwpposOptionsValidator();
391
  $structure = cwpposConfig::$structure;
392
- $defaults = cwppos_get_config_defaults($structure);
393
  $defaults = $validator->validate_defaults();
394
 
395
- add_option(cwppos_config("menu_slug"),$defaults,"","no");
396
-
397
  die();
398
  }
399
 
400
- function cwppos($name = ''){
401
- $op = get_option(cwppos_config("menu_slug"));
402
- if(empty($name))
403
- return $op;
404
-
405
- if(isset($op[$name])){
406
- return $op[$name];
407
  }
408
  return null;
409
  }
410
 
411
 
412
 
413
- add_action("admin_init","cwppos_add_options",999999);
414
- add_action("init","cwppos_check_options");
415
- add_action("admin_notices", "cwppos_admin_notice");
416
- add_action("wp_ajax_cwp_load_defaults", "cwppos_load_defaults_callback");
417
-
418
 
419
 
1
  <?php
2
 
3
+
4
 
5
  add_action( 'admin_menu', 'cwppos_options_add_page' );
6
+
7
+ function cwppos_options_add_page() {
8
+
9
  $render = new cwpposRenderView();
10
+ add_menu_page( __( cwppos_config( 'admin_page_title' ), 'cwppos' ), __( cwppos_config( 'admin_page_menu_name' ), 'cwppos' ), 'manage_options', cwppos_config( 'menu_slug' ), array( $render, 'show' ), 'dashicons-star-half' ,'99.87414' );
11
+ if ( ! class_exists( 'CWP_PR_PRO_Core' ) ) {
12
+ // add_submenu_page( cwppos_config("menu_slug"), __( cwppos_config("pro_page_title"), 'cwppos' ), __( cwppos_config("pro_page_menu_name"), 'cwppos' ), 'manage_options', "cwppos_pro", array($render, 'pro'));
13
+ }
14
  }
15
+
16
+ function cwppos_pro_features() {
17
+ include_once WPPR_PATH . '/admin/layout/pro.php';
18
+ }
19
+
20
+ function cwppos_config( $config_name, $echo = 0 ) {
21
+
22
+ $return = '';
23
  cwpposConfig::init();
24
+ $return = cwpposConfig::$$config_name;
25
+ if ( $echo ) {
26
+ echo $return; } else { return $return; }
 
 
27
  }
28
 
29
+ function cwppos_get_options() {
30
+ $error = cwppos_check_config();
31
+ if ( ! empty( $error ) ) { return false; }
32
+ $options = get_option( cwppos_config( 'menu_slug' ) );
33
+ $default = cwpposConfig::$structure;
34
  }
35
 
36
+ function cwppos_check_element( $field, $tab ) {
37
  $errors = array();
38
+ $group_fields = array( 'type','name','options' );
39
+ $input_text = array( 'type','name','description','id','default' );
40
+ $input_number = array_merge( $input_text,array( 'max', 'min', 'step' ) );
41
+ $select = $mselect = $checkbox = $radio = array_merge( $input_text,array( 'options' ) );
42
+
43
  $textarea = $editor = $color = $image = $typo = $bg = $input_text;
44
+
45
+ switch ( $field['type'] ) {
46
+ case 'input_text':
47
+
48
+ $keys = array_keys( $field );
49
+ $dif = array_diff( $input_text,$keys );
50
+ if ( ! empty( $dif ) ) {
51
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
52
+ break;
53
+ }
54
+
55
+ break;
56
+ case 'input_number':
57
+
58
+ $keys = array_keys( $field );
59
+ $dif = array_diff( $input_number,$keys );
60
+
61
+ if ( ! empty( $dif ) ) {
62
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
63
+ break;
64
+ }
65
+
66
+ break;
67
+ case 'textarea':
68
+
69
+ $keys = array_keys( $field );
70
+ $dif = array_diff( $input_text,$keys );
71
+ if ( ! empty( $dif ) ) {
72
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
73
+ break;
74
+ }
75
+
76
+ break;
77
+ case 'textarea_html':
78
+
79
+ $keys = array_keys( $field );
80
+ $dif = array_diff( $input_text,$keys );
81
+ if ( ! empty( $dif ) ) {
82
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
83
+ break;
84
+ }
85
+
86
+ break;
87
+ case 'editor':
88
+
89
+ $keys = array_keys( $field );
90
+ $dif = array_diff( $input_text,$keys );
91
+ if ( ! empty( $dif ) ) {
92
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
93
+ break;
94
+ }
95
+
96
+ break;
97
+ case 'color':
98
+
99
+ $keys = array_keys( $field );
100
+ $dif = array_diff( $input_text,$keys );
101
+ if ( ! empty( $dif ) ) {
102
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
103
+ break;
104
+ }
105
+
106
+ break;
107
+ case 'image':
108
+
109
+ $keys = array_keys( $field );
110
+ $dif = array_diff( $input_text,$keys );
111
+ if ( ! empty( $dif ) ) {
112
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
113
+ break;
114
+ }
115
+
116
+ break;
117
+ case 'typography':
118
+
119
+ $keys = array_keys( $field );
120
+ $dif = array_diff( $input_text,$keys );
121
+ if ( ! empty( $dif ) ) {
122
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
123
+ break;
124
+ }
125
+ $defaults = array( 'font','color','style','size' );
126
+ $kkeys = array_keys( $field['default'] );
127
+
128
+ $ddif = array_diff( $defaults,$kkeys );
129
+ if ( ! empty( $ddif ) ) {
130
+ $errors[] = 'You have not added the ' . implode( ',',$ddif ) . ' keys for the ' . $field['nume'] . ' in tab ' . $tab . ' on option no.: ' . $r;
131
+ break;
132
+ }
133
+
134
+ break;
135
+ case 'background':
136
+
137
+ $keys = array_keys( $field );
138
+ $dif = array_diff( $input_text,$keys );
139
+ if ( ! empty( $dif ) ) {
140
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
141
+ break;
142
+ }
143
+ $defaults = array( 'bgcolor','bgimage','bgposition','bgrepeat','bgattachment' );
144
+ $kkeys = array_keys( $field['default'] );
145
+ $ddif = array_diff( $defaults,$kkeys );
146
+
147
+ if ( ! empty( $ddif ) ) {
148
+ $errors[] = 'You have not added the ' . implode( ',',$ddif ) . ' keys for the ' . $field['name'] . ' in tab ' . $tab . ' tab ';
149
+ break;
150
+ }
151
+
152
+ break;
153
+ case 'input_number':
154
+ $keys = array_keys( $field );
155
+ $dif = array_diff( $input_number,$keys );
156
+ if ( ! empty( $dif ) ) {
157
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
158
+ break;
159
+ }
160
+ break;
161
+ case 'select':
162
+ $keys = array_keys( $field );
163
+ $dif = array_diff( $select,$keys );
164
+ if ( ! empty( $dif ) ) {
165
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
166
+ break;
167
+ }
168
+ $no = array();
169
+ foreach ( $field['options'] as $ov => $op ) {
170
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
171
+ }
172
+ $kno = array_keys( $no );
173
+ if ( ! in_array( $field['default'],$kno ) ) {
174
+ $errors[] = 'The default value for the select ' . $field['name'] . ' in tab ' . $tab . ' is not in the allowed values. ';
175
+ break;
176
+ }
177
+ break;
178
+ case 'radio':
179
+ $keys = array_keys( $field );
180
+ $dif = array_diff( $select,$keys );
181
+ if ( ! empty( $dif ) ) {
182
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
183
+ break;
184
+ }
185
+ $no = array();
186
+ foreach ( $field['options'] as $ov => $op ) {
187
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
188
+ }
189
+ $kno = array_keys( $no );
190
+ if ( ! in_array( $field['default'],$kno ) ) {
191
+ $errors[] = 'The default value for the radio ' . $field['name'] . ' in tab ' . $tab . ' is not in the allowed values. ';
192
+ break;
193
+ }
194
+ break;
195
+ case 'multiselect':
196
+ $keys = array_keys( $field );
197
+ $dif = array_diff( $select,$keys );
198
+ if ( ! empty( $dif ) ) {
199
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
200
+ break;
201
+ }
202
+ if ( ! is_array( $field['default'] ) ) {
203
+
204
+ $errors[] = 'The default value for the multiselect ' . $field['name'] . ' in tab ' . $tab . ' must be an array. ';
205
+ break;
206
+ }
207
+ $no = array();
208
+ foreach ( $field['options'] as $ov => $op ) {
209
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
210
+ }
211
+ $kno = array_keys( $no );
212
+ $ddif = array_diff( $field['default'],$kno );
213
+
214
+ if ( ! empty( $ddif ) ) {
215
+
216
+ $errors[] = 'The default values for the multiselect ' . $field['name'] . ' in tab ' . $tab . ' are not in the allowed values (' . implode( ',',$ddif ) . ') ';
217
+ break;
218
+ }
219
+
220
+ break;
221
+ case 'checkbox':
222
+ $keys = array_keys( $field );
223
+ $dif = array_diff( $select,$keys );
224
+ if ( ! empty( $dif ) ) {
225
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $tab . ' tab on .: ' . $field['name'];
226
+ break;
227
+ }
228
+ if ( ! is_array( $field['default'] ) ) {
229
+
230
+ $errors[] = 'The default value for the checkbox ' . $field['name'] . ' in tab ' . $tab . ' must be an array. ';
231
+ break;
232
+ }
233
+ $no = array();
234
+ foreach ( $field['options'] as $ov => $op ) {
235
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
236
+ }
237
+ $kno = array_keys( $no );
238
+ $ddif = array_diff( $field['default'],$kno );
239
+
240
+ if ( ! empty( $ddif ) ) {
241
+
242
+ $errors[] = 'The default values for the checkbox ' . $field['name'] . ' in tab ' . $tab . ' are not in the allowed values (' . implode( ',',$ddif ) . ') ';
243
+ break;
244
+ }
245
+
246
+ break;
247
+
248
+ }
 
249
  return $errors;
250
  }
 
251
 
252
+
253
+ function cwppos_check_config() {
254
  $errors = array();
255
  $config = cwpposConfig::$structure;
256
 
257
+ $tab_fields = array( 'type','name','options' );
258
+ $titles = array( 'name','type' );
259
+ $title = array_merge( $titles,array( 'default' ) );
260
+ foreach ( $config as $k => $fields ) {
261
+
262
+ $keys = array_keys( $fields );
263
+ $dif = array_diff( $tab_fields,$keys );
264
 
265
+ if ( ! empty( $dif ) ) {
266
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for first level item on key : ' . $k;
267
+ break;
268
+ }
269
 
270
+ if ( $fields['type'] == 'tab' ) {
 
271
 
272
+ } else {
273
+ $errors[] = 'All first level items from structure must be tabs';
274
+ break;
275
+ }
276
+ foreach ( $fields['options'] as $r => $field ) {
277
+ $keys = array_keys( $field );
278
+
279
+ $dif = array_diff( $titles,$keys );
280
+ if ( ! empty( $dif ) ) {
281
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $fields['name'] . ' tab on option no.: ' . $r;
282
+ break;
283
+ }
284
+ if ( ! isset( $field['default'] ) && ( $field['type'] != 'title' && $field['type'] != 'group' ) ) {
285
+ $errors[] = 'You have not added the default key for the ' . $fields['name'] . ' tab on option no.: ' . $r;
286
+ break;
287
+
288
+ }
289
+ if ( $field['type'] == 'group' ) {
290
+ if ( ! isset( $field['options'] ) ) {
291
+ $errors[] = 'You have not added the option key for the ' . $field['name'] . ' group in ' . $fields['name'] . ' tab on option no.: ' . $r;
292
+ break;
293
+ }
294
+ if ( empty( $field['options'] ) ) {
295
+ $errors[] = 'The option array is empty for the ' . $field['name'] . ' group in ' . $fields['name'] . ' tab on option no.: ' . $r;
296
+ break;
297
+
298
+ }
299
+ foreach ( $field['options'] as $m => $gfield ) {
300
+ $keys = array_keys( $gfield );
301
+ $dif = array_diff( $title,$keys );
302
+ if ( ! empty( $dif ) ) {
303
+ $errors[] = 'You have not added the ' . implode( ',',$dif ) . ' keys for the ' . $fields['name'] . ' tab on option no.: ' . $m;
304
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  }
306
+
307
+ $errors = array_merge( cwppos_check_element( $gfield,$fields['name'] ),$errors );
308
+ }
309
+ } else {
310
+ $errors = array_merge( cwppos_check_element( $field,$fields['name'] ),$errors );
311
+ }
312
+ }
313
+ if ( ! empty( $errors ) ) { break; }
314
+ }
315
 
316
  return $errors;
317
+ }
318
 
319
+ function cwppos_get_config_defaults( $structure ) {
320
  $defaults = array();
321
+ foreach ( $structure as $k => $fields ) {
322
+
323
+ if ( $fields['type'] == 'tab' ) {
324
+
325
+ foreach ( $fields['options'] as $r => $field ) {
326
+
327
+ if ( $field['type'] == 'group' ) {
328
+
329
+ foreach ( $field['options'] as $m => $gfield ) {
330
+ if ( $gfield['type'] != 'title' ) {
331
+ $defaults[ $gfield['id'] ] = $gfield['default']; }
332
+ }
333
+ } else {
334
+ if ( $field['type'] != 'title' ) {
335
+ $defaults[ $field['id'] ] = $field['default']; }
336
+ }
337
+ }
338
+ }
 
 
 
 
 
339
  }
340
  return $defaults;
341
  }
342
 
343
  function cwppos_admin_notice() {
344
 
345
+ $errors = cwppos_check_config();
346
+ if ( ! empty( $errors ) ) {
347
+ foreach ( $errors as $error ) {
348
  ?>
349
  <div id="message" class="error"> <p><strong><?php echo $error; ?></strong></p></div>
350
 
351
+ <?php
352
  }
353
  }
354
  }
355
 
356
+ function cwppos_check_options() {
357
+ $option = get_option( cwppos_config( 'menu_slug' ) );
358
+ if ( $option === false ) { cwppos_add_options(); }
359
  }
360
 
361
 
362
+ function cwppos_add_options() {
363
+ /*
364
+ $errors = cwppos_check_config();
365
  if(!empty($errors)) return false; */
366
  $validator = new cwpposOptionsValidator();
367
+ $option = get_option( cwppos_config( 'menu_slug' ) );
368
  $structure = cwpposConfig::$structure;
369
+ $defaults = cwppos_get_config_defaults( $structure );
370
  $defaults = $validator->validate_defaults();
371
+ $options = array_merge( $defaults,is_array( $option ) ? $option : array() );
372
 
373
+ if ( ! is_array( $option ) ) {
374
+ add_option( cwppos_config( 'menu_slug' ),$options,'','no' ); } else { update_option( cwppos_config( 'menu_slug' ),$options ); }
375
+ if ( function_exists( 'register_setting' ) ) {
376
+ register_setting( cwppos_config( 'menu_slug' ), cwppos_config( 'menu_slug' ), array( $validator, 'validate' ) );
377
+ }
 
 
 
378
  }
379
 
380
 
381
  function cwppos_load_defaults_callback() {
382
  $errors = cwppos_check_config();
383
+ if ( ! empty( $errors ) ) { return false; }
384
+ delete_option( cwppos_config( 'menu_slug' ) );
385
  $validator = new cwpposOptionsValidator();
386
  $structure = cwpposConfig::$structure;
387
+ $defaults = cwppos_get_config_defaults( $structure );
388
  $defaults = $validator->validate_defaults();
389
 
390
+ add_option( cwppos_config( 'menu_slug' ),$defaults,'','no' );
391
+
392
  die();
393
  }
394
 
395
+ function cwppos( $name = '' ) {
396
+ $op = get_option( cwppos_config( 'menu_slug' ) );
397
+ if ( empty( $name ) ) {
398
+ return $op; }
399
+
400
+ if ( isset( $op[ $name ] ) ) {
401
+ return $op[ $name ];
402
  }
403
  return null;
404
  }
405
 
406
 
407
 
408
+ add_action( 'admin_init','cwppos_add_options',999999 );
409
+ add_action( 'init','cwppos_check_options' );
410
+ add_action( 'admin_notices', 'cwppos_admin_notice' );
411
+ add_action( 'wp_ajax_cwp_load_defaults', 'cwppos_load_defaults_callback' );
412
+
413
 
414
 
admin/inc/render.php CHANGED
@@ -1,402 +1,396 @@
1
  <?php
2
 
3
- class cwpposRenderView {
4
- public $data = array();
5
- private $css = array();
6
- private $js = array();
7
- public $tabs = array();
8
- public $options = array();
9
- public function __construct(){
10
 
11
- $css_path = cwppos_config("admin_template_directory_uri")."/css/";
12
- $js_path = cwppos_config("admin_template_directory_uri")."/js/";
13
- $this->add_css("main_page_css",$css_path."main_page.css");
14
- $this->add_js("wp_product_review_main_page_js",$js_path."admin.js");
15
- $this->add_js("typsy",$js_path."tipsy.js");
16
- $this->add_js("jquery" );
17
- //$this->add_js("media" );
 
18
 
19
- $this->options = get_option(cwppos_config("menu_slug"));
 
20
 
21
- $this->add_js('wp-color-picker' );
22
- $this->add_css('wp-color-picker' );
23
 
 
24
 
25
- }
26
-
27
- public function add_element($tabid,$field ){
28
-
29
-
30
- switch($field['type']){
31
- case 'input_text':
32
 
33
- $this->add_input_text($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
34
 
35
- break;
36
- case 'input_number':
37
 
38
- $this->add_input_number($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
39
 
40
- break;
41
- case 'textarea':
42
 
43
- $this->add_textarea($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
44
 
45
- break;
46
- case 'textarea_html':
47
- if(current_user_can("unfiltered_html"))
48
- $this->add_textarea($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
49
- else
50
- $this->add_restriction($tabid,esc_html($field['name']));
51
 
52
- break;
53
- case 'editor':
54
 
55
- $this->add_editor($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
56
 
57
- break;
58
- case 'color':
59
 
60
- $this->add_color($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
61
 
62
- break;
63
- case 'image':
64
 
65
- $this->add_image($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
66
 
67
- break;
68
- case 'button':
69
 
70
- $this->add_button($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
71
 
72
- break;
73
- case 'typography':
74
 
 
 
 
75
 
76
- $this->add_typography($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
77
- break;
78
- case 'background':
79
 
 
 
 
 
 
 
 
80
 
81
- $this->add_background($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
82
- break;
83
- case 'select':
84
-
85
- $no = array();
86
- foreach($field['options'] as $ov=>$op){
87
- $no[esc_attr($ov)] = esc_html($op);
88
- }
89
- $this->add_select($tabid,esc_html($field['name']),esc_html($field['description']),esc_attr($field['id']),$no);
90
- break;
91
- case 'radio':
92
-
93
- $no = array();
94
- foreach($field['options'] as $ov=>$op){
95
- $no[esc_attr($ov)] = esc_html($op);
96
- }
97
- $this->add_radio($tabid,esc_html($field['name']),esc_html($field['description']),esc_attr($field['id']),$no);
98
- break;
99
- case 'multiselect':
100
-
101
- $no = array();
102
- foreach($field['options'] as $ov=>$op){
103
- $no[esc_attr($ov)] = esc_html($op);
104
- }
105
 
106
- $this->add_multiselect($tabid,esc_html($field['name']),esc_html($field['description']),esc_attr($field['id']),$no);
107
- break;
108
- case 'checkbox':
 
109
 
110
- $no = array();
111
- foreach($field['options'] as $ov=>$op){
112
- $no[esc_attr($ov)] = esc_html($op);
113
- }
114
 
115
- $this->add_checkbox($tabid,esc_html($field['name']),esc_html($field['description']),esc_attr($field['id']),$no);
116
- break;
117
- case 'title':
118
- $this->add_title($tabid,esc_html($field['name']));
119
- break;
120
 
121
- case 'change_icon':
122
- $this->change_review_icon($tabid,esc_html($field['name']),esc_html($field["description"]),esc_attr($field['id']));
123
- break;
 
 
124
 
 
 
 
125
 
126
- }
127
- if(isset($errors)) { return $errors; }
128
  }
129
- public function show(){
130
- $structure = cwpposConfig::$structure;
131
- $errors = cwppos_check_config();
132
- if(!empty($errors)) return false;
133
- foreach($structure as $k=>$fields){
134
-
135
- if($fields['type'] == 'tab'){
136
- $tname = esc_html($fields['name']);
137
- $tabid = $this->add_tab($tname);
138
-
139
-
140
- foreach ($fields['options'] as $r=>$field){
141
-
142
- if($field['type'] == 'group'){
143
 
144
- $this->start_group($tabid,esc_html($field['name']));
145
- foreach($field['options'] as $m=>$gfield){
 
146
 
147
- $this->add_element($tabid,$gfield ) ;
148
- }
149
 
150
- $this->end_group($tabid);
151
- }else{
152
- $this->add_element($tabid,$field) ;
153
- }
154
 
155
- }
 
156
 
 
157
  }
158
 
 
 
 
 
 
159
  }
160
- $this->render_view('main_page');
161
-
162
  }
163
- public function add_css($name,$location =''){
164
- if($location!='')
165
- wp_register_style($name, $location, array(), "201306" );
166
- $this->css[] = $name;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
- public function add_js($name,$location = '',$deps = array()){
169
-
170
- if($location!='')
171
- wp_register_script($name, $location, $deps, "201306", true );
172
- $this->js[] = $name;
173
-
174
  }
 
 
175
 
176
- public function render_view($name){
177
- $this->data["tabs"] = $this->tabs;
178
- foreach($this->data as $k=>$v){
179
- $$k = $v;
180
- }
181
- foreach($this->css as $file){
182
- wp_enqueue_style($file);
183
  }
184
- foreach($this->js as $file){
185
- if($file == "media"){
186
-
187
- wp_enqueue_media();
188
- }
189
- wp_enqueue_script($file) ;
190
- }
191
- include(plugin_dir_path(dirname(__FILE__))."layout/".$name.".php");
192
  }
193
- public function add_tab($name){
194
- $id = strtolower(preg_replace("/[^a-zA-Z0-9]|\s/", "_",$name));
195
- $this->tabs[] =
196
- array(
197
- "name"=>$name,
198
- "id" =>$id,
199
- "elements"=>array()
200
- );
 
 
201
 
202
- return count($this->tabs) - 1;
203
- }
204
- public function add_input_text($tabid,$name,$description,$id,$class=''){
205
- $html = '
206
- <div class="controls '.$class.'">
207
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> <input class="cwp_input " placeholder="'.$name.'" name="'.cwppos_config("menu_slug").'['.$id.']" type="text" value="'.$this->options[$id].'"></div>';
208
 
209
- $this->tabs[$tabid]["elements"][] = array("type"=>"input_text",
210
- "html"=>$html
211
- );
 
212
 
213
- }
214
 
215
 
216
- public function change_review_icon($tabid, $name, $description, $id, $class='') {
217
 
218
- $html = "<div class='controls'>
219
  <div class='explain'>$name</div>
220
  <p class='field_description'>$description</p>";
221
 
222
- $html .= "<li>";
223
 
224
- if (cwppos('cwppos_show_poweredby') == 'yes' || function_exists('wppr_ci_custom_bar_icon')) {
225
 
226
- wp_enqueue_script("cwp-custom-bar-icon", WPPR_URL."/admin/layout/js/custom-bar-icon.js", false, WPPR_LITE_VERSION, "all");
227
- if( cwppos("cwppos_fontawesome") === 'no' )
228
- {
229
- wp_enqueue_style("font-awesome-cdn", "//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
230
- }
231
 
232
- $html .= "<button id='cwp_select_bar_icon'>Select Bar Icon</button>";
233
- $html .= "<input type='hidden' id='cwp_bar_icon_field' name='".cwppos_config("menu_slug")."[".$id."][]' value='";
234
- if(isset($this->options[$id])) { if (@$this->options[$id][0]=="#") { $html.=$this->options[$id]; } else $html .= @$this->options[$id][0]; }
 
 
235
 
236
- $html .= "'/> <span class='current_bar_icon'>";
237
- if(!empty($this->options[$id][0])) {
238
- //var_dump($this->options[$id][0]);
239
- if ($this->options[$id][0]==="#") {
240
 
241
- $code = $this->options[$id];
242
- }
243
- else
244
- $code = $this->options[$id][0];
245
 
246
- $html .= "<i class='fa fa-fw'>&". $code . "</i> <a href='#' class='useDefault'>Use Default Styling</a>";
247
- } else {
248
- $html .= "* Currently set to the default styling</span>";
249
- } } else {
250
- $html .= '<span style="color:red;">'. __('You need the PRO <a style="color:red;" href="http://bit.ly/2bhylar" target="_blank" >add-on</a> in order to change the review icons.',"cwppos") . "</span>";
251
- }
252
- $html .= "</li>";
 
253
 
254
- $html .= "</div>";
255
 
256
- $this->tabs[$tabid]["elements"][] = array("type" => "change_icon", "html" => $html);
257
- }
258
 
259
 
260
 
261
 
262
- public function get_fonts(){
 
 
 
 
 
 
 
 
 
 
 
 
263
  return array(
264
- 'arial' => 'Arial',
265
- 'verdana' => 'Verdana, Geneva',
266
- 'trebuchet' => 'Trebuchet',
267
- 'georgia' => 'Georgia',
268
- 'times' => 'Times New Roman',
269
- 'tahoma' => 'Tahoma, Geneva',
270
- 'palatino' => 'Palatino',
271
- 'helvetica' => 'Helvetica*'
272
- );
273
- }
274
- public function get_font_styles(){
275
- return array(
276
- 'normal' => __( 'Normal', 'cwppos' ),
277
- 'italic' => __( 'Italic', 'cwppos' ),
278
- 'bold' => __( 'Bold', 'cwppos' ),
279
- 'bold italic' => __( 'Bold Italic', 'cwppos' )
280
- );
281
- }
282
- public function get_font_sizes(){
283
- $sizes = range( 9, 71 );
284
- $sizes = array_map( 'absint', $sizes );
285
- return $sizes;
286
- }
287
- public function add_typography($tabid,$name,$description,$id,$class=''){
288
- $fonts = $this->get_fonts();
289
- $style = $this->get_font_styles();
290
- $sizes = $this->get_font_sizes();
291
- $html = '
292
- <div class="controls '.$class.'">
293
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> <div class="cwp_typo">
294
 
295
- <input type="hidden" id="'.$id.'_color" name="'.cwppos_config("menu_slug").'['.$id.'][color]" value="'.$this->options[$id]['color'].'"/>
296
- <input type="text" name="" class="subo-color-picker" id="'.$id.'_color_selector" value="'.$this->options[$id]['color'].'" />
297
 
298
- <select class="cwp_select cwp_tipsy" original-title="Font family" name="'.cwppos_config("menu_slug").'['.$id.'][font]" > ';
299
- foreach($fonts as $k=>$v){
300
 
301
- $html.="<option value='".$k."' ".($this->options[$id]['font'] == $k ? 'selected' : '').">".$v."</option>";
302
- }
303
 
304
- $html .='</select>
305
- <select class="cwp_select cwp_tipsy" original-title="Font style" name="'.cwppos_config("menu_slug").'['.$id.'][style]" > ';
306
- foreach($style as $k=>$v){
307
 
308
- $html.="<option value='".$k."' ".($this->options[$id]['style'] == $k ? 'selected' : '').">".$v."</option>";
309
- }
310
 
311
- $html .='</select>
312
- <select class="cwp_select cwp_tipsy" original-title="Font size" " name="'.cwppos_config("menu_slug").'['.$id.'][size]" > ';
313
- foreach($sizes as $v){
314
 
315
- $html.="<option value='".$v."' ".($this->options[$id]['size'] == $v ? 'selected' : '').">".$v."px</option>";
316
- }
317
 
318
- $html .='</select>
319
 
320
  </div></div>';
321
 
322
- $this->tabs[$tabid]["elements"][] = array("type"=>"typography",
323
- "html"=>$html
324
- );
 
325
 
326
- }
327
 
328
- public function get_bg_repeat(){
329
 
330
- return array(
331
- 'no-repeat' => __('No Repeat', 'cwppos'),
332
- 'repeat-x' => __('Repeat Horizontally', 'cwppos'),
333
- 'repeat-y' => __('Repeat Vertically', 'cwppos'),
334
- 'repeat' => __('Repeat All', 'cwppos'),
335
- );
336
- }
337
- public function get_bg_position(){
338
- return array(
339
- 'top left' => __('Top Left', 'cwppos'),
340
- 'top center' => __('Top Center', 'cwppos'),
341
- 'top right' => __('Top Right', 'cwppos'),
342
- 'center left' => __('Middle Left', 'cwppos'),
343
- 'center center' => __('Middle Center', 'cwppos'),
344
- 'center right' => __('Middle Right', 'cwppos'),
345
- 'bottom left' => __('Bottom Left', 'cwppos'),
346
- 'bottom center' => __('Bottom Center', 'cwppos'),
347
- 'bottom right' => __('Bottom Right', 'cwppos')
348
- );
349
- }
350
- public function get_bg_attachment(){
351
- return array(
352
- 'scroll' => __('Scroll Normally', 'optionsframework'),
353
- 'fixed' => __('Fixed in Place', 'optionsframework')
354
  );
 
 
 
 
 
 
355
 
356
- }
357
- public function add_background($tabid,$name,$description,$id,$class=''){
358
- $repeats = $this->get_bg_repeat();
359
- $positions = $this->get_bg_position();
360
- $attachments = $this->get_bg_attachment();
361
- $html = '
362
- <div class="controls '.$class.'">
363
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p><div class="cwp_background">
364
  <div class="cwp_bgstyle">
365
  <div class="cwp_bgimage">
366
- <input type="hidden" id="'.$id.'" name="'.cwppos_config("menu_slug").'['.$id.'][bgimage]" value="'.$this->options[$id]['bgimage'].'"/>
367
- <img src="'.$this->options[$id]['bgimage'].'" id="'.$id.'_image" class="image-preview-input"/><br/>
368
- <a id="'.$id.'_button" class="selector-image button" >Select Image</a>
369
 
370
- <a id="'.$id.'_buttonclear" class="clear-image button" >Clear image</a>
371
  </div>
372
  <div class="cwp_bgcolor">
373
- <input type="hidden" id="'.$id.'_color" name="'.cwppos_config("menu_slug").'['.$id.'][bgcolor]" value="'.$this->options[$id]['bgcolor'].'"/> <br/>
374
- <input type="text" name="" class="subo-color-picker" id="'.$id.'_color_selector" value="'.$this->options[$id]['bgcolor'].'" />
375
  </div><div class="clear"></div>
376
  </div>
377
  <div class="cwp_bgformat">
378
 
379
- <select class="cwp_select cwp_tipsy" original-title="Background repeat" name="'.cwppos_config("menu_slug").'['.$id.'][bgrepeat]" > ';
380
- foreach($repeats as $k=>$v){
381
 
382
- $html.="<option value='".$k."' ".($this->options[$id]['bgrepeat'] == $k ? 'selected' : '').">".$v."</option>";
383
- }
384
 
385
- $html .='</select>
386
- <select class="cwp_select cwp_tipsy" original-title="Background position" name="'.cwppos_config("menu_slug").'['.$id.'][bgposition]" > ';
387
- foreach($positions as $k=>$v){
388
 
389
- $html.="<option value='".$k."' ".($this->options[$id]['bgposition'] == $k ? 'selected' : '').">".$v."</option>";
390
- }
391
 
392
- $html .='</select>
393
- <select class="cwp_select cwp_tipsy" original-title="Background attachament" name="'.cwppos_config("menu_slug").'['.$id.'][bgattachment]" > ';
394
- foreach($attachments as $k=>$v){
395
 
396
- $html.="<option value='".$k."' ".($this->options[$id]['bgattachment'] == $k ? 'selected' : '').">".$v."</option>";
397
- }
398
 
399
- $html .='</select>
400
  </div>
401
 
402
  </div>
@@ -404,205 +398,211 @@
404
 
405
  </div>';
406
 
407
- $this->tabs[$tabid]["elements"][] = array("type"=>"textarea",
408
- "html"=>$html
409
- );
 
410
 
411
- }
412
- public function add_textarea($tabid,$name,$description,$id,$class=''){
413
 
414
- $html = '
415
- <div class="controls '.$class.'">
416
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> <textarea class="cwp_textarea " placeholder="'.$name.'" name="'.cwppos_config("menu_slug").'['.$id.']" >'.$this->options[$id].'</textarea></div>';
417
 
418
- $this->tabs[$tabid]["elements"][] = array("type"=>"textarea",
419
- "html"=>$html
420
- );
 
421
 
422
- }
423
- public function add_restriction($tabid,$name){
424
 
425
- $html = '
426
- <div class="controls '.$class.'">
427
- <div class="explain">'.$name.'</div><p class="field_description">You need to have the capability to add HTML in order to use this feature !</p></div>';
428
 
429
- $this->tabs[$tabid]["elements"][] = array("type"=>"textarea_html",
430
- "html"=>$html
431
- );
 
432
 
433
- }
434
- public function add_editor($tabid,$name,$description,$id,$class=''){
435
- ob_start();
436
 
437
- wp_editor($this->options[$id], cwppos_config("menu_slug").'['.$id.']');
438
 
439
- $editor_contents = ob_get_clean();
440
 
441
- $html = '
442
- <div class="controls '.$class.'">
443
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p>'.$editor_contents.'</div>';
444
 
445
- $this->tabs[$tabid]["elements"][] = array("type"=>"editor",
446
- "html"=>$html
447
- );
 
448
 
449
- }
450
- public function add_input_number($tabid,$name, $description, $id, $min = false, $max = false, $step = false, $class = ""){
451
- $html = '
452
- <div class="controls '.$class.'">
453
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> <input placeholder="'.$name.'" type="number" class="cwp_input" value="'.$this->options[$id].'" name="'.cwppos_config("menu_slug").'['.$id.']"
454
- '.($min === false ? '' : ' min = "'.$min.'" ').'
455
- '.($max === false ? '' : ' max = "'.$max.'" ').'
456
- '.($step === false ? '' : ' step = "'.$step.'" ').'
457
  > </div>';
458
 
459
- $this->tabs[$tabid]["elements"][] = array("type"=>"input_number",
460
- "html"=>$html
461
- );
462
-
463
- }
464
-
465
- public function add_select($tabid,$name,$description,$id,$options,$class=""){
466
 
467
- $html = '
468
- <div class="controls '.$class.'">
469
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p>';
470
 
471
- $html .='<select class=" cwp_select" name="'.cwppos_config("menu_slug").'['.$id.']" > ';
472
-
473
- foreach($options as $k=>$v){
474
-
475
- $html.="<option value='".$k."' ".($this->options[$id] == $k ? 'selected' : '').">".$v."</option>";
476
- }
477
 
 
 
 
478
 
 
479
 
480
- $html .='</select></div>';
481
 
482
- $this->tabs[$tabid]["elements"][] = array("type"=>"select",
483
- "html"=>$html
484
- );
485
  }
486
- public function add_multiselect($tabid,$name,$description,$id,$options,$class=""){
487
 
488
- $html = '
489
- <div class="controls '.$class.'">
490
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> <select name="'.cwppos_config("menu_slug").'['.$id.'][]" class="cwp_multiselect" multiple > ';
491
- foreach($options as $k=>$v){
492
 
493
- $html.="<option value='".$k."' ".(in_array($k,$this->options[$id]) ? 'selected' : '').">".$v."</option>";
494
- }
 
 
 
 
 
 
 
 
 
495
 
496
- $html .='</select></div>';
497
- $this->tabs[$tabid]["elements"][] = array("type"=>"multiselect",
498
- "html"=>$html
499
- );
500
  }
501
- public function add_checkbox($tabid,$name,$description,$id,$options,$class=""){
502
 
503
- $html = '
504
- <div class="controls '.$class.'">
505
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> ';
506
- foreach($options as $k=>$v){
 
 
 
507
 
508
- $html.="<label class='cwp_label'><input class='cwp_checkbox' type=\"checkbox\" name='".cwppos_config("menu_slug")."[".$id."][]' value='".$k."' ".(in_array($k,$this->options[$id]) ? 'checked' : '')." >".$v."</label>";
509
- }
 
 
510
 
511
- $html .='</div>';
512
- $this->tabs[$tabid]["elements"][] = array("type"=>"checkbox",
513
- "html"=>$html
514
- );
515
  }
516
 
 
 
 
 
 
 
517
 
518
 
519
- public function add_radio($tabid,$name,$description,$id,$options,$class=""){
520
 
521
- $html = '
522
- <div class="controls '.$class.'">
523
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p> ';
524
- foreach($options as $k=>$v){
525
 
526
- $html.="<label class='cwp_label'><input class='cwp_radio' type=\"radio\" name='".cwppos_config("menu_slug")."[".$id."]' value='".$k."' ".($this->options[$id] == $k ? 'checked' : '').">".$v."</label>";
527
- }
 
 
528
 
529
- $html .='</div>';
530
- $this->tabs[$tabid]["elements"][] = array("type"=>"radio",
531
- "html"=>$html
532
- );
533
  }
534
 
 
 
 
 
 
 
 
535
 
536
 
537
- public function add_image($tabid,$name,$description,$id,$class = ''){
538
  $html = '
539
- <div class="controls '.$class.'">
540
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p>
541
- <input type="hidden" id="'.$id.'" name="'.cwppos_config("menu_slug").'['.$id.']" value="'.$this->options[$id].'"/>
542
- <img src="'.$this->options[$id].'" id="'.$id.'_image" class="image-preview-input"/><br/>
543
- <a id="'.$id.'_button" class="selector-image button" >Select Image</a>
544
- <a id="'.$id.'_buttonclear" class="clear-image button" >Clear image</a>
545
 
546
  </div>';
547
 
 
 
 
 
 
548
 
549
- $this->tabs[$tabid]["elements"][] = array("type"=>"image",
550
- "html"=>$html
551
- );
552
- }
553
-
554
- public function add_button($tabid,$name,$description,$id,$class = ''){
555
  $html = '
556
- <div class="controls '.$class.' ">
557
- <div class="explain">'.$name.'</div>
558
- <a href="https://themeisle.com/plugins/wp-product-review-pro-add-on/" class="button" style="color:red; text-decoration: none; ">'.$name.'</a>
559
  </div></div>';
560
- $this->tabs[$tabid]["elements"][] = array(
561
- "type"=>"button",
562
- "html"=>$html
563
- );
564
- }
565
-
566
- public function add_color($tabid,$name,$description,$id,$class = ''){
567
 
 
568
 
569
  $html = '
570
- <div class="controls '.$class.' ">
571
- <div class="explain">'.$name.'</div><p class="field_description">'.$description.'</p>
572
- <input type="hidden" id="'.$id.'_color" name="'.cwppos_config("menu_slug").'['.$id.']" value="'.$this->options[$id].'"/> </br>
573
- <input type="text" name="" class="subo-color-picker" id="'.$id.'_color_selector" value="'.$this->options[$id].'" /> <br/>
574
  </div>';
575
 
 
 
 
 
 
 
 
 
 
 
 
576
 
577
- $this->tabs[$tabid]["elements"][] = array( "type"=>"color",
578
- "html"=>$html
579
- );
580
- }
581
- public function add_title($tabid,$name){
582
- $html = '<h1 class="tab-title-area">'.$name.'</h1>';
583
- $this->tabs[$tabid]["elements"][] = array(
584
- "type"=>"title",
585
- "html"=>$html
586
- );
587
-
588
- }
589
 
590
- public function start_group($tabid, $name){
591
- $html = '<div class="group-in-tab">
592
- <p class="group-name">'.$name.'</p>
593
  <div class="group-content">
594
  ';
595
- $this->tabs[$tabid]["elements"][] = array(
596
- "type"=>"group_start",
597
- "html"=>$html
598
- );
599
- }
600
- public function end_group($tabid){
601
- $html = '</div></div>
602
  ';
603
- $this->tabs[$tabid]["elements"][] = array(
604
- "type"=>"end",
605
- "html"=>$html
606
- );
607
- }
608
- }
1
  <?php
2
 
3
+ class cwpposRenderView {
4
+ public $data = array();
5
+ private $css = array();
6
+ private $js = array();
7
+ public $tabs = array();
8
+ public $options = array();
9
+ public function __construct() {
10
 
11
+ $css_path = cwppos_config( 'admin_template_directory_uri' ) . '/css/';
12
+ $js_path = cwppos_config( 'admin_template_directory_uri' ) . '/js/';
13
+ $this->add_css( 'main_page_css',$css_path . 'main_page.css' );
14
+ $this->add_js( 'wp_product_review_main_page_js',$js_path . 'admin.js' );
15
+ $this->add_js( 'typsy',$js_path . 'tipsy.js' );
16
+ $this->add_js( 'jquery' );
17
+ // $this->add_js("media" );
18
+ $this->options = get_option( cwppos_config( 'menu_slug' ) );
19
 
20
+ $this->add_js( 'wp-color-picker' );
21
+ $this->add_css( 'wp-color-picker' );
22
 
23
+ }
 
24
 
25
+ public function add_element( $tabid, $field ) {
26
 
27
+ switch ( $field['type'] ) {
28
+ case 'input_text':
 
 
 
 
 
29
 
30
+ $this->add_input_text( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
31
 
32
+ break;
33
+ case 'input_number':
34
 
35
+ $this->add_input_number( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
36
 
37
+ break;
38
+ case 'textarea':
39
 
40
+ $this->add_textarea( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
41
 
42
+ break;
43
+ case 'textarea_html':
44
+ if ( current_user_can( 'unfiltered_html' ) ) {
45
+ $this->add_textarea( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) ); } else { $this->add_restriction( $tabid,esc_html( $field['name'] ) ); }
 
 
46
 
47
+ break;
48
+ case 'editor':
49
 
50
+ $this->add_editor( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
51
 
52
+ break;
53
+ case 'color':
54
 
55
+ $this->add_color( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
56
 
57
+ break;
58
+ case 'image':
59
 
60
+ $this->add_image( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
61
 
62
+ break;
63
+ case 'button':
64
 
65
+ $this->add_button( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
66
 
67
+ break;
68
+ case 'typography':
69
 
70
+ $this->add_typography( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
71
+ break;
72
+ case 'background':
73
 
74
+ $this->add_background( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
75
+ break;
76
+ case 'select':
77
 
78
+ $no = array();
79
+ foreach ( $field['options'] as $ov => $op ) {
80
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
81
+ }
82
+ $this->add_select( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ),$no );
83
+ break;
84
+ case 'radio':
85
 
86
+ $no = array();
87
+ foreach ( $field['options'] as $ov => $op ) {
88
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
89
+ }
90
+ $this->add_radio( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ),$no );
91
+ break;
92
+ case 'multiselect':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ $no = array();
95
+ foreach ( $field['options'] as $ov => $op ) {
96
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
97
+ }
98
 
99
+ $this->add_multiselect( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ),$no );
100
+ break;
101
+ case 'checkbox':
 
102
 
103
+ $no = array();
104
+ foreach ( $field['options'] as $ov => $op ) {
105
+ $no[ esc_attr( $ov ) ] = esc_html( $op );
106
+ }
 
107
 
108
+ $this->add_checkbox( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ),$no );
109
+ break;
110
+ case 'title':
111
+ $this->add_title( $tabid,esc_html( $field['name'] ) );
112
+ break;
113
 
114
+ case 'change_icon':
115
+ $this->change_review_icon( $tabid,esc_html( $field['name'] ),esc_html( $field['description'] ),esc_attr( $field['id'] ) );
116
+ break;
117
 
 
 
118
  }
119
+ if ( isset( $errors ) ) { return $errors; }
120
+ }
121
+ public function show() {
122
+ $structure = cwpposConfig::$structure;
123
+ $errors = cwppos_check_config();
124
+ if ( ! empty( $errors ) ) { return false; }
125
+ foreach ( $structure as $k => $fields ) {
 
 
 
 
 
 
 
126
 
127
+ if ( $fields['type'] == 'tab' ) {
128
+ $tname = esc_html( $fields['name'] );
129
+ $tabid = $this->add_tab( $tname );
130
 
131
+ foreach ( $fields['options'] as $r => $field ) {
 
132
 
133
+ if ( $field['type'] == 'group' ) {
 
 
 
134
 
135
+ $this->start_group( $tabid,esc_html( $field['name'] ) );
136
+ foreach ( $field['options'] as $m => $gfield ) {
137
 
138
+ $this->add_element( $tabid,$gfield );
139
  }
140
 
141
+ $this->end_group( $tabid );
142
+ } else {
143
+ $this->add_element( $tabid,$field );
144
+ }
145
+ }
146
  }
 
 
147
  }
148
+ $this->render_view( 'main_page' );
149
+
150
+ }
151
+ public function pro() {
152
+ $this->render_view( 'pro' );
153
+
154
+ }
155
+ public function add_css( $name, $location = '' ) {
156
+ if ( $location != '' ) {
157
+ wp_register_style( $name, $location, array(), '201306' ); }
158
+ $this->css[] = $name;
159
+ }
160
+ public function add_js( $name, $location = '', $deps = array() ) {
161
+
162
+ if ( $location != '' ) {
163
+ wp_register_script( $name, $location, $deps, '201306', true ); }
164
+ $this->js[] = $name;
165
+
166
+ }
167
+
168
+ public function render_view( $name ) {
169
+ $this->data['tabs'] = $this->tabs;
170
+ foreach ( $this->data as $k => $v ) {
171
+ $$k = $v;
172
  }
173
+ foreach ( $this->css as $file ) {
174
+ wp_enqueue_style( $file );
 
 
 
 
175
  }
176
+ foreach ( $this->js as $file ) {
177
+ if ( $file == 'media' ) {
178
 
179
+ wp_enqueue_media();
 
 
 
 
 
 
180
  }
181
+ wp_enqueue_script( $file );
 
 
 
 
 
 
 
182
  }
183
+ include( plugin_dir_path( dirname( __FILE__ ) ) . 'layout/' . $name . '.php' );
184
+ }
185
+ public function add_tab( $name ) {
186
+ $id = strtolower( preg_replace( '/[^a-zA-Z0-9]|\s/', '_',$name ) );
187
+ $this->tabs[] =
188
+ array(
189
+ 'name' => $name,
190
+ 'id' => $id,
191
+ 'elements' => array(),
192
+ );
193
 
194
+ return count( $this->tabs ) - 1;
195
+ }
196
+ public function add_input_text( $tabid, $name, $description, $id, $class = '' ) {
197
+ $html = '
198
+ <div class="controls ' . $class . '">
199
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> <input class="cwp_input " placeholder="' . $name . '" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . ']" type="text" value="' . $this->options[ $id ] . '"></div>';
200
 
201
+ $this->tabs[ $tabid ]['elements'][] = array(
202
+ 'type' => 'input_text',
203
+ 'html' => $html,
204
+ );
205
 
206
+ }
207
 
208
 
209
+ public function change_review_icon( $tabid, $name, $description, $id, $class = '' ) {
210
 
211
+ $html = "<div class='controls'>
212
  <div class='explain'>$name</div>
213
  <p class='field_description'>$description</p>";
214
 
215
+ $html .= '<li>';
216
 
217
+ if ( cwppos( 'cwppos_show_poweredby' ) == 'yes' || function_exists( 'wppr_ci_custom_bar_icon' ) ) {
218
 
219
+ wp_enqueue_script( 'cwp-custom-bar-icon', WPPR_URL . '/admin/layout/js/custom-bar-icon.js', false, WPPR_LITE_VERSION, 'all' );
220
+ if ( cwppos( 'cwppos_fontawesome' ) === 'no' ) {
221
+ wp_enqueue_style( 'font-awesome-cdn', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' );
222
+ }
 
223
 
224
+ $html .= "<button id='cwp_select_bar_icon'>Select Bar Icon</button>";
225
+ $html .= "<input type='hidden' id='cwp_bar_icon_field' name='" . cwppos_config( 'menu_slug' ) . '[' . $id . "][]' value='";
226
+ if ( isset( $this->options[ $id ] ) ) {
227
+ $html .= (isset( $this->options[ $id ][0] )) ? $this->options[ $id ][0] : $this->options[ $id ];
228
+ }
229
 
230
+ $html .= "'/> <span class='current_bar_icon'>";
231
+ if ( ! empty( $this->options[ $id ][0] ) ) {
232
+ // var_dump($this->options[$id][0]);
233
+ if ( $this->options[ $id ][0] === '#' ) {
234
 
235
+ $code = $this->options[ $id ];
236
+ } else { $code = $this->options[ $id ][0]; }
 
 
237
 
238
+ $html .= "<i class='fa fa-fw'>&" . $code . "</i> <a href='#' class='useDefault'>Use Default Styling</a>";
239
+ } else {
240
+ $html .= '* Currently set to the default styling</span>';
241
+ }
242
+ } else {
243
+ $html .= '<span style="color:red;">' . __( 'You need the PRO <a style="color:red;" href="http://bit.ly/2bhylar" target="_blank" >add-on</a> in order to change the review icons.','cwppos' ) . '</span>';
244
+ }
245
+ $html .= '</li>';
246
 
247
+ $html .= '</div>';
248
 
249
+ $this->tabs[ $tabid ]['elements'][] = array( 'type' => 'change_icon', 'html' => $html );
250
+ }
251
 
252
 
253
 
254
 
255
+ public function get_fonts() {
256
+ return array(
257
+ 'arial' => 'Arial',
258
+ 'verdana' => 'Verdana, Geneva',
259
+ 'trebuchet' => 'Trebuchet',
260
+ 'georgia' => 'Georgia',
261
+ 'times' => 'Times New Roman',
262
+ 'tahoma' => 'Tahoma, Geneva',
263
+ 'palatino' => 'Palatino',
264
+ 'helvetica' => 'Helvetica*',
265
+ );
266
+ }
267
+ public function get_font_styles() {
268
  return array(
269
+ 'normal' => __( 'Normal', 'cwppos' ),
270
+ 'italic' => __( 'Italic', 'cwppos' ),
271
+ 'bold' => __( 'Bold', 'cwppos' ),
272
+ 'bold italic' => __( 'Bold Italic', 'cwppos' ),
273
+ );
274
+ }
275
+ public function get_font_sizes() {
276
+ $sizes = range( 9, 71 );
277
+ $sizes = array_map( 'absint', $sizes );
278
+ return $sizes;
279
+ }
280
+ public function add_typography( $tabid, $name, $description, $id, $class = '' ) {
281
+ $fonts = $this->get_fonts();
282
+ $style = $this->get_font_styles();
283
+ $sizes = $this->get_font_sizes();
284
+ $html = '
285
+ <div class="controls ' . $class . '">
286
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> <div class="cwp_typo">
 
 
 
 
 
 
 
 
 
 
 
 
287
 
288
+ <input type="hidden" id="' . $id . '_color" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][color]" value="' . $this->options[ $id ]['color'] . '"/>
289
+ <input type="text" name="" class="subo-color-picker" id="' . $id . '_color_selector" value="' . $this->options[ $id ]['color'] . '" />
290
 
291
+ <select class="cwp_select cwp_tipsy" original-title="Font family" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][font]" > ';
292
+ foreach ( $fonts as $k => $v ) {
293
 
294
+ $html .= "<option value='" . $k . "' " . ($this->options[ $id ]['font'] == $k ? 'selected' : '') . '>' . $v . '</option>';
295
+ }
296
 
297
+ $html .= '</select>
298
+ <select class="cwp_select cwp_tipsy" original-title="Font style" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][style]" > ';
299
+ foreach ( $style as $k => $v ) {
300
 
301
+ $html .= "<option value='" . $k . "' " . ($this->options[ $id ]['style'] == $k ? 'selected' : '') . '>' . $v . '</option>';
302
+ }
303
 
304
+ $html .= '</select>
305
+ <select class="cwp_select cwp_tipsy" original-title="Font size" " name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][size]" > ';
306
+ foreach ( $sizes as $v ) {
307
 
308
+ $html .= "<option value='" . $v . "' " . ($this->options[ $id ]['size'] == $v ? 'selected' : '') . '>' . $v . 'px</option>';
309
+ }
310
 
311
+ $html .= '</select>
312
 
313
  </div></div>';
314
 
315
+ $this->tabs[ $tabid ]['elements'][] = array(
316
+ 'type' => 'typography',
317
+ 'html' => $html,
318
+ );
319
 
320
+ }
321
 
322
+ public function get_bg_repeat() {
323
 
324
+ return array(
325
+ 'no-repeat' => __( 'No Repeat', 'cwppos' ),
326
+ 'repeat-x' => __( 'Repeat Horizontally', 'cwppos' ),
327
+ 'repeat-y' => __( 'Repeat Vertically', 'cwppos' ),
328
+ 'repeat' => __( 'Repeat All', 'cwppos' ),
329
+ );
330
+ }
331
+ public function get_bg_position() {
332
+ return array(
333
+ 'top left' => __( 'Top Left', 'cwppos' ),
334
+ 'top center' => __( 'Top Center', 'cwppos' ),
335
+ 'top right' => __( 'Top Right', 'cwppos' ),
336
+ 'center left' => __( 'Middle Left', 'cwppos' ),
337
+ 'center center' => __( 'Middle Center', 'cwppos' ),
338
+ 'center right' => __( 'Middle Right', 'cwppos' ),
339
+ 'bottom left' => __( 'Bottom Left', 'cwppos' ),
340
+ 'bottom center' => __( 'Bottom Center', 'cwppos' ),
341
+ 'bottom right' => __( 'Bottom Right', 'cwppos' ),
 
 
 
 
 
 
342
  );
343
+ }
344
+ public function get_bg_attachment() {
345
+ return array(
346
+ 'scroll' => __( 'Scroll Normally', 'cwppos' ),
347
+ 'fixed' => __( 'Fixed in Place', 'cwppos' ),
348
+ );
349
 
350
+ }
351
+ public function add_background( $tabid, $name, $description, $id, $class = '' ) {
352
+ $repeats = $this->get_bg_repeat();
353
+ $positions = $this->get_bg_position();
354
+ $attachments = $this->get_bg_attachment();
355
+ $html = '
356
+ <div class="controls ' . $class . '">
357
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p><div class="cwp_background">
358
  <div class="cwp_bgstyle">
359
  <div class="cwp_bgimage">
360
+ <input type="hidden" id="' . $id . '" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][bgimage]" value="' . $this->options[ $id ]['bgimage'] . '"/>
361
+ <img src="' . $this->options[ $id ]['bgimage'] . '" id="' . $id . '_image" class="image-preview-input"/><br/>
362
+ <a id="' . $id . '_button" class="selector-image button" >Select Image</a>
363
 
364
+ <a id="' . $id . '_buttonclear" class="clear-image button" >Clear image</a>
365
  </div>
366
  <div class="cwp_bgcolor">
367
+ <input type="hidden" id="' . $id . '_color" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][bgcolor]" value="' . $this->options[ $id ]['bgcolor'] . '"/> <br/>
368
+ <input type="text" name="" class="subo-color-picker" id="' . $id . '_color_selector" value="' . $this->options[ $id ]['bgcolor'] . '" />
369
  </div><div class="clear"></div>
370
  </div>
371
  <div class="cwp_bgformat">
372
 
373
+ <select class="cwp_select cwp_tipsy" original-title="Background repeat" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][bgrepeat]" > ';
374
+ foreach ( $repeats as $k => $v ) {
375
 
376
+ $html .= "<option value='" . $k . "' " . ($this->options[ $id ]['bgrepeat'] == $k ? 'selected' : '') . '>' . $v . '</option>';
377
+ }
378
 
379
+ $html .= '</select>
380
+ <select class="cwp_select cwp_tipsy" original-title="Background position" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][bgposition]" > ';
381
+ foreach ( $positions as $k => $v ) {
382
 
383
+ $html .= "<option value='" . $k . "' " . ($this->options[ $id ]['bgposition'] == $k ? 'selected' : '') . '>' . $v . '</option>';
384
+ }
385
 
386
+ $html .= '</select>
387
+ <select class="cwp_select cwp_tipsy" original-title="Background attachament" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][bgattachment]" > ';
388
+ foreach ( $attachments as $k => $v ) {
389
 
390
+ $html .= "<option value='" . $k . "' " . ($this->options[ $id ]['bgattachment'] == $k ? 'selected' : '') . '>' . $v . '</option>';
391
+ }
392
 
393
+ $html .= '</select>
394
  </div>
395
 
396
  </div>
398
 
399
  </div>';
400
 
401
+ $this->tabs[ $tabid ]['elements'][] = array(
402
+ 'type' => 'textarea',
403
+ 'html' => $html,
404
+ );
405
 
406
+ }
407
+ public function add_textarea( $tabid, $name, $description, $id, $class = '' ) {
408
 
409
+ $html = '
410
+ <div class="controls ' . $class . '">
411
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> <textarea class="cwp_textarea " placeholder="' . $name . '" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . ']" >' . $this->options[ $id ] . '</textarea></div>';
412
 
413
+ $this->tabs[ $tabid ]['elements'][] = array(
414
+ 'type' => 'textarea',
415
+ 'html' => $html,
416
+ );
417
 
418
+ }
419
+ public function add_restriction( $tabid, $name ) {
420
 
421
+ $html = '
422
+ <div class="controls ' . $class . '">
423
+ <div class="explain">' . $name . '</div><p class="field_description">You need to have the capability to add HTML in order to use this feature !</p></div>';
424
 
425
+ $this->tabs[ $tabid ]['elements'][] = array(
426
+ 'type' => 'textarea_html',
427
+ 'html' => $html,
428
+ );
429
 
430
+ }
431
+ public function add_editor( $tabid, $name, $description, $id, $class = '' ) {
432
+ ob_start();
433
 
434
+ wp_editor( $this->options[ $id ], cwppos_config( 'menu_slug' ) . '[' . $id . ']' );
435
 
436
+ $editor_contents = ob_get_clean();
437
 
438
+ $html = '
439
+ <div class="controls ' . $class . '">
440
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p>' . $editor_contents . '</div>';
441
 
442
+ $this->tabs[ $tabid ]['elements'][] = array(
443
+ 'type' => 'editor',
444
+ 'html' => $html,
445
+ );
446
 
447
+ }
448
+ public function add_input_number( $tabid, $name, $description, $id, $min = false, $max = false, $step = false, $class = '' ) {
449
+ $html = '
450
+ <div class="controls ' . $class . '">
451
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> <input placeholder="' . $name . '" type="number" class="cwp_input" value="' . $this->options[ $id ] . '" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . ']"
452
+ ' . ($min === false ? '' : ' min = "' . $min . '" ') . '
453
+ ' . ($max === false ? '' : ' max = "' . $max . '" ') . '
454
+ ' . ($step === false ? '' : ' step = "' . $step . '" ') . '
455
  > </div>';
456
 
457
+ $this->tabs[ $tabid ]['elements'][] = array(
458
+ 'type' => 'input_number',
459
+ 'html' => $html,
460
+ );
 
 
 
461
 
462
+ }
 
 
463
 
464
+ public function add_select( $tabid, $name, $description, $id, $options, $class = '' ) {
 
 
 
 
 
465
 
466
+ $html = '
467
+ <div class="controls ' . $class . '">
468
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p>';
469
 
470
+ $html .= '<select class=" cwp_select" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . ']" > ';
471
 
472
+ foreach ( $options as $k => $v ) {
473
 
474
+ $html .= "<option value='" . $k . "' " . ($this->options[ $id ] == $k ? 'selected' : '') . '>' . $v . '</option>';
 
 
475
  }
 
476
 
477
+ $html .= '</select></div>';
 
 
 
478
 
479
+ $this->tabs[ $tabid ]['elements'][] = array(
480
+ 'type' => 'select',
481
+ 'html' => $html,
482
+ );
483
+ }
484
+ public function add_multiselect( $tabid, $name, $description, $id, $options, $class = '' ) {
485
+
486
+ $html = '
487
+ <div class="controls ' . $class . '">
488
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> <select name="' . cwppos_config( 'menu_slug' ) . '[' . $id . '][]" class="cwp_multiselect" multiple > ';
489
+ foreach ( $options as $k => $v ) {
490
 
491
+ $html .= "<option value='" . $k . "' " . (in_array( $k,$this->options[ $id ] ) ? 'selected' : '') . '>' . $v . '</option>';
 
 
 
492
  }
 
493
 
494
+ $html .= '</select></div>';
495
+ $this->tabs[ $tabid ]['elements'][] = array(
496
+ 'type' => 'multiselect',
497
+ 'html' => $html,
498
+ );
499
+ }
500
+ public function add_checkbox( $tabid, $name, $description, $id, $options, $class = '' ) {
501
 
502
+ $html = '
503
+ <div class="controls ' . $class . '">
504
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> ';
505
+ foreach ( $options as $k => $v ) {
506
 
507
+ $html .= "<label class='cwp_label'><input class='cwp_checkbox' type=\"checkbox\" name='" . cwppos_config( 'menu_slug' ) . '[' . $id . "][]' value='" . $k . "' " . (in_array( $k,$this->options[ $id ] ) ? 'checked' : '') . ' >' . $v . '</label>';
 
 
 
508
  }
509
 
510
+ $html .= '</div>';
511
+ $this->tabs[ $tabid ]['elements'][] = array(
512
+ 'type' => 'checkbox',
513
+ 'html' => $html,
514
+ );
515
+ }
516
 
517
 
 
518
 
519
+ public function add_radio( $tabid, $name, $description, $id, $options, $class = '' ) {
 
 
 
520
 
521
+ $html = '
522
+ <div class="controls ' . $class . '">
523
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p> ';
524
+ foreach ( $options as $k => $v ) {
525
 
526
+ $html .= "<label class='cwp_label'><input class='cwp_radio' type=\"radio\" name='" . cwppos_config( 'menu_slug' ) . '[' . $id . "]' value='" . $k . "' " . ($this->options[ $id ] == $k ? 'checked' : '') . '>' . $v . '</label>';
 
 
 
527
  }
528
 
529
+ $html .= '</div>';
530
+ $this->tabs[ $tabid ]['elements'][] = array(
531
+ 'type' => 'radio',
532
+ 'html' => $html,
533
+ );
534
+ }
535
+
536
 
537
 
538
+ public function add_image( $tabid, $name, $description, $id, $class = '' ) {
539
  $html = '
540
+ <div class="controls ' . $class . '">
541
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p>
542
+ <input type="hidden" id="' . $id . '" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . ']" value="' . $this->options[ $id ] . '"/>
543
+ <img src="' . $this->options[ $id ] . '" id="' . $id . '_image" class="image-preview-input"/><br/>
544
+ <a id="' . $id . '_button" class="selector-image button" >Select Image</a>
545
+ <a id="' . $id . '_buttonclear" class="clear-image button" >Clear image</a>
546
 
547
  </div>';
548
 
549
+ $this->tabs[ $tabid ]['elements'][] = array(
550
+ 'type' => 'image',
551
+ 'html' => $html,
552
+ );
553
+ }
554
 
555
+ public function add_button( $tabid, $name, $description, $id, $class = '' ) {
 
 
 
 
 
556
  $html = '
557
+ <div class="controls ' . $class . ' ">
558
+ <div class="explain">' . $name . '</div>
559
+ <a href="https://themeisle.com/plugins/wp-product-review-pro-add-on/" class="button" style="color:red; text-decoration: none; ">' . $name . '</a>
560
  </div></div>';
561
+ $this->tabs[ $tabid ]['elements'][] = array(
562
+ 'type' => 'button',
563
+ 'html' => $html,
564
+ );
565
+ }
 
 
566
 
567
+ public function add_color( $tabid, $name, $description, $id, $class = '' ) {
568
 
569
  $html = '
570
+ <div class="controls ' . $class . ' ">
571
+ <div class="explain">' . $name . '</div><p class="field_description">' . $description . '</p>
572
+ <input type="hidden" id="' . $id . '_color" name="' . cwppos_config( 'menu_slug' ) . '[' . $id . ']" value="' . $this->options[ $id ] . '"/> </br>
573
+ <input type="text" name="" class="subo-color-picker" id="' . $id . '_color_selector" value="' . $this->options[ $id ] . '" /> <br/>
574
  </div>';
575
 
576
+ $this->tabs[ $tabid ]['elements'][] = array(
577
+ 'type' => 'color',
578
+ 'html' => $html,
579
+ );
580
+ }
581
+ public function add_title( $tabid, $name ) {
582
+ $html = '<h1 class="tab-title-area">' . $name . '</h1>';
583
+ $this->tabs[ $tabid ]['elements'][] = array(
584
+ 'type' => 'title',
585
+ 'html' => $html,
586
+ );
587
 
588
+ }
 
 
 
 
 
 
 
 
 
 
 
589
 
590
+ public function start_group( $tabid, $name ) {
591
+ $html = '<div class="group-in-tab">
592
+ <p class="group-name">' . $name . '</p>
593
  <div class="group-content">
594
  ';
595
+ $this->tabs[ $tabid ]['elements'][] = array(
596
+ 'type' => 'group_start',
597
+ 'html' => $html,
598
+ );
599
+ }
600
+ public function end_group( $tabid ) {
601
+ $html = '</div></div>
602
  ';
603
+ $this->tabs[ $tabid ]['elements'][] = array(
604
+ 'type' => 'end',
605
+ 'html' => $html,
606
+ );
607
+ }
608
+ }
admin/layout/js/admin.js CHANGED
@@ -1,4 +1,4 @@
1
-
2
  jQuery("document").ready(function() {
3
 
4
 
1
+ /* jshint ignore:start */
2
  jQuery("document").ready(function() {
3
 
4
 
admin/layout/js/custom-bar-icon.js CHANGED
@@ -1,3 +1,4 @@
 
1
  jQuery("#cwp_select_bar_icon").click(function(a) {
2
  a.preventDefault();
3
  a.stopPropagation();
1
+ /* jshint ignore:start */
2
  jQuery("#cwp_select_bar_icon").click(function(a) {
3
  a.preventDefault();
4
  a.stopPropagation();
admin/layout/js/tipsy.js CHANGED
@@ -1,3 +1,4 @@
 
1
  // tipsy, facebook style tooltips for jquery
2
  // version 1.0.0a
3
  // (c) 2008-2010 jason frame [jason@onehackoranother.com]
1
+ /* jshint ignore:start */
2
  // tipsy, facebook style tooltips for jquery
3
  // version 1.0.0a
4
  // (c) 2008-2010 jason frame [jason@onehackoranother.com]
admin/layout/main_page.php CHANGED
@@ -1,57 +1,57 @@
1
  <div id="cwp_container" style="display:none">
2
- <form id="cwp_form" method="post" action="#" enctype="multipart/form-data">
3
- <?php settings_fields( cwppos_config("menu_slug")); ?>
4
-
5
  <div id="header">
6
 
7
  <div class="logo ">
8
  <h2>
9
 
10
- <img class="theme_options_logo" src="<?php echo plugins_url( 'img/logo.png' , __FILE__ ) . ''; ?>" alt="<?php echo cwppos_config('admin_page_header'); ?>">
11
 
12
- <?php if (!class_exists('CWP_PR_PRO_Core')) { ?><a href="http://themeisle.com/plugins/wp-product-review/" class="read_docs button" target="_blank" style="color:red;text-decoration: none;"><?php _e("Buy the PRO Add-on", "cwppos"); ?></a><?php } ?>
13
 
14
- <a href="https://themeisle.com/allthemes" class="read_docs button" target="_blank" style=" text-decoration: none; "><?php _e("Recommended Review Themes", "cwppos"); ?></a>
15
 
16
- <a href="http://themeisle.com/contact/" target="_blank" class="read_docs button" style="text-decoration: none;"><?php _e("Contact us", "cwppos"); ?></a>
17
 
18
  </h2>
19
  </div>
20
 
21
  <div class="clear"></div>
22
 
23
- </div>
24
 
25
  <div id="info_bar">
26
 
27
  <span class="spinner" ></span>
28
 
29
  <button type="button" class="button-primary cwp_save">
30
- <?php _e('Save All Changes','cwppos'); ?> </button>
31
 
32
  <span class="spinner spinner-reset" ></span>
33
- <button type="button" class="button submit-button reset-button cwp_reset"><?php _e('Options Reset','cwppos'); ?></button>
34
- </div><!--.info_bar-->
35
 
36
  <div id="main">
37
 
38
  <div id="cwp_nav">
39
  <ul>
40
- <?php foreach ($tabs as $tab) { ?>
41
 
42
 
43
- <li ><a href="#tab-<?php echo $tab['id']; ?>"><?php echo $tab['name']; ?></a></li>
44
 
45
  <?php } ?></ul>
46
  </div>
47
 
48
- <div id="content">
49
 
50
- <?php foreach ($tabs as $tab) { ?>
51
  <div id="tab-<?php echo $tab['id']; ?>" class="tab-section">
52
  <h2><?php echo $tab['name']; ?></h2>
53
 
54
- <?php foreach($tab['elements'] as $element){ ?>
55
  <?php echo $element['html']; ?>
56
  <?php } ?>
57
 
@@ -70,10 +70,10 @@
70
  <div class="save_bar">
71
  <span class="spinner " ></span>
72
  <button type="button" class="button-primary cwp_save">
73
- <?php _e('Save All Changes','cwppos'); ?> </button>
74
 
75
  <span class="spinner spinner-reset" ></span>
76
- <button type="button" class="button submit-button reset-button cwp_reset"><?php _e('Options Reset','cwppos'); ?></button>
77
 
78
 
79
  </div>
1
  <div id="cwp_container" style="display:none">
2
+ <form id="cwp_form" method="post" action="#" enctype="multipart/form-data">
3
+ <?php settings_fields( cwppos_config( 'menu_slug' ) ); ?>
4
+
5
  <div id="header">
6
 
7
  <div class="logo ">
8
  <h2>
9
 
10
+ <img class="theme_options_logo" src="<?php echo plugins_url( 'img/logo.png' , __FILE__ ) . ''; ?>" alt="<?php echo cwppos_config( 'admin_page_header' ); ?>">
11
 
12
+ <?php if ( ! class_exists( 'CWP_PR_PRO_Core' ) ) { ?><a href="http://themeisle.com/plugins/wp-product-review/" class="read_docs button" target="_blank" style="color:red;text-decoration: none;"><?php _e( 'Buy the PRO Add-on', 'cwppos' ); ?></a><?php } ?>
13
 
14
+ <a href="https://themeisle.com/allthemes" class="read_docs button" target="_blank" style=" text-decoration: none; "><?php _e( 'Recommended Review Themes', 'cwppos' ); ?></a>
15
 
16
+ <a href="http://themeisle.com/contact/" target="_blank" class="read_docs button" style="text-decoration: none;"><?php _e( 'Contact us', 'cwppos' ); ?></a>
17
 
18
  </h2>
19
  </div>
20
 
21
  <div class="clear"></div>
22
 
23
+ </div>
24
 
25
  <div id="info_bar">
26
 
27
  <span class="spinner" ></span>
28
 
29
  <button type="button" class="button-primary cwp_save">
30
+ <?php _e( 'Save All Changes','cwppos' ); ?> </button>
31
 
32
  <span class="spinner spinner-reset" ></span>
33
+ <button type="button" class="button submit-button reset-button cwp_reset"><?php _e( 'Options Reset','cwppos' ); ?></button>
34
+ </div><!--.info_bar-->
35
 
36
  <div id="main">
37
 
38
  <div id="cwp_nav">
39
  <ul>
40
+ <?php foreach ( $tabs as $tab ) { ?>
41
 
42
 
43
+ <li ><a href="#tab-<?php echo $tab['id']; ?>"><?php echo $tab['name']; ?></a></li>
44
 
45
  <?php } ?></ul>
46
  </div>
47
 
48
+ <div id="content">
49
 
50
+ <?php foreach ( $tabs as $tab ) { ?>
51
  <div id="tab-<?php echo $tab['id']; ?>" class="tab-section">
52
  <h2><?php echo $tab['name']; ?></h2>
53
 
54
+ <?php foreach ( $tab['elements'] as $element ) { ?>
55
  <?php echo $element['html']; ?>
56
  <?php } ?>
57
 
70
  <div class="save_bar">
71
  <span class="spinner " ></span>
72
  <button type="button" class="button-primary cwp_save">
73
+ <?php _e( 'Save All Changes','cwppos' ); ?> </button>
74
 
75
  <span class="spinner spinner-reset" ></span>
76
+ <button type="button" class="button submit-button reset-button cwp_reset"><?php _e( 'Options Reset','cwppos' ); ?></button>
77
 
78
 
79
  </div>
admin/layout/pro.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1>Features</h1>
2
+ <div id="pro-features">
3
+ <div class="pro-feature">
4
+ <div class="pro-feature-image"><img src="<?php echo WPPR_URL; ?>/images/amazon-cart.png"></div>
5
+ <div class="pro-feature-features"><div>
6
+ <h2>Amazon Integration</h2>
7
+ <h4>Connects your site with Amazon in just a click</h4>
8
+ <p>If you want the Amazon data to be imported to your site, you don't have to do it manually. Add the product ID and, by just clicking a button, the name, image, affiliate link, and price will be transferred. Saves a lot of time.</p>
9
+ <h4>Synchronizes the prices with Amazon</h4>
10
+ <p>The add-on automatically synchronizes the prices with the ones from Amazon, so you won't have to do it manually everytime they change. Because prices vary all the time and you probably have better stuff to do instead of tracking them.</p>
11
+ </div>
12
+ </div>
13
+ <div class="clear"></div>
14
+ </div>
15
+ <div class="clear"></div>
16
+ <div class="pro-feature">
17
+ <div class="pro-feature-image"><img src="<?php echo WPPR_URL; ?>/images/customize-icons.gif"></div>
18
+ <div class="pro-feature-features"><div>
19
+ <h2>Customize your icons</h2>
20
+
21
+ <p>WP Product Review PRO is a plugin designed to enhance your existing website with awesome review functions, please note that the PRO version is just an add-on, which means that the free version is also required.</p>
22
+ <p>With WP Product Review PRO you can easily choose the default icons to something that suit your audience.</p>
23
+ </div>
24
+ </div>
25
+ <div class="clear"></div>
26
+ </div>
27
+ <div class="clear"></div>
28
+ <div class="pro-feature">
29
+ <div class="pro-feature-image"><img src="<?php echo WPPR_URL; ?>/images/preload.png"></div>
30
+ <div class="pro-feature-features"><div>
31
+ <h2>Easy Preloader</h2>
32
+ <p>With the pro version bundle you don't manually enter the pros/cons or features that need to be rated for each post, we have build a simple and efficient tool that let you easily import the settings from other posts, in the same page using AJAX.</p>
33
+ </div>
34
+ </div>
35
+ <div class="clear"></div>
36
+ </div>
37
+ <div class="clear"></div>
38
+ <div class="pro-feature">
39
+ <div class="pro-feature-image"><img src="<?php echo WPPR_URL; ?>/images/comparison-table.gif"></div>
40
+ <div class="pro-feature-features"><div>
41
+ <h2>Comparison Table</h2>
42
+
43
+ <p>Our powerful ranking table add-on is also included in the bundle and by using it you can automatically generate comparison landing pages or enhance your review articles even more</p>
44
+ </div>
45
+ </div>
46
+ <div class="clear"></div>
47
+ </div>
48
+ <div class="clear"></div>
49
+ <div class="pro-feature">
50
+ <div class="pro-feature-image"><img src="<?php echo WPPR_URL; ?>/images/single.png"></div>
51
+ <div class="pro-feature-features"><div>
52
+ <h2>Single Review Shortcode</h2>
53
+
54
+ <p>WP Product Review Custom Icons is a plugin designed to enhance your existing website with awesome review functions, please note that the PRO version is just an add-on, which means that the free version is also required.</p>
55
+
56
+ <p>Use shortcodes to insert reviews anywhere into your article.</p>
57
+ </div>
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+ </div>
css/frontpage.css CHANGED
@@ -1,418 +1,690 @@
1
  /*
2
- Version: 2.9.5
3
  */
4
- #review-statistics{
5
 
6
- font-family:FontAwesome;
7
 
8
- width:100%;
9
 
10
- margin:auto;
11
 
12
  }
 
13
  .cwp-item-price {
14
- float: right;
15
- font-size: 1.75em;
16
- font-family: "Lato", Helvetica, sans-serif;
17
  }
18
 
19
  #review-statistics h1,
20
-
21
  #review-statistics h2,
22
-
23
  #review-statistics h3,
24
-
25
  #review-statistics h4,
26
-
27
  #review-statistics h5,
28
-
29
  #review-statistics h6 {
30
 
31
- font-family: "Lato", Helvetica, sans-serif;
32
 
33
- font-weight: normal;
34
- border:none;
35
- padding:0;
36
- margin:0;
37
 
38
  }
39
 
40
- .rev-option h3{
41
- width:auto!important;
42
  }
43
 
44
- #review-statistics .photo-wrapup{
45
 
46
-
47
-
48
- width:100%;
49
 
50
  }
51
 
52
- #review-statistics{
53
 
54
- font-family:FontAwesome;
55
 
56
  }
57
 
58
- #review-statistics .sec-top { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; margin: 40px 0 20px 0; }
 
 
 
 
59
 
60
- #review-statistics .sec-top h2 { line-height: 0; margin: 0; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-weight: normal; text-transform: uppercase; font-style: italic; font-size: 1.643em; padding: 20px 0; letter-spacing: -1px; border-left: 4px solid #D8D8D8;border-right: 4px solid #d8d8d8;padding-left: 20px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- #review-statistics .sec-top h2 i { color: #d9d9d9; margin-right: 10px;}
 
 
 
63
 
64
- #review-statistics .container .edit-article { padding-right: 35px; text-align: right; }
 
 
 
65
 
66
- #review-statistics .container .edit-article a { text-decoration: none; text-transform: uppercase; padding: 5px 10px; font-size: 12px; background:#f3f3f3; border-radius: 4px; color:#7d7d7d; }
 
 
 
 
 
 
 
 
67
 
68
- #review-statistics .container .edit-article a:hover { background:#ddd;}
 
 
69
 
70
- #review-statistics .article-meta { margin: 20px 0 20px 0;}
 
 
71
 
72
  #review-statistics .icon-bar-chart:before {
73
 
74
- content: "\f080";
75
 
76
  }
77
 
78
  #review-statistics .review-wu-right .cons {
79
- margin-top:15px;
80
  }
81
 
82
- #review-statistics .sec-top h2 i {
83
 
84
- color: #D9D9D9;
85
 
86
- margin-right: 10px;
87
 
88
  }
89
 
90
  #review-statistics .cwpr_clearfix:after {
91
 
92
- content: '\0020';
93
 
94
- display: block;
95
 
96
- overflow: hidden;
97
 
98
- visibility: hidden;
99
 
100
- width: 0;
101
 
102
- height: 0; }
 
103
 
104
  #review-statistics .cwpr_clearfix:after {
105
 
106
- clear: both; }
 
107
 
108
  #review-statistics .cwpr_clearfix {
109
 
110
- zoom: 1; }
 
111
 
112
- #review-statistics .cwp-review-chart { float: left; position: relative !important;top: 0;right: 0; border-radius: 50%;}
 
 
 
 
 
 
113
 
114
- #review-statistics .cwp-review-percentage span { font-family: "Lato"; font-size: 17px; font-weight: 900; background: #fff; display: block;border-radius: 50%; }
 
 
 
 
 
 
 
115
 
116
- .cwp-review-rating{
117
- line-height: inherit !important;
118
  }
119
- #review-statistics .cwp_easyPieChart { position: relative; text-align: center; }
120
 
121
- #review-statistics .cwp_easyPieChart canvas { position: absolute; top: 0; left: 0; }
 
 
 
 
 
 
 
 
 
122
 
123
- #review-statistics .review-wrap-up { margin-top: 20px; border:1px solid #e6e6e6; border-top: none;}
 
 
 
 
124
 
125
- #review-statistics .review-wu-bars h3, .review-wu-bars span { font-family: "Open Sans"; font-size: 13px !important; text-transform: uppercase; font-style: italic; line-height: 2; margin: 0; padding: 0; }
 
 
 
 
 
 
 
 
126
 
127
- #review-statistics .review-wu-bars h3 {float:left;}
 
 
128
 
129
- #review-statistics .review-wu-bars span { text-align: right; float: right; line-height: 2;}
 
 
 
 
130
 
131
- #review-statistics .review-wu-bars { width: 90%; padding: 0 5% 10px 5%; border-right:1px solid #e6e6e6; border-top:1px solid #e6e6e6;border-left: none; border-bottom: none;float:left; }
 
 
 
 
 
 
 
 
132
 
133
- #review-statistics .review-wu-bars ul { margin: 0; margin-left: 0 !important; width: 100% !important; padding-left:0 !important; }
 
 
 
 
 
134
 
135
- #review-statistics .review-wu-bars ul li {display: inline-block; height: 6px; margin-right: 2%; width: 8.2%; float:left; }
 
 
 
 
 
 
136
 
137
  #review-statistics .rev-option.customBarIcon ul li {
138
- background: none;
139
- font-size: 15px;
140
- width: 28px;
141
- height: auto !important;
142
- margin: 0;
143
  }
144
 
145
  #review-statistics .rev-option.customBarIcon ul li i {
146
- line-height: 1;
147
- font-style: normal !important;
148
- font-size: 22px;
149
- text-align: center;
150
  }
151
 
152
  #review-statistics .rev-option.customBarIcon h3,
153
  #review-statistics .rev-option.customBarIcon span {
154
- padding: 0 4px;
155
  }
156
 
 
 
 
157
 
 
 
 
158
 
159
- #review-statistics .review-wu-bars ul li:nth-child(10) { margin: 0 !important;}
160
-
161
- #review-statistics .review-wu-bars .rev-option div > * { display: inline-block; }
162
-
163
- #review-statistics .review-wrap-up .cwpr-review-top { padding: 20px; border-top: 5px solid #3baeda;border-bottom:1px solid #e6e6e6; }
164
-
165
- #review-statistics .review-wrap-up .cwpr-review-top .cwp-item { font-weight: 400; line-height: 1; margin: 0; padding: 0;}
166
- #review-statistics .review-wrap-up .cwpr-review-top h2.cwp-item {float:left;width:auto!important;letter-spacing: 1px;}
167
 
168
- #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category a { font-weight: 500; font-style: italic; letter-spacing: 1px; text-decoration: none;}
 
 
 
 
 
169
 
170
- #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category a:hover { text-decoration: underline;}
 
 
 
 
171
 
172
- #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category i { color:#e3e3e3; margin-right: 5px;}
 
 
 
 
 
173
 
174
- #review-statistics .review-wrap-up .review-wu-left {width: 51%; float: left;margin-top:10px; }
 
 
175
 
176
- #review-statistics .review-wrap-up .review-wu-left .rev-wu-image {text-align:center; float: left; width: 40%; overflow: hidden; border-top: none;padding:0;margin-left: 5%;margin-right: 5%;}
 
 
 
177
 
178
- #review-statistics .review-wrap-up .review-wu-left .rev-wu-image img { height: auto;width:100%; box-shadow:none;}
 
 
 
 
179
 
180
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {width: 50%;
181
- box-sizing: border-box; text-align:center;
182
- display:block; float: left; border:1px solid #e6e6e6; border-top:none;position: relative; border-bottom:none;}
 
 
 
 
 
 
 
183
 
184
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart { position: relative; margin:0px;float:none;display:inline-block;}
 
 
 
 
185
 
186
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage { width: 150px; }
 
 
 
 
 
 
 
 
 
 
187
 
188
- #review-statistics .review-wrap-up .review-wu-right { float: left; width: 44%; padding: 2% 2% 2% 3%; border-top: none; }
 
 
 
 
 
189
 
 
 
 
190
 
 
 
 
 
 
 
191
 
192
- #review-statistics .review-wrap-up .review-wu-right h2 { font-family: "Lato"; font-size: 15px; text-transform: uppercase; font-weight: 800; margin-bottom: 0;}
 
 
 
 
 
 
193
 
194
  #review-statistics .review-wrap-up .review-wu-right ul li {
195
- font-size: 16px;padding-left: 0;
196
- margin: 0 0 2%;
197
- font-family: "Lato";
198
- line-height:1;
 
199
  }
200
 
201
  #review-statistics .review-wrap-up .review-wu-right ul li:before {
202
- content: "-";
203
- margin-right: 5px;
204
  }
205
 
206
  #review-statistics .review-wrap-up .review-wu-right ul li {
207
  }
208
 
209
  .review-wu-right ul li {
210
- background:none !important;
211
  }
212
 
213
- .comment-form-meta-option input{
214
 
215
- background:none !important;
216
 
217
  }
218
 
219
- .rev-wu-image img{
220
 
221
- background:none!important;
222
 
223
- padding:0 !important;
224
 
225
- margin:0 !important;
226
 
227
  }
228
 
229
- .rev-option ul li{
230
 
231
- margin-left:0 !important;
232
 
233
- margin-top:0 !important;
234
 
235
- margin-bottom:0 !important;
236
 
237
- padding-left:0 !important;
238
 
239
  }
240
 
241
- .review-wu-bars,.review-wu-right{
242
 
243
- box-sizing:content-box !important;
244
- text-align:left;
245
 
246
  }
247
 
248
- #review-statistics .rev-option{
249
 
250
- margin-top:10px;
251
 
252
  }
253
 
 
 
 
 
 
254
 
 
 
 
 
 
 
255
 
256
- .affiliate-button { width:100%; margin-bottom:20px; clear:both;}
257
-
258
- .affiliate-button2 { width:50%!important; margin-bottom:20px; float:left;clear:none!important;}
259
-
260
- .affiliate-button a { display: table;
261
- border: none; padding: 10px 35px;
262
- margin: 20px auto 0;
263
- border-radius: 5px; text-decoration: none !important; }
264
-
265
- .affiliate-button a:hover span { ; text-decoration: none; }
266
-
267
- .affiliate-button a span { text-transform: uppercase; font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Lato, Arial, sans-serif; font-style: italic; font-weight: normal; font-size: 14px; padding-left: 20px; margin-left: -10px; text-decoration:none;}
268
-
269
-
270
-
271
- #review-statistics .review-wrap-up .review-wu-right ul{
272
-
273
- margin-top:10px!important;;
274
 
275
- padding-left:0 !important;
276
- margin-left: 0;
277
- list-style:none;
278
 
 
 
 
 
 
 
 
 
 
279
  }
280
 
 
281
 
 
282
 
283
- #cwp-slider-comment .comment-form-default label { }
 
 
284
 
285
- #cwp-slider-comment .comment-form-meta-option { width: 100%; float: right; margin-bottom: 12px;position:relative; }
286
 
287
- #cwp-slider-comment .comment-form-meta-option label { float: left; width: 80%; display:block;font-size:14px;line-height: 2;padding:0px;margin:0px;}
 
288
 
289
- #cwp-slider-comment .comment-form-meta-option .meta_option_input { float: right; width: 12%; text-align: center; border: none; padding: 5px 0px 0px 0px; font-weight: bold;line-height: 1.5;font-size:14px; height:26px;margin:0px;min-width:0%;}
 
 
 
 
 
290
 
291
- #cwp-slider-comment .comment-form-meta-option .comment_meta_slider { margin-top: 5px!important; background:#f3f3f3; border: none; height: 7px; box-shadow: inset 0 0 2px rgba(0,0,0,0.3); float:left;width:100%;}
 
 
 
 
 
 
 
 
292
 
293
- #cwp-slider-comment .comment-form-meta-option .comment_meta_slider .ui-slider-handle { background: #3baeda; border:none; border-radius: 50%; width: 13px; height: 13px; top: -4px; left: 5px; }
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
- #cwp-slider-comment .comment-form-meta-option .comment_meta_slider .ui-slider-handle:hover { cursor: pointer; box-shadow: inset 0 0 4px rgba(255,255,255,0.3);}
 
 
 
 
 
 
 
 
296
 
297
- #cwp-slider-comment cite.review-info { font-style: italic !important; color:#ddd; }
 
 
 
 
 
 
 
 
298
 
 
 
 
 
299
 
 
 
 
 
300
 
301
  /* User Comment Grades Styles */
302
 
303
- .user-comments-grades { width: 200px; float: right; margin-top: 25px; border: 1px solid #ddd; padding: 10px; border-radius: 5px; margin-left: 15px;}
304
-
305
- .user-comments-grades * { margin: 0 !important; padding: 0 !important; }
306
-
307
- .user-comments-grades .comment-meta-option-name { float: left; text-transform: uppercase; font-size: 10px; color: #7d7d7d; margin-bottom: 3px !important;}
 
 
 
 
308
 
309
- .user-comments-grades .comment-meta-option-grade { float: right; text-transform: uppercase; font-size: 10px; font-weight: bold;clear:none!important;}
 
 
 
310
 
311
- .user-comments-grades .comment-meta-option { margin-bottom: 10px !important; }
 
 
 
 
 
 
312
 
313
- .user-comments-grades .comment-meta-option:last-of-type { margin-bottom: 0 !important; }
 
 
 
 
 
 
314
 
 
 
 
315
 
 
 
 
316
 
317
  /* Comment Form Meta Options - GRADE BAR */
318
 
319
- .comment-meta-option .comment-meta-grade-bar { width: 100%; background: #ebedef;border-radius: 32px;height: 5px;-webkit-box-shadow: none;box-shadow: none; overflow: hidden;}
320
-
321
- .comment-meta-grade { height: 100%; }
322
-
 
 
 
 
 
323
 
 
 
 
324
 
325
  #cwp-slider-comment {
326
 
327
- width:230px;
328
 
329
-
330
- display:block;
331
 
332
- margin-bottom:10px;
333
- margin-top:10px;
334
 
335
  }
336
 
337
  .comment-form-meta-option {
338
 
339
- width:100% !important;
340
 
341
  }
342
 
343
- .cwpr_clearfix{
344
 
345
- clear:both !important;
346
 
347
  }
348
 
349
  /* Comment Form Meta Options - GRADE BAR */
350
 
351
- #cwp-slider-comment .comment-meta-option .comment-meta-grade-bar { width: 100%; background: #ebedef;border-radius: 32px;height: 5px;-webkit-box-shadow: none;box-shadow: none; overflow: hidden;}
 
 
 
 
 
 
 
 
352
 
353
- .review-wu-right ul li { list-style: none!important; }
 
 
354
 
355
  .cwp-chart-embed {
356
- position:relative!important;
357
- margin:10px!important;
358
  }
359
 
360
-
361
  @media (max-width: 440px) {
362
- #review-statistics .review-wrap-up .review-wu-left {
363
- width:100%;
364
- }
365
- #review-statistics .review-wrap-up .review-wu-right{
366
- width:95%;
367
- padding-left:5%;
368
- }
369
 
370
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade{
371
- border-right:none;
372
- }
373
- #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade { height:130px;}
374
 
375
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
 
 
376
 
377
- margin-top: 10%;
378
- }
 
379
 
380
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
381
- font-size: 30px;
382
- }
383
- }
384
 
385
- @media (min-width:440px) and (max-width: 700px) {
386
- #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade { height:100px;}
387
 
388
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
 
 
 
389
 
390
- margin-top: 10%;
391
- }
 
 
392
 
393
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
394
- font-size: 30px;
395
- }
396
- }
397
 
398
- @media (min-width:700px) and (max-width: 820px) {
399
- #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade { height:130px;}
400
 
401
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
 
 
 
 
 
 
 
 
402
 
403
- margin-top: 10%;
404
- }
405
 
406
- #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
407
- font-size: 30px;
408
- }
409
- }
410
 
411
- .cwp-review-percentage.cwp_easyPieChart canvas{
412
- position: absolute;
413
- left:0px;
414
  }
415
- .cwp-review-percentage.cwp_easyPieChart{
416
- position: relative;
417
- text-align: center;
 
 
 
 
 
 
418
  }
1
  /*
2
+ Version: 2.9.6
3
  */
4
+ #review-statistics {
5
 
6
+ font-family: FontAwesome;
7
 
8
+ width: 100%;
9
 
10
+ margin: auto;
11
 
12
  }
13
+
14
  .cwp-item-price {
15
+ float: right;
16
+ font-size: 1.75em;
17
+ font-family: "Lato", Helvetica, sans-serif;
18
  }
19
 
20
  #review-statistics h1,
 
21
  #review-statistics h2,
 
22
  #review-statistics h3,
 
23
  #review-statistics h4,
 
24
  #review-statistics h5,
 
25
  #review-statistics h6 {
26
 
27
+ font-family: "Lato", Helvetica, sans-serif;
28
 
29
+ font-weight: normal;
30
+ border: none;
31
+ padding: 0;
32
+ margin: 0;
33
 
34
  }
35
 
36
+ .rev-option h3 {
37
+ width: auto !important;
38
  }
39
 
40
+ #review-statistics .photo-wrapup {
41
 
42
+ width: 100%;
 
 
43
 
44
  }
45
 
46
+ #review-statistics {
47
 
48
+ font-family: FontAwesome;
49
 
50
  }
51
 
52
+ #review-statistics .sec-top {
53
+ border-top: 1px solid #ddd;
54
+ border-bottom: 1px solid #ddd;
55
+ margin: 40px 0 20px 0;
56
+ }
57
 
58
+ #review-statistics .sec-top h2 {
59
+ line-height: 0;
60
+ margin: 0;
61
+ font-family: "Open Sans", Helvetica, Arial, sans-serif;
62
+ font-weight: normal;
63
+ text-transform: uppercase;
64
+ font-style: italic;
65
+ font-size: 1.643em;
66
+ padding: 20px 0;
67
+ letter-spacing: -1px;
68
+ border-left: 4px solid #D8D8D8;
69
+ border-right: 4px solid #d8d8d8;
70
+ padding-left: 20px;
71
+ }
72
 
73
+ #review-statistics .sec-top h2 i {
74
+ color: #d9d9d9;
75
+ margin-right: 10px;
76
+ }
77
 
78
+ #review-statistics .container .edit-article {
79
+ padding-right: 35px;
80
+ text-align: right;
81
+ }
82
 
83
+ #review-statistics .container .edit-article a {
84
+ text-decoration: none;
85
+ text-transform: uppercase;
86
+ padding: 5px 10px;
87
+ font-size: 12px;
88
+ background: #f3f3f3;
89
+ border-radius: 4px;
90
+ color: #7d7d7d;
91
+ }
92
 
93
+ #review-statistics .container .edit-article a:hover {
94
+ background: #ddd;
95
+ }
96
 
97
+ #review-statistics .article-meta {
98
+ margin: 20px 0 20px 0;
99
+ }
100
 
101
  #review-statistics .icon-bar-chart:before {
102
 
103
+ content: "\f080";
104
 
105
  }
106
 
107
  #review-statistics .review-wu-right .cons {
108
+ margin-top: 15px;
109
  }
110
 
111
+ #review-statistics .sec-top h2 i {
112
 
113
+ color: #D9D9D9;
114
 
115
+ margin-right: 10px;
116
 
117
  }
118
 
119
  #review-statistics .cwpr_clearfix:after {
120
 
121
+ content: '\0020';
122
 
123
+ display: block;
124
 
125
+ overflow: hidden;
126
 
127
+ visibility: hidden;
128
 
129
+ width: 0;
130
 
131
+ height: 0;
132
+ }
133
 
134
  #review-statistics .cwpr_clearfix:after {
135
 
136
+ clear: both;
137
+ }
138
 
139
  #review-statistics .cwpr_clearfix {
140
 
141
+ zoom: 1;
142
+ }
143
 
144
+ #review-statistics .cwp-review-chart {
145
+ float: left;
146
+ position: relative !important;
147
+ top: 0;
148
+ right: 0;
149
+ border-radius: 50%;
150
+ }
151
 
152
+ #review-statistics .cwp-review-percentage span {
153
+ font-family: "Lato";
154
+ font-size: 17px;
155
+ font-weight: 900;
156
+ background: #fff;
157
+ display: block;
158
+ border-radius: 50%;
159
+ }
160
 
161
+ .cwp-review-rating {
162
+ line-height: inherit !important;
163
  }
 
164
 
165
+ #review-statistics .cwp_easyPieChart {
166
+ position: relative;
167
+ text-align: center;
168
+ }
169
+
170
+ #review-statistics .cwp_easyPieChart canvas {
171
+ position: absolute;
172
+ top: 0;
173
+ left: 0;
174
+ }
175
 
176
+ #review-statistics .review-wrap-up {
177
+ margin-top: 20px;
178
+ border: 1px solid #e6e6e6;
179
+ border-top: none;
180
+ }
181
 
182
+ #review-statistics .review-wu-bars h3, .review-wu-bars span {
183
+ font-family: "Open Sans";
184
+ font-size: 13px !important;
185
+ text-transform: uppercase;
186
+ font-style: italic;
187
+ line-height: 2;
188
+ margin: 0;
189
+ padding: 0;
190
+ }
191
 
192
+ #review-statistics .review-wu-bars h3 {
193
+ float: left;
194
+ }
195
 
196
+ #review-statistics .review-wu-bars span {
197
+ text-align: right;
198
+ float: right;
199
+ line-height: 2;
200
+ }
201
 
202
+ #review-statistics .review-wu-bars {
203
+ width: 90%;
204
+ padding: 0 5% 10px 5%;
205
+ border-right: 1px solid #e6e6e6;
206
+ border-top: 1px solid #e6e6e6;
207
+ border-left: none;
208
+ border-bottom: none;
209
+ float: left;
210
+ }
211
 
212
+ #review-statistics .review-wu-bars ul {
213
+ margin: 0;
214
+ margin-left: 0 !important;
215
+ width: 100% !important;
216
+ padding-left: 0 !important;
217
+ }
218
 
219
+ #review-statistics .review-wu-bars ul li {
220
+ display: inline-block;
221
+ height: 6px;
222
+ margin-right: 2%;
223
+ width: 8.2%;
224
+ float: left;
225
+ }
226
 
227
  #review-statistics .rev-option.customBarIcon ul li {
228
+ background: none;
229
+ font-size: 15px;
230
+ width: 28px;
231
+ height: auto !important;
232
+ margin: 0;
233
  }
234
 
235
  #review-statistics .rev-option.customBarIcon ul li i {
236
+ line-height: 1;
237
+ font-style: normal !important;
238
+ font-size: 22px;
239
+ text-align: center;
240
  }
241
 
242
  #review-statistics .rev-option.customBarIcon h3,
243
  #review-statistics .rev-option.customBarIcon span {
244
+ padding: 0 4px;
245
  }
246
 
247
+ #review-statistics .review-wu-bars ul li:nth-child(10) {
248
+ margin: 0 !important;
249
+ }
250
 
251
+ #review-statistics .review-wu-bars .rev-option div > * {
252
+ display: inline-block;
253
+ }
254
 
255
+ #review-statistics .review-wrap-up .cwpr-review-top {
256
+ padding: 20px;
257
+ border-top: 5px solid #3baeda;
258
+ border-bottom: 1px solid #e6e6e6;
259
+ }
 
 
 
260
 
261
+ #review-statistics .review-wrap-up .cwpr-review-top .cwp-item {
262
+ font-weight: 400;
263
+ line-height: 1;
264
+ margin: 0;
265
+ padding: 0;
266
+ }
267
 
268
+ #review-statistics .review-wrap-up .cwpr-review-top h2.cwp-item {
269
+ float: left;
270
+ width: auto !important;
271
+ letter-spacing: 1px;
272
+ }
273
 
274
+ #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category a {
275
+ font-weight: 500;
276
+ font-style: italic;
277
+ letter-spacing: 1px;
278
+ text-decoration: none;
279
+ }
280
 
281
+ #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category a:hover {
282
+ text-decoration: underline;
283
+ }
284
 
285
+ #review-statistics .review-wrap-up .cwpr-review-top .cwp-item-category i {
286
+ color: #e3e3e3;
287
+ margin-right: 5px;
288
+ }
289
 
290
+ #review-statistics .review-wrap-up .review-wu-left {
291
+ width: 51%;
292
+ float: left;
293
+ margin-top: 10px;
294
+ }
295
 
296
+ #review-statistics .review-wrap-up .review-wu-left .rev-wu-image {
297
+ text-align: center;
298
+ float: left;
299
+ width: 40%;
300
+ overflow: hidden;
301
+ border-top: none;
302
+ padding: 0;
303
+ margin-left: 5%;
304
+ margin-right: 5%;
305
+ }
306
 
307
+ #review-statistics .review-wrap-up .review-wu-left .rev-wu-image img {
308
+ height: auto;
309
+ width: 100%;
310
+ box-shadow: none;
311
+ }
312
 
313
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {
314
+ width: 50%;
315
+ box-sizing: border-box;
316
+ text-align: center;
317
+ display: block;
318
+ float: left;
319
+ border: 1px solid #e6e6e6;
320
+ border-top: none;
321
+ position: relative;
322
+ border-bottom: none;
323
+ }
324
 
325
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart {
326
+ position: relative;
327
+ margin: 0px;
328
+ float: none;
329
+ display: inline-block;
330
+ }
331
 
332
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
333
+ width: 150px;
334
+ }
335
 
336
+ #review-statistics .review-wrap-up .review-wu-right {
337
+ float: left;
338
+ width: 44%;
339
+ padding: 2% 2% 2% 3%;
340
+ border-top: none;
341
+ }
342
 
343
+ #review-statistics .review-wrap-up .review-wu-right h2 {
344
+ font-family: "Lato";
345
+ font-size: 15px;
346
+ text-transform: uppercase;
347
+ font-weight: 800;
348
+ margin-bottom: 0;
349
+ }
350
 
351
  #review-statistics .review-wrap-up .review-wu-right ul li {
352
+ font-size: 16px;
353
+ padding-left: 0;
354
+ margin: 0 0 2%;
355
+ font-family: "Lato";
356
+ line-height: 1;
357
  }
358
 
359
  #review-statistics .review-wrap-up .review-wu-right ul li:before {
360
+ content: "-";
361
+ margin-right: 5px;
362
  }
363
 
364
  #review-statistics .review-wrap-up .review-wu-right ul li {
365
  }
366
 
367
  .review-wu-right ul li {
368
+ background: none !important;
369
  }
370
 
371
+ .comment-form-meta-option input {
372
 
373
+ background: none !important;
374
 
375
  }
376
 
377
+ .rev-wu-image img {
378
 
379
+ background: none !important;
380
 
381
+ padding: 0 !important;
382
 
383
+ margin: 0 !important;
384
 
385
  }
386
 
387
+ .rev-option ul li {
388
 
389
+ margin-left: 0 !important;
390
 
391
+ margin-top: 0 !important;
392
 
393
+ margin-bottom: 0 !important;
394
 
395
+ padding-left: 0 !important;
396
 
397
  }
398
 
399
+ .review-wu-bars, .review-wu-right {
400
 
401
+ box-sizing: content-box !important;
402
+ text-align: left;
403
 
404
  }
405
 
406
+ #review-statistics .rev-option {
407
 
408
+ margin-top: 10px;
409
 
410
  }
411
 
412
+ .affiliate-button {
413
+ width: 100%;
414
+ margin-bottom: 20px;
415
+ clear: both;
416
+ }
417
 
418
+ .affiliate-button2 {
419
+ width: 50% !important;
420
+ margin-bottom: 20px;
421
+ float: left;
422
+ clear: none !important;
423
+ }
424
 
425
+ .affiliate-button a {
426
+ display: table;
427
+ border: none;
428
+ padding: 10px 35px;
429
+ margin: 20px auto 0;
430
+ border-radius: 5px;
431
+ text-decoration: none !important;
432
+ }
 
 
 
 
 
 
 
 
 
 
433
 
434
+ .affiliate-button a:hover span {;
435
+ text-decoration: none;
436
+ }
437
 
438
+ .affiliate-button a span {
439
+ text-transform: uppercase;
440
+ font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Lato, Arial, sans-serif;
441
+ font-style: italic;
442
+ font-weight: normal;
443
+ font-size: 14px;
444
+ padding-left: 20px;
445
+ margin-left: -10px;
446
+ text-decoration: none;
447
  }
448
 
449
+ #review-statistics .review-wrap-up .review-wu-right ul {
450
 
451
+ margin-top: 10px !important;;
452
 
453
+ padding-left: 0 !important;
454
+ margin-left: 0;
455
+ list-style: none;
456
 
457
+ }
458
 
459
+ #cwp-slider-comment .comment-form-default label {
460
+ }
461
 
462
+ #cwp-slider-comment .comment-form-meta-option {
463
+ width: 100%;
464
+ float: right;
465
+ margin-bottom: 12px;
466
+ position: relative;
467
+ }
468
 
469
+ #cwp-slider-comment .comment-form-meta-option label {
470
+ float: left;
471
+ width: 80%;
472
+ display: block;
473
+ font-size: 14px;
474
+ line-height: 2;
475
+ padding: 0px;
476
+ margin: 0px;
477
+ }
478
 
479
+ #cwp-slider-comment .comment-form-meta-option .meta_option_input {
480
+ float: right;
481
+ width: 12%;
482
+ text-align: center;
483
+ border: none;
484
+ padding: 5px 0px 0px 0px;
485
+ font-weight: bold;
486
+ line-height: 1.5;
487
+ font-size: 14px;
488
+ height: 26px;
489
+ margin: 0px;
490
+ min-width: 0%;
491
+ }
492
 
493
+ #cwp-slider-comment .comment-form-meta-option .comment_meta_slider {
494
+ margin-top: 5px !important;
495
+ background: #f3f3f3;
496
+ border: none;
497
+ height: 7px;
498
+ box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.3);
499
+ float: left;
500
+ width: 100%;
501
+ }
502
 
503
+ #cwp-slider-comment .comment-form-meta-option .comment_meta_slider .ui-slider-handle {
504
+ background: #3baeda;
505
+ border: none;
506
+ border-radius: 50%;
507
+ width: 13px;
508
+ height: 13px;
509
+ top: -4px;
510
+ left: 5px;
511
+ }
512
 
513
+ #cwp-slider-comment .comment-form-meta-option .comment_meta_slider .ui-slider-handle:hover {
514
+ cursor: pointer;
515
+ box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.3);
516
+ }
517
 
518
+ #cwp-slider-comment cite.review-info {
519
+ font-style: italic !important;
520
+ color: #ddd;
521
+ }
522
 
523
  /* User Comment Grades Styles */
524
 
525
+ .user-comments-grades {
526
+ width: 200px;
527
+ float: right;
528
+ margin-top: 25px;
529
+ border: 1px solid #ddd;
530
+ padding: 10px;
531
+ border-radius: 5px;
532
+ margin-left: 15px;
533
+ }
534
 
535
+ .user-comments-grades * {
536
+ margin: 0 !important;
537
+ padding: 0 !important;
538
+ }
539
 
540
+ .user-comments-grades .comment-meta-option-name {
541
+ float: left;
542
+ text-transform: uppercase;
543
+ font-size: 10px;
544
+ color: #7d7d7d;
545
+ margin-bottom: 3px !important;
546
+ }
547
 
548
+ .user-comments-grades .comment-meta-option-grade {
549
+ float: right;
550
+ text-transform: uppercase;
551
+ font-size: 10px;
552
+ font-weight: bold;
553
+ clear: none !important;
554
+ }
555
 
556
+ .user-comments-grades .comment-meta-option {
557
+ margin-bottom: 10px !important;
558
+ }
559
 
560
+ .user-comments-grades .comment-meta-option:last-of-type {
561
+ margin-bottom: 0 !important;
562
+ }
563
 
564
  /* Comment Form Meta Options - GRADE BAR */
565
 
566
+ .comment-meta-option .comment-meta-grade-bar {
567
+ width: 100%;
568
+ background: #ebedef;
569
+ border-radius: 32px;
570
+ height: 5px;
571
+ -webkit-box-shadow: none;
572
+ box-shadow: none;
573
+ overflow: hidden;
574
+ }
575
 
576
+ .comment-meta-grade {
577
+ height: 100%;
578
+ }
579
 
580
  #cwp-slider-comment {
581
 
582
+ width: 230px;
583
 
584
+ display: block;
 
585
 
586
+ margin-bottom: 10px;
587
+ margin-top: 10px;
588
 
589
  }
590
 
591
  .comment-form-meta-option {
592
 
593
+ width: 100% !important;
594
 
595
  }
596
 
597
+ .cwpr_clearfix {
598
 
599
+ clear: both !important;
600
 
601
  }
602
 
603
  /* Comment Form Meta Options - GRADE BAR */
604
 
605
+ #cwp-slider-comment .comment-meta-option .comment-meta-grade-bar {
606
+ width: 100%;
607
+ background: #ebedef;
608
+ border-radius: 32px;
609
+ height: 5px;
610
+ -webkit-box-shadow: none;
611
+ box-shadow: none;
612
+ overflow: hidden;
613
+ }
614
 
615
+ .review-wu-right ul li {
616
+ list-style: none !important;
617
+ }
618
 
619
  .cwp-chart-embed {
620
+ position: relative !important;
621
+ margin: 10px !important;
622
  }
623
 
 
624
  @media (max-width: 440px) {
625
+ #review-statistics .review-wrap-up .review-wu-left {
626
+ width: 100%;
627
+ }
 
 
 
 
628
 
629
+ #review-statistics .review-wrap-up .review-wu-right {
630
+ width: 95%;
631
+ padding-left: 5%;
632
+ }
633
 
634
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {
635
+ border-right: none;
636
+ }
637
 
638
+ #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {
639
+ height: 130px;
640
+ }
641
 
642
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
 
 
 
643
 
644
+ margin-top: 10%;
645
+ }
646
 
647
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
648
+ font-size: 30px;
649
+ }
650
+ }
651
 
652
+ @media (min-width: 440px) and (max-width: 700px) {
653
+ #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {
654
+ height: 100px;
655
+ }
656
 
657
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
 
 
 
658
 
659
+ margin-top: 10%;
660
+ }
661
 
662
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
663
+ font-size: 30px;
664
+ }
665
+ }
666
+
667
+ @media (min-width: 700px) and (max-width: 820px) {
668
+ #review-statistics .review-wrap-up .review-wu-left .rev-wu-image, #review-statistics .review-wrap-up .review-wu-left .review-wu-grade {
669
+ height: 130px;
670
+ }
671
 
672
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
 
673
 
674
+ margin-top: 10%;
675
+ }
 
 
676
 
677
+ #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
678
+ font-size: 30px;
679
+ }
680
  }
681
+
682
+ .cwp-review-percentage.cwp_easyPieChart canvas {
683
+ position: absolute;
684
+ left: 0px;
685
+ }
686
+
687
+ .cwp-review-percentage.cwp_easyPieChart {
688
+ position: relative;
689
+ text-align: center;
690
  }
images/amazon-cart.png ADDED
Binary file
images/comparison-table.gif ADDED
Binary file
images/customize-icons.gif ADDED
Binary file
images/preload.png ADDED
Binary file
images/single.png ADDED
Binary file
inc/abtesting/abtesting.php CHANGED
@@ -1,52 +1,48 @@
1
  <?php
2
 
3
- class TIABTesting
4
- {
5
- private $config;
6
- private $slug;
7
- private $version;
8
-
9
- public function __construct($slug, $version)
10
- {
11
- $this->version = str_replace(".", "_", $version);
12
- $this->loadHooks($slug);
13
- }
14
-
15
- private function loadHooks($slug)
16
- {
17
- $this->slug = $slug;
18
- $this->config = apply_filters($this->slug . "_upsell_config", array());
19
-
20
- foreach ($this->config as $section=>$values) {
21
- add_filter($this->slug . "_" . $section . "_upsell_text", array($this, "getUpsellText"), 10, 2);
22
- }
23
- }
24
-
25
- public function getUpsellText($default="", $escapeHTML=false)
26
- {
27
- $filter = current_filter();
28
- if (strpos($filter, $this->slug) !== false) {
29
- $section = str_replace(array($this->slug . "_", "_upsell_text"), "", $filter);
30
- if (!empty($section)) {
31
- if (array_key_exists($section, $this->config)) {
32
- // check if a value has already been saved against this slug, version, section
33
- $savedVal = get_option($this->slug . "_" . $this->version . "_" . $section, "");
34
- if (!empty($savedVal)) return $savedVal;
35
- $values = $this->config[$section];
36
- $html = $values[rand(0, count($values) - 1)];
37
- $html = $escapeHTML ? esc_html($html) : $html;
38
- update_option($this->slug . "_" . $this->version . "_" . $section, $html);
39
- return $html;
40
- }
41
- }
42
- }
43
- return $default;
44
- }
45
-
46
- public static function writeDebug($msg)
47
- {
48
- @mkdir(dirname(__FILE__) . "/tmp");
49
- file_put_contents(dirname(__FILE__) . "/tmp/log.log", date("F j, Y H:i:s", current_time("timestamp")) . " - " . $msg."\n", FILE_APPEND);
50
- }
51
 
52
  }
1
  <?php
2
 
3
+ class TIABTesting {
4
+
5
+ private $config;
6
+ private $slug;
7
+ private $version;
8
+
9
+ public function __construct( $slug, $version ) {
10
+ $this->version = str_replace( '.', '_', $version );
11
+ $this->loadHooks( $slug );
12
+ }
13
+
14
+ private function loadHooks( $slug ) {
15
+ $this->slug = $slug;
16
+ $this->config = apply_filters( $this->slug . '_upsell_config', array() );
17
+
18
+ foreach ( $this->config as $section => $values ) {
19
+ add_filter( $this->slug . '_' . $section . '_upsell_text', array( $this, 'getUpsellText' ), 10, 2 );
20
+ }
21
+ }
22
+
23
+ public function getUpsellText( $default = '', $escapeHTML = false ) {
24
+ $filter = current_filter();
25
+ if ( strpos( $filter, $this->slug ) !== false ) {
26
+ $section = str_replace( array( $this->slug . '_', '_upsell_text' ), '', $filter );
27
+ if ( ! empty( $section ) ) {
28
+ if ( array_key_exists( $section, $this->config ) ) {
29
+ // check if a value has already been saved against this slug, version, section
30
+ $savedVal = get_option( $this->slug . '_' . $this->version . '_' . $section, '' );
31
+ if ( ! empty( $savedVal ) ) { return $savedVal; }
32
+ $values = $this->config[ $section ];
33
+ $html = $values[ rand( 0, count( $values ) - 1 ) ];
34
+ $html = $escapeHTML ? esc_html( $html ) : $html;
35
+ update_option( $this->slug . '_' . $this->version . '_' . $section, $html );
36
+ return $html;
37
+ }
38
+ }
39
+ }
40
+ return $default;
41
+ }
42
+
43
+ public static function writeDebug( $msg ) {
44
+ @mkdir( dirname( __FILE__ ) . '/tmp' );
45
+ file_put_contents( dirname( __FILE__ ) . '/tmp/log.log', date( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $msg . "\n", FILE_APPEND );
46
+ }
 
 
 
 
47
 
48
  }
inc/class-remote-notification-client.php DELETED
@@ -1,383 +0,0 @@
1
- <?php
2
- /**
3
- * Remote Dashobard Notifications.
4
- *
5
- * This class is part of the Remote Dashboard Notifications plugin.
6
- * This plugin allows you to send notifications to your client's
7
- * WordPress dashboard easily.
8
- *
9
- * Notification you send will be displayed as admin notifications
10
- * using the standard WordPress hooks. A "dismiss" option is added
11
- * in order to let the user hide the notification.
12
- *
13
- * @package Remote Dashboard Notifications
14
- * @author ThemeAvenue <web@themeavenue.net>
15
- * @license GPL-2.0+
16
- * @link http://themeavenue.net
17
- * @link http://wordpress.org/plugins/remote-dashboard-notifications/
18
- * @link https://github.com/ThemeAvenue/Remote-Dashboard-Notifications
19
- * @copyright 2014 ThemeAvenue
20
- */
21
-
22
- // If this file is called directly, abort.
23
- if ( ! defined( 'WPINC' ) ) {
24
- die;
25
- }
26
-
27
- class TAV_Remote_Notification_Client {
28
-
29
- /**
30
- * Class version.
31
- *
32
- * @since 0.1.0
33
- *
34
- * @var string
35
- */
36
- protected static $version = '0.1.2';
37
-
38
- public function __construct( $channel_id = false, $channel_key = false, $server = false, $debug = false ) {
39
-
40
- /* Don't continue during Ajax process */
41
- if( !is_admin() || defined( 'DOING_AJAX' ) && DOING_AJAX )
42
- return;
43
-
44
- $this->id = intval( $channel_id );
45
- $this->key = sanitize_key( $channel_key );
46
- $this->server = esc_url( $server );
47
- $this->notice = false;
48
- $this->cache = apply_filters( 'rn_notice_caching_time', 6 );
49
- $this->debug = $debug;
50
- $this->error = null;
51
-
52
- /* The plugin can't work without those 2 parameters */
53
- if( false === ( $this->id || $this->key || $this->server ) )
54
- return;
55
-
56
- /* Call the dismiss method before testing for Ajax */
57
- if( isset( $_GET['rn'] ) && isset( $_GET['notification'] ) )
58
- add_action( 'init', array( $this, 'dismiss' ) );
59
-
60
- add_action( 'init', array( $this, 'request_server' ) );
61
-
62
- }
63
-
64
- /**
65
- * Send a request to notification server
66
- *
67
- * The distant WordPress notification server is
68
- * queried using the WordPress HTTP API.
69
- *
70
- * @since 0.1.0
71
- */
72
- public function request_server() {
73
-
74
- /* Current channel ID */
75
- $channel_id = $this->id;
76
-
77
- /* Current channel key */
78
- $channel_key = $this->key;
79
-
80
- /* Generate a unique identifyer used for the transient */
81
- $uniqid = $channel_id . substr( $channel_key, 0, 5 );
82
-
83
- /* Prepare the payload to send to server */
84
- $payload = base64_encode( json_encode( array( 'channel' => $channel_id, 'key' => $channel_key ) ) );
85
-
86
- /* Get the endpoint URL ready */
87
- $url = add_query_arg( array( 'payload' => $payload ), $this->server );
88
-
89
- /* Content is false at first */
90
- $content = get_transient( "rn_last_notification_$uniqid" );
91
-
92
- /* Set the request response to null */
93
- $request = null;
94
-
95
- /* If no notice is present in DB we query the server */
96
- if( false === $content || defined( 'RDN_DEV' ) && RDN_DEV ) {
97
-
98
- /* Query the server */
99
- $request = wp_remote_get( $url, array( 'timeout' => apply_filters( 'rn_http_request_timeout', 5 ) ) );
100
-
101
- /* If we have a WP_Error object we abort */
102
- if( is_wp_error( $request ) )
103
- return;
104
-
105
- /* Check if we have a valid response */
106
- if( is_array( $request ) && isset( $request['response']['code'] ) && 200 === intval( $request['response']['code'] ) ) {
107
-
108
- /* Get the response body */
109
- if( isset( $request['body'] ) ) {
110
-
111
- /**
112
- * Decode the response JSON string
113
- */
114
- $content = json_decode( $request['body'] );
115
-
116
- /**
117
- * Check if the payload is in a usable JSON format
118
- */
119
- if( version_compare( phpversion(), '5.3.0', '>=' ) ) {
120
-
121
- if( ! ( json_last_error() == JSON_ERROR_NONE ) )
122
- return false;
123
-
124
- } else {
125
-
126
- if( $content == NULL )
127
- return false;
128
-
129
- }
130
-
131
- set_transient( "rn_last_notification_$uniqid", $content, $this->cache*60*60*5 );
132
-
133
- }
134
-
135
- }
136
-
137
- }
138
-
139
- /**
140
- * If the JSON string has been decoded we can go ahead
141
- */
142
- if( is_object( $content ) ) {
143
-
144
- if( isset( $content->error ) ) {
145
-
146
- /* Display debug info in the admin footer */
147
- if( true === $this->debug ) {
148
-
149
- /* Save the error message */
150
- $this->error = $content->error;
151
-
152
- /* Display it commented in the footer */
153
- add_action( 'admin_footer', array( $this, 'debug_info' ) );
154
-
155
- }
156
-
157
- /* Stop */
158
- return;
159
-
160
- }
161
-
162
- $this->notice = $content;
163
-
164
- /**
165
- * Check if notice has already been dismissed
166
- */
167
- $dismissed = get_option( '_rn_dismissed' );
168
-
169
- if( is_array( $dismissed ) && in_array( $content->slug, $dismissed ) )
170
- return;
171
-
172
- /**
173
- * Add the notice style
174
- */
175
- add_action( 'admin_print_styles', array( $this, 'style' ), 100 );
176
-
177
- /**
178
- * Add the notice to WP dashboard
179
- */
180
- add_action( 'admin_notices', array( $this, 'show_notice' ) );
181
-
182
- } else {
183
-
184
- return false;
185
-
186
- }
187
-
188
- }
189
-
190
- /**
191
- * Display the admin notice
192
- *
193
- * The function will do some checks to verify if
194
- * the notice can be displayed on the current page.
195
- * If all the checks are passed, the notice
196
- * is added to the page.
197
- *
198
- * @since 0.1.0
199
- */
200
- public function show_notice() {
201
-
202
- $content = $this->notice;
203
-
204
- /* If there is no content we abort */
205
- if( false === $content )
206
- return;
207
-
208
- /* If the type array isn't empty we have a limitation */
209
- if( isset( $content->type ) && is_array( $content->type ) && !empty( $content->type ) ) {
210
-
211
- /* Get current post type */
212
- $pt = get_post_type();
213
-
214
- /**
215
- * If the current post type can't be retrieved
216
- * or if it's not in the allowed post types,
217
- * then we don't display the admin notice.
218
- */
219
- if( false === $pt || !in_array( $pt, $content->type ) )
220
- return;
221
-
222
- }
223
-
224
- /* Prepare alert class */
225
- $style = isset( $content->style ) ? $content->style : 'updated';
226
-
227
- if( 'updated' == $style )
228
- $class = $style;
229
-
230
- elseif( 'error' == $style )
231
- $class = 'updated error';
232
-
233
- else
234
- $class = "updated rn-alert rn-alert-$style";
235
-
236
- /**
237
- * Prepare the dismiss URL
238
- *
239
- * @var (string) URL
240
- * @todo get a more accurate URL of the current page
241
- */
242
- $args = array();
243
- $nonce = wp_create_nonce( 'rn-dismiss' );
244
- $slug = $content->slug;
245
-
246
- array_push( $args, "rn=$nonce" );
247
- array_push( $args, "notification=$slug" );
248
-
249
- foreach( $_GET as $key => $value ) {
250
-
251
- array_push( $args, "$key=$value" );
252
-
253
- }
254
-
255
- $args = implode( '&', $args );
256
- $url = "?$args";
257
- ?>
258
-
259
- <div class="<?php echo $class; ?>">
260
- <?php if( !in_array( $style, array( 'updated', 'error' ) ) ): ?><a href="<?php echo $url; ?>" id="rn-dismiss" class="rn-dismiss-btn" title="<?php _e( 'Dismiss notification', 'remote-notifications' ); ?>">&times;</a><?php endif; ?>
261
- <p><?php echo html_entity_decode( $content->message ); ?></p>
262
- <?php if( in_array( $style, array( 'updated', 'error' ) ) ): ?><p><a href="<?php echo $url; ?>" id="rn-dismiss" class="rn-dismiss-button button-secondary"><?php _e( 'Dismiss', 'remote-notifications' ); ?></a></p><?php endif; ?>
263
- </div>
264
- <?php
265
-
266
- }
267
-
268
- /**
269
- * Dismiss notice
270
- *
271
- * When the user dismisses a notice, its slug
272
- * is added to the _rn_dismissed entry in the DB options table.
273
- * This entry is then used to check if a notie has been dismissed
274
- * before displaying it on the dashboard.
275
- *
276
- * @since 0.1.0
277
- */
278
- public function dismiss() {
279
-
280
- /* Check if we have all the vars */
281
- if( !isset( $_GET['rn'] ) || !isset( $_GET['notification'] ) )
282
- return;
283
-
284
- /* Validate nonce */
285
- if( !wp_verify_nonce( sanitize_key( $_GET['rn'] ), 'rn-dismiss' ) )
286
- return;
287
-
288
- /* Get dismissed list */
289
- $dismissed = get_option( '_rn_dismissed', array() );
290
-
291
- /* Add the current notice to the list if needed */
292
- if( is_array( $dismissed ) && !in_array( $_GET['notification'], $dismissed ) )
293
- array_push( $dismissed, $_GET['notification'] );
294
-
295
- /* Update option */
296
- update_option( '_rn_dismissed', $dismissed );
297
-
298
- /* Get redirect URL */
299
- $args = array();
300
-
301
- /* Get URL args */
302
- foreach( $_GET as $key => $value ) {
303
-
304
- if( in_array( $key, array( 'rn', 'notification' ) ) )
305
- continue;
306
-
307
- array_push( $args, "$key=$value" );
308
-
309
- }
310
-
311
- $args = implode( '&', $args );
312
- $url = "?$args";
313
-
314
- /* Redirect */
315
- wp_redirect( $url );
316
-
317
- }
318
-
319
- /**
320
- * Adds inline style for non standard notices
321
- *
322
- * This function will only be called if the notice style is not standard.
323
- *
324
- * @since 0.1.0
325
- */
326
- public function style() { ?>
327
-
328
- <style type="text/css">div.rn-alert{
329
- padding: 15px 35px 15px 15px;
330
- margin-bottom:20px;border:1px solid transparent;-webkit-box-shadow:none;box-shadow:none}div.rn-alert p:empty{display:none}div.rn-alert ul,div.rn-alert ul li,div.rn-alert ol,div.rn-alert ol li{list-style:inherit !important}div.rn-alert ul,div.rn-alert ol{padding-left:30px}div.rn-alert hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}div.rn-alert h1,h2,h3,h4,h5,h6{margin-top:0;color:inherit}div.rn-alert a{font-weight:700}div.rn-alert a:hover{text-decoration:underline}div.rn-alert>p{margin:0;padding:0;line-height:1}div.rn-alert>p,div.rn-alert>ul{margin-bottom:0}div.rn-alert>p+p{margin-top:5px}div.rn-alert .rn-dismiss-btn{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;position:relative;top:-2px;right:-21px;padding:0;cursor:pointer;background:0;border:0;-webkit-appearance:none;float:right;font-size:21px;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20);text-decoration:none}div.rn-alert-success{background-color:#dff0d8;border-color:#d6e9c6;color:#3c763d}div.rn-alert-success hr{border-top-color:#c9e2b3}div.rn-alert-success a{color:#2b542c}div.rn-alert-info{background-color:#d9edf7;border-color:#bce8f1;color:#31708f}div.rn-alert-info hr{border-top-color:#a6e1ec}div.rn-alert-info a{color:#245269}div.rn-alert-warning{background-color:#fcf8e3;border-color:#faebcc;color:#8a6d3b}div.rn-alert-warning hr{border-top-color:#f7e1b5}div.rn-alert-warning a{color:#66512c}div.rn-alert-danger{background-color:#f2dede;border-color:#ebccd1;color:#a94442}div.rn-alert-danger hr{border-top-color:#e4b9c0}div.rn-alert-danger a{color:#843534}</style>
331
-
332
- <?php }
333
-
334
- /**
335
- * Dismiss notice using Ajax
336
- *
337
- * This function is NOT used. Testing only.
338
- */
339
- public function script() {
340
-
341
- $url = admin_url();
342
- ?>
343
-
344
- <script type="text/javascript">
345
- jQuery(document).ready(function($) {
346
-
347
- var prout = 'prout';
348
-
349
- $('#rn-dismiss').on('click', function(event) {
350
- event.preventDefault();
351
- $.ajax({
352
- type: "GET",
353
- url: <?php echo $url; ?>,
354
- data: prout
355
- });
356
- console.log('clicked');
357
- });
358
-
359
- return false;
360
-
361
- });
362
- </script>
363
-
364
- <?php
365
-
366
- }
367
-
368
- /**
369
- * Debug info.
370
- *
371
- * Display an error message commented in the admin footer.
372
- *
373
- * @since 0.1.2
374
- */
375
- public function debug_info() {
376
-
377
- $error = $this->error;
378
-
379
- echo "<!-- RDN Debug Info: $error -->";
380
-
381
- }
382
-
383
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cwp_comment.php CHANGED
@@ -1,195 +1,157 @@
1
- <?php
2
-
3
- if( cwppos('cwppos_show_userreview') == "yes" ) :
4
-
5
- add_action( 'comment_form_logged_in_after', 'cwp_additional_fields' );
6
-
7
- add_action( 'comment_form_after_fields', 'cwp_additional_fields' );
8
-
9
- add_filter('comment_text', "cwp_pac_comment_single");
10
-
11
- add_action ('comment_post', 'cwp_add_comment_meta_values', 1);
12
-
13
- else:
14
-
15
-
16
-
17
- remove_action( 'comment_form_logged_in_after', 'cwp_additional_fields' );
18
-
19
- remove_action( 'comment_form_after_fields', 'cwp_additional_fields' );
20
-
21
- remove_filter('comment_text', "cwp_pac_comment_single");
22
-
23
- remove_action ('comment_post', 'cwp_add_comment_meta_values', 1);
24
-
25
- endif ;
26
-
27
-
28
-
29
- function cwp_pac_comment_single($text){
30
-
31
- global $post;
32
-
33
- global $comment;
34
-
35
- $return = '';
36
-
37
-
38
-
39
-
40
-
41
- for ($i=1; $i <=cwppos("cwppos_option_nr") ; $i++) {
42
-
43
- $post_options[$i] = get_post_meta($post->ID, "option_{$i}_content", true);
44
-
45
- $comment_meta_options["comment-meta-option-{$i}"] = get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true);
46
-
47
- }
48
-
49
- $filtered_post_options = array_filter($comment_meta_options);
50
-
51
-
52
-
53
- if(!empty($filtered_post_options))
54
-
55
- {
56
-
57
-
58
-
59
- $return .= "<div class='user-comments-grades'>";
60
-
61
-
62
-
63
- $k = 1; // keep track
64
-
65
- foreach ($comment_meta_options as $comment_meta_option => $comment_meta_value)
66
-
67
- {
68
-
69
- if(!empty($comment_meta_value))
70
-
71
- {
72
-
73
- $comment_meta_score = $comment_meta_value * 10;
74
-
75
- $return .= "<div class='comment-meta-option'>
76
-
77
- <p class='comment-meta-option-name'>{$post_options[$k]}</p>
78
-
79
- <p class='comment-meta-option-grade'>$comment_meta_value</p>
80
-
81
- <div class='cwpr_clearfix'></div>
82
-
83
- <div class='comment-meta-grade-bar'>
84
-
85
- <div class='comment-meta-grade' style='width: {$comment_meta_score}%'></div>
86
-
87
- </div><!-- end .comment-meta-grade-bar -->
88
-
89
- </div><!-- end .comment-meta-option -->
90
-
91
- ";
92
-
93
- }
94
-
95
-
96
-
97
- $k++;
98
-
99
- }
100
-
101
-
102
-
103
- $return .= "</div><!-- end .user-comments-grades -->";
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
- }
112
-
113
-
114
-
115
- return $return.$text."<div class='cwpr_clearfix'></div>";
116
-
117
- }
118
-
119
- function cwp_additional_fields () {
120
- global $post;
121
- $is_review = get_post_meta($post->ID, "cwp_meta_box_check", true);
122
-
123
- if ($is_review=="Yes") {
124
-
125
-
126
- wp_enqueue_style( 'jqueryui', WPPR_URL.'/css/jquery-ui.css',array(),WPPR_LITE_VERSION );
127
- wp_enqueue_script("jquery-ui-slider");
128
-
129
-
130
- $meta_options = array();
131
-
132
-
133
- for ($i=1;$i<=cwppos("cwppos_option_nr");$i++) {
134
- $meta_options['meta_option_'.$i] = get_post_meta($post->ID, "option_".$i."_content", true);
135
-
136
- }
137
-
138
-
139
-
140
- foreach ($meta_options as $k => $value) {
141
-
142
- if($meta_options[$k]=='') {
143
-
144
- unset($meta_options[$k]);
145
-
146
- }
147
-
148
- }
149
-
150
- $sliders = array();
151
-
152
- foreach ($meta_options as $k => $value) {
153
-
154
- $sliders[] =
155
-
156
- "<div class='comment-form-meta-option'>
157
-
158
- <label for='$k'>$meta_options[$k]</label>
159
-
160
- <input type='text' id='$k' class='meta_option_input' value='' name='$k' readonly='readonly'>
161
-
162
- <div class='comment_meta_slider'></div>
163
-
164
- <div class='cwpr_clearfix'></div>
165
-
166
- </div>";
167
-
168
- }
169
-
170
- echo "<div id='cwp-slider-comment'>".implode("",$sliders)."<div class='cwpr_clearfix'></div></div>";
171
- }
172
-
173
- }
174
-
175
-
176
-
177
- function cwp_add_comment_meta_values($comment_id)
178
-
179
- {
180
- for ($i=1;$i<=cwppos("cwppos_option_nr");$i++) {
181
-
182
- if(isset($_POST['meta_option_'.$i])) {
183
-
184
- ${'meta_option_'.$i} = wp_filter_nohtml_kses($_POST['meta_option_'.$i]);
185
-
186
- add_comment_meta($comment_id, 'meta_option_'.$i, ${'meta_option_'.$i}, false);
187
-
188
- }
189
-
190
- }
191
-
192
-
193
- }
194
-
195
-
1
+ <?php
2
+
3
+ if ( cwppos( 'cwppos_show_userreview' ) == 'yes' ) :
4
+
5
+ add_action( 'comment_form_logged_in_after', 'cwp_additional_fields' );
6
+
7
+ add_action( 'comment_form_after_fields', 'cwp_additional_fields' );
8
+
9
+ add_filter( 'comment_text', 'cwp_pac_comment_single' );
10
+
11
+ add_action( 'comment_post', 'cwp_add_comment_meta_values', 1 );
12
+
13
+ else :
14
+
15
+
16
+
17
+ remove_action( 'comment_form_logged_in_after', 'cwp_additional_fields' );
18
+
19
+ remove_action( 'comment_form_after_fields', 'cwp_additional_fields' );
20
+
21
+ remove_filter( 'comment_text', 'cwp_pac_comment_single' );
22
+
23
+ remove_action( 'comment_post', 'cwp_add_comment_meta_values', 1 );
24
+
25
+ endif ;
26
+
27
+
28
+
29
+ function cwp_pac_comment_single( $text ) {
30
+
31
+ global $post;
32
+
33
+ global $comment;
34
+
35
+ $return = '';
36
+
37
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i++ ) {
38
+
39
+ $post_options[ $i ] = get_post_meta( $post->ID, "option_{$i}_content", true );
40
+
41
+ $comment_meta_options[ "comment-meta-option-{$i}" ] = get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true );
42
+
43
+ }
44
+
45
+ $filtered_post_options = array_filter( $comment_meta_options );
46
+
47
+ if ( ! empty( $filtered_post_options ) ) {
48
+
49
+ $return .= "<div class='user-comments-grades'>";
50
+
51
+ $k = 1; // keep track
52
+
53
+ foreach ( $comment_meta_options as $comment_meta_option => $comment_meta_value ) {
54
+
55
+ if ( ! empty( $comment_meta_value ) ) {
56
+
57
+ $comment_meta_score = $comment_meta_value * 10;
58
+
59
+ $return .= "<div class='comment-meta-option'>
60
+
61
+ <p class='comment-meta-option-name'>{$post_options[$k]}</p>
62
+
63
+ <p class='comment-meta-option-grade'>$comment_meta_value</p>
64
+
65
+ <div class='cwpr_clearfix'></div>
66
+
67
+ <div class='comment-meta-grade-bar'>
68
+
69
+ <div class='comment-meta-grade' style='width: {$comment_meta_score}%'></div>
70
+
71
+ </div><!-- end .comment-meta-grade-bar -->
72
+
73
+ </div><!-- end .comment-meta-option -->
74
+
75
+ ";
76
+
77
+ }
78
+
79
+ $k++;
80
+
81
+ }
82
+
83
+ $return .= '</div><!-- end .user-comments-grades -->';
84
+
85
+ }
86
+
87
+ return $return . $text . "<div class='cwpr_clearfix'></div>";
88
+
89
+ }
90
+
91
+ function cwp_additional_fields() {
92
+ global $post;
93
+ $is_review = get_post_meta( $post->ID, 'cwp_meta_box_check', true );
94
+
95
+ if ( $is_review == 'Yes' ) {
96
+
97
+ wp_enqueue_style( 'jqueryui', WPPR_URL . '/css/jquery-ui.css',array(),WPPR_LITE_VERSION );
98
+ wp_enqueue_script( 'jquery-ui-slider' );
99
+
100
+ $meta_options = array();
101
+
102
+ for ( $i = 1;$i <= cwppos( 'cwppos_option_nr' );$i++ ) {
103
+ $meta_options[ 'meta_option_' . $i ] = get_post_meta( $post->ID, 'option_' . $i . '_content', true );
104
+
105
+ }
106
+
107
+ foreach ( $meta_options as $k => $value ) {
108
+
109
+ if ( $meta_options[ $k ] == '' ) {
110
+
111
+ unset( $meta_options[ $k ] );
112
+
113
+ }
114
+ }
115
+
116
+ $sliders = array();
117
+
118
+ foreach ( $meta_options as $k => $value ) {
119
+
120
+ $sliders[] =
121
+
122
+ "<div class='comment-form-meta-option'>
123
+
124
+ <label for='$k'>$meta_options[$k]</label>
125
+
126
+ <input type='text' id='$k' class='meta_option_input' value='' name='$k' readonly='readonly'>
127
+
128
+ <div class='comment_meta_slider'></div>
129
+
130
+ <div class='cwpr_clearfix'></div>
131
+
132
+ </div>";
133
+
134
+ }
135
+
136
+ echo "<div id='cwp-slider-comment'>" . implode( '',$sliders ) . "<div class='cwpr_clearfix'></div></div>";
137
+ }
138
+
139
+ }
140
+
141
+
142
+
143
+ function cwp_add_comment_meta_values( $comment_id ) {
144
+ for ( $i = 1;$i <= cwppos( 'cwppos_option_nr' );$i++ ) {
145
+
146
+ if ( isset( $_POST[ 'meta_option_' . $i ] ) ) {
147
+
148
+ ${'meta_option_' . $i} = wp_filter_nohtml_kses( $_POST[ 'meta_option_' . $i ] );
149
+
150
+ add_comment_meta( $comment_id, 'meta_option_' . $i, ${'meta_option_' . $i}, false );
151
+
152
+ }
153
+ }
154
+
155
+ }
156
+
157
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cwp_frontpage.php CHANGED
@@ -1 +1,20 @@
1
- <?php
2
  global $post;
3
  $cwp_review_stored_meta = get_post_meta($post->ID);
4
  $return_string = cwppos_show_review();
5
  global $page;
6
  if(@$cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' && (is_single() || is_page()) && $page === 1 ) {
7
  if(cwppos("cwppos_show_reviewbox") == 'yes') return $content.$return_string;
8
  if(cwppos("cwppos_show_reviewbox") == 'no') return $return_string.$content;
9
  return $content;
10
  }
11
  else
12
  return $content;
13
  add_filter('the_content', 'cwp_pac_before_content');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  global $post;
2
  $cwp_review_stored_meta = get_post_meta($post->ID);
3
  $return_string = cwppos_show_review();
4
  global $page;
5
  if(@$cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' && (is_single() || is_page()) && $page === 1 ) {
6
  if(cwppos("cwppos_show_reviewbox") == 'yes') return $content.$return_string;
7
  if(cwppos("cwppos_show_reviewbox") == 'no') return $return_string.$content;
8
  return $content;
9
  }
10
  else
11
  return $content;
12
  add_filter('the_content', 'cwp_pac_before_content');
13
+ <?php
14
+ function cwp_pac_before_content( $content ) {
15
+ global $post;
16
+ $cwp_review_stored_meta = get_post_meta( $post->ID );
17
+ $return_string = cwppos_show_review();
18
+
19
+ global $page;
20
+ if ( isset( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) && $cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' && (is_single() || is_page()) && $page === 1 ) {
21
+ if ( cwppos( 'cwppos_show_reviewbox' ) == 'yes' ) { return $content . $return_string; }
22
+ if ( cwppos( 'cwppos_show_reviewbox' ) == 'no' ) { return $return_string . $content; }
23
+ return $content;
24
+ } else {
25
+ return $content; }
26
+ }
27
+
28
+ $currentTheme = wp_get_theme();
29
+ if ( $currentTheme->get( 'Name' ) !== 'Bookrev' && $currentTheme->get( 'Name' ) !== 'Book Rev Lite' ) {
30
+
31
+ add_filter( 'the_content', 'cwp_pac_before_content' );
32
+ }
inc/cwp_js_preloader.php CHANGED
@@ -3,179 +3,179 @@
3
  add_action( 'wp_ajax_cwp_load_preloader', 'cwp_load_preloader' );
4
 
5
  function cwp_load_preloader() {
6
- global $post;
7
-
8
- $args = array(
9
- 'offset' => 0,
10
- 'post_type' => array('any'),
11
- //'post__not_in' => array($post->ID),
12
- 'meta_query' => array(
13
- array(
14
- 'key' => 'cwp_meta_box_check',
15
- 'value' => 'Yes',
16
- ),
17
- ),
18
- );
19
-
20
- $cwp_query = new WP_Query($args);
21
- //var_dump($cwp_query);
22
- while ($cwp_query->have_posts()) : $cwp_query->the_post();
23
- //var_dump($post);
24
- $post_id = $post->ID;
25
- $preloaded_info = array();
26
- $preloaded_info[$post_id] = array();
27
-
28
- ?>
29
- <li class="cwp_preloaded_item cwpr_clearfix">
30
- <header>
31
-
32
- <h3 class="cwp_p_title"><?php the_title(); ?></h3>
33
- <button class="preload" title="Preload all details">&curarr;</button>
34
- </header>
35
- <?php
36
-
37
- for ($i=1; $i <=cwppos("cwppos_option_nr"); $i++) {
38
- $preloaded_info[$post_id]["option".$i] = array(
39
- "content" => get_post_meta($post->ID, "option_" . $i ."_content", true),
40
- "grade" => get_post_meta($post->ID, "option_" . $i ."_grade", true),
41
- "pro" => get_post_meta($post->ID, "cwp_option_". $i ."_pro", true),
42
- "cons" => get_post_meta($post->ID, "cwp_option_". $i ."_cons", true),
43
- );
44
- }
45
- //var_dump($preloaded_info);
46
- ?>
47
-
48
- <div class="cwp_pitem_info post_<?php echo $post_id; ?>">
49
- <ul class="cwp_pitem_options_content">
50
- <h4><?php _e("Options", "cwppos"); ?></h4>
51
- <?php
52
- for ($i=1; $i <= cwppos("cwppos_option_nr"); $i++) {
53
- $pinfo_temp = $preloaded_info[$post_id]["option". $i]['content'];
54
- if (!empty($pinfo_temp)) {
55
- echo "<li>" . $pinfo_temp. "</li>";
56
- } else {
57
- echo "<li>-</li>";
58
- }
59
- }
60
- ?>
61
- </ul><!-- end .cwp_pitem_options_content -->
62
-
63
- <ul class="cwp_pitem_options_pros">
64
- <h4><?php _e("Pros", "cwppos"); ?></h4>
65
- <?php
66
- for ($i=1; $i <=cwppos("cwppos_option_nr"); $i++) {
67
- $pinfo_temp = $preloaded_info[$post_id]["option". $i]['pro'];
68
- if (!empty($pinfo_temp)) {
69
- echo "<li>" . $pinfo_temp. "</li>";
70
- } else {
71
- echo "<li>-</li>";
72
- }
73
- }
74
- ?>
75
- </ul><!-- end .cwp_pitem_options_pros -->
76
-
77
- <ul class="cwp_pitem_options_cons">
78
- <h4><?php _e("Cons", "cwppos"); ?></h4>
79
- <?php
80
- for ($i=1; $i <=cwppos("cwppos_option_nr"); $i++) {
81
- $pinfo_temp = $preloaded_info[$post_id]["option". $i]['cons'];
82
- if (!empty($pinfo_temp)) {
83
- echo "<li>" . $pinfo_temp. "</li>";
84
- } else {
85
- echo "<li>-</li>";
86
- }
87
- }
88
- ?>
89
- </ul><!-- end .cwp_pitem_options_cons -->
90
- </div><!-- end .cwp_pitem_info -->
91
- </li><!-- end .cwp_preloaded_item -->
92
- <?php endwhile; wp_reset_postdata();
93
-
94
- die(); // this is required to terminate immediately and return a proper response
95
  }
96
 
97
- add_action('admin_footer','cwppos_js_preloader');
98
-
99
- function cwppos_js_preloader() {
100
- ?>
101
- <script type="text/javascript">
102
- jQuery(document).ready(function(){
103
- function cwpPreloadOptions(item) {
104
- for (var i = 1; i <= <?php echo cwppos("cwppos_option_nr");?>; i++) {
105
- var preloadListItem = jQuery(item).parent().parent().children(".cwp_pitem_info").children(".cwp_pitem_options_content").children("li:eq("+(i-1)+")").text();
106
- if(preloadListItem != "-") { jQuery("input#option_" + i + "_content").val(preloadListItem); }
107
- };
108
- }
109
-
110
- function cwpPreloadCons(item)
111
- {
112
- for (var i = 1; i <= <?php echo cwppos("cwppos_option_nr");?>; i++) {
113
- var preloadListItem = jQuery(item).parent().parent().children(".cwp_pitem_info").children(".cwp_pitem_options_pros").children("li:eq("+(i-1)+")").text();
114
- if(preloadListItem != "-") { jQuery("input#cwp_option_" + i + "_pro").val(preloadListItem); }
115
- };
116
- }
117
-
118
- function cwpPreloadPros(item)
119
- {
120
- for (var i = 1; i <= <?php echo cwppos("cwppos_option_nr");?>; i++) {
121
- var preloadListItem = jQuery(item).parent().parent().children(".cwp_pitem_info").children(".cwp_pitem_options_cons").children("li:eq("+(i-1)+")").text();
122
- if(preloadListItem != "-") { jQuery("input#cwp_option_" + i + "_cons").val(preloadListItem); }
123
- };
124
- }
125
-
126
- jQuery(".preload_info").click(function(e){
127
- e.preventDefault();
128
-
129
- var cwpThemeUrl = '<?php echo plugins_url( '', __FILE__ ); ?>';
130
- var ajaxLoad = "<img class='ajax_load_icon' src='" + cwpThemeUrl +"/images/ajaxload.gif' alt='Loading...'/>";
131
-
132
- jQuery("body #wpwrap").append("<div class='preload_result'><div class='preload_inner'><header><h2>Preload Info</h2><div class='preload_close'></div></header><div class='preloader_body'><ul class='preload_list'></ul></div></div></div>");
133
- jQuery(".preload_result").fadeIn();
134
-
135
- jQuery(".preload_close").bind("click", function(){
136
- jQuery(".preload_result").fadeOut();
137
- });
138
- jQuery(".preload_list").html(ajaxLoad);
139
-
140
- jQuery.get(ajaxurl,{'action':'cwp_load_preloader'},
141
- function(response){
142
- jQuery(".preload_list").html(response);
143
- });
144
-
145
- //jQuery(".preload_list").html(ajaxLoad).load(loadUrl);
146
-
147
-
148
- jQuery(".preload_list .cwp_p_title").live("click", function(){
149
- jQuery(this).parent().parent().children(".cwp_pitem_info").slideToggle();
150
- });
151
-
152
- jQuery(".preload_list li button.preload").live("click", function(){
153
- cwpPreloadOptions(this);
154
- cwpPreloadCons(this);
155
- cwpPreloadPros(this);
156
- jQuery(".preload_result").fadeOut();
157
- });
158
-
159
- jQuery(".preload_list .cwp_pitem_options_content li").live("click",function(){
160
- var plIndex = jQuery(this).index();
161
- var preloadListItem = jQuery(this).text();
162
- if(preloadListItem != "-") { jQuery("input#option_" + plIndex + "_content").val(preloadListItem); }
163
- });
164
-
165
- jQuery(".preload_list .cwp_pitem_options_pros li").live("click",function(){
166
- var plIndex = jQuery(this).index();
167
- var preloadListItem = jQuery(this).text();
168
- if(preloadListItem != "-") { jQuery("input#cwp_option_" + plIndex + "_pro").val(preloadListItem); }
169
- });
170
-
171
- jQuery(".preload_list .cwp_pitem_options_cons li").live("click",function(){
172
- var plIndex = jQuery(this).index();
173
- var preloadListItem = jQuery(this).text();
174
- if(preloadListItem != "-") { jQuery("input#cwp_option_" + plIndex + "_cons").val(preloadListItem); }
175
- });
176
-
177
- });
178
- });
179
- </script>
180
- <?php
181
- }
3
  add_action( 'wp_ajax_cwp_load_preloader', 'cwp_load_preloader' );
4
 
5
  function cwp_load_preloader() {
6
+ global $post;
7
+
8
+ $args = array(
9
+ 'offset' => 0,
10
+ 'post_type' => array( 'any' ),
11
+ // 'post__not_in' => array($post->ID),
12
+ 'meta_query' => array(
13
+ array(
14
+ 'key' => 'cwp_meta_box_check',
15
+ 'value' => 'Yes',
16
+ ),
17
+ ),
18
+ );
19
+
20
+ $cwp_query = new WP_Query( $args );
21
+ // var_dump($cwp_query);
22
+ while ( $cwp_query->have_posts() ) : $cwp_query->the_post();
23
+ // var_dump($post);
24
+ $post_id = $post->ID;
25
+ $preloaded_info = array();
26
+ $preloaded_info[ $post_id ] = array();
27
+
28
+ ?>
29
+ <li class="cwp_preloaded_item cwpr_clearfix">
30
+ <header>
31
+
32
+ <h3 class="cwp_p_title"><?php the_title(); ?></h3>
33
+ <button class="preload" title="Preload all details">&curarr;</button>
34
+ </header>
35
+ <?php
36
+
37
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i++ ) {
38
+ $preloaded_info[ $post_id ][ 'option' . $i ] = array(
39
+ 'content' => get_post_meta( $post->ID, 'option_' . $i . '_content', true ),
40
+ 'grade' => get_post_meta( $post->ID, 'option_' . $i . '_grade', true ),
41
+ 'pro' => get_post_meta( $post->ID, 'cwp_option_' . $i . '_pro', true ),
42
+ 'cons' => get_post_meta( $post->ID, 'cwp_option_' . $i . '_cons', true ),
43
+ );
44
+ }
45
+ // var_dump($preloaded_info);
46
+ ?>
47
+
48
+ <div class="cwp_pitem_info post_<?php echo $post_id; ?>">
49
+ <ul class="cwp_pitem_options_content">
50
+ <h4><?php _e( 'Options', 'cwppos' ); ?></h4>
51
+ <?php
52
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i++ ) {
53
+ $pinfo_temp = $preloaded_info[ $post_id ][ 'option' . $i ]['content'];
54
+ if ( ! empty( $pinfo_temp ) ) {
55
+ echo '<li>' . $pinfo_temp . '</li>';
56
+ } else {
57
+ echo '<li>-</li>';
58
+ }
59
+ }
60
+ ?>
61
+ </ul><!-- end .cwp_pitem_options_content -->
62
+
63
+ <ul class="cwp_pitem_options_pros">
64
+ <h4><?php _e( 'Pros', 'cwppos' ); ?></h4>
65
+ <?php
66
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i++ ) {
67
+ $pinfo_temp = $preloaded_info[ $post_id ][ 'option' . $i ]['pro'];
68
+ if ( ! empty( $pinfo_temp ) ) {
69
+ echo '<li>' . $pinfo_temp . '</li>';
70
+ } else {
71
+ echo '<li>-</li>';
72
+ }
73
+ }
74
+ ?>
75
+ </ul><!-- end .cwp_pitem_options_pros -->
76
+
77
+ <ul class="cwp_pitem_options_cons">
78
+ <h4><?php _e( 'Cons', 'cwppos' ); ?></h4>
79
+ <?php
80
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i++ ) {
81
+ $pinfo_temp = $preloaded_info[ $post_id ][ 'option' . $i ]['cons'];
82
+ if ( ! empty( $pinfo_temp ) ) {
83
+ echo '<li>' . $pinfo_temp . '</li>';
84
+ } else {
85
+ echo '<li>-</li>';
86
+ }
87
+ }
88
+ ?>
89
+ </ul><!-- end .cwp_pitem_options_cons -->
90
+ </div><!-- end .cwp_pitem_info -->
91
+ </li><!-- end .cwp_preloaded_item -->
92
+ <?php endwhile; wp_reset_postdata();
93
+
94
+ die(); // this is required to terminate immediately and return a proper response
95
  }
96
 
97
+ add_action( 'admin_footer','cwppos_js_preloader' );
98
+
99
+ function cwppos_js_preloader() {
100
+ ?>
101
+ <script type="text/javascript">
102
+ jQuery(document).ready(function(){
103
+ function cwpPreloadOptions(item) {
104
+ for (var i = 1; i <= <?php echo cwppos( 'cwppos_option_nr' );?>; i++) {
105
+ var preloadListItem = jQuery(item).parent().parent().children(".cwp_pitem_info").children(".cwp_pitem_options_content").children("li:eq("+(i-1)+")").text();
106
+ if(preloadListItem != "-") { jQuery("input#option_" + i + "_content").val(preloadListItem); }
107
+ };
108
+ }
109
+
110
+ function cwpPreloadCons(item)
111
+ {
112
+ for (var i = 1; i <= <?php echo cwppos( 'cwppos_option_nr' );?>; i++) {
113
+ var preloadListItem = jQuery(item).parent().parent().children(".cwp_pitem_info").children(".cwp_pitem_options_pros").children("li:eq("+(i-1)+")").text();
114
+ if(preloadListItem != "-") { jQuery("input#cwp_option_" + i + "_pro").val(preloadListItem); }
115
+ };
116
+ }
117
+
118
+ function cwpPreloadPros(item)
119
+ {
120
+ for (var i = 1; i <= <?php echo cwppos( 'cwppos_option_nr' );?>; i++) {
121
+ var preloadListItem = jQuery(item).parent().parent().children(".cwp_pitem_info").children(".cwp_pitem_options_cons").children("li:eq("+(i-1)+")").text();
122
+ if(preloadListItem != "-") { jQuery("input#cwp_option_" + i + "_cons").val(preloadListItem); }
123
+ };
124
+ }
125
+
126
+ jQuery(".preload_info").click(function(e){
127
+ e.preventDefault();
128
+
129
+ var cwpThemeUrl = '<?php echo plugins_url( '', __FILE__ ); ?>';
130
+ var ajaxLoad = "<img class='ajax_load_icon' src='" + cwpThemeUrl +"/images/ajaxload.gif' alt='Loading...'/>";
131
+
132
+ jQuery("body #wpwrap").append("<div class='preload_result'><div class='preload_inner'><header><h2>Preload Info</h2><div class='preload_close'></div></header><div class='preloader_body'><ul class='preload_list'></ul></div></div></div>");
133
+ jQuery(".preload_result").fadeIn();
134
+
135
+ jQuery(".preload_close").bind("click", function(){
136
+ jQuery(".preload_result").fadeOut();
137
+ });
138
+ jQuery(".preload_list").html(ajaxLoad);
139
+
140
+ jQuery.get(ajaxurl,{'action':'cwp_load_preloader'},
141
+ function(response){
142
+ jQuery(".preload_list").html(response);
143
+ });
144
+
145
+ //jQuery(".preload_list").html(ajaxLoad).load(loadUrl);
146
+
147
+
148
+ jQuery(".preload_list .cwp_p_title").live("click", function(){
149
+ jQuery(this).parent().parent().children(".cwp_pitem_info").slideToggle();
150
+ });
151
+
152
+ jQuery(".preload_list li button.preload").live("click", function(){
153
+ cwpPreloadOptions(this);
154
+ cwpPreloadCons(this);
155
+ cwpPreloadPros(this);
156
+ jQuery(".preload_result").fadeOut();
157
+ });
158
+
159
+ jQuery(".preload_list .cwp_pitem_options_content li").live("click",function(){
160
+ var plIndex = jQuery(this).index();
161
+ var preloadListItem = jQuery(this).text();
162
+ if(preloadListItem != "-") { jQuery("input#option_" + plIndex + "_content").val(preloadListItem); }
163
+ });
164
+
165
+ jQuery(".preload_list .cwp_pitem_options_pros li").live("click",function(){
166
+ var plIndex = jQuery(this).index();
167
+ var preloadListItem = jQuery(this).text();
168
+ if(preloadListItem != "-") { jQuery("input#cwp_option_" + plIndex + "_pro").val(preloadListItem); }
169
+ });
170
+
171
+ jQuery(".preload_list .cwp_pitem_options_cons li").live("click",function(){
172
+ var plIndex = jQuery(this).index();
173
+ var preloadListItem = jQuery(this).text();
174
+ if(preloadListItem != "-") { jQuery("input#cwp_option_" + plIndex + "_cons").val(preloadListItem); }
175
+ });
176
+
177
+ });
178
+ });
179
+ </script>
180
+ <?php
181
+ }
inc/cwp_latest_products_widget.php CHANGED
@@ -7,84 +7,69 @@
7
 
8
  class cwp_latest_products_widget extends WP_Widget {
9
 
10
- const RESTRICT_TITLE_CHARS = 100;
11
 
12
- function __construct() {
13
 
14
- parent::__construct(
15
 
16
- 'cwp_latest_products_widget',
17
-
18
- __('CWP Latest Products Widget', 'cwppos'),
19
-
20
-
21
-
22
- // Widget description
23
-
24
- array( 'description' => __( 'This widget displays the latest products based on their rating.', 'cwppos' ), )
25
-
26
- );
27
-
28
-
29
-
30
- }
31
 
32
- public function assets(){
33
 
 
34
 
35
- wp_enqueue_style( 'cwp-pac-widget-stylesheet', WPPR_URL.'/css/cwppos-widget.css' );
36
- wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL.'/javascript/main.js',array("jquery",'pie-chart'),WPPR_LITE_VERSION,true );
37
- wp_enqueue_script( 'pie-chart', WPPR_URL.'/javascript/pie-chart.js',array("jquery"), WPPR_LITE_VERSION,true );
38
 
39
- // Added by Ash/Upwork
40
- wp_enqueue_style( 'cwp-widget-stylesheet1', WPPR_URL.'/css/cwppos-widget-style1.css' );
41
- wp_enqueue_style( 'cwp-widget-rating', WPPR_URL.'/css/cwppos-widget-rating.css' );
42
- // Added by Ash/Upwork
43
- }
44
 
45
  public function widget( $args, $instance ) {
46
  $this->assets();
47
- if ( isset( $instance[ 'title' ]) )
48
 
49
- $title = apply_filters( 'widget_title', $instance['title'] );
50
 
51
- if ( isset( $instance[ 'no_items' ]) )
52
 
53
- $no_items = apply_filters( 'widget_content', $instance['no_items'] );
54
 
55
- if ( isset( $instance[ 'cwp_tp_category' ]) )
56
 
57
- $cwp_tp_category = apply_filters( 'widget_content', $instance['cwp_tp_category'] );
58
 
59
- if ( isset( $instance[ 'title_type' ]) )
60
 
61
- $post_type = apply_filters( 'widget_content', $instance['title_type'] );
62
-
63
- if ( isset( $instance[ 'show_image' ]) )
64
-
65
- $show_image = apply_filters( 'widget_content', $instance['show_image'] );
66
 
 
67
 
 
68
 
69
  // before and after widget arguments are defined by themes
70
-
71
- //echo "<div id='cwp_latest_products_widget'>";
72
-
73
  echo $args['before_widget'];
74
 
75
- if ( ! empty( $title ) )
76
 
77
- echo $args['before_title'] . $title . $args['after_title'];
78
-
79
-
80
- if ( $cwp_tp_category=="All") $cwp_tp_category="";
81
- // Loop to get the most popular posts, ordered by the author's final grade.
82
 
 
 
83
  $query_args = array(
84
 
85
- 'posts_per_page'=> $no_items, // limit it to the specified no of posts
86
- 'post_type' => "any",
87
- 'post__not_in' => get_option('sticky_posts'),
88
  'category_name' => $cwp_tp_category, // limit it to the specified category
89
  'meta_key' => 'option_overall_score',
90
 
@@ -96,146 +81,128 @@ array( 'description' => __( 'This widget displays the latest products based on t
96
 
97
  'value' => 'Yes',
98
 
99
-
100
- ),
101
 
102
  ),
103
  'orderby' => 'date',
104
- 'order' => 'DESC'
105
 
106
  );
107
 
108
-
109
-
110
  $cwp_products_loop = new WP_Query( $query_args );
111
 
112
- // Added by Ash/Upwork
113
- if ( !isset( $instance[ 'cwp_tp_buynow' ]) ) {
114
- $instance[ 'cwp_tp_buynow' ] = __("Buy Now", "cwppos");
115
- }
116
-
117
- if ( !isset( $instance[ 'cwp_tp_readreview' ]) ) {
118
- $instance[ 'cwp_tp_readreview' ] = __("Read Review", "cwppos");
119
- }
120
 
121
- if ( !isset( $instance[ 'cwp_tp_layout' ]) ) {
122
- $instance[ 'cwp_tp_layout' ] = "default.php";
123
- }
124
 
125
- if ( !isset( $instance[ 'cwp_tp_rating_type' ]) ) {
126
- $instance[ 'cwp_tp_rating_type' ] = "round";
127
- }
128
 
129
- include trailingslashit(dirname(__FILE__)) . "/widget-layouts/" . $instance['cwp_tp_layout'];
130
- // Added by Ash/Upwork
 
131
 
 
 
132
  echo $args['after_widget'];
133
 
134
- //echo "</div>"; // end #cwp_latest_products_widget
135
-
136
  }
137
 
138
 
139
 
140
  // Widget Backend
141
-
142
- // Added by Ash/Upwork
143
- public function adminAssets(){
144
- if(is_admin()){
145
- wp_enqueue_style( 'cwp-widget-admin-css', WPPR_URL.'/css/cwppos-widget-admin.css' );
146
-
147
- wp_register_script('cwp-widget-script-latest', WPPR_URL.'/javascript/widget-latest.js');
148
- wp_localize_script("cwp-widget-script-latest", "cwpw_latest", array(
149
- "widgetName" => $this->id_base,
150
- "imageCheckbox" => $this->get_field_id( 'show_image' ),
151
- "ratingSelect" => $this->get_field_id( 'cwp_tp_rating_type' )
152
- ));
153
- wp_enqueue_script('cwp-widget-script-latest');
154
- }
155
- }
156
- // Added by Ash/Upwork
157
-
158
  public function form( $instance ) {
159
 
160
- // Added by Ash/Upwork
161
- $this->adminAssets();
162
- // Added by Ash/Upwork
 
163
 
164
- if ( isset( $instance[ 'title' ] ) ) {
165
-
166
- $title = $instance[ 'title' ];
167
- }
168
- else {
169
  $title = __( 'Latest Products', 'cwppos' );
170
  }
171
- if ( isset( $instance[ 'no_items' ]) ) {
172
- $no_items = $instance[ 'no_items' ];
173
- }
174
- else {
175
- $no_items = __( '10', 'cwppos');
176
- }
177
- if ( isset( $instance[ 'cwp_tp_category' ]) ) {
178
- $cwp_tp_category = $instance[ 'cwp_tp_category' ];}
179
- else {
180
- $cwp_tp_category = "Select Category";
181
- }
182
- if ( isset( $instance[ 'title_type' ]) ) {
183
- $title_type = $instance[ 'title_type' ];
184
-
185
- }
186
- else {
187
- $title_type = false;
188
- }
189
-
190
- if ( isset( $instance[ 'show_image' ]) ) {
191
- $show_image = $instance[ 'show_image' ];
192
-
193
  }
194
- else {
195
- $show_image = false;
196
- }
197
-
198
- // Added by Ash/Upwork
199
- $cwp_tp_buynow = __("Buy Now", "cwppos");
200
- if ( isset( $instance[ 'cwp_tp_buynow' ]) ) {
201
- $cwp_tp_buynow = $instance[ 'cwp_tp_buynow' ];
202
- }
203
-
204
- $cwp_tp_readreview = __("Read Review", "cwppos");
205
- if ( isset( $instance[ 'cwp_tp_readreview' ]) ) {
206
- $cwp_tp_readreview = $instance[ 'cwp_tp_readreview' ];
207
- }
208
-
209
- $cwp_tp_layout = "default.php";
210
- if ( isset( $instance[ 'cwp_tp_layout' ]) ) {
211
- $cwp_tp_layout = $instance[ 'cwp_tp_layout' ];
212
- }
213
-
214
- if($cwp_tp_layout == "default.php"){
215
- $cwp_tp_rating_type = "round";
216
- }else{
217
- $cwp_tp_rating_type = "star";
218
- }
219
- // Added by Ash/Upwork
220
-
221
 
222
- $cwp_tp_categ_array = get_categories('hide_empty=0');
223
-
224
- foreach ($cwp_tp_categ_array as $categs) {
225
 
226
- $cwp_tp_all_categories[$categs->slug] = $categs->name;
 
227
 
228
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
 
230
 
 
231
 
232
- // Widget admin form
233
 
 
234
  ?>
235
 
236
  <p>
237
 
238
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', "cwppos" ); ?></label>
239
 
240
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
241
 
@@ -245,7 +212,7 @@ array( 'description' => __( 'This widget displays the latest products based on t
245
 
246
  <p>
247
 
248
- <label for="<?php echo $this->get_field_id( 'no_items' ); ?>"><?php _e( 'Number of posts to show:', "cwppos" ); ?></label>
249
 
250
  <input id="<?php echo $this->get_field_id( 'no_items' ); ?>" name="<?php echo $this->get_field_name( 'no_items' ); ?>" size="3" type="text" value="<?php echo esc_attr( $no_items ); ?>" />
251
 
@@ -257,26 +224,26 @@ array( 'description' => __( 'This widget displays the latest products based on t
257
 
258
  <?php $cwp_tp_selected_categ = esc_attr( $cwp_tp_category ); ?>
259
 
260
- <label for="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>"><?php _e( 'Category:', "cwppos" ); ?></label>
261
 
262
  <select id="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_category' ); ?>">
263
- <?php echo "<option>All</option>"; ?>
264
 
265
- <?php foreach ($cwp_tp_all_categories as $categ_slug => $categ_name): ?>
266
 
267
- <?php if($categ_slug == $cwp_tp_selected_categ) {
268
 
269
- echo "<option selected>".$categ_slug."</option>";
270
 
271
- } elseif($categ_slug == "") {
272
 
273
- echo "<option>There are no categs</select>";
274
 
275
- } else {
276
 
277
- echo "<option>".$categ_slug."</option>";
278
 
279
- } ?>
280
 
281
  <?php endforeach; ?>
282
 
@@ -284,37 +251,37 @@ array( 'description' => __( 'This widget displays the latest products based on t
284
 
285
  </p>
286
 
287
- <?php // Added by Ash/Upwork ?>
288
 
289
  <p>
290
 
291
  <?php $cwp_tp_layout = esc_attr( $cwp_tp_layout ); ?>
292
 
293
- <label for="<?php echo $this->get_field_id( 'cwp_tp_layout' ); ?>"><?php _e( 'Layout:', "cwppos" ); ?></label>
294
-
295
- <?php
296
-
297
- $layouts = array();
298
- $customLayoutFiles = glob(trailingslashit(dirname(__FILE__)) . "widget-layouts/*.php");
299
- foreach($customLayoutFiles as $file){
300
- $layouts[basename($file)] = ucwords(basename($file, ".php"));
301
- }
302
-
303
- foreach ($layouts as $key => $val):
304
- $extra = "";
305
- if($key == $cwp_tp_layout) $extra = "checked";
306
-
307
- $styleName = strtolower(str_replace(" ", "", $val));
308
- $id = $this->get_field_id($styleName);
309
- ?>
310
- <br>
311
- <input type="radio" name="<?php echo $this->get_field_name( 'cwp_tp_layout' ); ?>" value="<?php echo $key;?>" id="<?php echo $id."style"?>" <?php echo $extra;?> class="wppr-stylestyle"><label for="<?php echo $id."style";?>" class="wppr-stylestyle"><?php echo $val;?></label>
312
- <span class="wppr-styleimg" id="<?php echo $id."style"?>img">
313
- <img src="<?php echo WPPR_URL . "/assets/".$styleName. ".png";?>">
314
- </span>
315
- <?php
316
  endforeach;
317
- ?>
318
 
319
  </p>
320
 
@@ -322,7 +289,7 @@ array( 'description' => __( 'This widget displays the latest products based on t
322
 
323
  <?php $cwp_tp_buynow = esc_attr( $cwp_tp_buynow ); ?>
324
 
325
- <label for="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>"><?php _e( 'Buy Now text:', "cwppos" ); ?></label>
326
 
327
  <input id="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_buynow' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_buynow; ?>" />
328
 
@@ -332,24 +299,24 @@ array( 'description' => __( 'This widget displays the latest products based on t
332
 
333
  <?php $cwp_tp_readreview = esc_attr( $cwp_tp_readreview ); ?>
334
 
335
- <label for="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>"><?php _e( 'Read Review text:', "cwppos" ); ?></label>
336
 
337
  <input id="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_readreview' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_readreview; ?>" />
338
 
339
  </p>
340
 
341
- <?php // Added by Ash/Upwork ?>
342
 
343
  <p>
344
 
345
- <label for="<?php echo $this->get_field_id( 'title_type' ); ?>"><?php _e( 'Display Product Titles :', "cwppos" ); ?></label>
346
 
347
  <input id="<?php echo $this->get_field_id( 'title_type' ); ?>" name="<?php echo $this->get_field_name( 'title_type' ); ?>" type="checkbox" <?php checked( $title_type ); ?> />
348
  </p>
349
 
350
  <p>
351
 
352
- <label for="<?php echo $this->get_field_id( 'show_image' ); ?>"><?php _e( 'Display Product Image :', "cwppos" ); ?></label>
353
 
354
  <input id="<?php echo $this->get_field_id( 'show_image' ); ?>" name="<?php echo $this->get_field_name( 'show_image' ); ?>" type="checkbox" <?php checked( $show_image ); ?> />
355
  </p>
@@ -360,7 +327,6 @@ array( 'description' => __( 'This widget displays the latest products based on t
360
 
361
 
362
  // Updating widget replacing old instances with new
363
-
364
  public function update( $new_instance, $old_instance ) {
365
 
366
  $instance = $old_instance;
@@ -374,13 +340,12 @@ array( 'description' => __( 'This widget displays the latest products based on t
374
  $instance['title_type'] = (bool) $new_instance['title_type'] ;
375
  $instance['show_image'] = (bool) $new_instance['show_image'] ;
376
 
377
- // Added by Ash/Upwork
378
- $instance['cwp_tp_buynow'] = ( ! empty( $new_instance['cwp_tp_buynow'] ) ) ? strip_tags( $new_instance['cwp_tp_buynow'] ) : '';
379
- $instance['cwp_tp_readreview'] = ( ! empty( $new_instance['cwp_tp_readreview'] ) ) ? strip_tags( $new_instance['cwp_tp_readreview'] ) : '';
380
- $instance['cwp_tp_layout'] = ( ! empty( $new_instance['cwp_tp_layout'] ) ) ? strip_tags( $new_instance['cwp_tp_layout'] ) : '';
381
- $instance['cwp_tp_rating_type'] = ( ! empty( $new_instance['cwp_tp_rating_type'] ) ) ? strip_tags( $new_instance['cwp_tp_rating_type'] ) : '';
382
- // Added by Ash/Upwork
383
-
384
  return $instance;
385
 
386
  }
@@ -394,7 +359,6 @@ array( 'description' => __( 'This widget displays the latest products based on t
394
 
395
 
396
  // Register and load the widget
397
-
398
  /**
399
  *
400
  */
7
 
8
  class cwp_latest_products_widget extends WP_Widget {
9
 
10
+ const RESTRICT_TITLE_CHARS = 100;
11
 
12
+ function __construct() {
13
 
14
+ parent::__construct(
15
 
16
+ 'cwp_latest_products_widget',
17
+ __( 'CWP Latest Products Widget', 'cwppos' ),
18
+ // Widget description
19
+ array( 'description' => __( 'This widget displays the latest products based on their rating.', 'cwppos' ) )
20
+ );
 
 
 
 
 
 
 
 
 
 
21
 
22
+ }
23
 
24
+ public function assets() {
25
 
26
+ wp_enqueue_style( 'cwp-pac-widget-stylesheet', WPPR_URL . '/css/cwppos-widget.css' );
27
+ wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL . '/javascript/main.js',array( 'jquery', 'pie-chart' ),WPPR_LITE_VERSION,true );
28
+ wp_enqueue_script( 'pie-chart', WPPR_URL . '/javascript/pie-chart.js',array( 'jquery' ), WPPR_LITE_VERSION,true );
29
 
30
+ // Added by Ash/Upwork
31
+ wp_enqueue_style( 'cwp-widget-stylesheet1', WPPR_URL . '/css/cwppos-widget-style1.css' );
32
+ wp_enqueue_style( 'cwp-widget-rating', WPPR_URL . '/css/cwppos-widget-rating.css' );
33
+ // Added by Ash/Upwork
34
+ }
35
 
36
  public function widget( $args, $instance ) {
37
  $this->assets();
38
+ if ( isset( $instance['title'] ) ) {
39
 
40
+ $title = apply_filters( 'widget_title', $instance['title'] ); }
41
 
42
+ if ( isset( $instance['no_items'] ) ) {
43
 
44
+ $no_items = apply_filters( 'widget_content', $instance['no_items'] ); }
45
 
46
+ if ( isset( $instance['cwp_tp_category'] ) ) {
47
 
48
+ $cwp_tp_category = apply_filters( 'widget_content', $instance['cwp_tp_category'] ); }
49
 
50
+ if ( isset( $instance['title_type'] ) ) {
51
 
52
+ $post_type = apply_filters( 'widget_content', $instance['title_type'] ); }
 
 
 
 
53
 
54
+ if ( isset( $instance['show_image'] ) ) {
55
 
56
+ $show_image = apply_filters( 'widget_content', $instance['show_image'] ); }
57
 
58
  // before and after widget arguments are defined by themes
59
+ // echo "<div id='cwp_latest_products_widget'>";
 
 
60
  echo $args['before_widget'];
61
 
62
+ if ( ! empty( $title ) ) {
63
 
64
+ echo $args['before_title'] . $title . $args['after_title']; }
 
 
 
 
65
 
66
+ if ( $cwp_tp_category == 'All' ) { $cwp_tp_category = ''; }
67
+ // Loop to get the most popular posts, ordered by the author's final grade.
68
  $query_args = array(
69
 
70
+ 'posts_per_page' => $no_items, // limit it to the specified no of posts
71
+ 'post_type' => 'any',
72
+ 'post__not_in' => get_option( 'sticky_posts' ),
73
  'category_name' => $cwp_tp_category, // limit it to the specified category
74
  'meta_key' => 'option_overall_score',
75
 
81
 
82
  'value' => 'Yes',
83
 
84
+ ),
 
85
 
86
  ),
87
  'orderby' => 'date',
88
+ 'order' => 'DESC',
89
 
90
  );
91
 
 
 
92
  $cwp_products_loop = new WP_Query( $query_args );
93
 
94
+ // Added by Ash/Upwork
95
+ if ( ! isset( $instance['cwp_tp_buynow'] ) ) {
96
+ $instance['cwp_tp_buynow'] = __( 'Buy Now', 'cwppos' );
97
+ }
 
 
 
 
98
 
99
+ if ( ! isset( $instance['cwp_tp_readreview'] ) ) {
100
+ $instance['cwp_tp_readreview'] = __( 'Read Review', 'cwppos' );
101
+ }
102
 
103
+ if ( ! isset( $instance['cwp_tp_layout'] ) ) {
104
+ $instance['cwp_tp_layout'] = 'default.php';
105
+ }
106
 
107
+ if ( ! isset( $instance['cwp_tp_rating_type'] ) ) {
108
+ $instance['cwp_tp_rating_type'] = 'round';
109
+ }
110
 
111
+ include trailingslashit( dirname( __FILE__ ) ) . '/widget-layouts/' . $instance['cwp_tp_layout'];
112
+ // Added by Ash/Upwork
113
  echo $args['after_widget'];
114
 
115
+ // echo "</div>"; // end #cwp_latest_products_widget
 
116
  }
117
 
118
 
119
 
120
  // Widget Backend
121
+ // Added by Ash/Upwork
122
+ public function adminAssets() {
123
+ if ( is_admin() ) {
124
+ wp_enqueue_style( 'cwp-widget-admin-css', WPPR_URL . '/css/cwppos-widget-admin.css' );
125
+
126
+ wp_register_script( 'cwp-widget-script-latest', WPPR_URL . '/javascript/widget-latest.js' );
127
+ wp_localize_script('cwp-widget-script-latest', 'cwpw_latest', array(
128
+ 'widgetName' => $this->id_base,
129
+ 'imageCheckbox' => $this->get_field_id( 'show_image' ),
130
+ 'ratingSelect' => $this->get_field_id( 'cwp_tp_rating_type' ),
131
+ ));
132
+ wp_enqueue_script( 'cwp-widget-script-latest' );
133
+ }
134
+ }
135
+ // Added by Ash/Upwork
 
 
136
  public function form( $instance ) {
137
 
138
+ // Added by Ash/Upwork
139
+ $this->adminAssets();
140
+ // Added by Ash/Upwork
141
+ if ( isset( $instance['title'] ) ) {
142
 
143
+ $title = $instance['title'];
144
+ } else {
 
 
 
145
  $title = __( 'Latest Products', 'cwppos' );
146
  }
147
+ if ( isset( $instance['no_items'] ) ) {
148
+ $no_items = $instance['no_items'];
149
+ } else {
150
+ $no_items = __( '10', 'cwppos' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
+ if ( isset( $instance['cwp_tp_category'] ) ) {
153
+ $cwp_tp_category = $instance['cwp_tp_category'];} else {
154
+ $cwp_tp_category = 'Select Category';
155
+ }
156
+ if ( isset( $instance['title_type'] ) ) {
157
+ $title_type = $instance['title_type'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
+ } else {
160
+ $title_type = false;
161
+ }
162
 
163
+ if ( isset( $instance['show_image'] ) ) {
164
+ $show_image = $instance['show_image'];
165
 
166
+ } else {
167
+ $show_image = false;
168
+ }
169
+
170
+ // Added by Ash/Upwork
171
+ $cwp_tp_buynow = __( 'Buy Now', 'cwppos' );
172
+ if ( isset( $instance['cwp_tp_buynow'] ) ) {
173
+ $cwp_tp_buynow = $instance['cwp_tp_buynow'];
174
+ }
175
+
176
+ $cwp_tp_readreview = __( 'Read Review', 'cwppos' );
177
+ if ( isset( $instance['cwp_tp_readreview'] ) ) {
178
+ $cwp_tp_readreview = $instance['cwp_tp_readreview'];
179
+ }
180
+
181
+ $cwp_tp_layout = 'default.php';
182
+ if ( isset( $instance['cwp_tp_layout'] ) ) {
183
+ $cwp_tp_layout = $instance['cwp_tp_layout'];
184
+ }
185
+
186
+ if ( $cwp_tp_layout == 'default.php' ) {
187
+ $cwp_tp_rating_type = 'round';
188
+ } else {
189
+ $cwp_tp_rating_type = 'star';
190
+ }
191
+ // Added by Ash/Upwork
192
+ $cwp_tp_categ_array = get_categories( 'hide_empty=0' );
193
 
194
+ foreach ( $cwp_tp_categ_array as $categs ) {
195
 
196
+ $cwp_tp_all_categories[ $categs->slug ] = $categs->name;
197
 
198
+ }
199
 
200
+ // Widget admin form
201
  ?>
202
 
203
  <p>
204
 
205
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'cwppos' ); ?></label>
206
 
207
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
208
 
212
 
213
  <p>
214
 
215
+ <label for="<?php echo $this->get_field_id( 'no_items' ); ?>"><?php _e( 'Number of posts to show:', 'cwppos' ); ?></label>
216
 
217
  <input id="<?php echo $this->get_field_id( 'no_items' ); ?>" name="<?php echo $this->get_field_name( 'no_items' ); ?>" size="3" type="text" value="<?php echo esc_attr( $no_items ); ?>" />
218
 
224
 
225
  <?php $cwp_tp_selected_categ = esc_attr( $cwp_tp_category ); ?>
226
 
227
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>"><?php _e( 'Category:', 'cwppos' ); ?></label>
228
 
229
  <select id="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_category' ); ?>">
230
+ <?php echo '<option>All</option>'; ?>
231
 
232
+ <?php foreach ( $cwp_tp_all_categories as $categ_slug => $categ_name ) : ?>
233
 
234
+ <?php if ( $categ_slug == $cwp_tp_selected_categ ) {
235
 
236
+ echo '<option selected>' . $categ_slug . '</option>';
237
 
238
+ } elseif ( $categ_slug == '' ) {
239
 
240
+ echo '<option>There are no categs</select>';
241
 
242
+ } else {
243
 
244
+ echo '<option>' . $categ_slug . '</option>';
245
 
246
+ } ?>
247
 
248
  <?php endforeach; ?>
249
 
251
 
252
  </p>
253
 
254
+ <?php // Added by Ash/Upwork ?>
255
 
256
  <p>
257
 
258
  <?php $cwp_tp_layout = esc_attr( $cwp_tp_layout ); ?>
259
 
260
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_layout' ); ?>"><?php _e( 'Layout:', 'cwppos' ); ?></label>
261
+
262
+ <?php
263
+
264
+ $layouts = array();
265
+ $customLayoutFiles = glob( trailingslashit( dirname( __FILE__ ) ) . 'widget-layouts/*.php' );
266
+ foreach ( $customLayoutFiles as $file ) {
267
+ $layouts[ basename( $file ) ] = ucwords( basename( $file, '.php' ) );
268
+ }
269
+
270
+ foreach ( $layouts as $key => $val ) :
271
+ $extra = '';
272
+ if ( $key == $cwp_tp_layout ) { $extra = 'checked'; }
273
+
274
+ $styleName = strtolower( str_replace( ' ', '', $val ) );
275
+ $id = $this->get_field_id( $styleName );
276
+ ?>
277
+ <br>
278
+ <input type="radio" name="<?php echo $this->get_field_name( 'cwp_tp_layout' ); ?>" value="<?php echo $key;?>" id="<?php echo $id . 'style'?>" <?php echo $extra;?> class="wppr-stylestyle"><label for="<?php echo $id . 'style';?>" class="wppr-stylestyle"><?php echo $val;?></label>
279
+ <span class="wppr-styleimg" id="<?php echo $id . 'style'?>img">
280
+ <img src="<?php echo WPPR_URL . '/assets/' . $styleName . '.png';?>">
281
+ </span>
282
+ <?php
283
  endforeach;
284
+ ?>
285
 
286
  </p>
287
 
289
 
290
  <?php $cwp_tp_buynow = esc_attr( $cwp_tp_buynow ); ?>
291
 
292
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>"><?php _e( 'Buy Now text:', 'cwppos' ); ?></label>
293
 
294
  <input id="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_buynow' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_buynow; ?>" />
295
 
299
 
300
  <?php $cwp_tp_readreview = esc_attr( $cwp_tp_readreview ); ?>
301
 
302
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>"><?php _e( 'Read Review text:', 'cwppos' ); ?></label>
303
 
304
  <input id="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_readreview' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_readreview; ?>" />
305
 
306
  </p>
307
 
308
+ <?php // Added by Ash/Upwork ?>
309
 
310
  <p>
311
 
312
+ <label for="<?php echo $this->get_field_id( 'title_type' ); ?>"><?php _e( 'Display Product Titles :', 'cwppos' ); ?></label>
313
 
314
  <input id="<?php echo $this->get_field_id( 'title_type' ); ?>" name="<?php echo $this->get_field_name( 'title_type' ); ?>" type="checkbox" <?php checked( $title_type ); ?> />
315
  </p>
316
 
317
  <p>
318
 
319
+ <label for="<?php echo $this->get_field_id( 'show_image' ); ?>"><?php _e( 'Display Product Image :', 'cwppos' ); ?></label>
320
 
321
  <input id="<?php echo $this->get_field_id( 'show_image' ); ?>" name="<?php echo $this->get_field_name( 'show_image' ); ?>" type="checkbox" <?php checked( $show_image ); ?> />
322
  </p>
327
 
328
 
329
  // Updating widget replacing old instances with new
 
330
  public function update( $new_instance, $old_instance ) {
331
 
332
  $instance = $old_instance;
340
  $instance['title_type'] = (bool) $new_instance['title_type'] ;
341
  $instance['show_image'] = (bool) $new_instance['show_image'] ;
342
 
343
+ // Added by Ash/Upwork
344
+ $instance['cwp_tp_buynow'] = ( ! empty( $new_instance['cwp_tp_buynow'] ) ) ? strip_tags( $new_instance['cwp_tp_buynow'] ) : '';
345
+ $instance['cwp_tp_readreview'] = ( ! empty( $new_instance['cwp_tp_readreview'] ) ) ? strip_tags( $new_instance['cwp_tp_readreview'] ) : '';
346
+ $instance['cwp_tp_layout'] = ( ! empty( $new_instance['cwp_tp_layout'] ) ) ? strip_tags( $new_instance['cwp_tp_layout'] ) : '';
347
+ $instance['cwp_tp_rating_type'] = ( ! empty( $new_instance['cwp_tp_rating_type'] ) ) ? strip_tags( $new_instance['cwp_tp_rating_type'] ) : '';
348
+ // Added by Ash/Upwork
 
349
  return $instance;
350
 
351
  }
359
 
360
 
361
  // Register and load the widget
 
362
  /**
363
  *
364
  */
inc/cwp_metabox.php CHANGED
@@ -1,369 +1,368 @@
1
- <?php
2
- function cwp_review_meta_boxes() {
3
- add_meta_box( 'cwp_review_meta_box', 'Product Review Extra Settings', 'cwp_review_meta_box_callback' );
4
- }
5
-
6
- /*
7
- * Function for rendering the review custom meta boxes.
8
- */
9
- function cwp_review_meta_box_callback( $post ) {
10
- wp_nonce_field( 'cwp_product_review_meta_box_nonce', 'cwp_meta_box_nonce' );
11
- $cwp_review_stored_meta = get_post_meta( $post->ID );
12
- $check = isset( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) ? esc_attr( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) : "No";
13
- $query_args = array(
14
- 'posts_per_page' => '1', // limit it to the specified no of posts
15
- 'post_type' => "any",
16
- 'post__not_in' => get_option( 'sticky_posts' ),
17
- 'meta_key' => 'option_overall_score',
18
- 'meta_query' => array(
19
- array(
20
- 'key' => 'cwp_meta_box_check',
21
- 'value' => 'Yes',
22
- ),
23
- ),
24
- 'orderby' => 'date',
25
- 'order' => 'DESC'
26
- );
27
- $cwp_latest_products_loop = get_posts( $query_args );
28
- foreach ( $cwp_latest_products_loop as $w_post ) : setup_postdata( $w_post );
29
- $wppr_id = $w_post->ID;
30
- endforeach;
31
- wp_reset_postdata();
32
- $p_meta = isset( $wppr_id ) ? get_post_meta( $wppr_id ) : array();
33
- if ( isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ) {
34
- $checkset = esc_attr( $cwp_review_stored_meta['cwp_image_link'][0] );
35
- } else {
36
- $checkset = isset( $p_meta['cwp_image_link'][0] ) ? esc_attr( $p_meta['cwp_image_link'][0] ) : "image";
37
-
38
- }
39
- //$checkset = isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ? ) : "image";
40
- ?>
41
- <p class="isReview<?php echo $check; ?>">
42
- <label for="my_meta_box_check">Is this a review post ? </label>
43
- <input type="radio" id="cwp_meta_box_check_yes" name="cwp_meta_box_check"
44
- value="Yes" <?php checked( $check, 'Yes' ); ?> />
45
- <label for="my_meta_box_check">Yes</label>
46
- <input type="radio" id="cwp_meta_box_check_no" name="cwp_meta_box_check"
47
- value="No" <?php checked( $check, 'No' ); ?> />
48
- <label for="my_meta_box_check" style="margin-right:30px;">No</label>
49
-
50
- </p>
51
- <div class="product-review-meta-<?php echo $check; ?>">
52
-
53
- <div class="review-settings-notice">
54
- <h4><?php _e( "Product Details", "cwppos" ); ?></h4>
55
- <p style="margin:0;"><?php _e( "Specify the general details for the reviewed product.", "cwppos" ); ?></p>
56
- </div><!-- end .review-settings-notice -->
57
- <div class="review-settings-group">
58
- <div class="review-settings-group-option">
59
- <ul>
60
- <?php
61
- // Added by Ash/Upwork
62
- do_action( "wppr-amazon-addfields", $cwp_review_stored_meta );
63
- // Added by Ash/Upwork
64
- ?>
65
-
66
- <li>
67
- <label for="cwp_rev_product_name"><?php _e( "Product Name", "cwppos" ); ?></label>
68
- <input type="text" name="cwp_rev_product_name" id="cwp_rev_product_name" value="<?php
69
- if ( isset( $cwp_review_stored_meta['cwp_rev_product_name'][0] ) ) {
70
- echo $cwp_review_stored_meta['cwp_rev_product_name'][0];
71
- }
72
- ?>"/>
73
- </li>
74
- <li>
75
- <label for="cwp_rev_product_image"
76
- class="cwp_rev_product_image-title"><?php _e( 'Product Image', 'cwp' ) ?></label>
77
- <input type="text" name="cwp_rev_product_image" id="cwp_rev_product_image"
78
- value="<?php if ( isset ( $cwp_review_stored_meta['cwp_rev_product_image'][0] ) ) {
79
- echo $cwp_review_stored_meta['cwp_rev_product_image'][0];
80
- } ?>"/>
81
- <input type="button" id="cwp_rev_product_image-button" class="button"
82
- value="<?php _e( 'Choose or Upload an Image', 'cwp' ) ?>"/>
83
- <p><?php _e( "*If no image is provided, featured image is used" ); ?>
84
- </li>
85
- <li class="cwp_image_link">
86
- <label for="cwp_image_link_aff">Product Image Click : </label>
87
- <input type="radio" id="cwp_image_link_aff" name="cwp_image_link"
88
- value="image" <?php checked( $checkset, 'image' ); ?> />
89
- <label for="cwp_image_link_image">Show Whole Image</label>
90
- <input type="radio" id="cwp_image_link_image" name="cwp_image_link"
91
- value="link" <?php checked( $checkset, 'link' ); ?> />
92
- <label for="my_meta_box_check">Open Affiliate link</label>
93
- </li>
94
- <li>
95
- <label
96
- for="cwp_product_affiliate_text"><?php _e( "Affiliate Button Text", "cwppos" ); ?></label>
97
- <input type="text" name="cwp_product_affiliate_text" id="cwp_product_affiliate_text"
98
- value="<?php
99
- if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_text'][0] ) ) {
100
- echo $cwp_review_stored_meta['cwp_product_affiliate_text'][0];
101
- } else {
102
- if ( isset( $p_meta['cwp_product_affiliate_text'][0] ) ) {
103
- echo $p_meta['cwp_product_affiliate_text'][0];
104
- }
105
- }
106
- ?>"/>
107
- </li>
108
- <li>
109
- <label for="cwp_product_affiliate_link"><?php _e( "Affiliate Link", "cwppos" ); ?></label>
110
- <input type="text" name="cwp_product_affiliate_link" id="cwp_product_affiliate_link"
111
- value="<?php
112
- if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_link'][0] ) ) {
113
- echo $cwp_review_stored_meta['cwp_product_affiliate_link'][0];
114
- }
115
- ?>"/>
116
- <span id="wppr_product_affiliate_link_upsell" style="display: none">&nbsp;</span>
117
- <?php
118
- $hide_button2 = false;
119
- if ( ! isset( $cwp_review_stored_meta['cwp_product_affiliate_text2'][0] ) ) {
120
- $hide_button2 = true;
121
- ?>
122
- <a href="#" id="cwp_add_button" title="Add new button">+</a>
123
- <?php } ?>
124
- </li>
125
-
126
- <li class="<?php if ( $hide_button2 ) {
127
- echo 'cwp_hide_button2';
128
- } ?>">
129
- <label
130
- for="cwp_product_affiliate_text2"><?php _e( "Affiliate Button Text 2", "cwppos" ); ?></label>
131
- <input type="text" name="cwp_product_affiliate_text2" id="cwp_product_affiliate_text2"
132
- value="<?php
133
- if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_text2'][0] ) ) {
134
- echo $cwp_review_stored_meta['cwp_product_affiliate_text2'][0];
135
- }
136
- ?>"/>
137
- </li>
138
- <li class="<?php if ( $hide_button2 ) {
139
- echo 'cwp_hide_button2';
140
- } ?>">
141
- <label for="cwp_product_affiliate_link2"><?php _e( "Affiliate Link 2", "cwppos" ); ?></label>
142
- <input type="text" name="cwp_product_affiliate_link2" id="cwp_product_affiliate_link2"
143
- value="<?php
144
- if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_link2'][0] ) ) {
145
- echo $cwp_review_stored_meta['cwp_product_affiliate_link2'][0];
146
- }
147
- ?>"/>
148
- </li>
149
-
150
- <li>
151
- <label for="cwp_cwp_rev_price"><?php _e( "Product Price", "cwppos" ); ?></label>
152
- <input type="text" name="cwp_rev_price" id="cwp_rev_price" value="<?php
153
- if ( isset( $cwp_review_stored_meta['cwp_rev_price'][0] ) ) {
154
- echo $cwp_review_stored_meta['cwp_rev_price'][0];
155
- }
156
- ?>"/>
157
- </li>
158
-
159
- </ul>
160
- </div><!-- end .review-settings-group option -->
161
- </div><!-- end .review-settings group -->
162
- <div class="review-settings-notice">
163
- <h4><?php _e( "Product Options Setting", "cwppos" ); ?></h4>
164
- <?php _e( "Insert your options and their grades. Grading must be done <b><i>from 0 to 100</i></b>." );
165
- if ( cwppos( "cwppos_show_poweredby" ) === 'yes' || class_exists( 'CWP_PR_PRO_Core' ) || function_exists( 'wppr_ep_js_preloader' ) ) { ?>
166
- <a href="#" class="preload_info"><?php _e( "Preload Info", "cwppos" ); ?></a>
167
- <?php
168
- } else {
169
- $pageURL = admin_url( 'admin.php?page=cwppos_options#tab-upgrade_to_pro' );
170
- $pageURL = str_replace( ":80", "", $pageURL );
171
- echo apply_filters( WPPR_SLUG . "_" . "preloader" . "_upsell_text", "" );
172
- } ?>
173
- </div><!-- end .review-settings-notice -->
174
- <div class="review-settings-group">
175
- <?php
176
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) { ?>
177
- <div class="review-settings-group-option">
178
- <label for="option_<?php echo $i; ?>_content" class="option_label"><?php echo $i; ?></label>
179
- <input type="text" name="option_<?php echo $i; ?>_content" id="option_<?php echo $i; ?>_content"
180
- class="option_content" placeholder="Option <?php echo $i; ?>" value="<?php
181
- if ( isset( $cwp_review_stored_meta[ 'option_' . $i . '_content' ][0] ) ) {
182
- echo $cwp_review_stored_meta[ 'option_' . $i . '_content' ][0];
183
- } else {
184
- //Get latest modified post from the same category id
185
- if ( isset( $p_meta[ 'option_' . $i . '_content' ][0] ) ) {
186
- echo $p_meta[ 'option_' . $i . '_content' ][0];
187
- }
188
- }
189
- ?>"/>
190
- <input type="text" name="option_<?php echo $i; ?>_grade" class="option_grade" placeholder="Grade"
191
- value="<?php
192
- if ( isset( $cwp_review_stored_meta[ 'option_' . $i . '_grade' ][0] ) ) {
193
- echo $cwp_review_stored_meta[ 'option_' . $i . '_grade' ][0];
194
- }
195
- ?>"/>
196
- </div><!-- end .review-settings-group option -->
197
- <?php } ?>
198
-
199
- </div><!-- end .review-settings group -->
200
- <div class="cwp_proscons">
201
- <div class="review-settings-notice">
202
- <h4><?php _e( "Pro Features", "cwppos" ); ?></h4>
203
- <p style="margin:0;"><?php _e( "Insert product's pro features below.", "cwppos" ); ?></p>
204
- </div><!-- end .review-settings-notice -->
205
- <div class="review-settings-group">
206
- <?php for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) { ?>
207
-
208
- <div class="review-settings-group-option">
209
- <label for="cwp_option_<?php echo $i; ?>_pro" class="option_label"><?php echo $i; ?></label>
210
- <input type="text" name="cwp_option_<?php echo $i; ?>_pro" id="cwp_option_<?php echo $i; ?>_pro"
211
- class="option_content" placeholder="Option <?php echo $i; ?>" value="<?php
212
- if ( isset( $cwp_review_stored_meta[ 'cwp_option_' . $i . '_pro' ][0] ) ) {
213
- echo $cwp_review_stored_meta[ 'cwp_option_' . $i . '_pro' ][0];
214
- }
215
- ?>"/>
216
- </div><!-- end .review-settings-group option -->
217
- <?php } ?>
218
-
219
- </div><!-- end .review-settings group -->
220
- </div>
221
- <div class="cwp_proscons">
222
- <div class="review-settings-notice">
223
- <h4><?php _e( "Cons Features", "cwppos" ); ?></h4>
224
- <p style="margin:0;"><?php _e( "Insert product's cons features below.", "cwppos" ); ?></p>
225
- </div><!-- end .review-settings-notice -->
226
- <div class="review-settings-group">
227
- <?php for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) { ?>
228
-
229
- <div class="review-settings-group-option">
230
- <label for="cwp_option_<?php echo $i; ?>_cons" class="option_label"><?php echo $i; ?></label>
231
- <input type="text" name="cwp_option_<?php echo $i; ?>_cons"
232
- id="cwp_option_<?php echo $i; ?>_cons" class="option_content"
233
- placeholder="Option <?php echo $i; ?>" value="<?php
234
- if ( isset( $cwp_review_stored_meta[ 'cwp_option_' . $i . '_cons' ][0] ) ) {
235
- echo $cwp_review_stored_meta[ 'cwp_option_' . $i . '_cons' ][0];
236
- }
237
- ?>"/>
238
- </div><!-- end .review-settings-group option -->
239
- <?php } ?>
240
-
241
- </div><!-- end .review-settings group -->
242
- </div>
243
- <?php if ( ! shortcode_exists( "P_REVIEW" ) ): ?>
244
- <label> You can use the shortcode <b>[P_REVIEW]</b> to show a review you already made or
245
- <b>[wpr_landing]</b> to display a comparision table of them. The shortcodes are available on the <a
246
- target="_blank" href="http://bit.ly/2bpKIlP">Pro Bundle</a><br/><br/></label>
247
- <?php endif; ?>
248
- </div>
249
- <?php
250
- }
251
-
252
- /**
253
- * Function for saving the review custom meta boxes.
254
- */
255
- function cwp_review_meta_boxes_save( $post_id ) {
256
- $is_autosave = wp_is_post_autosave( $post_id );
257
- $is_revision = wp_is_post_revision( $post_id );
258
- $is_valid_nonce = ( isset( $_POST['cwp_meta_box_nonce'] ) && wp_verify_nonce( $_POST['cwp_meta_box_nonce'], 'cwp_product_review_meta_box_nonce' ) ) ? 'true' :
259
- 'false';
260
- if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
261
- return;
262
- }
263
- // Added by Ash/Upwork
264
- do_action( "wppr-amazon-savefields", $post_id );
265
- // Added by Ash/Upwork
266
- // Moved from inside the if loop to here by Ash/Upwork
267
- if ( isset( $_POST['cwp_meta_box_check'] ) ) {
268
- update_post_meta( $post_id, 'cwp_meta_box_check', sanitize_text_field( $_POST['cwp_meta_box_check'] ) );
269
- }
270
- // Moved from inside the if loop to here by Ash/Upwork
271
- if ( isset( $_POST['cwp_meta_box_check'] ) && $_POST['cwp_meta_box_check'] == "Yes" ) {
272
- if ( isset( $_POST['cwp_rev_product_name'] ) ) {
273
- update_post_meta( $post_id, 'cwp_rev_product_name', sanitize_text_field( $_POST['cwp_rev_product_name'] ) );
274
- }
275
- if ( isset( $_POST['cwp_rev_price'] ) ) {
276
- update_post_meta( $post_id, 'cwp_rev_price', sanitize_text_field( $_POST['cwp_rev_price'] ) );
277
- }
278
- if ( isset( $_POST['cwp_image_link'] ) ) {
279
- update_post_meta( $post_id, 'cwp_image_link', sanitize_text_field( $_POST['cwp_image_link'] ) );
280
- }
281
- if ( isset( $_POST['cwp_product_affiliate_text'] ) ) {
282
- update_post_meta( $post_id, 'cwp_product_affiliate_text', sanitize_text_field( $_POST['cwp_product_affiliate_text'] ) );
283
- }
284
- if ( isset( $_POST['cwp_product_affiliate_link'] ) ) {
285
- update_post_meta( $post_id, 'cwp_product_affiliate_link', esc_url( $_POST['cwp_product_affiliate_link'] ) );
286
- }
287
- if ( isset( $_POST['cwp_product_affiliate_text2'] ) ) {
288
- update_post_meta( $post_id, 'cwp_product_affiliate_text2', sanitize_text_field( $_POST['cwp_product_affiliate_text2'] ) );
289
- }
290
- if ( isset( $_POST['cwp_product_affiliate_link2'] ) ) {
291
- update_post_meta( $post_id, 'cwp_product_affiliate_link2', esc_url( $_POST['cwp_product_affiliate_link2'] ) );
292
- }
293
- if ( ! empty( $_POST['cwp_bar_icon'] ) ) {
294
- update_post_meta( $post_id, 'cwp_bar_icon', esc_url( $_POST['cwp_bar_icon'] ) );
295
- } else {
296
- update_post_meta( $post_id, 'cwp_bar_icon', "" );
297
- }
298
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
299
- if ( isset( $_POST[ 'option_' . $i . '_content' ] ) ) {
300
- update_post_meta( $post_id, 'option_' . $i . '_content', sanitize_text_field( $_POST[ 'option_' . $i . '_content' ] ) );
301
- }
302
- if ( isset( $_POST[ 'option_' . $i . '_grade' ] ) ) {
303
- update_post_meta( $post_id, 'option_' . $i . '_grade', sanitize_text_field( $_POST[ 'option_' . $i . '_grade' ] ) );
304
- }
305
- }
306
- if ( isset( $_POST['cwp_rev_product_image'] ) ) {
307
- update_post_meta( $post_id, 'cwp_rev_product_image', sanitize_text_field( $_POST['cwp_rev_product_image'] ) );
308
- } elseif ( cwppos( "cwppos_show_poweredby" ) == 'yes' || class_exists( 'CWP_PR_PRO_Core' ) ) {
309
- $image = "";
310
- if ( strlen( $img = get_the_post_thumbnail( $post_id, array( 150, 150 ) ) ) ) :
311
- $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'optional-size' );
312
- $image = $image_array[0];
313
- else :
314
- $post = get_post( $post_id );
315
- $image = '';
316
- ob_start();
317
- ob_end_clean();
318
- $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
319
- //$image = $matches[1][0];
320
- endif;
321
- update_post_meta( $post_id, 'cwp_rev_product_image', $image );
322
- }
323
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
324
- if ( isset( $_POST[ 'cwp_option_' . $i . '_pro' ] ) ) {
325
- update_post_meta( $post_id, 'cwp_option_' . $i . '_pro', sanitize_text_field( $_POST[ 'cwp_option_' . $i . '_pro' ] ) );
326
- }
327
- if ( isset( $_POST[ 'cwp_option_' . $i . '_cons' ] ) ) {
328
- update_post_meta( $post_id, 'cwp_option_' . $i . '_cons', sanitize_text_field( $_POST[ 'cwp_option_' . $i . '_cons' ] ) );
329
- }
330
-
331
- }
332
- $overall_score = "";
333
- $iter = 0;
334
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
335
- ${"option" . $i . "_grade"} = get_post_meta( $post_id, "option_" . $i . "_grade", true );
336
- if ( ! empty( ${"option" . $i . "_grade"} ) || ${"option" . $i . "_grade"} === '0' ) {
337
- $overall_score += ${"option" . $i . "_grade"};
338
- $iter ++;
339
- }
340
- }
341
- if ( $iter == 0 ) {
342
- $overall_score = 0;
343
- } else {
344
- $overall_score = $overall_score / $iter;
345
- }
346
- update_post_meta( $post_id, 'option_overall_score', $overall_score / 10 );
347
- }
348
- }
349
-
350
- function cwp_review_plugin_activation() {
351
- if ( "yes" != get_option( 'cwp_review_activate' ) ) {
352
- add_option( 'cwp_review_activate', "yes" );
353
- update_option( 'cwp_review_activate', "yes" );
354
- $html = '<div class="updated">';
355
- $html .= '<p>';
356
- $html .= __( 'In order to use the WP Product Review plugin, go on a edit a post and set : <strong>Is this a review to yes</strong>.', 'cwppos' );
357
- $html .= '</p>';
358
- $html .= '</div><!-- /.updated -->';
359
- echo $html;
360
-
361
- } // end if
362
- } // end plugin_activation
363
- /**
364
- * Hooks.
365
- */
366
- add_action( 'add_meta_boxes', 'cwp_review_meta_boxes' );
367
- add_action( 'save_post', 'cwp_review_meta_boxes_save' );
368
- add_action( "admin_notices", "cwp_review_plugin_activation" );
369
- ?>
1
+ <?php
2
+ function cwp_review_meta_boxes() {
3
+ add_meta_box( 'cwp_review_meta_box', 'Product Review Extra Settings', 'cwp_review_meta_box_callback' );
4
+ }
5
+
6
+ /*
7
+ * Function for rendering the review custom meta boxes.
8
+ */
9
+ function cwp_review_meta_box_callback( $post ) {
10
+ wp_nonce_field( 'cwp_product_review_meta_box_nonce', 'cwp_meta_box_nonce' );
11
+ $cwp_review_stored_meta = get_post_meta( $post->ID );
12
+ $check = isset( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) ? esc_attr( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) : 'No';
13
+ $query_args = array(
14
+ 'posts_per_page' => '1', // limit it to the specified no of posts
15
+ 'post_type' => 'any',
16
+ 'post__not_in' => get_option( 'sticky_posts' ),
17
+ 'meta_key' => 'option_overall_score',
18
+ 'meta_query' => array(
19
+ array(
20
+ 'key' => 'cwp_meta_box_check',
21
+ 'value' => 'Yes',
22
+ ),
23
+ ),
24
+ 'orderby' => 'date',
25
+ 'order' => 'DESC',
26
+ );
27
+ $cwp_latest_products_loop = get_posts( $query_args );
28
+ foreach ( $cwp_latest_products_loop as $w_post ) : setup_postdata( $w_post );
29
+ $wppr_id = $w_post->ID;
30
+ endforeach;
31
+ wp_reset_postdata();
32
+ $p_meta = isset( $wppr_id ) ? get_post_meta( $wppr_id ) : array();
33
+ if ( isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ) {
34
+ $checkset = esc_attr( $cwp_review_stored_meta['cwp_image_link'][0] );
35
+ } else {
36
+ $checkset = isset( $p_meta['cwp_image_link'][0] ) ? esc_attr( $p_meta['cwp_image_link'][0] ) : 'image';
37
+
38
+ }
39
+ // $checkset = isset( $cwp_review_stored_meta['cwp_image_link'][0] ) ? ) : "image";
40
+ ?>
41
+ <p class="isReview<?php echo $check; ?>">
42
+ <label for="my_meta_box_check">Is this a review post ? </label>
43
+ <input type="radio" id="cwp_meta_box_check_yes" name="cwp_meta_box_check"
44
+ value="Yes" <?php checked( $check, 'Yes' ); ?> />
45
+ <label for="my_meta_box_check">Yes</label>
46
+ <input type="radio" id="cwp_meta_box_check_no" name="cwp_meta_box_check"
47
+ value="No" <?php checked( $check, 'No' ); ?> />
48
+ <label for="my_meta_box_check" style="margin-right:30px;">No</label>
49
+
50
+ </p>
51
+ <div class="product-review-meta-<?php echo $check; ?>">
52
+
53
+ <div class="review-settings-notice">
54
+ <h4><?php _e( 'Product Details', 'cwppos' ); ?></h4>
55
+ <p style="margin:0;"><?php _e( 'Specify the general details for the reviewed product.', 'cwppos' ); ?></p>
56
+ </div><!-- end .review-settings-notice -->
57
+ <div class="review-settings-group">
58
+ <div class="review-settings-group-option">
59
+ <ul>
60
+ <?php
61
+ // Added by Ash/Upwork
62
+ do_action( 'wppr-amazon-addfields', $cwp_review_stored_meta );
63
+ // Added by Ash/Upwork
64
+ ?>
65
+
66
+ <li>
67
+ <label for="cwp_rev_product_name"><?php _e( 'Product Name', 'cwppos' ); ?></label>
68
+ <input type="text" name="cwp_rev_product_name" id="cwp_rev_product_name" value="<?php
69
+ if ( isset( $cwp_review_stored_meta['cwp_rev_product_name'][0] ) ) {
70
+ echo $cwp_review_stored_meta['cwp_rev_product_name'][0];
71
+ }
72
+ ?>"/>
73
+ </li>
74
+ <li>
75
+ <label for="cwp_rev_product_image"
76
+ class="cwp_rev_product_image-title"><?php _e( 'Product Image', 'cwppos' ) ?></label>
77
+ <input type="text" name="cwp_rev_product_image" id="cwp_rev_product_image"
78
+ value="<?php if ( isset( $cwp_review_stored_meta['cwp_rev_product_image'][0] ) ) {
79
+ echo $cwp_review_stored_meta['cwp_rev_product_image'][0];
80
+ } ?>"/>
81
+ <input type="button" id="cwp_rev_product_image-button" class="button"
82
+ value="<?php _e( 'Choose or Upload an Image', 'cwppos' ) ?>"/>
83
+ <p><?php _e( '*If no image is provided, featured image is used','cwppos' ); ?>
84
+ </li>
85
+ <li class="cwp_image_link">
86
+ <label for="cwp_image_link_aff">Product Image Click : </label>
87
+ <input type="radio" id="cwp_image_link_aff" name="cwp_image_link"
88
+ value="image" <?php checked( $checkset, 'image' ); ?> />
89
+ <label for="cwp_image_link_image">Show Whole Image</label>
90
+ <input type="radio" id="cwp_image_link_image" name="cwp_image_link"
91
+ value="link" <?php checked( $checkset, 'link' ); ?> />
92
+ <label for="my_meta_box_check">Open Affiliate link</label>
93
+ </li>
94
+ <li>
95
+ <label
96
+ for="cwp_product_affiliate_text"><?php _e( 'Affiliate Button Text', 'cwppos' ); ?></label>
97
+ <input type="text" name="cwp_product_affiliate_text" id="cwp_product_affiliate_text"
98
+ value="<?php
99
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_text'][0] ) ) {
100
+ echo $cwp_review_stored_meta['cwp_product_affiliate_text'][0];
101
+ } else {
102
+ if ( isset( $p_meta['cwp_product_affiliate_text'][0] ) ) {
103
+ echo $p_meta['cwp_product_affiliate_text'][0];
104
+ }
105
+ }
106
+ ?>"/>
107
+ </li>
108
+ <li>
109
+ <label for="cwp_product_affiliate_link"><?php _e( 'Affiliate Link', 'cwppos' ); ?></label>
110
+ <input type="text" name="cwp_product_affiliate_link" id="cwp_product_affiliate_link"
111
+ value="<?php
112
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_link'][0] ) ) {
113
+ echo $cwp_review_stored_meta['cwp_product_affiliate_link'][0];
114
+ }
115
+ ?>"/>
116
+ <span id="wppr_product_affiliate_link_upsell" style="display: none">&nbsp;</span>
117
+ <?php
118
+ $hide_button2 = false;
119
+ if ( ! isset( $cwp_review_stored_meta['cwp_product_affiliate_text2'][0] ) ) {
120
+ $hide_button2 = true;
121
+ ?>
122
+ <a href="#" id="cwp_add_button" title="Add new button">+</a>
123
+ <?php } ?>
124
+ </li>
125
+
126
+ <li class="<?php if ( $hide_button2 ) {
127
+ echo 'cwp_hide_button2';
128
+ } ?>">
129
+ <label
130
+ for="cwp_product_affiliate_text2"><?php _e( 'Affiliate Button Text 2', 'cwppos' ); ?></label>
131
+ <input type="text" name="cwp_product_affiliate_text2" id="cwp_product_affiliate_text2"
132
+ value="<?php
133
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_text2'][0] ) ) {
134
+ echo $cwp_review_stored_meta['cwp_product_affiliate_text2'][0];
135
+ }
136
+ ?>"/>
137
+ </li>
138
+ <li class="<?php if ( $hide_button2 ) {
139
+ echo 'cwp_hide_button2';
140
+ } ?>">
141
+ <label for="cwp_product_affiliate_link2"><?php _e( 'Affiliate Link 2', 'cwppos' ); ?></label>
142
+ <input type="text" name="cwp_product_affiliate_link2" id="cwp_product_affiliate_link2"
143
+ value="<?php
144
+ if ( isset( $cwp_review_stored_meta['cwp_product_affiliate_link2'][0] ) ) {
145
+ echo $cwp_review_stored_meta['cwp_product_affiliate_link2'][0];
146
+ }
147
+ ?>"/>
148
+ </li>
149
+
150
+ <li>
151
+ <label for="cwp_cwp_rev_price"><?php _e( 'Product Price', 'cwppos' ); ?></label>
152
+ <input type="text" name="cwp_rev_price" id="cwp_rev_price" value="<?php
153
+ if ( isset( $cwp_review_stored_meta['cwp_rev_price'][0] ) ) {
154
+ echo $cwp_review_stored_meta['cwp_rev_price'][0];
155
+ }
156
+ ?>"/>
157
+ </li>
158
+
159
+ </ul>
160
+ </div><!-- end .review-settings-group option -->
161
+ </div><!-- end .review-settings group -->
162
+ <div class="review-settings-notice">
163
+ <h4><?php _e( 'Product Options Setting', 'cwppos' ); ?></h4>
164
+ <?php _e( 'Insert your options and their grades. Grading must be done <b><i>from 0 to 100</i></b>.','cwppos' );
165
+ if ( cwppos( 'cwppos_show_poweredby' ) === 'yes' || class_exists( 'CWP_PR_PRO_Core' ) || function_exists( 'wppr_ep_js_preloader' ) ) { ?>
166
+ <a href="#" class="preload_info"><?php _e( 'Preload Info', 'cwppos' ); ?></a>
167
+ <?php
168
+ } else {
169
+ $pageURL = admin_url( 'admin.php?page=cwppos_options#tab-upgrade_to_pro' );
170
+ $pageURL = str_replace( ':80', '', $pageURL );
171
+ echo apply_filters( WPPR_SLUG . '_' . 'preloader' . '_upsell_text', '' );
172
+ } ?>
173
+ </div><!-- end .review-settings-notice -->
174
+ <div class="review-settings-group">
175
+ <?php
176
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) { ?>
177
+ <div class="review-settings-group-option">
178
+ <label for="option_<?php echo $i; ?>_content" class="option_label"><?php echo $i; ?></label>
179
+ <input type="text" name="option_<?php echo $i; ?>_content" id="option_<?php echo $i; ?>_content"
180
+ class="option_content" placeholder="Option <?php echo $i; ?>" value="<?php
181
+ if ( isset( $cwp_review_stored_meta[ 'option_' . $i . '_content' ][0] ) ) {
182
+ echo $cwp_review_stored_meta[ 'option_' . $i . '_content' ][0];
183
+ } else {
184
+ // Get latest modified post from the same category id
185
+ if ( isset( $p_meta[ 'option_' . $i . '_content' ][0] ) ) {
186
+ echo $p_meta[ 'option_' . $i . '_content' ][0];
187
+ }
188
+ }
189
+ ?>"/>
190
+ <input type="text" name="option_<?php echo $i; ?>_grade" class="option_grade" placeholder="Grade"
191
+ value="<?php
192
+ if ( isset( $cwp_review_stored_meta[ 'option_' . $i . '_grade' ][0] ) ) {
193
+ echo $cwp_review_stored_meta[ 'option_' . $i . '_grade' ][0];
194
+ }
195
+ ?>"/>
196
+ </div><!-- end .review-settings-group option -->
197
+ <?php } ?>
198
+
199
+ </div><!-- end .review-settings group -->
200
+ <div class="cwp_proscons">
201
+ <div class="review-settings-notice">
202
+ <h4><?php _e( 'Pro Features', 'cwppos' ); ?></h4>
203
+ <p style="margin:0;"><?php _e( "Insert product's pro features below.", 'cwppos' ); ?></p>
204
+ </div><!-- end .review-settings-notice -->
205
+ <div class="review-settings-group">
206
+ <?php for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) { ?>
207
+
208
+ <div class="review-settings-group-option">
209
+ <label for="cwp_option_<?php echo $i; ?>_pro" class="option_label"><?php echo $i; ?></label>
210
+ <input type="text" name="cwp_option_<?php echo $i; ?>_pro" id="cwp_option_<?php echo $i; ?>_pro"
211
+ class="option_content" placeholder="Option <?php echo $i; ?>" value="<?php
212
+ if ( isset( $cwp_review_stored_meta[ 'cwp_option_' . $i . '_pro' ][0] ) ) {
213
+ echo $cwp_review_stored_meta[ 'cwp_option_' . $i . '_pro' ][0];
214
+ }
215
+ ?>"/>
216
+ </div><!-- end .review-settings-group option -->
217
+ <?php } ?>
218
+
219
+ </div><!-- end .review-settings group -->
220
+ </div>
221
+ <div class="cwp_proscons">
222
+ <div class="review-settings-notice">
223
+ <h4><?php _e( 'Cons Features', 'cwppos' ); ?></h4>
224
+ <p style="margin:0;"><?php _e( "Insert product's cons features below.", 'cwppos' ); ?></p>
225
+ </div><!-- end .review-settings-notice -->
226
+ <div class="review-settings-group">
227
+ <?php for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) { ?>
228
+
229
+ <div class="review-settings-group-option">
230
+ <label for="cwp_option_<?php echo $i; ?>_cons" class="option_label"><?php echo $i; ?></label>
231
+ <input type="text" name="cwp_option_<?php echo $i; ?>_cons"
232
+ id="cwp_option_<?php echo $i; ?>_cons" class="option_content"
233
+ placeholder="Option <?php echo $i; ?>" value="<?php
234
+ if ( isset( $cwp_review_stored_meta[ 'cwp_option_' . $i . '_cons' ][0] ) ) {
235
+ echo $cwp_review_stored_meta[ 'cwp_option_' . $i . '_cons' ][0];
236
+ }
237
+ ?>"/>
238
+ </div><!-- end .review-settings-group option -->
239
+ <?php } ?>
240
+
241
+ </div><!-- end .review-settings group -->
242
+ </div>
243
+ <?php if ( ! shortcode_exists( 'P_REVIEW' ) ) : ?>
244
+ <label> You can use the shortcode <b>[P_REVIEW]</b> to show a review you already made or
245
+ <b>[wpr_landing]</b> to display a comparision table of them. The shortcodes are available on the <a
246
+ target="_blank" href="http://bit.ly/2bpKIlP">Pro Bundle</a><br/><br/></label>
247
+ <?php endif; ?>
248
+ </div>
249
+ <?php
250
+ }
251
+
252
+ /**
253
+ * Function for saving the review custom meta boxes.
254
+ */
255
+ function cwp_review_meta_boxes_save( $post_id ) {
256
+ $is_autosave = wp_is_post_autosave( $post_id );
257
+ $is_revision = wp_is_post_revision( $post_id );
258
+ $is_valid_nonce = ( isset( $_POST['cwp_meta_box_nonce'] ) && wp_verify_nonce( $_POST['cwp_meta_box_nonce'], 'cwp_product_review_meta_box_nonce' ) ) ? 'true' :
259
+ 'false';
260
+ if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
261
+ return;
262
+ }
263
+ // Added by Ash/Upwork
264
+ do_action( 'wppr-amazon-savefields', $post_id );
265
+ // Added by Ash/Upwork
266
+ // Moved from inside the if loop to here by Ash/Upwork
267
+ if ( isset( $_POST['cwp_meta_box_check'] ) ) {
268
+ update_post_meta( $post_id, 'cwp_meta_box_check', sanitize_text_field( $_POST['cwp_meta_box_check'] ) );
269
+ }
270
+ // Moved from inside the if loop to here by Ash/Upwork
271
+ if ( isset( $_POST['cwp_meta_box_check'] ) && $_POST['cwp_meta_box_check'] == 'Yes' ) {
272
+ if ( isset( $_POST['cwp_rev_product_name'] ) ) {
273
+ update_post_meta( $post_id, 'cwp_rev_product_name', apply_filters( 'wppr_sanitize_product_title', $_POST['cwp_rev_product_name'] ) );
274
+ }
275
+ if ( isset( $_POST['cwp_rev_price'] ) ) {
276
+ update_post_meta( $post_id, 'cwp_rev_price', apply_filters( 'wppr_sanitize_product_price', $_POST['cwp_rev_price'] ) );
277
+ }
278
+ if ( isset( $_POST['cwp_image_link'] ) ) {
279
+ update_post_meta( $post_id, 'cwp_image_link', apply_filters( 'wppr_sanitize_product_image', $_POST['cwp_image_link'] ) );
280
+ }
281
+ if ( isset( $_POST['cwp_product_affiliate_text'] ) ) {
282
+ update_post_meta( $post_id, 'cwp_product_affiliate_text', sanitize_text_field( $_POST['cwp_product_affiliate_text'] ) );
283
+ }
284
+ if ( isset( $_POST['cwp_product_affiliate_link'] ) ) {
285
+ update_post_meta( $post_id, 'cwp_product_affiliate_link', apply_filters( 'wppr_sanitize_link1', $_POST['cwp_product_affiliate_link'] ) );
286
+ }
287
+ if ( isset( $_POST['cwp_product_affiliate_text2'] ) ) {
288
+ update_post_meta( $post_id, 'cwp_product_affiliate_text2', sanitize_text_field( $_POST['cwp_product_affiliate_text2'] ) );
289
+ }
290
+ if ( isset( $_POST['cwp_product_affiliate_link2'] ) ) {
291
+ update_post_meta( $post_id, 'cwp_product_affiliate_link2', apply_filters( 'wppr_sanitize_link2', $_POST['cwp_product_affiliate_link2'] ) );
292
+ }
293
+ if ( ! empty( $_POST['cwp_bar_icon'] ) ) {
294
+ update_post_meta( $post_id, 'cwp_bar_icon', esc_url( $_POST['cwp_bar_icon'] ) );
295
+ } else {
296
+ update_post_meta( $post_id, 'cwp_bar_icon', '' );
297
+ }
298
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
299
+ if ( isset( $_POST[ 'option_' . $i . '_content' ] ) ) {
300
+ update_post_meta( $post_id, 'option_' . $i . '_content', sanitize_text_field( $_POST[ 'option_' . $i . '_content' ] ) );
301
+ }
302
+ if ( isset( $_POST[ 'option_' . $i . '_grade' ] ) ) {
303
+ update_post_meta( $post_id, 'option_' . $i . '_grade', sanitize_text_field( $_POST[ 'option_' . $i . '_grade' ] ) );
304
+ }
305
+ }
306
+ if ( isset( $_POST['cwp_rev_product_image'] ) ) {
307
+ update_post_meta( $post_id, 'cwp_rev_product_image', sanitize_text_field( $_POST['cwp_rev_product_image'] ) );
308
+ } elseif ( cwppos( 'cwppos_show_poweredby' ) == 'yes' || class_exists( 'CWP_PR_PRO_Core' ) ) {
309
+ $image = '';
310
+ if ( strlen( $img = get_the_post_thumbnail( $post_id, array( 150, 150 ) ) ) ) :
311
+ $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'optional-size' );
312
+ $image = $image_array[0];
313
+ else :
314
+ $post = get_post( $post_id );
315
+ $image = '';
316
+ ob_start();
317
+ ob_end_clean();
318
+ $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
319
+ // $image = $matches[1][0];
320
+ endif;
321
+ update_post_meta( $post_id, 'cwp_rev_product_image', $image );
322
+ }
323
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
324
+ if ( isset( $_POST[ 'cwp_option_' . $i . '_pro' ] ) ) {
325
+ update_post_meta( $post_id, 'cwp_option_' . $i . '_pro', sanitize_text_field( $_POST[ 'cwp_option_' . $i . '_pro' ] ) );
326
+ }
327
+ if ( isset( $_POST[ 'cwp_option_' . $i . '_cons' ] ) ) {
328
+ update_post_meta( $post_id, 'cwp_option_' . $i . '_cons', sanitize_text_field( $_POST[ 'cwp_option_' . $i . '_cons' ] ) );
329
+ }
330
+ }
331
+ $overall_score = '';
332
+ $iter = 0;
333
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
334
+ ${'option' . $i . '_grade'} = get_post_meta( $post_id, 'option_' . $i . '_grade', true );
335
+ if ( ! empty( ${'option' . $i . '_grade'} ) || ${'option' . $i . '_grade'} === '0' ) {
336
+ $overall_score += ${'option' . $i . '_grade'};
337
+ $iter ++;
338
+ }
339
+ }
340
+ if ( $iter == 0 ) {
341
+ $overall_score = 0;
342
+ } else {
343
+ $overall_score = $overall_score / $iter;
344
+ }
345
+ update_post_meta( $post_id, 'option_overall_score', $overall_score / 10 );
346
+ }
347
+ }
348
+
349
+ function cwp_review_plugin_activation() {
350
+ if ( 'yes' != get_option( 'cwp_review_activate' ) ) {
351
+ add_option( 'cwp_review_activate', 'yes' );
352
+ update_option( 'cwp_review_activate', 'yes' );
353
+ $html = '<div class="updated">';
354
+ $html .= '<p>';
355
+ $html .= __( 'In order to use the WP Product Review plugin, go on a edit a post and set : <strong>Is this a review to yes</strong>.', 'cwppos' );
356
+ $html .= '</p>';
357
+ $html .= '</div><!-- /.updated -->';
358
+ echo $html;
359
+
360
+ } // end if
361
+ } // end plugin_activation
362
+ /**
363
+ * Hooks.
364
+ */
365
+ add_action( 'add_meta_boxes', 'cwp_review_meta_boxes' );
366
+ add_action( 'save_post', 'cwp_review_meta_boxes_save' );
367
+ add_action( 'admin_notices', 'cwp_review_plugin_activation' );
368
+ ?>
 
inc/cwp_top_products_widget.php CHANGED
@@ -1,402 +1,369 @@
1
- <?php
2
- /**
3
- * CWP - Top Producs Widget
4
- */
5
-
6
-
7
-
8
- class cwp_top_products_widget extends WP_Widget {
9
-
10
- const RESTRICT_TITLE_CHARS = 100;
11
-
12
- function __construct() {
13
-
14
- parent::__construct(
15
-
16
- 'cwp_top_products_widget',
17
-
18
- __('CWP Top Products Widget', 'cwppos'),
19
-
20
-
21
-
22
- // Widget description
23
-
24
- array( 'description' => __( 'This widget displays the top products based on their rating.', 'cwppos' ), )
25
-
26
- );
27
-
28
-
29
-
30
- }
31
-
32
-
33
- public function assets(){
34
-
35
- wp_enqueue_style( 'cwp-pac-widget-stylesheet', WPPR_URL.'/css/cwppos-widget.css' );
36
- wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL.'/javascript/main.js',array("jquery",'pie-chart'),WPPR_LITE_VERSION,true );
37
- wp_enqueue_script( 'pie-chart', WPPR_URL.'/javascript/pie-chart.js',array("jquery"), WPPR_LITE_VERSION,true );
38
-
39
- // Added by Ash/Upwork
40
- wp_enqueue_style( 'cwp-widget-stylesheet1', WPPR_URL.'/css/cwppos-widget-style1.css' );
41
- wp_enqueue_style( 'cwp-widget-rating', WPPR_URL.'/css/cwppos-widget-rating.css' );
42
- // Added by Ash/Upwork
43
- }
44
-
45
- // Added by Ash/Upwork
46
- public function adminAssets(){
47
- if(is_admin()){
48
- wp_enqueue_style( 'cwp-widget-admin-css', WPPR_URL.'/css/cwppos-widget-admin.css' );
49
-
50
- wp_register_script('cwp-widget-script-top', WPPR_URL.'/javascript/widget-top.js');
51
- wp_localize_script("cwp-widget-script-top", "cwpw_top", array(
52
- "widgetName" => $this->id_base,
53
- "imageCheckbox" => $this->get_field_id( 'show_image' ),
54
- "ratingSelect" => $this->get_field_id( 'cwp_tp_rating_type' )
55
- ));
56
- wp_enqueue_script('cwp-widget-script-top');
57
- }
58
- }
59
- // Added by Ash/Upwork
60
-
61
- public function custom_order_by($orderby){
62
-
63
- return 'mt1.meta_value DESC, mt2.meta_value+0 DESC';
64
- }
65
- public function widget( $args, $instance ) {
66
- $this->assets();
67
- if ( isset( $instance[ 'title' ]) )
68
-
69
- $title = apply_filters( 'widget_title', $instance['title'] );
70
-
71
- if ( isset( $instance[ 'no_items' ]) )
72
-
73
- $no_items = apply_filters( 'widget_content', $instance['no_items'] );
74
-
75
- if ( isset( $instance[ 'cwp_tp_category' ]) )
76
-
77
- $cwp_tp_category = apply_filters( 'widget_content', $instance['cwp_tp_category'] );
78
-
79
- if ( isset( $instance[ 'title_type' ]) )
80
-
81
- $post_type = apply_filters( 'widget_content', $instance['title_type'] );
82
-
83
- if ( isset( $instance[ 'show_image' ]) )
84
-
85
- $show_image = apply_filters( 'widget_content', $instance['show_image'] );
86
-
87
-
88
-
89
- // before and after widget arguments are defined by themes
90
-
91
- //echo "<div id='cwp_top_products_widget'>";
92
-
93
- echo $args['before_widget'];
94
-
95
- if ( ! empty( $title ) )
96
-
97
- echo $args['before_title'] . $title . $args['after_title'];
98
-
99
-
100
- if ( $cwp_tp_category=="All") $cwp_tp_category="";
101
- // Loop to get the most popular posts, ordered by the author's final grade.
102
-
103
- $query_args = array(
104
-
105
- 'posts_per_page'=> $no_items, // limit it to the specified no of posts
106
- 'post_type' => "any",
107
- 'post__not_in' => get_option('sticky_posts'),
108
- 'category_name' => $cwp_tp_category,
109
- 'meta_key'=> 'cwp_meta_box_check',
110
- 'meta_query' => array(
111
- array(
112
- 'key' => 'cwp_meta_box_check',
113
- 'value'=> 'Yes',
114
- ),
115
- array(
116
- 'key' => 'option_overall_score'
117
- ),
118
-
119
- )
120
- );
121
- add_filter('posts_orderby',array($this,'custom_order_by'));
122
- $cwp_products_loop = new WP_Query( $query_args );
123
- remove_filter('posts_orderby',array($this,'custom_order_by'));
124
- //echo $cwp_top_products_loop->request;
125
-
126
-
127
- // Added by Ash/Upwork
128
- if ( !isset( $instance[ 'cwp_tp_buynow' ]) ) {
129
- $instance[ 'cwp_tp_buynow' ] = __("Buy Now", "cwppos");
130
- }
131
-
132
- if ( !isset( $instance[ 'cwp_tp_readreview' ]) ) {
133
- $instance[ 'cwp_tp_readreview' ] = __("Read Review", "cwppos");
134
- }
135
-
136
- if ( !isset( $instance[ 'cwp_tp_layout' ]) ) {
137
- $instance[ 'cwp_tp_layout' ] = "default.php";
138
- }
139
-
140
- if ( !isset( $instance[ 'cwp_tp_rating_type' ]) ) {
141
- $instance[ 'cwp_tp_rating_type' ] = "round";
142
- }
143
-
144
- include trailingslashit(dirname(__FILE__)) . "/widget-layouts/" . $instance['cwp_tp_layout'];
145
- // Added by Ash/Upwork
146
-
147
- echo $args['after_widget'];
148
-
149
- //echo "</div>"; // end #cwp_top_products_widget
150
-
151
- }
152
-
153
-
154
-
155
- // Widget Backend
156
-
157
- public function form( $instance ) {
158
-
159
- // Added by Ash/Upwork
160
- $this->adminAssets();
161
- // Added by Ash/Upwork
162
-
163
- if ( isset( $instance[ 'title' ] ) ) {
164
-
165
- $title = $instance[ 'title' ];
166
- }
167
- else {
168
- $title = __( 'Top Products', 'cwppos' );
169
- }
170
- if ( isset( $instance[ 'no_items' ]) ) {
171
- $no_items = $instance[ 'no_items' ];
172
- }
173
- else {
174
- $no_items = __( '10', 'cwppos');
175
- }
176
- if ( isset( $instance[ 'cwp_tp_category' ]) ) {
177
- $cwp_tp_category = $instance[ 'cwp_tp_category' ];}
178
- else {
179
- $cwp_tp_category = "Select Category";
180
- }
181
- if ( isset( $instance[ 'title_type' ]) ) {
182
- $title_type = $instance[ 'title_type' ];
183
-
184
- }
185
- else {
186
- $title_type = false;
187
- }
188
-
189
- if ( isset( $instance[ 'show_image' ]) ) {
190
- $show_image = $instance[ 'show_image' ];
191
-
192
- }
193
- else {
194
- $show_image = false;
195
- }
196
-
197
-
198
- // Added by Ash/Upwork
199
- $cwp_tp_buynow = __("Buy Now", "cwppos");
200
- if ( isset( $instance[ 'cwp_tp_buynow' ]) ) {
201
- $cwp_tp_buynow = $instance[ 'cwp_tp_buynow' ];
202
- }
203
-
204
- $cwp_tp_readreview = __("Read Review", "cwppos");
205
- if ( isset( $instance[ 'cwp_tp_readreview' ]) ) {
206
- $cwp_tp_readreview = $instance[ 'cwp_tp_readreview' ];
207
- }
208
-
209
- $cwp_tp_layout = "default.php";
210
- if ( isset( $instance[ 'cwp_tp_layout' ]) ) {
211
- $cwp_tp_layout = $instance[ 'cwp_tp_layout' ];
212
- }
213
-
214
- if($cwp_tp_layout == "default.php"){
215
- $cwp_tp_rating_type = "round";
216
- }else{
217
- $cwp_tp_rating_type = "star";
218
- }
219
- // Added by Ash/Upwork
220
-
221
- $cwp_tp_categ_array = get_categories('hide_empty=0');
222
-
223
- foreach ($cwp_tp_categ_array as $categs) {
224
-
225
- $cwp_tp_all_categories[$categs->slug] = $categs->name;
226
-
227
- }
228
-
229
-
230
-
231
- // Widget admin form
232
-
233
- ?>
234
-
235
- <p>
236
-
237
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', "cwppos" ); ?></label>
238
-
239
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
240
-
241
- </p>
242
-
243
-
244
-
245
- <p>
246
-
247
- <label for="<?php echo $this->get_field_id( 'no_items' ); ?>"><?php _e( 'Number of posts to show:', "cwppos" ); ?></label>
248
-
249
- <input id="<?php echo $this->get_field_id( 'no_items' ); ?>" name="<?php echo $this->get_field_name( 'no_items' ); ?>" size="3" type="text" value="<?php echo esc_attr( $no_items ); ?>" />
250
-
251
- </p>
252
-
253
-
254
-
255
- <p>
256
-
257
- <?php $cwp_tp_selected_categ = esc_attr( $cwp_tp_category ); ?>
258
-
259
- <label for="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>"><?php _e( 'Category:', "cwppos" ); ?></label>
260
-
261
- <select id="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_category' ); ?>">
262
- <?php echo "<option>All</option>"; ?>
263
-
264
- <?php foreach ($cwp_tp_all_categories as $categ_slug => $categ_name): ?>
265
-
266
- <?php if($categ_slug == $cwp_tp_selected_categ) {
267
-
268
- echo "<option selected>".$categ_slug."</option>";
269
-
270
- } elseif($categ_slug == "") {
271
-
272
- echo "<option>There are no categs</select>";
273
-
274
- } else {
275
-
276
- echo "<option>".$categ_slug."</option>";
277
-
278
- } ?>
279
-
280
- <?php endforeach; ?>
281
-
282
- </select>
283
-
284
- </p>
285
-
286
- <?php // Added by Ash/Upwork ?>
287
-
288
- <p>
289
-
290
- <?php $cwp_tp_layout = esc_attr( $cwp_tp_layout ); ?>
291
-
292
- <label for="<?php echo $this->get_field_id( 'cwp_tp_layout' ); ?>"><?php _e( 'Layout:', "cwppos" ); ?></label>
293
-
294
- <?php
295
-
296
- $layouts = array();
297
- $customLayoutFiles = glob(trailingslashit(dirname(__FILE__)) . "widget-layouts/*.php");
298
- foreach($customLayoutFiles as $file){
299
- $layouts[basename($file)] = ucwords(basename($file, ".php"));
300
- }
301
-
302
- foreach ($layouts as $key => $val):
303
- $extra = "";
304
- if($key == $cwp_tp_layout) $extra = "checked";
305
-
306
- $styleName = strtolower(str_replace(" ", "", $val));
307
- $id = $this->get_field_id($styleName);
308
- ?>
309
- <br>
310
- <input type="radio" name="<?php echo $this->get_field_name( 'cwp_tp_layout' ); ?>" value="<?php echo $key;?>" id="<?php echo $id."style"?>" <?php echo $extra;?> class="wppr-stylestyle"><label for="<?php echo $id."style";?>" class="wppr-stylestyle"><?php echo $val;?></label>
311
- <span class="wppr-styleimg" id="<?php echo $id."style"?>img">
312
- <img src="<?php echo WPPR_URL . "/assets/".$styleName. ".png";?>">
313
- </span>
314
- <?php
315
- endforeach;
316
- ?>
317
-
318
- </p>
319
-
320
- <p class="wppr-customField" style="display: none">
321
-
322
- <?php $cwp_tp_buynow = esc_attr( $cwp_tp_buynow ); ?>
323
-
324
- <label for="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>"><?php _e( 'Buy Now text:', "cwppos" ); ?></label>
325
-
326
- <input id="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_buynow' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_buynow; ?>" />
327
-
328
- </p>
329
-
330
- <p class="wppr-customField" style="display: none">
331
-
332
- <?php $cwp_tp_readreview = esc_attr( $cwp_tp_readreview ); ?>
333
-
334
- <label for="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>"><?php _e( 'Read Review text:', "cwppos" ); ?></label>
335
-
336
- <input id="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_readreview' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_readreview; ?>" />
337
-
338
- </p>
339
-
340
- <?php // Added by Ash/Upwork ?>
341
-
342
- <p>
343
-
344
- <label for="<?php echo $this->get_field_id( 'title_type' ); ?>"><?php _e( 'Display Product Titles :', "cwppos" ); ?></label>
345
-
346
- <input id="<?php echo $this->get_field_id( 'title_type' ); ?>" name="<?php echo $this->get_field_name( 'title_type' ); ?>" type="checkbox" <?php checked( $title_type ); ?> />
347
- </p>
348
-
349
- <p>
350
-
351
- <label for="<?php echo $this->get_field_id( 'show_image' ); ?>"><?php _e( 'Display Product Image :', "cwppos" ); ?></label>
352
-
353
- <input id="<?php echo $this->get_field_id( 'show_image' ); ?>" name="<?php echo $this->get_field_name( 'show_image' ); ?>" type="checkbox" <?php checked( $show_image ); ?> />
354
- </p>
355
-
356
-
357
- <?php }
358
-
359
-
360
-
361
- // Updating widget replacing old instances with new
362
-
363
- public function update( $new_instance, $old_instance ) {
364
-
365
- $instance = $old_instance;
366
-
367
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
368
-
369
- $instance['no_items'] = ( ! empty( $new_instance['no_items'] ) ) ? strip_tags( $new_instance['no_items'] ) : '';
370
-
371
- $instance['cwp_tp_category'] = ( ! empty( $new_instance['cwp_tp_category'] ) ) ? strip_tags( $new_instance['cwp_tp_category'] ) : '';
372
-
373
- $instance['title_type'] = (bool) $new_instance['title_type'] ;
374
- $instance['show_image'] = (bool) $new_instance['show_image'] ;
375
-
376
- // Added by Ash/Upwork
377
- $instance['cwp_tp_buynow'] = ( ! empty( $new_instance['cwp_tp_buynow'] ) ) ? strip_tags( $new_instance['cwp_tp_buynow'] ) : '';
378
- $instance['cwp_tp_readreview'] = ( ! empty( $new_instance['cwp_tp_readreview'] ) ) ? strip_tags( $new_instance['cwp_tp_readreview'] ) : '';
379
- $instance['cwp_tp_layout'] = ( ! empty( $new_instance['cwp_tp_layout'] ) ) ? strip_tags( $new_instance['cwp_tp_layout'] ) : '';
380
- $instance['cwp_tp_rating_type'] = ( ! empty( $new_instance['cwp_tp_rating_type'] ) ) ? strip_tags( $new_instance['cwp_tp_rating_type'] ) : '';
381
- // Added by Ash/Upwork
382
- return $instance;
383
-
384
- }
385
-
386
-
387
-
388
- } // end Class cwp_top_products_widget
389
-
390
-
391
-
392
-
393
-
394
- // Register and load the widget
395
-
396
- function cwp_load_top_products_widget() {
397
-
398
- register_widget( 'cwp_top_products_widget' );
399
-
400
- }
401
-
402
- add_action( 'widgets_init', 'cwp_load_top_products_widget' );
1
+ <?php
2
+ /**
3
+ * CWP - Top Producs Widget
4
+ */
5
+
6
+
7
+
8
+ class cwp_top_products_widget extends WP_Widget {
9
+
10
+ const RESTRICT_TITLE_CHARS = 100;
11
+
12
+ function __construct() {
13
+
14
+ parent::__construct(
15
+
16
+ 'cwp_top_products_widget',
17
+ __( 'CWP Top Products Widget', 'cwppos' ),
18
+ // Widget description
19
+ array( 'description' => __( 'This widget displays the top products based on their rating.', 'cwppos' ) )
20
+ );
21
+
22
+ }
23
+
24
+
25
+ public function assets() {
26
+
27
+ wp_enqueue_style( 'cwp-pac-widget-stylesheet', WPPR_URL . '/css/cwppos-widget.css' );
28
+ wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL . '/javascript/main.js',array( 'jquery', 'pie-chart' ),WPPR_LITE_VERSION,true );
29
+ wp_enqueue_script( 'pie-chart', WPPR_URL . '/javascript/pie-chart.js',array( 'jquery' ), WPPR_LITE_VERSION,true );
30
+
31
+ // Added by Ash/Upwork
32
+ wp_enqueue_style( 'cwp-widget-stylesheet1', WPPR_URL . '/css/cwppos-widget-style1.css' );
33
+ wp_enqueue_style( 'cwp-widget-rating', WPPR_URL . '/css/cwppos-widget-rating.css' );
34
+ // Added by Ash/Upwork
35
+ }
36
+
37
+ // Added by Ash/Upwork
38
+ public function adminAssets() {
39
+ if ( is_admin() ) {
40
+ wp_enqueue_style( 'cwp-widget-admin-css', WPPR_URL . '/css/cwppos-widget-admin.css' );
41
+
42
+ wp_register_script( 'cwp-widget-script-top', WPPR_URL . '/javascript/widget-top.js' );
43
+ wp_localize_script('cwp-widget-script-top', 'cwpw_top', array(
44
+ 'widgetName' => $this->id_base,
45
+ 'imageCheckbox' => $this->get_field_id( 'show_image' ),
46
+ 'ratingSelect' => $this->get_field_id( 'cwp_tp_rating_type' ),
47
+ ));
48
+ wp_enqueue_script( 'cwp-widget-script-top' );
49
+ }
50
+ }
51
+ // Added by Ash/Upwork
52
+ public function custom_order_by( $orderby ) {
53
+
54
+ return 'mt1.meta_value DESC, mt2.meta_value+0 DESC';
55
+ }
56
+ public function widget( $args, $instance ) {
57
+ $this->assets();
58
+ if ( isset( $instance['title'] ) ) {
59
+
60
+ $title = apply_filters( 'widget_title', $instance['title'] ); }
61
+
62
+ if ( isset( $instance['no_items'] ) ) {
63
+
64
+ $no_items = apply_filters( 'widget_content', $instance['no_items'] ); }
65
+
66
+ if ( isset( $instance['cwp_tp_category'] ) ) {
67
+
68
+ $cwp_tp_category = apply_filters( 'widget_content', $instance['cwp_tp_category'] ); }
69
+
70
+ if ( isset( $instance['title_type'] ) ) {
71
+
72
+ $post_type = apply_filters( 'widget_content', $instance['title_type'] ); }
73
+
74
+ if ( isset( $instance['show_image'] ) ) {
75
+
76
+ $show_image = apply_filters( 'widget_content', $instance['show_image'] ); }
77
+
78
+ // before and after widget arguments are defined by themes
79
+ // echo "<div id='cwp_top_products_widget'>";
80
+ echo $args['before_widget'];
81
+
82
+ if ( ! empty( $title ) ) {
83
+
84
+ echo $args['before_title'] . $title . $args['after_title']; }
85
+
86
+ if ( $cwp_tp_category == 'All' ) { $cwp_tp_category = ''; }
87
+ // Loop to get the most popular posts, ordered by the author's final grade.
88
+ $query_args = array(
89
+
90
+ 'posts_per_page' => $no_items, // limit it to the specified no of posts
91
+ 'post_type' => 'any',
92
+ 'post__not_in' => get_option( 'sticky_posts' ),
93
+ 'category_name' => $cwp_tp_category,
94
+ 'meta_key' => 'cwp_meta_box_check',
95
+ 'meta_query' => array(
96
+ array(
97
+ 'key' => 'cwp_meta_box_check',
98
+ 'value' => 'Yes',
99
+ ),
100
+ array(
101
+ 'key' => 'option_overall_score',
102
+ ),
103
+
104
+ ),
105
+ );
106
+ add_filter( 'posts_orderby',array( $this, 'custom_order_by' ) );
107
+ $cwp_products_loop = new WP_Query( $query_args );
108
+ remove_filter( 'posts_orderby',array( $this, 'custom_order_by' ) );
109
+ // echo $cwp_top_products_loop->request;
110
+ // Added by Ash/Upwork
111
+ if ( ! isset( $instance['cwp_tp_buynow'] ) ) {
112
+ $instance['cwp_tp_buynow'] = __( 'Buy Now', 'cwppos' );
113
+ }
114
+
115
+ if ( ! isset( $instance['cwp_tp_readreview'] ) ) {
116
+ $instance['cwp_tp_readreview'] = __( 'Read Review', 'cwppos' );
117
+ }
118
+
119
+ if ( ! isset( $instance['cwp_tp_layout'] ) ) {
120
+ $instance['cwp_tp_layout'] = 'default.php';
121
+ }
122
+
123
+ if ( ! isset( $instance['cwp_tp_rating_type'] ) ) {
124
+ $instance['cwp_tp_rating_type'] = 'round';
125
+ }
126
+
127
+ include trailingslashit( dirname( __FILE__ ) ) . '/widget-layouts/' . $instance['cwp_tp_layout'];
128
+ // Added by Ash/Upwork
129
+ echo $args['after_widget'];
130
+
131
+ // echo "</div>"; // end #cwp_top_products_widget
132
+ }
133
+
134
+
135
+
136
+ // Widget Backend
137
+ public function form( $instance ) {
138
+
139
+ // Added by Ash/Upwork
140
+ $this->adminAssets();
141
+ // Added by Ash/Upwork
142
+ if ( isset( $instance['title'] ) ) {
143
+
144
+ $title = $instance['title'];
145
+ } else {
146
+ $title = __( 'Top Products', 'cwppos' );
147
+ }
148
+ if ( isset( $instance['no_items'] ) ) {
149
+ $no_items = $instance['no_items'];
150
+ } else {
151
+ $no_items = __( '10', 'cwppos' );
152
+ }
153
+ if ( isset( $instance['cwp_tp_category'] ) ) {
154
+ $cwp_tp_category = $instance['cwp_tp_category'];} else {
155
+ $cwp_tp_category = 'Select Category';
156
+ }
157
+ if ( isset( $instance['title_type'] ) ) {
158
+ $title_type = $instance['title_type'];
159
+
160
+ } else {
161
+ $title_type = false;
162
+ }
163
+
164
+ if ( isset( $instance['show_image'] ) ) {
165
+ $show_image = $instance['show_image'];
166
+
167
+ } else {
168
+ $show_image = false;
169
+ }
170
+
171
+ // Added by Ash/Upwork
172
+ $cwp_tp_buynow = __( 'Buy Now', 'cwppos' );
173
+ if ( isset( $instance['cwp_tp_buynow'] ) ) {
174
+ $cwp_tp_buynow = $instance['cwp_tp_buynow'];
175
+ }
176
+
177
+ $cwp_tp_readreview = __( 'Read Review', 'cwppos' );
178
+ if ( isset( $instance['cwp_tp_readreview'] ) ) {
179
+ $cwp_tp_readreview = $instance['cwp_tp_readreview'];
180
+ }
181
+
182
+ $cwp_tp_layout = 'default.php';
183
+ if ( isset( $instance['cwp_tp_layout'] ) ) {
184
+ $cwp_tp_layout = $instance['cwp_tp_layout'];
185
+ }
186
+
187
+ if ( $cwp_tp_layout == 'default.php' ) {
188
+ $cwp_tp_rating_type = 'round';
189
+ } else {
190
+ $cwp_tp_rating_type = 'star';
191
+ }
192
+ // Added by Ash/Upwork
193
+ $cwp_tp_categ_array = get_categories( 'hide_empty=0' );
194
+
195
+ foreach ( $cwp_tp_categ_array as $categs ) {
196
+
197
+ $cwp_tp_all_categories[ $categs->slug ] = $categs->name;
198
+
199
+ }
200
+
201
+ // Widget admin form
202
+ ?>
203
+
204
+ <p>
205
+
206
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'cwppos' ); ?></label>
207
+
208
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
209
+
210
+ </p>
211
+
212
+
213
+
214
+ <p>
215
+
216
+ <label for="<?php echo $this->get_field_id( 'no_items' ); ?>"><?php _e( 'Number of posts to show:', 'cwppos' ); ?></label>
217
+
218
+ <input id="<?php echo $this->get_field_id( 'no_items' ); ?>" name="<?php echo $this->get_field_name( 'no_items' ); ?>" size="3" type="text" value="<?php echo esc_attr( $no_items ); ?>" />
219
+
220
+ </p>
221
+
222
+
223
+
224
+ <p>
225
+
226
+ <?php $cwp_tp_selected_categ = esc_attr( $cwp_tp_category ); ?>
227
+
228
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>"><?php _e( 'Category:', 'cwppos' ); ?></label>
229
+
230
+ <select id="<?php echo $this->get_field_id( 'cwp_tp_category' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_category' ); ?>">
231
+ <?php echo '<option>All</option>'; ?>
232
+
233
+ <?php foreach ( $cwp_tp_all_categories as $categ_slug => $categ_name ) : ?>
234
+
235
+ <?php if ( $categ_slug == $cwp_tp_selected_categ ) {
236
+
237
+ echo '<option selected>' . $categ_slug . '</option>';
238
+
239
+ } elseif ( $categ_slug == '' ) {
240
+
241
+ echo '<option>There are no categs</select>';
242
+
243
+ } else {
244
+
245
+ echo '<option>' . $categ_slug . '</option>';
246
+
247
+ } ?>
248
+
249
+ <?php endforeach; ?>
250
+
251
+ </select>
252
+
253
+ </p>
254
+
255
+ <?php // Added by Ash/Upwork ?>
256
+
257
+ <p>
258
+
259
+ <?php $cwp_tp_layout = esc_attr( $cwp_tp_layout ); ?>
260
+
261
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_layout' ); ?>"><?php _e( 'Layout:', 'cwppos' ); ?></label>
262
+
263
+ <?php
264
+
265
+ $layouts = array();
266
+ $customLayoutFiles = glob( trailingslashit( dirname( __FILE__ ) ) . 'widget-layouts/*.php' );
267
+ foreach ( $customLayoutFiles as $file ) {
268
+ $layouts[ basename( $file ) ] = ucwords( basename( $file, '.php' ) );
269
+ }
270
+
271
+ foreach ( $layouts as $key => $val ) :
272
+ $extra = '';
273
+ if ( $key == $cwp_tp_layout ) { $extra = 'checked'; }
274
+
275
+ $styleName = strtolower( str_replace( ' ', '', $val ) );
276
+ $id = $this->get_field_id( $styleName );
277
+ ?>
278
+ <br>
279
+ <input type="radio" name="<?php echo $this->get_field_name( 'cwp_tp_layout' ); ?>" value="<?php echo $key;?>" id="<?php echo $id . 'style'?>" <?php echo $extra;?> class="wppr-stylestyle"><label for="<?php echo $id . 'style';?>" class="wppr-stylestyle"><?php echo $val;?></label>
280
+ <span class="wppr-styleimg" id="<?php echo $id . 'style'?>img">
281
+ <img src="<?php echo WPPR_URL . '/assets/' . $styleName . '.png';?>">
282
+ </span>
283
+ <?php
284
+ endforeach;
285
+ ?>
286
+
287
+ </p>
288
+
289
+ <p class="wppr-customField" style="display: none">
290
+
291
+ <?php $cwp_tp_buynow = esc_attr( $cwp_tp_buynow ); ?>
292
+
293
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>"><?php _e( 'Buy Now text:', 'cwppos' ); ?></label>
294
+
295
+ <input id="<?php echo $this->get_field_id( 'cwp_tp_buynow' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_buynow' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_buynow; ?>" />
296
+
297
+ </p>
298
+
299
+ <p class="wppr-customField" style="display: none">
300
+
301
+ <?php $cwp_tp_readreview = esc_attr( $cwp_tp_readreview ); ?>
302
+
303
+ <label for="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>"><?php _e( 'Read Review text:', 'cwppos' ); ?></label>
304
+
305
+ <input id="<?php echo $this->get_field_id( 'cwp_tp_readreview' ); ?>" name="<?php echo $this->get_field_name( 'cwp_tp_readreview' ); ?>" class="widefat" type="text" value="<?php echo $cwp_tp_readreview; ?>" />
306
+
307
+ </p>
308
+
309
+ <?php // Added by Ash/Upwork ?>
310
+
311
+ <p>
312
+
313
+ <label for="<?php echo $this->get_field_id( 'title_type' ); ?>"><?php _e( 'Display Product Titles :', 'cwppos' ); ?></label>
314
+
315
+ <input id="<?php echo $this->get_field_id( 'title_type' ); ?>" name="<?php echo $this->get_field_name( 'title_type' ); ?>" type="checkbox" <?php checked( $title_type ); ?> />
316
+ </p>
317
+
318
+ <p>
319
+
320
+ <label for="<?php echo $this->get_field_id( 'show_image' ); ?>"><?php _e( 'Display Product Image :', 'cwppos' ); ?></label>
321
+
322
+ <input id="<?php echo $this->get_field_id( 'show_image' ); ?>" name="<?php echo $this->get_field_name( 'show_image' ); ?>" type="checkbox" <?php checked( $show_image ); ?> />
323
+ </p>
324
+
325
+
326
+ <?php }
327
+
328
+
329
+
330
+ // Updating widget replacing old instances with new
331
+ public function update( $new_instance, $old_instance ) {
332
+
333
+ $instance = $old_instance;
334
+
335
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
336
+
337
+ $instance['no_items'] = ( ! empty( $new_instance['no_items'] ) ) ? strip_tags( $new_instance['no_items'] ) : '';
338
+
339
+ $instance['cwp_tp_category'] = ( ! empty( $new_instance['cwp_tp_category'] ) ) ? strip_tags( $new_instance['cwp_tp_category'] ) : '';
340
+
341
+ $instance['title_type'] = (bool) $new_instance['title_type'] ;
342
+ $instance['show_image'] = (bool) $new_instance['show_image'] ;
343
+
344
+ // Added by Ash/Upwork
345
+ $instance['cwp_tp_buynow'] = ( ! empty( $new_instance['cwp_tp_buynow'] ) ) ? strip_tags( $new_instance['cwp_tp_buynow'] ) : '';
346
+ $instance['cwp_tp_readreview'] = ( ! empty( $new_instance['cwp_tp_readreview'] ) ) ? strip_tags( $new_instance['cwp_tp_readreview'] ) : '';
347
+ $instance['cwp_tp_layout'] = ( ! empty( $new_instance['cwp_tp_layout'] ) ) ? strip_tags( $new_instance['cwp_tp_layout'] ) : '';
348
+ $instance['cwp_tp_rating_type'] = ( ! empty( $new_instance['cwp_tp_rating_type'] ) ) ? strip_tags( $new_instance['cwp_tp_rating_type'] ) : '';
349
+ // Added by Ash/Upwork
350
+ return $instance;
351
+
352
+ }
353
+
354
+
355
+
356
+ } // end Class cwp_top_products_widget
357
+
358
+
359
+
360
+
361
+
362
+ // Register and load the widget
363
+ function cwp_load_top_products_widget() {
364
+
365
+ register_widget( 'cwp_top_products_widget' );
366
+
367
+ }
368
+
369
+ add_action( 'widgets_init', 'cwp_load_top_products_widget' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widget-layouts/default.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
- echo "<ul>";
3
 
4
- while($cwp_products_loop->have_posts()) : $cwp_products_loop->the_post();
5
 
6
- $product_image = wppr_get_image_id(get_the_ID(),get_post_meta(get_the_ID(), "cwp_rev_product_image", true),'wppr_widget_image');
7
- $product_title = ($post_type==true) ? get_post_meta($cwp_products_loop->post->ID, "cwp_rev_product_name", true) : get_the_title();
8
- $product_title_display = $product_title;
9
- if(strlen($product_title_display) > self::RESTRICT_TITLE_CHARS){
10
- $product_title_display = substr($product_title_display, 0, self::RESTRICT_TITLE_CHARS) . "...";
11
- }
12
- ?>
13
 
14
 
15
 
16
- <li class="cwp-popular-review cwp_top_posts_widget_<?php the_ID(); if ($show_image==true&&!empty($product_image)) echo ' wppr-cols-3'; else echo ' wppr-cols-2' ?>">
17
- <?php
18
 
19
- if ($show_image==true&&!empty($product_image)) {
20
- ?>
21
 
22
- <img class="cwp_rev_image wppr-col" src="<?php echo $product_image;?>" alt="<?php echo $product_title; ?>">
23
  <?php } ?>
24
  <a href="<?php the_permalink(); ?>" class="wppr-col" title="<?php echo $product_title; ?>">
25
 
26
- <?php echo $product_title_display; ?>
27
 
28
  </a>
29
 
@@ -31,16 +31,16 @@
31
 
32
 
33
 
34
- <?php
35
 
36
- for($i=1; $i<6; $i++) {
37
- ${"option".$i."_content"} = get_post_meta($cwp_products_loop->post->ID, "option_".$i."_content", true);
38
- //if(empty(${"option".$i."_content"})) { ${"option".$i."_content"} = __("Default Feature ".$i, "cwppos"); }
39
- }
40
- $review_score = cwppos_calc_overall_rating($cwp_products_loop->post->ID);
41
- $review_score = $review_score['overall'];
42
 
43
- if(!empty($review_score)) { ?>
44
 
45
  <div class="review-grade-widget wppr-col">
46
 
@@ -64,4 +64,4 @@
64
 
65
 
66
 
67
- echo "</ul>";
1
  <?php
2
+ echo '<ul>';
3
 
4
+ while ( $cwp_products_loop->have_posts() ) : $cwp_products_loop->the_post();
5
 
6
+ $product_image = wppr_get_image_id( get_the_ID(),get_post_meta( get_the_ID(), 'cwp_rev_product_image', true ),'wppr_widget_image' );
7
+ $product_title = ($post_type == true) ? get_post_meta( $cwp_products_loop->post->ID, 'cwp_rev_product_name', true ) : get_the_title();
8
+ $product_title_display = $product_title;
9
+ if ( strlen( $product_title_display ) > self::RESTRICT_TITLE_CHARS ) {
10
+ $product_title_display = substr( $product_title_display, 0, self::RESTRICT_TITLE_CHARS ) . '...';
11
+ }
12
+ ?>
13
 
14
 
15
 
16
+ <li class="cwp-popular-review cwp_top_posts_widget_<?php the_ID(); if ( $show_image == true&& ! empty( $product_image ) ) { echo ' wppr-cols-3'; } else { echo ' wppr-cols-2'; } ?>">
17
+ <?php
18
 
19
+ if ( $show_image == true&& ! empty( $product_image ) ) {
20
+ ?>
21
 
22
+ <img class="cwp_rev_image wppr-col" src="<?php echo $product_image;?>" alt="<?php echo $product_title; ?>">
23
  <?php } ?>
24
  <a href="<?php the_permalink(); ?>" class="wppr-col" title="<?php echo $product_title; ?>">
25
 
26
+ <?php echo $product_title_display; ?>
27
 
28
  </a>
29
 
31
 
32
 
33
 
34
+ <?php
35
 
36
+ for ( $i = 1; $i < 6; $i++ ) {
37
+ ${'option' . $i . '_content'} = get_post_meta( $cwp_products_loop->post->ID, 'option_' . $i . '_content', true );
38
+ // if(empty(${"option".$i."_content"})) { ${"option".$i."_content"} = __("Default Feature ".$i, "cwppos"); }
39
+ }
40
+ $review_score = cwppos_calc_overall_rating( $cwp_products_loop->post->ID );
41
+ $review_score = $review_score['overall'];
42
 
43
+ if ( ! empty( $review_score ) ) { ?>
44
 
45
  <div class="review-grade-widget wppr-col">
46
 
64
 
65
 
66
 
67
+ echo '</ul>';
inc/widget-layouts/style 1.php CHANGED
@@ -1,76 +1,76 @@
1
  <div class="wppr-prodlist">
2
  <?php
3
- while($cwp_products_loop->have_posts()) : $cwp_products_loop->the_post();
4
 
5
- $product_image = wppr_get_image_id(get_the_ID(),get_post_meta(get_the_ID(), "cwp_rev_product_image", true),'thumbnail');
6
- $product_title = ($post_type==true) ? get_post_meta($cwp_products_loop->post->ID, "cwp_rev_product_name", true) : get_the_title();
7
- $product_title_display = $product_title;
8
- if(strlen($product_title_display) > self::RESTRICT_TITLE_CHARS){
9
- $product_title_display = substr($product_title_display, 0, self::RESTRICT_TITLE_CHARS) . "...";
10
- }
11
- $affiliate_link = get_post_meta(get_the_ID(), "cwp_product_affiliate_link", true);
12
- $review_link = get_the_permalink();
13
 
14
- $showingImg = $show_image==true&&!empty($product_image);
15
  ?>
16
 
17
- <div class="wppr-prodrow">
18
- <?php if($showingImg){ ?>
19
- <div class="wppr-prodrowleft">
20
- <a href="<?php echo $review_link; ?>" class="wppr-col" title="<?php echo $product_title; ?>">
21
- <img class="cwp_rev_image wppr-col" src="<?php echo $product_image;?>" alt="<?php echo $product_title; ?>"/>
22
- </a>
23
- </div>
24
- <?php
25
- }
26
- ?>
27
- <div class="wppr-prodrowright <?php echo $showingImg ? "wppr-prodrowrightadjust" : ""?>">
28
- <p><strong><?php echo $product_title_display; ?></strong></p>
29
- <?php
30
- for($i=1; $i<6; $i++) {
31
- ${"option".$i."_content"} = get_post_meta($cwp_products_loop->post->ID, "option_".$i."_content", true);
32
- //if(empty(${"option".$i."_content"})) { ${"option".$i."_content"} = __("Default Feature ".$i, "cwppos"); }
33
- }
34
- $review_score = cwppos_calc_overall_rating($cwp_products_loop->post->ID);
35
- $review_score = $review_score['overall'];
36
 
37
- if(!empty($review_score)) {
38
- if($instance['cwp_tp_rating_type'] == "round"){
39
- ?>
40
- <div class="review-grade-widget wppr-col">
41
- <div class="cwp-review-chart relative">
42
- <div class="cwp-review-percentage" data-percent="<?php echo $review_score; ?>"><span></span></div>
43
- </div><!-- end .chart -->
44
- </div>
45
- <div class="clear"></div>
46
- <?php
47
- }else{
48
- ?>
49
- <div class="wppr-rating">
50
- <div style="width:<?php echo $review_score; ?>%;"> <?php echo $review_score; ?></div>
51
- </div>
52
- <?php
53
- }
54
- }
55
- ?>
56
- <p class="wppr-style1-buttons">
57
- <?php
58
- $link = "<a href='{$affiliate_link}' rel='nofollow' target='_blank' class='wppr-bttn'>" . __($instance['cwp_tp_buynow'], "cwppos") . "</a>";
59
- if (!empty($instance['cwp_tp_buynow'])) {
60
- echo apply_filters("wppr_widget_style1_buynow_link", $link, get_the_ID(), $affiliate_link, $instance['cwp_tp_buynow']);
61
- }
62
 
63
- $link = "<a href='{$review_link}' rel='nofollow' target='_blank' class='wppr-bttn'>" . __($instance['cwp_tp_readreview'], "cwppos") . "</a>";
64
- if (!empty($instance['cwp_tp_readreview'])) {
65
- echo apply_filters("wppr_widget_style1_readreview_link", $link, get_the_ID(), $review_link, $instance['cwp_tp_readreview']);
66
- }
67
- ?>
68
- </p>
69
- </div>
70
- <div class="clear"></div>
71
- </div>
72
  <?php endwhile; ?>
73
 
74
  <?php wp_reset_postdata(); // reset the query ?>
75
 
76
- </div>
1
  <div class="wppr-prodlist">
2
  <?php
3
+ while ( $cwp_products_loop->have_posts() ) : $cwp_products_loop->the_post();
4
 
5
+ $product_image = wppr_get_image_id( get_the_ID(),get_post_meta( get_the_ID(), 'cwp_rev_product_image', true ),'thumbnail' );
6
+ $product_title = ($post_type == true) ? get_post_meta( $cwp_products_loop->post->ID, 'cwp_rev_product_name', true ) : get_the_title();
7
+ $product_title_display = $product_title;
8
+ if ( strlen( $product_title_display ) > self::RESTRICT_TITLE_CHARS ) {
9
+ $product_title_display = substr( $product_title_display, 0, self::RESTRICT_TITLE_CHARS ) . '...';
10
+ }
11
+ $affiliate_link = get_post_meta( get_the_ID(), 'cwp_product_affiliate_link', true );
12
+ $review_link = get_the_permalink();
13
 
14
+ $showingImg = $show_image == true&& ! empty( $product_image );
15
  ?>
16
 
17
+ <div class="wppr-prodrow">
18
+ <?php if ( $showingImg ) { ?>
19
+ <div class="wppr-prodrowleft">
20
+ <a href="<?php echo $review_link; ?>" class="wppr-col" title="<?php echo $product_title; ?>">
21
+ <img class="cwp_rev_image wppr-col" src="<?php echo $product_image;?>" alt="<?php echo $product_title; ?>"/>
22
+ </a>
23
+ </div>
24
+ <?php
25
+ }
26
+ ?>
27
+ <div class="wppr-prodrowright <?php echo $showingImg ? 'wppr-prodrowrightadjust' : ''?>">
28
+ <p><strong><?php echo $product_title_display; ?></strong></p>
29
+ <?php
30
+ for ( $i = 1; $i < 6; $i++ ) {
31
+ ${'option' . $i . '_content'} = get_post_meta( $cwp_products_loop->post->ID, 'option_' . $i . '_content', true );
32
+ // if(empty(${"option".$i."_content"})) { ${"option".$i."_content"} = __("Default Feature ".$i, "cwppos"); }
33
+ }
34
+ $review_score = cwppos_calc_overall_rating( $cwp_products_loop->post->ID );
35
+ $review_score = $review_score['overall'];
36
 
37
+ if ( ! empty( $review_score ) ) {
38
+ if ( $instance['cwp_tp_rating_type'] == 'round' ) {
39
+ ?>
40
+ <div class="review-grade-widget wppr-col">
41
+ <div class="cwp-review-chart relative">
42
+ <div class="cwp-review-percentage" data-percent="<?php echo $review_score; ?>"><span></span></div>
43
+ </div><!-- end .chart -->
44
+ </div>
45
+ <div class="clear"></div>
46
+ <?php
47
+ } else {
48
+ ?>
49
+ <div class="wppr-rating">
50
+ <div style="width:<?php echo $review_score; ?>%;"> <?php echo $review_score; ?></div>
51
+ </div>
52
+ <?php
53
+ }
54
+ }
55
+ ?>
56
+ <p class="wppr-style1-buttons">
57
+ <?php
58
+ $link = "<a href='{$affiliate_link}' rel='nofollow' target='_blank' class='wppr-bttn'>" . __( $instance['cwp_tp_buynow'], 'cwppos' ) . '</a>';
59
+ if ( ! empty( $instance['cwp_tp_buynow'] ) ) {
60
+ echo apply_filters( 'wppr_widget_style1_buynow_link', $link, get_the_ID(), $affiliate_link, $instance['cwp_tp_buynow'] );
61
+ }
62
 
63
+ $link = "<a href='{$review_link}' rel='nofollow' target='_blank' class='wppr-bttn'>" . __( $instance['cwp_tp_readreview'], 'cwppos' ) . '</a>';
64
+ if ( ! empty( $instance['cwp_tp_readreview'] ) ) {
65
+ echo apply_filters( 'wppr_widget_style1_readreview_link', $link, get_the_ID(), $review_link, $instance['cwp_tp_readreview'] );
66
+ }
67
+ ?>
68
+ </p>
69
+ </div>
70
+ <div class="clear"></div>
71
+ </div>
72
  <?php endwhile; ?>
73
 
74
  <?php wp_reset_postdata(); // reset the query ?>
75
 
76
+ </div>
inc/wppr-filters.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  /**
3
  * Filters of WPPR
 
4
  * @package WPPR
5
  * @author ThemeIsle
6
  * @since 2.6.9
@@ -33,7 +34,7 @@ add_filter( 'wppr_review_product_name_html','wppr_review_product_name_html_filte
33
  */
34
  function wppr_review_product_name_html_filter( $name = '' ) {
35
 
36
- return '<h2 class="cwp-item" itemprop="name" >'.$name.'</h2>';
37
 
38
  }
39
 
@@ -42,14 +43,14 @@ add_filter( 'wppr_option_name_html','wppr_option_name_html_filter',10,2 );
42
  /**
43
  * Filter html tag for the options name
44
  *
45
- * @param int $id Id of the review.
46
  * @param string $name Name of the option.
47
  * @return string $html tag for the option name
48
  * @since 2.6.9
49
  */
50
  function wppr_option_name_html_filter( $id = 0, $name = '' ) {
51
 
52
- return ( ! empty( $name ) ) ? '<h3 >'.$name.'</h3>' : '';
53
 
54
  }
55
 
@@ -58,14 +59,14 @@ add_filter( 'wppr_review_pros_text','wppr_review_pros_text_filter',10,2 );
58
  /**
59
  * Filter html tag for the pros text heading
60
  *
61
- * @param int $id Id of the review.
62
  * @param string $name The pros heading text.
63
  * @return string $html tag for the pros text
64
  * @since 2.6.9
65
  */
66
  function wppr_review_pros_text_filter( $id = 0, $name = '' ) {
67
 
68
- return ( ! empty( $name ) ) ? '<h2>'.$name.'</h2>' : '';
69
 
70
  }
71
 
@@ -74,29 +75,69 @@ add_filter( 'wppr_review_cons_text','wppr_review_cons_text_filter',10,2 );
74
  /**
75
  * Filter html tag for the cons text heading
76
  *
77
- * @param int $id Id of the review.
78
  * @param string $name The cons heading text.
79
  * @return string $html tag for the cons text
80
  * @since 2.6.9
81
  */
82
  function wppr_review_cons_text_filter( $id = 0, $name = '' ) {
83
 
84
- return ( ! empty( $name ) ) ? '<h2>'.$name.'</h2>' : '';
85
 
86
  }
87
 
88
 
 
 
 
 
 
 
 
 
 
89
  add_filter( 'wppr_admin_pointers-post', 'wppr_admin_pointers' );
90
  function wppr_admin_pointers( $p ) {
91
- $p['amazon_upsell'] = array(
92
- 'target' => '#wppr_product_affiliate_link_upsell',
93
- 'options' => array(
94
- 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
95
- apply_filters("wppr_amazon_title_upsell_text", null),
96
- apply_filters("wppr_amazon_body_upsell_text", null)
97
- ),
98
- 'position' => array( 'edge' => 'left', 'align' => 'left' )
99
- )
100
- );
101
- return $p;
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * Filters of WPPR
4
+ *
5
  * @package WPPR
6
  * @author ThemeIsle
7
  * @since 2.6.9
34
  */
35
  function wppr_review_product_name_html_filter( $name = '' ) {
36
 
37
+ return '<h2 class="cwp-item" itemprop="name" >' . $name . '</h2>';
38
 
39
  }
40
 
43
  /**
44
  * Filter html tag for the options name
45
  *
46
+ * @param int $id Id of the review.
47
  * @param string $name Name of the option.
48
  * @return string $html tag for the option name
49
  * @since 2.6.9
50
  */
51
  function wppr_option_name_html_filter( $id = 0, $name = '' ) {
52
 
53
+ return ( ! empty( $name ) ) ? '<h3 >' . $name . '</h3>' : '';
54
 
55
  }
56
 
59
  /**
60
  * Filter html tag for the pros text heading
61
  *
62
+ * @param int $id Id of the review.
63
  * @param string $name The pros heading text.
64
  * @return string $html tag for the pros text
65
  * @since 2.6.9
66
  */
67
  function wppr_review_pros_text_filter( $id = 0, $name = '' ) {
68
 
69
+ return ( ! empty( $name ) ) ? '<h2>' . $name . '</h2>' : '';
70
 
71
  }
72
 
75
  /**
76
  * Filter html tag for the cons text heading
77
  *
78
+ * @param int $id Id of the review.
79
  * @param string $name The cons heading text.
80
  * @return string $html tag for the cons text
81
  * @since 2.6.9
82
  */
83
  function wppr_review_cons_text_filter( $id = 0, $name = '' ) {
84
 
85
+ return ( ! empty( $name ) ) ? '<h2>' . $name . '</h2>' : '';
86
 
87
  }
88
 
89
 
90
+ /**
91
+ * Add pro pointer for the amazon upsell link
92
+ *
93
+ * @param array $p The pointers array.
94
+ * @return array The altered pointers array with amazon upsell.
95
+ * @since 2.9.0
96
+ */
97
+
98
+
99
  add_filter( 'wppr_admin_pointers-post', 'wppr_admin_pointers' );
100
  function wppr_admin_pointers( $p ) {
101
+ $p['amazon_upsell'] = array(
102
+ 'target' => '#wppr_product_affiliate_link_upsell',
103
+ 'options' => array(
104
+ 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
105
+ apply_filters( 'wppr_amazon_title_upsell_text', null ),
106
+ apply_filters( 'wppr_amazon_body_upsell_text', null )
107
+ ),
108
+ 'position' => array( 'edge' => 'left', 'align' => 'left' ),
109
+ ),
110
+ );
111
+ return $p;
112
+ }
113
+
114
+ /**
115
+ * Sanitize links in the options review panel
116
+ *
117
+ * @param string $text The raw value.
118
+ * @return string The sanitized value.
119
+ * @since 2.9.6
120
+ */
121
+ add_filter( 'wppr_sanitize_link1', 'wppr_sanitize_link' );
122
+ add_filter( 'wppr_sanitize_link2', 'wppr_sanitize_link' );
123
+
124
+ function wppr_sanitize_link( $text ) {
125
+ return esc_url( $text );
126
+ }
127
+
128
+
129
+ /**
130
+ * Sanitize texts in the options review panel
131
+ *
132
+ * @param string $text The raw value.
133
+ * @return string The sanitized value.
134
+ * @since 2.9.6
135
+ */
136
+ add_filter( 'wppr_sanitize_product_price', 'wppr_sanitize_text' );
137
+ add_filter( 'wppr_sanitize_product_title', 'wppr_sanitize_text' );
138
+ add_filter( 'wppr_sanitize_product_image', 'wppr_sanitize_text' );
139
+
140
+
141
+ function wppr_sanitize_text( $text ) {
142
+ return sanitize_text_field( $text );
143
+ }
inc/wppr-main.php CHANGED
@@ -1,22 +1,22 @@
1
  <?php
2
  /**
3
  * Core functions of WPPR
 
4
  * @package WPPR
5
  * @author ThemeIsle
6
  * @since 1.0.0
7
- *
8
  */
9
  function cwppos_calc_overall_rating( $id ) {
10
  $options = cwppos();
11
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
12
- ${"option" . $i . "_grade"} = get_post_meta( $id, "option_" . $i . "_grade", true );
13
  // echo ${"option".$i."_grade"};
14
- ${"comment_meta_option_nr_" . $i} = 0;
15
- ${"comment_meta_option_" . $i} = 0;
16
 
17
  }
18
  $nr_of_comments = 0;
19
- if ( $options['cwppos_show_userreview'] == "yes" ) {
20
  $args = array(
21
  'status' => 'approve',
22
  'post_id' => $id, // use post_id, not post_ID
@@ -24,21 +24,20 @@ function cwppos_calc_overall_rating( $id ) {
24
  $comments = get_comments( $args );
25
  $nr_of_comments = get_comments_number( $id );
26
  foreach ( $comments as $comment ) :
27
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
28
  if ( get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true ) !== '' ) {
29
- ${"comment_meta_option_nr_" . $i} ++;
30
- ${"comment_meta_option_" . $i} += get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true ) * 10;
31
  }
32
 
33
- //var_dump(${"comment_meta_option_".$i});
34
  }
35
  endforeach;
36
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
37
- if ( ${"comment_meta_option_nr_" . $i} !== 0 ) {
38
- ${"comment_meta_option_" . $i} = ${"comment_meta_option_" . $i} / ${"comment_meta_option_nr_" . $i};
39
  }
40
  }
41
-
42
  } else {
43
  $options['cwppos_infl_userreview'] = 0;
44
  }
@@ -48,24 +47,24 @@ function cwppos_calc_overall_rating( $id ) {
48
  $overall_score = 0;
49
  $iter = 0;
50
  $rating = array();
51
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
52
- if ( ${"comment_meta_option_nr_" . $i} !== 0 ) {
53
  $infl = $options['cwppos_infl_userreview'];
54
  } else {
55
  $infl = 0;
56
 
57
  }
58
  if ( ! empty( ${'option' . $i . '_grade'} ) || ${'option' . $i . '_grade'} === '0' ) {
59
- //if($infl !== 0 ){
60
  ${'option' . $i . '_grade'} = round( ( ${'option' . $i . '_grade'} * ( 100 - $infl ) + ${'comment_meta_option_' . $i} * $infl ) / 100 );
61
- //}else{
62
- //}
63
  $iter ++;
64
  $rating[ 'option' . $i ] = round( ${'option' . $i . '_grade'} );
65
  $overall_score += ${'option' . $i . '_grade'};
66
  }
67
  }
68
- //$overall_score = ($option1_grade + $option2_grade + $option3_grade + $option4_grade + $option5_grade) / $iter;
69
  if ( $iter !== 0 ) {
70
  $rating['overall'] = $overall_score / $iter;
71
  } else {
@@ -77,43 +76,42 @@ function cwppos_calc_overall_rating( $id ) {
77
 
78
  }
79
 
80
- function cwppos_show_review( $id = "", $visual = "full" ) {
81
  global $post;
82
- if ( post_password_required( $post ) ) {
83
  return false;
84
  }
85
- if ( $id == "" ) {
86
  $id = $post->ID;
87
  }
88
  $cwp_review_stored_meta = get_post_meta( $id );
89
- $return_string = "";
90
- if ( @$cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' ) {
91
  wp_enqueue_style( 'cwp-pac-frontpage-stylesheet', WPPR_URL . '/css/frontpage.css', array(), WPPR_LITE_VERSION );
92
- wp_enqueue_script( 'pie-chart', WPPR_URL . '/javascript/pie-chart.js', array( "jquery" ), WPPR_LITE_VERSION, true );
93
  wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL . '/javascript/main.js', array(
94
- "jquery",
95
- 'pie-chart'
96
  ), WPPR_LITE_VERSION, true );
97
- $cwp_price = get_post_meta( $id, "cwp_rev_price", true );
98
  $p_string = $cwp_price;
99
- $p_name = apply_filters( "wppr_review_product_name", $id );
100
- if ( $p_string != "" ) {
101
  // Added by Ash/Upwork
102
  $cwp_price = do_shortcode( $cwp_price );
103
  // Added by Ash/Upwork
104
- $p_price = preg_replace( "/[^0-9.,]/", "", $cwp_price );
105
- $p_currency = preg_replace( "/[0-9.,]/", "", $cwp_price );
106
  // Added by Ash/Upwork
107
- $p_disable = apply_filters( "wppr_disable_price_richsnippet", false );
108
  // Added by Ash/Upwork
109
  if ( ! $p_disable ) {
110
  $p_string = '<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span itemprop="priceCurrency">' . $p_currency . '</span><span itemprop="price">' . $p_price . '</span></span>';
111
  }
112
-
113
  }
114
- $product_image = do_shortcode( get_post_meta( $id, "cwp_rev_product_image", true ) );
115
- $imgurl = do_shortcode( get_post_meta( $id, "cwp_image_link", true ) );
116
- $lightbox = "";
117
  $feat_image = wp_get_attachment_url( get_post_thumbnail_id( $id ) );
118
  if ( ! empty( $product_image ) ) {
119
  $product_image_cropped = wppr_get_image_id( $id, $product_image );
@@ -121,26 +119,26 @@ function cwppos_show_review( $id = "", $visual = "full" ) {
121
  $product_image_cropped = wppr_get_image_id( $id );
122
  $product_image = $feat_image;
123
  }
124
- if ( $imgurl == "image" ) {
125
- //no means no disabled
126
- if ( cwppos( "cwppos_lighbox" ) == "no" ) {
127
  $lightbox = 'data-lightbox="' . $product_image . '"';
128
- wp_enqueue_script( "img-lightbox", WPPR_URL . '/javascript/lightbox.min.js', array(), WPPR_LITE_VERSION, array() );
129
- wp_enqueue_style( "img-lightbox-css", WPPR_URL . '/css/lightbox.css', array(), WPPR_LITE_VERSION );
130
  }
131
  } else {
132
- $product_image = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_link", true ) );
133
  }
134
  $rating = cwppos_calc_overall_rating( $id );
135
  $divrating = $rating['overall'] / 10;
136
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
137
- ${"option" . $i . "_content"} = do_shortcode( get_post_meta( $id, "option_" . $i . "_content", true ) );
138
- if ( empty( ${"option" . $i . "_content"} ) ) {
139
- ${"option" . $i . "_content"} = __( "Default Feature " . $i, "cwppos" );
140
  }
141
  }
142
  $commentNr = get_comments_number( $id ) + 1;
143
- if ( $visual == "full" ) {
144
  $return_string .= '<section id="review-statistics" class="article-section" itemscope itemtype="http://schema.org/Product">
145
  <div class="review-wrap-up cwpr_clearfix" >
146
  <div class="cwpr-review-top cwpr_clearfix">
@@ -150,15 +148,15 @@ function cwppos_show_review( $id = "", $visual = "full" ) {
150
  </div><!-- end .cwpr-review-top -->
151
  <div class="review-wu-left">
152
  <div class="rev-wu-image">
153
- <a href="' . $product_image . '" ' . $lightbox . ' rel="nofollow" target="_blank"><img itemprop="image" src="' . $product_image_cropped . '" alt="' . do_shortcode( get_post_meta( $id, "cwp_rev_product_name", true ) ) . '" class="photo photo-wrapup wppr-product-image" /></a>
154
  </div><!-- end .rev-wu-image -->
155
  <div class="review-wu-grade">';
156
  }
157
- if ( $visual == "full" || $visual == "yes" ) {
158
- $extra_class = $visual == "yes" ? "cwp-chart-embed" : "";
159
  $return_string .= '<div class="cwp-review-chart ' . $extra_class . '">
160
- <meta itemprop="datePublished" datetime="' . get_the_time( "Y-m-d", $id ) . '">';
161
- if ( cwppos( "cwppos_infl_userreview" ) != 0 && $commentNr > 1 ) {
162
  $return_string .= '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="cwp-review-percentage" data-percent="';
163
  $return_string .= $rating['overall'] . '"><span itemprop="ratingValue" class="cwp-review-rating">' . $divrating . '</span><meta itemprop="bestRating" content = "10"/>
164
  <meta itemprop="ratingCount" content="' . $commentNr . '"> </div>';
@@ -171,14 +169,14 @@ function cwppos_show_review( $id = "", $visual = "full" ) {
171
  }
172
  $return_string .= '</div><!-- end .chart -->';
173
  }
174
- if ( $visual == "full" ) {
175
  $return_string .= '</div><!-- end .review-wu-grade -->
176
  <div class="review-wu-bars">';
177
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
178
  if ( ! empty( ${'option' . $i . '_content'} ) && isset( $rating[ 'option' . $i ] ) && ( ! empty( $rating[ 'option' . $i ] ) || $rating[ 'option' . $i ] === '0' ) && strtoupper( ${'option' . $i . '_content'} ) != 'DEFAULT FEATURE ' . $i ) {
179
  $return_string .= '<div class="rev-option" data-value=' . $rating[ 'option' . $i ] . '>
180
  <div class="cwpr_clearfix">
181
- ' . apply_filters( "wppr_option_name_html", $id, ${'option' . $i . '_content'} ) . '
182
  <span>' . round( $rating[ 'option' . $i ] / 10 ) . '/10</span>
183
  </div>
184
  <ul class="cwpr_clearfix"></ul>
@@ -190,35 +188,33 @@ function cwppos_show_review( $id = "", $visual = "full" ) {
190
  <div class="review-wu-right">
191
  <div class="pros">';
192
  }
193
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
194
- ${"pro_option_" . $i} = do_shortcode( get_post_meta( $id, "cwp_option_" . $i . "_pro", true ) );
195
- if ( empty( ${"pro_option_" . $i} ) ) {
196
- ${"pro_option_" . $i} = "";
197
  }
198
  }
199
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
200
- ${"cons_option_" . $i} = do_shortcode( get_post_meta( $id, "cwp_option_" . $i . "_cons", true ) );
201
- if ( empty( ${"cons_option_" . $i} ) ) {
202
- ${"cons_option_" . $i} = "";
203
  }
204
-
205
  }
206
- if ( $visual == "full" ) {
207
- $return_string .= apply_filters( 'wppr_review_pros_text', $id, __( cwppos( "cwppos_pros_text" ), "cwppos" ) ) . ' <ul>';
208
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
209
- if ( ! empty( ${"pro_option_" . $i} ) ) {
210
- $return_string .= ' <li>' . ${"pro_option_" . $i} . '</li>';
211
  }
212
  }
213
  $return_string .= ' </ul>
214
  </div><!-- end .pros -->
215
  <div class="cons">';
216
- $return_string .= apply_filters( 'wppr_review_cons_text', $id, __( cwppos( "cwppos_cons_text" ), "cwppos" ) ) . ' <ul>';
217
- for ( $i = 1; $i <= cwppos( "cwppos_option_nr" ); $i ++ ) {
218
- if ( ! empty( ${"cons_option_" . $i} ) ) {
219
- $return_string .= ' <li>' . ${"cons_option_" . $i} . '</li>';
220
  }
221
-
222
  }
223
  $return_string .= '
224
  </ul>
@@ -227,29 +223,29 @@ function cwppos_show_review( $id = "", $visual = "full" ) {
227
  </div><!-- end .review-wrap-up -->
228
  </section><!-- end #review-statistics -->';
229
  }
230
- if ( cwppos( "cwppos_show_poweredby" ) == 'yes' && ! class_exists( 'CWP_PR_PRO_Core' ) ) {
231
  $return_string .= '<div style="font-size:12px;width:100%;float:right"><p style="float:right;">Powered by <a href="http://wordpress.org/plugins/wp-product-review/" target="_blank" rel="nofollow" > WP Product Review</a></p></div>';
232
  }
233
- $affiliate_text = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_text", true ) );
234
- $affiliate_link = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_link", true ) );
235
- $affiliate_text2 = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_text2", true ) );
236
- $affiliate_link2 = do_shortcode( get_post_meta( $id, "cwp_product_affiliate_link2", true ) );
237
  if ( ! empty( $affiliate_text2 ) && ! empty( $affiliate_link2 ) ) {
238
- $bclass = "affiliate-button2 affiliate-button";
239
  } else {
240
- $bclass = "affiliate-button";
241
  }
242
- if ( $visual == "full" && ! empty( $affiliate_text ) && ! empty( $affiliate_link ) ) {
243
  $return_string .= '<div class="' . $bclass . '">
244
  <a href="' . $affiliate_link . '" rel="nofollow" target="_blank"><span>' . $affiliate_text . '</span> </a>
245
  </div><!-- end .affiliate-button -->';
246
  }
247
- if ( $visual == "full" && ! empty( $affiliate_text2 ) && ! empty( $affiliate_link2 ) ) {
248
  $return_string .= '<div class="affiliate-button affiliate-button2">
249
  <a href="' . $affiliate_link2 . '" rel="nofollow" target="_blank"><span>' . $affiliate_text2 . '</span> </a>
250
  </div><!-- end .affiliate-button -->';
251
  }
252
- if ( $visual == "no" ) {
253
  $return_string = round( $divrating );
254
  }
255
  }
@@ -259,19 +255,19 @@ function cwppos_show_review( $id = "", $visual = "full" ) {
259
 
260
  function cwppos_pac_admin_init() {
261
  wp_enqueue_style( 'cwp-pac-admin-stylesheet', WPPR_URL . '/css/dashboard_styles.css' );
262
- wp_register_script( 'cwp-pac-script', WPPR_URL . '/javascript/admin-review.js', array( "jquery" ), "20140101", true );
263
  wp_localize_script( 'cwp-pac-script', 'ispro', array( 'value' => class_exists( 'CWP_PR_PRO_Core' ) ) );
264
  wp_enqueue_script( 'cwp-pac-script' );
265
  if ( class_exists( 'CWP_PR_PRO_Core' ) ) {
266
  wp_enqueue_style( 'cwp-pac-pro-admin-stylesheet', WPPR_URL . '/css/pro_dashboard_styles.css' );
267
  }
268
- do_action( "wppr-amazon-enqueue" );
269
  }
270
 
271
- function wppr_get_image_id( $post_id, $image_url = "", $size = "thumbnail" ) {
272
  global $wpdb;
273
- //filter for image size;
274
- $size = apply_filters( "wppr_review_image_size", $size, $post_id );
275
  if ( ! empty( $image_url ) && $image_url !== false ) {
276
  $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ) );
277
  $image_id = isset( $attachment[0] ) ? $attachment[0] : '';
@@ -279,12 +275,12 @@ function wppr_get_image_id( $post_id, $image_url = "", $size = "thumbnail" ) {
279
  $image_id = get_post_thumbnail_id( $post_id );
280
 
281
  }
282
- $image_thumb = "";
283
  if ( ! empty( $image_id ) ) {
284
  $image_thumb = wp_get_attachment_image_src( $image_id, $size );
285
  if ( $size !== 'thumbnail' ) {
286
  if ( $image_thumb[0] === $image_url ) {
287
- $image_thumb = wp_get_attachment_image_src( $image_id, "thumbnail" );
288
  }
289
  }
290
  }
@@ -294,9 +290,9 @@ function wppr_get_image_id( $post_id, $image_url = "", $size = "thumbnail" ) {
294
 
295
  function custom_bar_icon() {
296
  $options = cwppos();
297
- if ( ( isset( $options['cwppos_show_poweredby'] ) && $options['cwppos_show_poweredby'] == "yes" ) || function_exists( "wppr_ci_custom_bar_icon" ) || class_exists( 'CWP_PR_PRO_Core' ) ) {
298
- wp_register_script( "cwp-custom-bar-icon", WPPR_URL . '/javascript/custom-bar-icon.js', false, "1.0", "all" );
299
- wp_enqueue_script( "cwp-custom-bar-icon" );
300
  }
301
  wppr_add_pointers();
302
  }
@@ -324,38 +320,38 @@ function wppr_add_pointers() {
324
  return;
325
  }
326
  // Add pointers style to queue.
327
- wp_enqueue_style( 'wp-pointer', array( "jquery" ) );
328
- wp_enqueue_script( 'wppr-pointers', WPPR_URL . '/javascript/cwp-pointers.js', array( "wp-pointer" ), WPPR_LITE_VERSION, true );
329
- wp_localize_script( 'wppr-pointers', 'cwpp', array( "pointers" => $valid ) );
330
  }
331
 
332
  function cwppos_pac_register() {
333
- add_image_size( "wppr_widget_image", 50, 50 );
334
  }
335
 
336
  function cwp_def_settings() {
337
  global $post;
338
  $options = cwppos();
339
- if ( function_exists( 'wppr_ci_custom_bar_icon' ) || ( isset( $options['cwppos_show_poweredby'] ) && $options['cwppos_show_poweredby'] == "yes" ) ) {
340
  $isSetToPro = true;
341
  } else {
342
  $isSetToPro = false;
343
  }
344
- $uni_font = cwppos( "cwppos_change_bar_icon" );
345
  $track = $options['cwppos_rating_chart_default'];
346
- //if ($uni_font!=="&#")
347
  if ( isset( $uni_font[0] ) ) {
348
- if ( $uni_font[0] == "#" ) {
349
  $uni_font = $uni_font;
350
  } else {
351
  $uni_font = $uni_font[0];
352
  }
353
  } else {
354
- $uni_font = "";
355
  }
356
  if ( ! empty( $uni_font ) ) {
357
- if ( function_exists( "wppr_ci_custom_bar_icon" ) || cwppos( 'cwppos_show_poweredby' ) == 'yes' ) {
358
- if ( cwppos( "cwppos_fontawesome" ) === "no" ) {
359
  wp_enqueue_style( 'cwp-pac-fontawesome-stylesheet', WPPR_URL . '/css/font-awesome.min.css' );
360
  }
361
  }
@@ -373,10 +369,10 @@ function cwppos_pac_print() {
373
 
374
  function cwppos_dynamic_stylesheet() {
375
  $options = cwppos();
376
- //Get theme content width or plugin setting content width
377
  global $content_width;
378
  $c_width = 700;
379
- if ( $options['cwppos_widget_size'] != "" ) {
380
  $c_width = $options['cwppos_widget_size'];
381
  } else {
382
  $c_width = $content_width;
@@ -397,14 +393,14 @@ function cwppos_dynamic_stylesheet() {
397
 
398
  #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
399
 
400
- margin-top: <?php echo $f_img_size*0.1;?>%;
401
  }
402
 
403
  #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
404
- font-size: <?php echo round(30*$f_img_size/140);?>px;
405
  }
406
 
407
- <?php if ($options['cwppos_widget_size']!="") { ?>
408
  #review-statistics {
409
  width: <?php echo $options['cwppos_widget_size']; ?>px;
410
  }
@@ -462,7 +458,7 @@ function cwppos_dynamic_stylesheet() {
462
  color: <?php echo $options['cwppos_buttontxth_color']; ?>;
463
  }
464
 
465
- <?php if($options['cwppos_show_icon'] == 'yes') { ?>
466
  div.affiliate-button a span {
467
  background: url("<?php echo WPPR_URL; ?>/images/cart-icon.png") no-repeat left center;
468
  }
@@ -473,7 +469,7 @@ function cwppos_dynamic_stylesheet() {
473
 
474
  <?php } ?>
475
 
476
- <?php if($options['cwppos_show_userreview'] == 'yes') { ?>
477
  .commentlist .comment-body p {
478
  clear: left;
479
  }
@@ -494,23 +490,19 @@ add_action( 'wp_head', 'cwppos_pac_print' );
494
  add_action( 'wp_footer', 'cwppos_dynamic_stylesheet' );
495
  add_action( 'admin_init', 'cwppos_pac_admin_init' );
496
  add_action( 'admin_enqueue_scripts', 'custom_bar_icon' );
497
- add_action( "wp_ajax_wppr-dismiss-amazon-link", "wppr_dismiss_amazon_link" );
498
  function wppr_dismiss_amazon_link() {
499
- $pointer_id = isset( $_POST["pointer"] ) ? $_POST["pointer"] : null;
500
  if ( $pointer_id ) {
501
  $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
502
  if ( ! $dismissed ) {
503
  $dismissed = array();
504
  }
505
  $dismissed[] = $pointer_id;
506
- update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', implode( ",", $dismissed ) );
507
  }
508
  }
509
 
510
- if ( ! class_exists( 'TAV_Remote_Notification_Client' ) ) {
511
- require( WPPR_PATH . '/inc/class-remote-notification-client.php' );
512
- }
513
- $notification = new TAV_Remote_Notification_Client( 36, '71a28628279f6d55', 'https://themeisle.com/?post_type=notification' );
514
  if ( class_exists( 'CWP_PR_PRO_Core' ) ) {
515
  $cwp_pr_pro = new CWP_PR_PRO_Core();
516
  }
1
  <?php
2
  /**
3
  * Core functions of WPPR
4
+ *
5
  * @package WPPR
6
  * @author ThemeIsle
7
  * @since 1.0.0
 
8
  */
9
  function cwppos_calc_overall_rating( $id ) {
10
  $options = cwppos();
11
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
12
+ ${'option' . $i . '_grade'} = get_post_meta( $id, 'option_' . $i . '_grade', true );
13
  // echo ${"option".$i."_grade"};
14
+ ${'comment_meta_option_nr_' . $i} = 0;
15
+ ${'comment_meta_option_' . $i} = 0;
16
 
17
  }
18
  $nr_of_comments = 0;
19
+ if ( $options['cwppos_show_userreview'] == 'yes' ) {
20
  $args = array(
21
  'status' => 'approve',
22
  'post_id' => $id, // use post_id, not post_ID
24
  $comments = get_comments( $args );
25
  $nr_of_comments = get_comments_number( $id );
26
  foreach ( $comments as $comment ) :
27
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
28
  if ( get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true ) !== '' ) {
29
+ ${'comment_meta_option_nr_' . $i} ++;
30
+ ${'comment_meta_option_' . $i} += get_comment_meta( $comment->comment_ID, "meta_option_{$i}", true ) * 10;
31
  }
32
 
33
+ // var_dump(${"comment_meta_option_".$i});
34
  }
35
  endforeach;
36
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
37
+ if ( ${'comment_meta_option_nr_' . $i} !== 0 ) {
38
+ ${'comment_meta_option_' . $i} = ${'comment_meta_option_' . $i} / ${'comment_meta_option_nr_' . $i};
39
  }
40
  }
 
41
  } else {
42
  $options['cwppos_infl_userreview'] = 0;
43
  }
47
  $overall_score = 0;
48
  $iter = 0;
49
  $rating = array();
50
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
51
+ if ( ${'comment_meta_option_nr_' . $i} !== 0 ) {
52
  $infl = $options['cwppos_infl_userreview'];
53
  } else {
54
  $infl = 0;
55
 
56
  }
57
  if ( ! empty( ${'option' . $i . '_grade'} ) || ${'option' . $i . '_grade'} === '0' ) {
58
+ // if($infl !== 0 ){
59
  ${'option' . $i . '_grade'} = round( ( ${'option' . $i . '_grade'} * ( 100 - $infl ) + ${'comment_meta_option_' . $i} * $infl ) / 100 );
60
+ // }else{
61
+ // }
62
  $iter ++;
63
  $rating[ 'option' . $i ] = round( ${'option' . $i . '_grade'} );
64
  $overall_score += ${'option' . $i . '_grade'};
65
  }
66
  }
67
+ // $overall_score = ($option1_grade + $option2_grade + $option3_grade + $option4_grade + $option5_grade) / $iter;
68
  if ( $iter !== 0 ) {
69
  $rating['overall'] = $overall_score / $iter;
70
  } else {
76
 
77
  }
78
 
79
+ function cwppos_show_review( $id = '', $visual = 'full' ) {
80
  global $post;
81
+ if ( (is_null( $post ) && $id == '') || post_password_required( $post ) ) {
82
  return false;
83
  }
84
+ if ( $id == '' ) {
85
  $id = $post->ID;
86
  }
87
  $cwp_review_stored_meta = get_post_meta( $id );
88
+ $return_string = '';
89
+ if ( isset( $cwp_review_stored_meta['cwp_meta_box_check'][0] ) && $cwp_review_stored_meta['cwp_meta_box_check'][0] == 'Yes' ) {
90
  wp_enqueue_style( 'cwp-pac-frontpage-stylesheet', WPPR_URL . '/css/frontpage.css', array(), WPPR_LITE_VERSION );
91
+ wp_enqueue_script( 'pie-chart', WPPR_URL . '/javascript/pie-chart.js', array( 'jquery' ), WPPR_LITE_VERSION, true );
92
  wp_enqueue_script( 'cwp-pac-main-script', WPPR_URL . '/javascript/main.js', array(
93
+ 'jquery',
94
+ 'pie-chart',
95
  ), WPPR_LITE_VERSION, true );
96
+ $cwp_price = get_post_meta( $id, 'cwp_rev_price', true );
97
  $p_string = $cwp_price;
98
+ $p_name = apply_filters( 'wppr_review_product_name', $id );
99
+ if ( $p_string != '' ) {
100
  // Added by Ash/Upwork
101
  $cwp_price = do_shortcode( $cwp_price );
102
  // Added by Ash/Upwork
103
+ $p_price = preg_replace( '/[^0-9.,]/', '', $cwp_price );
104
+ $p_currency = preg_replace( '/[0-9.,]/', '', $cwp_price );
105
  // Added by Ash/Upwork
106
+ $p_disable = apply_filters( 'wppr_disable_price_richsnippet', false );
107
  // Added by Ash/Upwork
108
  if ( ! $p_disable ) {
109
  $p_string = '<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span itemprop="priceCurrency">' . $p_currency . '</span><span itemprop="price">' . $p_price . '</span></span>';
110
  }
 
111
  }
112
+ $product_image = do_shortcode( get_post_meta( $id, 'cwp_rev_product_image', true ) );
113
+ $imgurl = do_shortcode( get_post_meta( $id, 'cwp_image_link', true ) );
114
+ $lightbox = '';
115
  $feat_image = wp_get_attachment_url( get_post_thumbnail_id( $id ) );
116
  if ( ! empty( $product_image ) ) {
117
  $product_image_cropped = wppr_get_image_id( $id, $product_image );
119
  $product_image_cropped = wppr_get_image_id( $id );
120
  $product_image = $feat_image;
121
  }
122
+ if ( $imgurl == 'image' ) {
123
+ // no means no disabled
124
+ if ( cwppos( 'cwppos_lighbox' ) == 'no' ) {
125
  $lightbox = 'data-lightbox="' . $product_image . '"';
126
+ wp_enqueue_script( 'img-lightbox', WPPR_URL . '/javascript/lightbox.min.js', array(), WPPR_LITE_VERSION, array() );
127
+ wp_enqueue_style( 'img-lightbox-css', WPPR_URL . '/css/lightbox.css', array(), WPPR_LITE_VERSION );
128
  }
129
  } else {
130
+ $product_image = do_shortcode( get_post_meta( $id, 'cwp_product_affiliate_link', true ) );
131
  }
132
  $rating = cwppos_calc_overall_rating( $id );
133
  $divrating = $rating['overall'] / 10;
134
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
135
+ ${'option' . $i . '_content'} = do_shortcode( get_post_meta( $id, 'option_' . $i . '_content', true ) );
136
+ if ( empty( ${'option' . $i . '_content'} ) ) {
137
+ ${'option' . $i . '_content'} = __( 'Default Feature ' . $i, 'cwppos' );
138
  }
139
  }
140
  $commentNr = get_comments_number( $id ) + 1;
141
+ if ( $visual == 'full' ) {
142
  $return_string .= '<section id="review-statistics" class="article-section" itemscope itemtype="http://schema.org/Product">
143
  <div class="review-wrap-up cwpr_clearfix" >
144
  <div class="cwpr-review-top cwpr_clearfix">
148
  </div><!-- end .cwpr-review-top -->
149
  <div class="review-wu-left">
150
  <div class="rev-wu-image">
151
+ <a href="' . $product_image . '" ' . $lightbox . ' rel="nofollow" target="_blank"><img itemprop="image" src="' . $product_image_cropped . '" alt="' . do_shortcode( get_post_meta( $id, 'cwp_rev_product_name', true ) ) . '" class="photo photo-wrapup wppr-product-image" /></a>
152
  </div><!-- end .rev-wu-image -->
153
  <div class="review-wu-grade">';
154
  }
155
+ if ( $visual == 'full' || $visual == 'yes' ) {
156
+ $extra_class = $visual == 'yes' ? 'cwp-chart-embed' : '';
157
  $return_string .= '<div class="cwp-review-chart ' . $extra_class . '">
158
+ <meta itemprop="datePublished" datetime="' . get_the_time( 'Y-m-d', $id ) . '">';
159
+ if ( cwppos( 'cwppos_infl_userreview' ) != 0 && $commentNr > 1 ) {
160
  $return_string .= '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="cwp-review-percentage" data-percent="';
161
  $return_string .= $rating['overall'] . '"><span itemprop="ratingValue" class="cwp-review-rating">' . $divrating . '</span><meta itemprop="bestRating" content = "10"/>
162
  <meta itemprop="ratingCount" content="' . $commentNr . '"> </div>';
169
  }
170
  $return_string .= '</div><!-- end .chart -->';
171
  }
172
+ if ( $visual == 'full' ) {
173
  $return_string .= '</div><!-- end .review-wu-grade -->
174
  <div class="review-wu-bars">';
175
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
176
  if ( ! empty( ${'option' . $i . '_content'} ) && isset( $rating[ 'option' . $i ] ) && ( ! empty( $rating[ 'option' . $i ] ) || $rating[ 'option' . $i ] === '0' ) && strtoupper( ${'option' . $i . '_content'} ) != 'DEFAULT FEATURE ' . $i ) {
177
  $return_string .= '<div class="rev-option" data-value=' . $rating[ 'option' . $i ] . '>
178
  <div class="cwpr_clearfix">
179
+ ' . apply_filters( 'wppr_option_name_html', $id, ${'option' . $i . '_content'} ) . '
180
  <span>' . round( $rating[ 'option' . $i ] / 10 ) . '/10</span>
181
  </div>
182
  <ul class="cwpr_clearfix"></ul>
188
  <div class="review-wu-right">
189
  <div class="pros">';
190
  }
191
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
192
+ ${'pro_option_' . $i} = do_shortcode( get_post_meta( $id, 'cwp_option_' . $i . '_pro', true ) );
193
+ if ( empty( ${'pro_option_' . $i} ) ) {
194
+ ${'pro_option_' . $i} = '';
195
  }
196
  }
197
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
198
+ ${'cons_option_' . $i} = do_shortcode( get_post_meta( $id, 'cwp_option_' . $i . '_cons', true ) );
199
+ if ( empty( ${'cons_option_' . $i} ) ) {
200
+ ${'cons_option_' . $i} = '';
201
  }
 
202
  }
203
+ if ( $visual == 'full' ) {
204
+ $return_string .= apply_filters( 'wppr_review_pros_text', $id, __( cwppos( 'cwppos_pros_text' ), 'cwppos' ) ) . ' <ul>';
205
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
206
+ if ( ! empty( ${'pro_option_' . $i} ) ) {
207
+ $return_string .= ' <li>' . ${'pro_option_' . $i} . '</li>';
208
  }
209
  }
210
  $return_string .= ' </ul>
211
  </div><!-- end .pros -->
212
  <div class="cons">';
213
+ $return_string .= apply_filters( 'wppr_review_cons_text', $id, __( cwppos( 'cwppos_cons_text' ), 'cwppos' ) ) . ' <ul>';
214
+ for ( $i = 1; $i <= cwppos( 'cwppos_option_nr' ); $i ++ ) {
215
+ if ( ! empty( ${'cons_option_' . $i} ) ) {
216
+ $return_string .= ' <li>' . ${'cons_option_' . $i} . '</li>';
217
  }
 
218
  }
219
  $return_string .= '
220
  </ul>
223
  </div><!-- end .review-wrap-up -->
224
  </section><!-- end #review-statistics -->';
225
  }
226
+ if ( cwppos( 'cwppos_show_poweredby' ) == 'yes' && ! class_exists( 'CWP_PR_PRO_Core' ) ) {
227
  $return_string .= '<div style="font-size:12px;width:100%;float:right"><p style="float:right;">Powered by <a href="http://wordpress.org/plugins/wp-product-review/" target="_blank" rel="nofollow" > WP Product Review</a></p></div>';
228
  }
229
+ $affiliate_text = do_shortcode( get_post_meta( $id, 'cwp_product_affiliate_text', true ) );
230
+ $affiliate_link = do_shortcode( get_post_meta( $id, 'cwp_product_affiliate_link', true ) );
231
+ $affiliate_text2 = do_shortcode( get_post_meta( $id, 'cwp_product_affiliate_text2', true ) );
232
+ $affiliate_link2 = do_shortcode( get_post_meta( $id, 'cwp_product_affiliate_link2', true ) );
233
  if ( ! empty( $affiliate_text2 ) && ! empty( $affiliate_link2 ) ) {
234
+ $bclass = 'affiliate-button2 affiliate-button';
235
  } else {
236
+ $bclass = 'affiliate-button';
237
  }
238
+ if ( $visual == 'full' && ! empty( $affiliate_text ) && ! empty( $affiliate_link ) ) {
239
  $return_string .= '<div class="' . $bclass . '">
240
  <a href="' . $affiliate_link . '" rel="nofollow" target="_blank"><span>' . $affiliate_text . '</span> </a>
241
  </div><!-- end .affiliate-button -->';
242
  }
243
+ if ( $visual == 'full' && ! empty( $affiliate_text2 ) && ! empty( $affiliate_link2 ) ) {
244
  $return_string .= '<div class="affiliate-button affiliate-button2">
245
  <a href="' . $affiliate_link2 . '" rel="nofollow" target="_blank"><span>' . $affiliate_text2 . '</span> </a>
246
  </div><!-- end .affiliate-button -->';
247
  }
248
+ if ( $visual == 'no' ) {
249
  $return_string = round( $divrating );
250
  }
251
  }
255
 
256
  function cwppos_pac_admin_init() {
257
  wp_enqueue_style( 'cwp-pac-admin-stylesheet', WPPR_URL . '/css/dashboard_styles.css' );
258
+ wp_register_script( 'cwp-pac-script', WPPR_URL . '/javascript/admin-review.js', array( 'jquery' ), '20140101', true );
259
  wp_localize_script( 'cwp-pac-script', 'ispro', array( 'value' => class_exists( 'CWP_PR_PRO_Core' ) ) );
260
  wp_enqueue_script( 'cwp-pac-script' );
261
  if ( class_exists( 'CWP_PR_PRO_Core' ) ) {
262
  wp_enqueue_style( 'cwp-pac-pro-admin-stylesheet', WPPR_URL . '/css/pro_dashboard_styles.css' );
263
  }
264
+ do_action( 'wppr-amazon-enqueue' );
265
  }
266
 
267
+ function wppr_get_image_id( $post_id, $image_url = '', $size = 'thumbnail' ) {
268
  global $wpdb;
269
+ // filter for image size;
270
+ $size = apply_filters( 'wppr_review_image_size', $size, $post_id );
271
  if ( ! empty( $image_url ) && $image_url !== false ) {
272
  $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ) );
273
  $image_id = isset( $attachment[0] ) ? $attachment[0] : '';
275
  $image_id = get_post_thumbnail_id( $post_id );
276
 
277
  }
278
+ $image_thumb = '';
279
  if ( ! empty( $image_id ) ) {
280
  $image_thumb = wp_get_attachment_image_src( $image_id, $size );
281
  if ( $size !== 'thumbnail' ) {
282
  if ( $image_thumb[0] === $image_url ) {
283
+ $image_thumb = wp_get_attachment_image_src( $image_id, 'thumbnail' );
284
  }
285
  }
286
  }
290
 
291
  function custom_bar_icon() {
292
  $options = cwppos();
293
+ if ( ( isset( $options['cwppos_show_poweredby'] ) && $options['cwppos_show_poweredby'] == 'yes' ) || function_exists( 'wppr_ci_custom_bar_icon' ) || class_exists( 'CWP_PR_PRO_Core' ) ) {
294
+ wp_register_script( 'cwp-custom-bar-icon', WPPR_URL . '/javascript/custom-bar-icon.js', false, '1.0', 'all' );
295
+ wp_enqueue_script( 'cwp-custom-bar-icon' );
296
  }
297
  wppr_add_pointers();
298
  }
320
  return;
321
  }
322
  // Add pointers style to queue.
323
+ wp_enqueue_style( 'wp-pointer', array( 'jquery' ) );
324
+ wp_enqueue_script( 'wppr-pointers', WPPR_URL . '/javascript/cwp-pointers.js', array( 'wp-pointer' ), WPPR_LITE_VERSION, true );
325
+ wp_localize_script( 'wppr-pointers', 'cwpp', array( 'pointers' => $valid ) );
326
  }
327
 
328
  function cwppos_pac_register() {
329
+ add_image_size( 'wppr_widget_image', 50, 50 );
330
  }
331
 
332
  function cwp_def_settings() {
333
  global $post;
334
  $options = cwppos();
335
+ if ( function_exists( 'wppr_ci_custom_bar_icon' ) || ( isset( $options['cwppos_show_poweredby'] ) && $options['cwppos_show_poweredby'] == 'yes' ) ) {
336
  $isSetToPro = true;
337
  } else {
338
  $isSetToPro = false;
339
  }
340
+ $uni_font = cwppos( 'cwppos_change_bar_icon' );
341
  $track = $options['cwppos_rating_chart_default'];
342
+ // if ($uni_font!=="&#")
343
  if ( isset( $uni_font[0] ) ) {
344
+ if ( $uni_font[0] == '#' ) {
345
  $uni_font = $uni_font;
346
  } else {
347
  $uni_font = $uni_font[0];
348
  }
349
  } else {
350
+ $uni_font = '';
351
  }
352
  if ( ! empty( $uni_font ) ) {
353
+ if ( function_exists( 'wppr_ci_custom_bar_icon' ) || cwppos( 'cwppos_show_poweredby' ) == 'yes' ) {
354
+ if ( cwppos( 'cwppos_fontawesome' ) === 'no' ) {
355
  wp_enqueue_style( 'cwp-pac-fontawesome-stylesheet', WPPR_URL . '/css/font-awesome.min.css' );
356
  }
357
  }
369
 
370
  function cwppos_dynamic_stylesheet() {
371
  $options = cwppos();
372
+ // Get theme content width or plugin setting content width
373
  global $content_width;
374
  $c_width = 700;
375
+ if ( $options['cwppos_widget_size'] != '' ) {
376
  $c_width = $options['cwppos_widget_size'];
377
  } else {
378
  $c_width = $content_width;
393
 
394
  #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart .cwp-review-percentage {
395
 
396
+ margin-top: <?php echo $f_img_size * 0.1;?>%;
397
  }
398
 
399
  #review-statistics .review-wrap-up .review-wu-left .review-wu-grade .cwp-review-chart span {
400
+ font-size: <?php echo round( 30 * $f_img_size / 140 );?>px;
401
  }
402
 
403
+ <?php if ( $options['cwppos_widget_size'] != '' ) { ?>
404
  #review-statistics {
405
  width: <?php echo $options['cwppos_widget_size']; ?>px;
406
  }
458
  color: <?php echo $options['cwppos_buttontxth_color']; ?>;
459
  }
460
 
461
+ <?php if ( $options['cwppos_show_icon'] == 'yes' ) { ?>
462
  div.affiliate-button a span {
463
  background: url("<?php echo WPPR_URL; ?>/images/cart-icon.png") no-repeat left center;
464
  }
469
 
470
  <?php } ?>
471
 
472
+ <?php if ( $options['cwppos_show_userreview'] == 'yes' ) { ?>
473
  .commentlist .comment-body p {
474
  clear: left;
475
  }
490
  add_action( 'wp_footer', 'cwppos_dynamic_stylesheet' );
491
  add_action( 'admin_init', 'cwppos_pac_admin_init' );
492
  add_action( 'admin_enqueue_scripts', 'custom_bar_icon' );
493
+ add_action( 'wp_ajax_wppr-dismiss-amazon-link', 'wppr_dismiss_amazon_link' );
494
  function wppr_dismiss_amazon_link() {
495
+ $pointer_id = isset( $_POST['pointer'] ) ? $_POST['pointer'] : null;
496
  if ( $pointer_id ) {
497
  $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
498
  if ( ! $dismissed ) {
499
  $dismissed = array();
500
  }
501
  $dismissed[] = $pointer_id;
502
+ update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', implode( ',', $dismissed ) );
503
  }
504
  }
505
 
 
 
 
 
506
  if ( class_exists( 'CWP_PR_PRO_Core' ) ) {
507
  $cwp_pr_pro = new CWP_PR_PRO_Core();
508
  }
javascript/admin-review.js CHANGED
@@ -1,3 +1,4 @@
 
1
  jQuery(document).ready(function(){
2
 
3
  var meta_image_frame;
1
+ /* jshint ignore:start */
2
  jQuery(document).ready(function(){
3
 
4
  var meta_image_frame;
javascript/custom-bar-icon.js CHANGED
@@ -1,4 +1,5 @@
1
- jQuery("#cwp_select_bar_icon").click(function(a) {
 
2
  a.preventDefault();
3
  a.stopPropagation();
4
  var b = ["&#xf096","&#xf08a","&#xf11b","&#xf06d","&#xf1b2","&#xf005","&#xf155","&#xf1db","&#xf006","&#xf0c8","&#xf02d","&#xf135","&#xf013","&#xf0fa",];
1
+ /* jshint ignore:start */
2
+ jQuery("#cwp_select_bar_icon").click(function(a) {
3
  a.preventDefault();
4
  a.stopPropagation();
5
  var b = ["&#xf096","&#xf08a","&#xf11b","&#xf06d","&#xf1b2","&#xf005","&#xf155","&#xf1db","&#xf006","&#xf0c8","&#xf02d","&#xf135","&#xf013","&#xf0fa",];
javascript/cwp-pointers.js CHANGED
@@ -1,3 +1,4 @@
 
1
  (function ($, cwpp){
2
 
3
  $(document).ready( function() {
1
+ /* jshint ignore:start */
2
  (function ($, cwpp){
3
 
4
  $(document).ready( function() {
javascript/lightbox.min.js CHANGED
@@ -1,3 +1,4 @@
 
1
  /**
2
  * Lightbox v2.7.1
3
  * by Lokesh Dhakar - http:
1
+ /* jshint ignore:start */
2
  /**
3
  * Lightbox v2.7.1
4
  * by Lokesh Dhakar - http:
javascript/main.js CHANGED
@@ -1,3 +1,4 @@
 
1
  /**
2
  * Main JavaScript File
3
  */
1
+ /* jshint ignore:start */
2
  /**
3
  * Main JavaScript File
4
  */
javascript/pie-chart.js CHANGED
@@ -1,4 +1,4 @@
1
-
2
 
3
  /*
4
 
1
+ /* jshint ignore:start */
2
 
3
  /*
4
 
javascript/widget-latest.js CHANGED
@@ -1,3 +1,4 @@
 
1
  (function($, w){
2
 
3
  $(document).ready(function(){
1
+ /* jshint ignore:start */
2
  (function($, w){
3
 
4
  $(document).ready(function(){
javascript/widget-top.js CHANGED
@@ -1,3 +1,4 @@
 
1
  (function($, w){
2
 
3
  $(document).ready(function(){
1
+ /* jshint ignore:start */
2
  (function($, w){
3
 
4
  $(document).ready(function(){
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: codeinwp,marius2012,marius_codeinwp,hardeepasrani,themeisle,Madali
3
  Tags: review, rating, posts, widget, review blogger, review blogging, affiliate, product reviews,plugin, google rating, product review, rating, review, star rating, user rating, wp rating, wp review, google, hreview,rich snippets,seo,snippet
4
  Author URI: http://themeisle.com
5
  Requires at least: 3.5
6
- Tested up to: 4.6
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -72,6 +72,11 @@ If you wanna learn more about the <a href="http://www.codeinwp.com/blog/fastest-
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
75
  **New in 2.9.5**
76
 
77
  - Added amazon integration support
3
  Tags: review, rating, posts, widget, review blogger, review blogging, affiliate, product reviews,plugin, google rating, product review, rating, review, star rating, user rating, wp rating, wp review, google, hreview,rich snippets,seo,snippet
4
  Author URI: http://themeisle.com
5
  Requires at least: 3.5
6
+ Tested up to: 4.6.1
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
72
 
73
  == Changelog ==
74
 
75
+ **New in 2.9.6**
76
+
77
+ - Fixed undefined notices
78
+ - Fixed sanitization issues
79
+
80
  **New in 2.9.5**
81
 
82
  - Added amazon integration support
wp-product-review.php CHANGED
@@ -9,7 +9,7 @@
9
  *
10
  * Plugin Name: WP Product Review Lite
11
  * Description: The highest rated and most complete review plugin, now with rich snippets support. Easily turn your basic posts into in-depth reviews.
12
- * Version: 2.9.5
13
  * Author: Themeisle
14
  * Author URI: http://themeisle.com/
15
  * Plugin URI: http://themeisle.com/plugins/wp-product-review-lite/
@@ -22,9 +22,9 @@
22
  * Domain Path: /languages
23
  */
24
 
25
- define( 'WPPR_LITE_VERSION','2.9.5' );
26
  define( 'WPPR_PATH',dirname( __FILE__ ) );
27
- define( 'WPPR_SLUG', "wppr" );
28
  define( 'WPPR_URL',plugins_url( 'wp-product-review' ) );
29
 
30
  if ( wp_get_theme() !== 'Reviewgine Affiliate PRO' ) {
@@ -40,29 +40,28 @@ if ( wp_get_theme() !== 'Reviewgine Affiliate PRO' ) {
40
  include 'inc/abtesting/abtesting.php';
41
  }
42
 
43
- add_filter(WPPR_SLUG . "_upsell_config", "wppr_upsell_config");
44
- if( class_exists("TIABTesting") ) {
45
 
46
- $abtesting = new TIABTesting(WPPR_SLUG, WPPR_LITE_VERSION);
47
 
48
  }
49
- function wppr_upsell_config($config)
50
- {
51
- return array (
52
- "preloader" => array(
53
- __(" In order to be able to automatically load your options from another posts, you need the PRO add-on", "cwppos"). '<a href="http://bit.ly/2bpC3vT" target="_blank" class="preload_info_upsell">'.__("View Preload features","cwppos").'</a>',
54
- "<i>".__(" You can always import options from other reviews using the preloader feature from the PRO add-on", "cwppos"). '</i><a href="http://bit.ly/2c1QNFK" target="_blank" class="preload_info_upsell">'.__("View more PRO features","cwppos").'</a>',
55
- "<i>".__(" Build review more easily by importing them from other posts using the preloader feature from the pro addon", "cwppos"). '</i><a href="http://bit.ly/2bT89Sk" target="_blank" class="preload_info_upsell">'.__("View details","cwppos").'</a>',
56
- ),
57
- "amazon_title" => array(
58
- __("Hold on", "cwppos"),
59
- __("Breaking news", "cwppos"),
60
- __("Review tip", "cwppos"),
61
- __("Integrate with Amazon", "cwppos"),
62
- ),
63
- "amazon_body" => array(
64
- __("Do you know that you can import products directly from your amazon affiliate account using the <a href='http://bit.ly/2cjpsux'>PRO</a> version", "cwppos"),
65
- __("Do you know that you can import products from amazon and keep them synced using the <a href='http://bit.ly/2cEefYy'>PRO</a> version ", "cwppos")
66
- ),
67
  );
68
  }
9
  *
10
  * Plugin Name: WP Product Review Lite
11
  * Description: The highest rated and most complete review plugin, now with rich snippets support. Easily turn your basic posts into in-depth reviews.
12
+ * Version: 2.9.6
13
  * Author: Themeisle
14
  * Author URI: http://themeisle.com/
15
  * Plugin URI: http://themeisle.com/plugins/wp-product-review-lite/
22
  * Domain Path: /languages
23
  */
24
 
25
+ define( 'WPPR_LITE_VERSION', '2.9.6' );
26
  define( 'WPPR_PATH',dirname( __FILE__ ) );
27
+ define( 'WPPR_SLUG', 'wppr' );
28
  define( 'WPPR_URL',plugins_url( 'wp-product-review' ) );
29
 
30
  if ( wp_get_theme() !== 'Reviewgine Affiliate PRO' ) {
40
  include 'inc/abtesting/abtesting.php';
41
  }
42
 
43
+ add_filter( WPPR_SLUG . '_upsell_config', 'wppr_upsell_config' );
44
+ if ( class_exists( 'TIABTesting' ) ) {
45
 
46
+ $abtesting = new TIABTesting( WPPR_SLUG, WPPR_LITE_VERSION );
47
 
48
  }
49
+ function wppr_upsell_config( $config ) {
50
+ return array(
51
+ 'preloader' => array(
52
+ __( ' In order to be able to automatically load your options from another posts, you need the PRO add-on', 'cwppos' ) . '<a href="http://bit.ly/2bpC3vT" target="_blank" class="preload_info_upsell">' . __( 'View Preload features','cwppos' ) . '</a>',
53
+ '<i>' . __( ' You can always import options from other reviews using the preloader feature from the PRO add-on', 'cwppos' ) . '</i><a href="http://bit.ly/2c1QNFK" target="_blank" class="preload_info_upsell">' . __( 'View more PRO features','cwppos' ) . '</a>',
54
+ '<i>' . __( ' Build review more easily by importing them from other posts using the preloader feature from the pro addon', 'cwppos' ) . '</i><a href="http://bit.ly/2bT89Sk" target="_blank" class="preload_info_upsell">' . __( 'View details','cwppos' ) . '</a>',
55
+ ),
56
+ 'amazon_title' => array(
57
+ __( 'Hold on', 'cwppos' ),
58
+ __( 'Breaking news', 'cwppos' ),
59
+ __( 'Review tip', 'cwppos' ),
60
+ __( 'Integrate with Amazon', 'cwppos' ),
61
+ ),
62
+ 'amazon_body' => array(
63
+ __( "Do you know that you can import products directly from your amazon affiliate account using the <a href='http://bit.ly/2cjpsux'>PRO</a> version", 'cwppos' ),
64
+ __( "Do you know that you can import products from amazon and keep them synced using the <a href='http://bit.ly/2cEefYy'>PRO</a> version ", 'cwppos' ),
65
+ ),
 
66
  );
67
  }