Advanced AJAX Product Filters - Version 1.2.1

Version Description

  • Upgrade - Option to subscribe
  • Upgrade - Better advertisement
Download this release

Release Info

Developer dholovnia
Plugin Icon wp plugin Advanced AJAX Product Filters
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

css/admin.css CHANGED
@@ -14,4 +14,4 @@
14
  .admin-column-theme{width: 14%;}
15
  .admin-column-theme select{max-width: 100%;}
16
  .tab-item{display: none;}
17
- .tab-item.current{display: block;}
14
  .admin-column-theme{width: 14%;}
15
  .admin-column-theme select{max-width: 100%;}
16
  .tab-item{display: none;}
17
+ .tab-item.current{display: block;}
images/ad_white_on_orange.png ADDED
Binary file
includes/admin_notices.php ADDED
@@ -0,0 +1,666 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*new berocket_admin_notices(array(
3
+ 'start' => 1497880000, // timestamp when notice start
4
+ 'end' => 1497885000, // timestamp when notice end
5
+ 'name' => 'name', //notice name must be unique for this time period
6
+ 'html' => '', //text or html code as content of notice
7
+ 'righthtml' => '<a class="berocket_no_thanks">No thanks</a>', //content in the right block, this is default value. This html code must be added to all notices
8
+ 'rightwidth' => 80, //width of right content is static and will be as this value. berocket_no_thanks block is 60px and 20px is additional
9
+ 'nothankswidth' => 60, //berocket_no_thanks width. set to 0 if block doesn't uses. Or set to any other value if uses other text inside berocket_no_thanks
10
+ 'contentwidth' => 400, //width that uses for mediaquery is image_width + contentwidth + rightwidth
11
+ 'subscribe' => false, //add subscribe form to the righthtml
12
+ 'priority' => 20, //priority of notice. 1-5 is main priority and displays on settings page always
13
+ 'height' => 50, //height of notice. image will be scaled
14
+ 'repeat' => false, //repeat notice after some time. time can use any values that accept function strtotime
15
+ 'repeatcount' => 1, //repeat count. how many times notice will be displayed after close
16
+ 'image' => array(
17
+ 'global' => 'http://berocket.com/images/logo-2.png', //image URL from other site. Image will be copied to uploads folder if it possible
18
+ //'local' => 'http://wordpress-site.com/wp-content/uploads/logo-2.png', //notice will be used this image directly
19
+ ),
20
+ ));*/
21
+ //delete_option('berocket_admin_notices'); //remove all notice information
22
+ //delete_option('berocket_last_close_notices_time'); //remove wait time before next notice
23
+ if( ! class_exists( 'berocket_admin_notices' ) ) {
24
+ class berocket_admin_notices {
25
+ public $find_names, $notice_exist = false;
26
+ public static $last_time = '-24 hours';
27
+ public static $end_soon_time = '+1 hour';
28
+ public static $subscribed = false;
29
+ public static $jquery_script_exist = false;
30
+ function __construct($options = array()) {
31
+ $options = array_merge(
32
+ array(
33
+ 'start' => 0,
34
+ 'end' => 0,
35
+ 'name' => 'sale',
36
+ 'html' => '',
37
+ 'righthtml' => '<a class="berocket_no_thanks">No thanks</a>',
38
+ 'rightwidth' => 80,
39
+ 'nothankswidth' => 60,
40
+ 'contentwidth' => 400,
41
+ 'subscribe' => false,
42
+ 'closed' => '0',
43
+ 'priority' => 20,
44
+ 'height' => 50,
45
+ 'repeat' => false,
46
+ 'repeatcount' => 1,
47
+ 'image' => array(
48
+ 'global' => 'http://berocket.com/images/logo-2.png'
49
+ ),
50
+ ),
51
+ $options
52
+ );
53
+ self::set_notice_by_path($options);
54
+ }
55
+ public static function sort_notices($notices) {
56
+ return self::sort_array (
57
+ $notices,
58
+ array(
59
+ 1 => 'krsort',
60
+ 2 => 'ksort',
61
+ 3 => 'ksort'
62
+ ),
63
+ array(
64
+ '1' => SORT_NUMERIC,
65
+ '2' => SORT_NUMERIC,
66
+ '3' => SORT_NUMERIC
67
+ )
68
+ );
69
+ }
70
+ public static function sort_array($array, $sort_functions, $options, $count = 3) {
71
+ if( $count > 0 ) {
72
+ if( ! is_array($array) ) {
73
+ return array();
74
+ }
75
+ $call_function = $sort_functions[$count];
76
+ $call_function($array, $options[$count]);
77
+ if( isset($array[0]) ) {
78
+ $first_element = $array[0];
79
+ unset($array[0]);
80
+ $array[0] = $first_element;
81
+ unset($first_element);
82
+ }
83
+ foreach($array as $item_id => $item) {
84
+ if( $count == 2 ) {
85
+ $time = time();
86
+ if( $item_id < $time && $item_id != 0 ) {
87
+ unset($array[$item_id]);
88
+ } else {
89
+ $array[$item_id] = self::sort_array($item, $sort_functions, $options, $count - 1);
90
+ }
91
+ } else {
92
+ $array[$item_id] = self::sort_array($item, $sort_functions, $options, $count - 1);
93
+ }
94
+ if( isset($array[$item_id]) && ( ! is_array($array[$item_id]) || count($array[$item_id]) == 0 ) ) {
95
+ unset($array[$item_id]);
96
+ }
97
+ }
98
+ }
99
+ return $array;
100
+ }
101
+ public static function get_notice_by_path($find_names) {
102
+ $notices = get_option('berocket_admin_notices');
103
+ if( ! is_array($notices) ) {
104
+ $notices = array();
105
+ }
106
+ $current_notice = &$notices;
107
+ foreach($find_names as $find_name) {
108
+ if( isset($current_notice[$find_name]) ) {
109
+ $new_current_notice = &$current_notice[$find_name];
110
+ unset($current_notice);
111
+ $current_notice = &$new_current_notice;
112
+ unset($new_current_notice);
113
+ } else {
114
+ unset($current_notice);
115
+ break;
116
+ }
117
+ }
118
+ return $current_notice;
119
+ }
120
+ public static function set_notice_by_path($options, $replace = false, $find_names = false) {
121
+ self::$subscribed = get_option('berocket_email_subscribed');
122
+ if( self::$subscribed && $options['subscribe'] ) {
123
+ return false;
124
+ }
125
+ $notices = get_option('berocket_admin_notices');
126
+ if( $options['end'] < time() && $options['end'] != 0 ) {
127
+ return false;
128
+ }
129
+ if( $find_names === false ) {
130
+ $find_names = array($options['priority'], $options['end'], $options['start'], $options['name']);
131
+ }
132
+ if( ! is_array($notices) ) {
133
+ $notices = array();
134
+ }
135
+ $current_notice = &$notices;
136
+ foreach($find_names as $find_name) {
137
+ if( ! isset($current_notice[$find_name]) ) {
138
+ $current_notice[$find_name] = array();
139
+ }
140
+ $new_current_notice = &$current_notice[$find_name];
141
+ unset($current_notice);
142
+ $current_notice = &$new_current_notice;
143
+ unset($new_current_notice);
144
+ }
145
+ if( empty($options['image']) || (empty($options['image']['local']) && empty($options['image']['global'])) ) {
146
+ $options['image'] = array('width' => 0, 'height' => 0, 'scale' => 0);
147
+ } else {
148
+ if( isset($options['image']['global']) ) {
149
+ $wp_upload = wp_upload_dir();
150
+ if( ! isset($options['image']['local']) ) {
151
+ $url_global = $options['image']['global'];
152
+ $img_local = $wp_upload['basedir'] . '/' . basename($url_global);
153
+ $url_local = $wp_upload['baseurl'] . '/' . basename($url_global);
154
+ if( ! file_exists($img_local) && is_writable($wp_upload['path']) ) {
155
+ file_put_contents($img_local, file_get_contents($url_global));
156
+ }
157
+ if( file_exists($img_local) ) {
158
+ $options['image']['local'] = $url_local;
159
+ $options['image']['pathlocal'] = $img_local;
160
+ } else {
161
+ $options['image']['local'] = $url_global;
162
+ }
163
+ }
164
+ }
165
+ $image_size = @ getimagesize($options['image']['local']);
166
+ if( ! empty($image_size[0]) && ! empty($image_size[1]) ) {
167
+ $options['image']['width'] = $image_size[0];
168
+ $options['image']['height'] = $image_size[1];
169
+ } else {
170
+ $options['image']['width'] = $options['height'];
171
+ $options['image']['height'] = $options['height'];
172
+ }
173
+ $options['image']['scale'] = $options['height'] / $options['image']['height'];
174
+ }
175
+ if( count($current_notice) == 0 ) {
176
+ $current_notice = $options;
177
+ } else {
178
+ if( ! empty($options['image']['local']) && $options['image']['local'] != $current_notice['image']['local'] ) {
179
+ if( isset($current_notice['image']['pathlocal']) ) {
180
+ unlink($current_notice['image']['pathlocal']);
181
+ }
182
+ }
183
+ if( ! $replace ) {
184
+ $options['closed'] = $current_notice['closed'];
185
+ }
186
+ $current_notice = $options;
187
+ }
188
+ $notices = self::sort_notices($notices);
189
+ update_option('berocket_admin_notices', $notices);
190
+ return true;
191
+ }
192
+ public static function get_notice() {
193
+ $notices = get_option('berocket_admin_notices');
194
+ $last_time = get_option('berocket_last_close_notices_time');
195
+ self::$subscribed = get_option('berocket_email_subscribed');
196
+ if( ! is_array($notices) || count($notices) == 0 ) return false;
197
+ if( $last_time > strtotime(self::$last_time) ) {
198
+ $current_notice = self::get_not_closed_notice($notices, true);
199
+ } else {
200
+ $current_notice = self::get_not_closed_notice($notices);
201
+ }
202
+ update_option('berocket_current_displayed_notice', $current_notice);
203
+ return $current_notice;
204
+ }
205
+ public static function get_notice_for_settings() {
206
+ $notices = get_option('berocket_admin_notices');
207
+ $last_notice = get_option('berocket_admin_notices_last_on_options');
208
+ self::$subscribed = get_option('berocket_email_subscribed');
209
+ $notices = self::get_notices_with_priority($notices);
210
+ if( ! is_array($notices) || count($notices) == 0 ) {
211
+ return false;
212
+ }
213
+ if( $last_notice === false ) {
214
+ $last_notice = 0;
215
+ } else {
216
+ $last_notice++;
217
+ }
218
+ if( count($notices) <= $last_notice ) {
219
+ $last_notice = 0;
220
+ }
221
+ update_option('berocket_admin_notices_last_on_options', $last_notice);
222
+ $notice = $notices[$last_notice];
223
+ return $notice;
224
+ }
225
+ public static function get_not_closed_notice($array, $end_soon = false, $closed = 0, $count = 3) {
226
+ $notice = false;
227
+ if( empty($array) || ! is_array($array) ) {
228
+ $array = array();
229
+ }
230
+ $time = time();
231
+ foreach($array as $item_id => $item) {
232
+ if( $count > 0 ) {
233
+ if( $count == 2 && $item_id < $time && $item_id != 0 || $count == 1 && $item_id > $time && $item_id != 0 ) {
234
+ continue;
235
+ }
236
+ if( $count == 2 && $item_id < strtotime(self::$end_soon_time) && $item_id != 0 ) {
237
+ $notice = self::get_not_closed_notice($item, $end_soon, 1, $count - 1);
238
+ } else {
239
+ if( $end_soon && $count == 2 ) {
240
+ break;
241
+ }
242
+ $notice = self::get_not_closed_notice($item, $end_soon, $closed, $count - 1);
243
+ }
244
+ } else {
245
+ if( $item['closed'] <= $closed && ( ! self::$subscribed || ! $item['subscribe'] ) ) {
246
+ return $item;
247
+ }
248
+ }
249
+ if( $notice != false ) break;
250
+ }
251
+ return $notice;
252
+ }
253
+ public static function get_notices_with_priority($array, $priority = 5, $count = 3) {
254
+ $notice = false;
255
+ if( empty($array) || ! is_array($array) ) {
256
+ $array = array();
257
+ }
258
+ $time = time();
259
+ $notices = array();
260
+ foreach($array as $item_id => $item) {
261
+ if( $count > 0 ) {
262
+ if( $count == 3 && $item_id > $priority || $count == 2 && $item_id < $time && $item_id != 0 || $count == 1 && $item_id > $time && $item_id != 0 ) {
263
+ continue;
264
+ }
265
+ $notice = self::get_notices_with_priority($item, $priority, $count - 1);
266
+ $notices = array_merge($notices, $notice);
267
+ } else {
268
+ if( ! self::$subscribed || ! $item['subscribe'] ) {
269
+ $notices[] = $item;
270
+ }
271
+ }
272
+ }
273
+ return $notices;
274
+ }
275
+ public static function display_admin_notice() {
276
+ $settings_page = apply_filters('is_berocket_settings_page', false);
277
+ if( $settings_page ) {
278
+ $notice = self::get_notice_for_settings();
279
+ } else {
280
+ $notice = self::get_notice();
281
+ }
282
+ if( ! empty($notice['original']) ) {
283
+ $original_notice = self::get_notice_by_path($notice['original']);
284
+ unset($original_notice['start'], $original_notice['closed'], $original_notice['repeatcount']);
285
+ $notice = $original_notice;
286
+ }
287
+
288
+ if( $notice !== false ) {
289
+ $notice_data = array(
290
+ 'start' => $notice['start'],
291
+ 'end' => $notice['end'],
292
+ 'name' => $notice['name'],
293
+ 'priority' => $notice['priority'],
294
+ );
295
+ if( $notice['end'] < strtotime(self::$end_soon_time) && $notice['end'] != 0 ) {
296
+ $time_left = $notice['end'] - time();
297
+ $time_left_str = "";
298
+ $time = $time_left;
299
+ if ( $time >= 3600 ) {
300
+ $hours = floor( $time/3600 );
301
+ $time = $time%3600;
302
+ $time_left_str .= sprintf("%02d", $hours) . ":";
303
+ }
304
+ if ( $time >= 60 || $time_left >= 3600 ) {
305
+ $minutes = floor( $time/60 );
306
+ $time = $time%60;
307
+ $time_left_str .= sprintf("%02d", $minutes) . ":";
308
+ }
309
+
310
+ $time_left_str .= sprintf("%02d", $time);
311
+ $notice['rightwidth'] += 60;
312
+ $notice['righthtml'] .= '<div class="berocket_time_left_block">Left<br><span class="berocket_time_left" data-time="' . $time_left . '">' . $time_left_str . '</span></div>';
313
+ }
314
+ if( ! empty($notice['subscribe']) ) {
315
+ $user_email = wp_get_current_user();
316
+ if( isset($user_email->user_email) ) {
317
+ $user_email = $user_email->user_email;
318
+ } else {
319
+ $user_email = '';
320
+ }
321
+ $notice['righthtml'] =
322
+ '<form class="berocket_subscribe_form" method="POST" action="' . admin_url( 'admin-ajax.php' ) . '">
323
+ <input type="hidden" name="action" value="berocket_subscribe_email">
324
+ <input class="berocket_subscribe_email" type="email" name="email" value="' . $user_email . '">
325
+ <input type="submit" class="button-primary button berocket_notice_submit" value="Subscribe">
326
+ </form>' . $notice['righthtml'];
327
+ $notice['rightwidth'] += 300;
328
+ }
329
+ echo '
330
+ <div class="notice berocket_admin_notice" data-notice=\'', json_encode($notice_data), '\'>',
331
+ ( empty($notice['image']['local']) ? '' : '<img class="berocket_notice_img" src="' . $notice['image']['local'] . '">' ),
332
+ ( empty($notice['righthtml']) ? '' :
333
+ '<div class="berocket_notice_right_content">
334
+ <div class="berocket_notice_content">' . $notice['righthtml'] . '</div>
335
+ <div class="berocket_notice_after_content"></div>
336
+ </div>' ),
337
+ '<div class="berocket_notice_content_wrap">
338
+ <div class="berocket_notice_content">', $notice['html'], '</div>
339
+ <div class="berocket_notice_after_content"></div>
340
+ </div></div>';
341
+ if( $settings_page ) {
342
+ $notice['rightwidth'] -= $notice['nothankswidth'];
343
+ }
344
+ echo '<style>
345
+ .berocket_admin_notice {
346
+ height: ', $notice['height'], 'px;
347
+ padding: 0;
348
+ min-width: ', max($notice['image']['width'] * $notice['image']['scale'], $notice['rightwidth']), 'px;
349
+ border-left: 0 none;
350
+ border-radius: 3px;
351
+ overflow: hidden;
352
+ box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.2);
353
+ }
354
+ .berocket_admin_notice .berocket_notice_img {
355
+ height: ', $notice['height'], 'px;
356
+ width: ', ($notice['image']['width'] * $notice['image']['scale']), 'px;
357
+ float: left;
358
+ }
359
+ .berocket_admin_notice .berocket_notice_content_wrap {
360
+ margin-left: ', ($notice['image']['width'] * $notice['image']['scale'] + 5), 'px;
361
+ margin-right: ', ($notice['rightwidth'] <= 20 ? 0 : $notice['rightwidth'] + 15), 'px;
362
+ box-sizing: border-box;
363
+ height: ', $notice['height'], 'px;
364
+ overflow: auto;
365
+ overflow-x: hidden;
366
+ overflow-y: auto;
367
+ }
368
+ .berocket_admin_notice .berocket_notice_content {
369
+ display: inline-block;
370
+ vertical-align: middle;
371
+ padding: 5px;
372
+ max-width: 99%;
373
+ box-sizing: border-box;
374
+ }
375
+ .berocket_admin_notice .berocket_notice_after_content {
376
+ display: inline-block;
377
+ vertical-align: middle;
378
+ height: 100%;
379
+ width: 0px;
380
+ }
381
+ .berocket_admin_notice .berocket_notice_right_content {',
382
+ ( $notice['rightwidth'] <= 20 ? ' display: none' :
383
+ 'height: ' . $notice['height'] . 'px;
384
+ float: right;
385
+ width: ' . $notice['rightwidth'] . 'px;
386
+ -webkit-box-shadow: box-shadow: -1px 0 0 0 rgba(0, 0, 0, 0.1);
387
+ box-shadow: -1px 0 0 0 rgba(0, 0, 0, 0.1);
388
+ padding-left: 10px;' ),
389
+ '}
390
+ .berocket_admin_notice .berocket_no_thanks {',
391
+ ( $settings_page ? 'display: none!important;' : 'cursor: pointer;
392
+ color: #0073aa;
393
+ opacity: 0.5;
394
+ display: inline-block;' ),
395
+ '}
396
+ .berocket_admin_notice .berocket_no_thanks:hover {
397
+ opacity: 1;
398
+ }
399
+ .berocket_admin_notice .berocket_time_left_block {
400
+ display: inline-block;
401
+ text-align: center;
402
+ vertical-align: middle;
403
+ padding: 0 0 0 10px;
404
+ }
405
+ .berocket_notice_content .berocket_button {
406
+ margin: 0 0 0 10px;
407
+ min-width: 80px;
408
+ max-width: 120px;
409
+ width: 120px;
410
+ padding: 6px;
411
+ display: inline;
412
+ vertical-align: baseline;
413
+ color: #fff;
414
+ box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
415
+ text-shadow: none;
416
+ border: 0 none;
417
+ -moz-user-select: none;
418
+ background: #ff5252 none repeat scroll 0 0;
419
+ box-sizing: border-box;
420
+ cursor: pointer;
421
+ font-size: 15px;
422
+ outline: 0 none;
423
+ position: relative;
424
+ text-align: center;
425
+ text-decoration: none;
426
+ transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0s, background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0s;
427
+ white-space: nowrap;
428
+ height: auto;
429
+ display: inline-block;
430
+ }
431
+ ', ( empty($notice['subscribe']) ? '' : '
432
+ .berocket_admin_notice .berocket_subscribe_form {
433
+ display: inline-block;
434
+ padding-right: 10px;
435
+ }
436
+ .berocket_admin_notice .berocket_subscribe_form .berocket_subscribe_email {
437
+ width: 180px;
438
+ margin: 0;
439
+ height: 28px
440
+ display: inline;
441
+ }
442
+ .berocket_admin_notice .berocket_subscribe_form .berocket_notice_submit {
443
+ margin: 0 0 0 10px;
444
+ min-width: 80px;
445
+ max-width: 80px;
446
+ width: 80px;
447
+ padding: 0;
448
+ display: inline;
449
+ vertical-align: baseline;
450
+ color: #fff;
451
+ box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
452
+ text-shadow: none;
453
+ border: 0 none;
454
+ -moz-user-select: none;
455
+ background: #ff5252 none repeat scroll 0 0;
456
+ box-sizing: border-box;
457
+ cursor: pointer;
458
+ font-size: 14px;
459
+ outline: 0 none;
460
+ position: relative;
461
+ text-align: center;
462
+ text-decoration: none;
463
+ transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0s, background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0s;
464
+ white-space: nowrap;
465
+ height: auto;
466
+ }
467
+ .berocket_admin_notice .berocket_subscribe_form .berocket_notice_submit:hover,
468
+ .berocket_admin_notice .berocket_subscribe_form .berocket_notice_submit:focus,
469
+ .berocket_admin_notice .berocket_subscribe_form .berocket_notice_submit:active{
470
+ background: #ff6e68 none repeat scroll 0 0;
471
+ color: white;
472
+ }' ), '
473
+ @media screen and (max-width: ', ($notice['image']['width'] * $notice['image']['scale'] + $notice['rightwidth'] + $notice['contentwidth'] + 10), 'px) {
474
+ div.berocket_admin_notice .berocket_notice_content_wrap {
475
+ margin-left: 0;
476
+ margin-right: 0;
477
+ clear: both;
478
+ height: initial;
479
+ }
480
+ div.berocket_admin_notice {
481
+ height: initial;
482
+ text-align: center;
483
+ }
484
+ .berocket_admin_notice .berocket_notice_img {
485
+ float: none;
486
+ display: inline-block;
487
+ }
488
+ div.berocket_admin_notice .berocket_notice_right_content {
489
+ display: block;
490
+ float: none;
491
+ clear: both;
492
+ width: 100%;
493
+ -webkit-box-shadow: none;
494
+ box-shadow: none;
495
+ }
496
+ }
497
+ </style>
498
+ <script>
499
+ jQuery(document).ready(function() {
500
+ jQuery(document).on("click", ".berocket_admin_notice .berocket_no_thanks", function(event){
501
+ event.preventDefault();
502
+ var notice = jQuery(this).parents(".berocket_admin_notice").data("notice");
503
+ console.log(notice);
504
+ jQuery.post(ajaxurl, {action:"berocket_admin_close_notice", notice:notice}, function(data){console.log(data)});
505
+ jQuery(this).parents(".berocket_admin_notice").hide();
506
+ });
507
+ });';
508
+ if( $notice['end'] < strtotime(self::$end_soon_time) && $notice['end'] != 0 ) {
509
+ echo 'setInterval(function(){
510
+ jQuery(".berocket_admin_notice .berocket_time_left").each(function(i, o) {
511
+ var left_time = jQuery(o).data("time");
512
+ var time = left_time;
513
+ if( time <= 0 ) {
514
+ jQuery(o).parents(".berocket_admin_notice").hide();
515
+ } else {
516
+ time--;
517
+ jQuery(o).data("time", time);
518
+ var str = "";
519
+ if ( time >= 3600 ) {
520
+ hours = Math.floor( time/3600 );
521
+ time = time%3600;
522
+ str += ("0" + hours).slice(-2) + ":";
523
+ }
524
+ if ( time >= 60 || left_time >= 3600 ) {
525
+ minutes = Math.floor( time/60 );
526
+ time = time%60;
527
+ str += ("0" + minutes).slice(-2) + ":";
528
+ }
529
+ seconds = time;
530
+ str += ("0" + seconds).slice(-2);
531
+ jQuery(o).html(str);
532
+ }
533
+ });
534
+ }, 1000);';
535
+ }
536
+ echo '</script>';
537
+ self::echo_jquery_functions();
538
+ }
539
+ }
540
+ public static function echo_jquery_functions() {
541
+ if( ! self::$jquery_script_exist ) {
542
+ self::$jquery_script_exist = true;
543
+ echo '<script>
544
+ jQuery(document).on("berocket_subscribed", ".berocket_admin_notice", function(){
545
+ jQuery(this).find(".berocket_no_thanks").click();
546
+ });
547
+ jQuery(document).on("berocket_incorrect_email", ".berocket_admin_notice", function(){
548
+ jQuery(this).find(".berocket_subscribe_form").addClass("form-invalid");
549
+ });
550
+ jQuery(document).on("change", ".berocket_admin_notice", function(){
551
+ jQuery(this).find(".berocket_subscribe_form").removeClass("form-invalid");
552
+ });
553
+ var berocket_email_submited = false;
554
+ jQuery(document).on("submit berocket_subscribe_send", ".berocket_subscribe_form", function(event){
555
+ event.preventDefault();
556
+ event.stopPropagation();
557
+ var $this = jQuery(this);
558
+ var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
559
+ var email = $this.find("[name=email]").val();
560
+ if( ! re.test(email) ) {
561
+ $this.trigger("berocket_incorrect_email");
562
+ return false;
563
+ }
564
+ if( ! berocket_email_submited ) {
565
+ berocket_email_submited = true;
566
+ if( $this.is("form") ) {
567
+ var data = $this.serialize();
568
+ } else {
569
+ var data = {email:email, action: $this.find("[name=\'action\']").val()};
570
+ }
571
+ var url = $this.attr("action");
572
+ $this.trigger("berocket_subscribing");
573
+ jQuery.post(url, data, function(data){
574
+ $this.trigger("berocket_subscribed");
575
+ }).fail(function(){
576
+ $this.trigger("berocket_not_subscribed");
577
+ });
578
+ }
579
+ });
580
+ jQuery(document).on("berocket_subscribing", ".berocket_subscribe", function(event) {
581
+ event.preventDefault();
582
+ jQuery(this).hide();
583
+ });
584
+ jQuery(document).on("berocket_incorrect_email", ".berocket_subscribe", function(event) {
585
+ event.preventDefault();
586
+ jQuery(this).addClass("form-invalid").find(".error").show();
587
+ });
588
+ jQuery(document).on("keyup", ".berocket_subscribe.berocket_subscribe_form .berocket_subscribe_email", function(event) {
589
+ var keyCode = event.keyCode || event.which;
590
+ if (keyCode === 13) {
591
+ event.preventDefault();
592
+ jQuery(this).parents(".berocket_subscribe_form").trigger("berocket_subscribe_send");
593
+ return false;
594
+ }
595
+ });
596
+ jQuery(document).on("click", ".berocket_subscribe.berocket_subscribe_form .berocket_notice_submit", function(event) {
597
+ event.preventDefault();
598
+ jQuery(this).parents(".berocket_subscribe_form").trigger("berocket_subscribe_send");
599
+ });
600
+
601
+ </script>';
602
+ }
603
+ }
604
+ public static function close_notice($notice = FALSE) {
605
+ self::$subscribed = get_option('berocket_email_subscribed');
606
+ if( ( $notice == FALSE || ! is_array($notice) ) && ! empty($_POST['notice']) ) {
607
+ $notice = $_POST['notice'];
608
+ }
609
+ if( $notice == FALSE || ! is_array($notice) ) {
610
+ wp_die();
611
+ }
612
+ $find_names = array($notice['priority'], $notice['end'], $notice['start'], $notice['name']);
613
+ $current_notice = self::get_notice_by_path($find_names);
614
+ if( isset($current_notice) ) {
615
+ if( $current_notice['end'] < strtotime(self::$end_soon_time) ) {
616
+ $current_notice['closed'] = 2;
617
+ } else {
618
+ $current_notice['closed'] = 1;
619
+ }
620
+ if( ! empty($current_notice['repeat']) && ! empty($current_notice['repeatcount']) && ( ! self::$subscribed || ! $current_notice['subscribe'] ) ) {
621
+ $new_notice = $current_notice;
622
+ if( empty($current_notice['original']) ) {
623
+ $new_notice['original'] = $find_names;
624
+ }
625
+ $new_notice['repeatcount'] = $current_notice['repeatcount'] - 1;
626
+ $new_notice['start'] = strtotime($current_notice['repeat']);
627
+ $new_notice['closed'] = 0;
628
+ self::set_notice_by_path($new_notice);
629
+ }
630
+ self::set_notice_by_path($current_notice, true);
631
+ }
632
+ update_option('berocket_last_close_notices_time', time());
633
+ wp_die();
634
+ }
635
+ public static function subscribe() {
636
+ if( ! empty($_POST['email']) ) {
637
+ if( $ch = curl_init() ) {
638
+ update_option('berocket_email_subscribed', true);
639
+ curl_setopt($ch, CURLOPT_URL,"http://berocket.com/main/subscribe");
640
+ curl_setopt($ch, CURLOPT_POST, 1);
641
+ curl_setopt($ch, CURLOPT_POSTFIELDS, "email=" . $_POST['email']);
642
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
643
+ echo curl_exec ($ch);
644
+ curl_close ($ch);
645
+ }
646
+ }
647
+ wp_die();
648
+ }
649
+ public static function generate_subscribe_notice() {
650
+ new berocket_admin_notices(array(
651
+ 'start' => 0,
652
+ 'end' => 0,
653
+ 'name' => 'subscribe',
654
+ 'html' => 'Subscribe to get latest BeRocket news and updates, plugin recommendations and configuration help, promotional email with discount codes.',
655
+ 'subscribe' => true,
656
+ 'image' => array(
657
+ 'local' => plugin_dir_url( __FILE__ ) . '../images/ad_white_on_orange.png',
658
+ ),
659
+ ));
660
+ }
661
+ }
662
+ add_action( 'admin_notices', array('berocket_admin_notices', 'display_admin_notice') );
663
+ add_action( 'wp_ajax_berocket_admin_close_notice', array('berocket_admin_notices', 'close_notice') );
664
+ add_action( 'wp_ajax_berocket_subscribe_email', array('berocket_admin_notices', 'subscribe') );
665
+ }
666
+ ?>
js/widget.min.js CHANGED
@@ -283,29 +283,49 @@
283
  }
284
  }
285
  } else {
286
- if( $(data).find(the_ajax_script.products_holder_id).length == 0 ) {
287
- if( $(data).find('.woocommerce-info').length == 0 ) {
288
- $(the_ajax_script.products_holder_id).html('<div class="'+the_ajax_script.no_products_class+'">'+the_ajax_script.no_products_message+'</div>');
289
- } else {
290
- $(the_ajax_script.products_holder_id).html($(data).find('.woocommerce-info').first());
291
- }
292
- } else {
293
- $(the_ajax_script.products_holder_id).replaceWith($(data).find(the_ajax_script.products_holder_id).first());
294
  }
295
  if( $(data).find(the_ajax_script.result_count_class).length == 0 ) {
296
  $(the_ajax_script.result_count_class).html('');
297
  } else {
298
- $(the_ajax_script.result_count_class).replaceWith($(data).find(the_ajax_script.result_count_class).first());
 
 
 
 
299
  }
300
  if( $(data).find(the_ajax_script.ordering_class).length == 0 ) {
301
  $(the_ajax_script.ordering_class).html('');
302
  } else {
303
- $(the_ajax_script.ordering_class).replaceWith($(data).find(the_ajax_script.ordering_class).first());
 
 
 
 
304
  }
305
  if( $(data).find(the_ajax_script.pagination_class).length == 0 ) {
306
  $(the_ajax_script.pagination_class).html('');
307
  } else {
308
- $(the_ajax_script.pagination_class).replaceWith($(data).find(the_ajax_script.pagination_class).first());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  }
310
  }
311
 
283
  }
284
  }
285
  } else {
286
+ var $products_holder_id = $(the_ajax_script.products_holder_id)
287
+ if( $(the_ajax_script.products_holder_id).length == 0 && $('.woocommerce-info').length > 0 ) {
288
+ $products_holder_id = $('.woocommerce-info');
 
 
 
 
 
289
  }
290
  if( $(data).find(the_ajax_script.result_count_class).length == 0 ) {
291
  $(the_ajax_script.result_count_class).html('');
292
  } else {
293
+ if( $(the_ajax_script.result_count_class).length > 0 ) {
294
+ $(the_ajax_script.result_count_class).replaceWith($(data).find(the_ajax_script.result_count_class).first());
295
+ } else {
296
+ $products_holder_id.before($(data).find(the_ajax_script.result_count_class).first());
297
+ }
298
  }
299
  if( $(data).find(the_ajax_script.ordering_class).length == 0 ) {
300
  $(the_ajax_script.ordering_class).html('');
301
  } else {
302
+ if( $(the_ajax_script.ordering_class).length > 0 ) {
303
+ $(the_ajax_script.ordering_class).replaceWith($(data).find(the_ajax_script.ordering_class).first());
304
+ } else {
305
+ $products_holder_id.before($(data).find(the_ajax_script.ordering_class).first());
306
+ }
307
  }
308
  if( $(data).find(the_ajax_script.pagination_class).length == 0 ) {
309
  $(the_ajax_script.pagination_class).html('');
310
  } else {
311
+ if( $(the_ajax_script.pagination_class).length > 0 ) {
312
+ $(the_ajax_script.pagination_class).replaceWith($(data).find(the_ajax_script.pagination_class).first());
313
+ } else {
314
+ $products_holder_id.after($(data).find(the_ajax_script.pagination_class).first());
315
+ }
316
+ }
317
+ if( $(data).find(the_ajax_script.products_holder_id).length == 0 ) {
318
+ if( $(data).find('.woocommerce-info').length == 0 ) {
319
+ $products_holder_id.html('<div class="no-products '+the_ajax_script.no_products_class+'">'+the_ajax_script.no_products_message+'</div>');
320
+ } else {
321
+ if( the_ajax_script.no_products_message.length > 0 ) {
322
+ $products_holder_id.html('<div class="no-products '+the_ajax_script.no_products_class+'">'+the_ajax_script.no_products_message+'</div>');
323
+ } else {
324
+ $products_holder_id.html($(data).find('.woocommerce-info').first());
325
+ }
326
+ }
327
+ } else {
328
+ $products_holder_id.replaceWith($(data).find(the_ajax_script.products_holder_id).first());
329
  }
330
  }
331
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://berocket.com
5
  Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
6
  Requires at least: 4.0
7
  Tested up to: 4.7.4
8
- Stable tag: 1.2.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -155,6 +155,10 @@ http://woocommerce-products-filter.berocket.com/
155
 
156
  == Changelog ==
157
 
 
 
 
 
158
  = 1.2.0 =
159
  * Premium Feature - best support for the themes moved from premium version of the plugin. If you have any issues ith theme update and set Template ajax load fix to jQuery
160
  * Enhancement - No Products message
5
  Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
6
  Requires at least: 4.0
7
  Tested up to: 4.7.4
8
+ Stable tag: 1.2.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
155
 
156
  == Changelog ==
157
 
158
+ = 1.2.1 =
159
+ * Upgrade - Option to subscribe
160
+ * Upgrade - Better advertisement
161
+
162
  = 1.2.0 =
163
  * Premium Feature - best support for the themes moved from premium version of the plugin. If you have any issues ith theme update and set Template ajax load fix to jQuery
164
  * Enhancement - No Products message
templates/admin-settings.php CHANGED
@@ -7,7 +7,7 @@ $dplugin_desc = '';
7
  @ include 'discount.php';
8
  ?>
9
  <div class="wrap">
10
- <form method="post" action="options.php">
11
  <?php
12
  settings_fields('br_filters_plugin_options');
13
  $options = get_option('br_filters_options');
@@ -189,7 +189,6 @@ $dplugin_desc = '';
189
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
190
  </p>
191
  </form>
192
- </div>
193
  <?php
194
  /*
195
  <h3>Receive more features and control with Paid version of the plugin:</h3>
@@ -239,3 +238,4 @@ $feature_list = array(
239
  );
240
  @ include 'settings_footer.php';
241
  ?>
 
7
  @ include 'discount.php';
8
  ?>
9
  <div class="wrap">
10
+ <form class="show_premium" method="post" action="options.php">
11
  <?php
12
  settings_fields('br_filters_plugin_options');
13
  $options = get_option('br_filters_options');
189
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
190
  </p>
191
  </form>
 
192
  <?php
193
  /*
194
  <h3>Receive more features and control with Paid version of the plugin:</h3>
238
  );
239
  @ include 'settings_footer.php';
240
  ?>
241
+ </div>
templates/mail.png ADDED
Binary file
templates/settings_footer.php CHANGED
@@ -1,62 +1,153 @@
1
- <div class="wrap">
2
- <?php if( ! empty($feature_list) && count($feature_list) > 0 ) { ?>
3
- <div class="paid_features">
4
- <?php
5
- $feature_text = '';
6
- foreach($feature_list as $feature) {
7
- $feature_text .= '<li>'.$feature.'</li>';
8
- }
9
- $text = '<h3>Receive more features and control with Paid version of the plugin:</h3>
10
- <div>
11
- <ul>
12
- %feature_list%
13
- </ul>
14
- </div>
15
- <div><a class="get_premium_version" href="%link%">PREMIUM VERSION</a></div>
16
- <p>Support the plugin by purchasing paid version. This will provide faster growth, better support and much more functionality for the plugin</p>';
17
- $text = str_replace('%feature_list%', $feature_text, $text);
18
- $text = str_replace('%link%', $dplugin_link, $text);
19
- $text = str_replace('%plugin_name%', @ $plugin_info['Name'], $text);
20
- $text = str_replace('%plugin_link%', @ $plugin_info['PluginURI'], $text);
21
- echo $text;
22
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </div>
24
  <?php
25
- $text = '<h4>Both <a href="%plugin_link%" target="_blank">Free</a> and <a href="%link%" target="_blank">Paid</a> versions of %plugin_name% developed by <a href="http://berocket.com" target="_blank">BeRocket</a></h4>';
26
- } else {
27
- $text = '<h4><a href="%plugin_link%" target="_blank">%plugin_name%</a> developed by <a href="http://berocket.com" target="_blank">BeRocket</a></h4>';
28
- }
29
- $text = str_replace('%link%', $dplugin_link, $text);
30
- $text = str_replace('%plugin_name%', @ $plugin_info['Name'], $text);
31
- $text = str_replace('%plugin_link%', @ $plugin_info['PluginURI'], $text);
32
- echo $text;
33
- ?>
34
- </div>
35
- <style>
36
- .paid_features {
37
- border: 1px solid #c29a9a;
38
- background: white;
39
- padding: 20px 20px 10px 30px;
40
- font-weight: 600;
41
- }
42
- .get_premium_version {
43
- display: inline-block;
44
- background-color: rgb(239, 109, 109);
45
- border-color: rgb(222, 72, 72);
46
- color: white;
47
- font-size: 20px;
48
- height: auto;
49
- padding: 10px 41px;
50
- margin: 1em 0 1em 0;
51
- text-decoration: none;
52
- cursor: pointer;
53
- }
54
- .get_premium_version:hover {
55
- color: white;
56
- background-color: rgb(222, 72, 72);
57
- }
58
- .paid_features ul li{
59
- list-style: initial;
60
- margin-left: 2em;
61
  }
62
- </style>
 
 
 
 
1
+ <?php if( ! empty($feature_list) && count($feature_list) > 0 ) { ?>
2
+ <div class="paid_features">
3
+ <?php
4
+ $feature_text = '';
5
+ foreach($feature_list as $feature) {
6
+ $feature_text .= '<li>'.$feature.'</li>';
7
+ }
8
+ $text = '<h3>Receive more features and control with Paid version of the plugin:</h3>
9
+ <div>
10
+ <ul>
11
+ %feature_list%
12
+ </ul>
13
+ </div>
14
+ <div><a class="get_premium_version" href="%link%">PREMIUM VERSION</a></div>
15
+ <p>Support the plugin by purchasing paid version. This will provide faster growth, better support and much more functionality for the plugin</p>';
16
+ $text = str_replace('%feature_list%', $feature_text, $text);
17
+ echo $text;
18
+ ?>
19
+ </div>
20
+ <style>
21
+ .paid_features, .berocket_subscribe {
22
+ border: 1px solid #c29a9a;
23
+ background: white;
24
+ float: right;
25
+ clear: right;
26
+ width: 28%;
27
+ box-sizing: border-box;
28
+ text-align: center;
29
+ padding: 0 25px;
30
+ margin-bottom: 30px;
31
+ }
32
+ .paid_features {
33
+ font-weight: 600;
34
+ }
35
+ .paid_features ul li {
36
+ text-align: left;
37
+ }
38
+ .berocket_subscribe {
39
+ background-color: #2c3644;
40
+ background-image: url(<?php echo plugin_dir_url( __FILE__ ) . 'mail.png'; ?>);
41
+ background-position: right top;
42
+ background-repeat: no-repeat;
43
+ color: #aaa;
44
+ font-size: 16px;
45
+ overflow: hidden;
46
+ }
47
+ .berocket_subscribe h3 {
48
+ color: white;
49
+ }
50
+ .berocket_subscribe p {
51
+ font-size: 16px;
52
+ text-align: left;
53
+ }
54
+ .berocket_subscribe .berocket_subscribe_email {
55
+ background-color: #404c5d;
56
+ border: 0;
57
+ outline: 0;
58
+ color: #aaa;
59
+ width: 100%;
60
+ line-height: 2em;
61
+ font-size: 16px;
62
+ }
63
+ .berocket_subscribe .berocket_notice_submit,
64
+ .get_premium_version {
65
+ display: inline-block;
66
+ background-color: rgb(239, 109, 109);
67
+ border-color: rgb(222, 72, 72);
68
+ color: white;
69
+ font-size: 20px;
70
+ height: auto;
71
+ padding: 10px 41px;
72
+ margin: 1em 0 1em 0;
73
+ text-decoration: none;
74
+ cursor: pointer;
75
+ outline: none;
76
+ box-shadow: none;
77
+ border: none;
78
+ text-shadow: none;
79
+ font-weight: 600;
80
+ line-height: 1em;
81
+ border-radius: 0;
82
+ }
83
+ .berocket_subscribe .berocket_notice_submit:hover,
84
+ .get_premium_version:hover {
85
+ color: white;
86
+ background-color: rgb(222, 72, 72);
87
+ box-shadow: none;
88
+ border: none;
89
+ }
90
+ .berocket_subscribe .berocket_notice_submit:focus,
91
+ .get_premium_version:focus,
92
+ .berocket_subscribe .berocket_notice_submit:active,
93
+ .get_premium_version:active {
94
+ color: white;
95
+ background-color: rgb(222, 72, 72);
96
+ -webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30,140,190,.8);
97
+ box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30,140,190,.8);
98
+ }
99
+ .paid_features ul li{
100
+ list-style: initial;
101
+ margin-left: 2em;
102
+ }
103
+ .show_premium {
104
+ float: left;
105
+ width: 70%;
106
+ box-sizing: border-box;
107
+ }
108
+ @media screen and (max-width: 900px) {
109
+ .show_premium,
110
+ .paid_features,
111
+ .berocket_subscribe {
112
+ float: none;
113
+ width: 100%;
114
+ }
115
+
116
+ .paid_features,
117
+ .berocket_subscribe {
118
+ margin-top: 30px;
119
+ margin-bottom: 0;
120
+ }
121
+ }
122
+ </style>
123
+ <?php
124
+ $subscribed = get_option('berocket_email_subscribed');
125
+ if( ! $subscribed ) {
126
+ $user_email = wp_get_current_user();
127
+ if( isset($user_email->user_email) ) {
128
+ $user_email = $user_email->user_email;
129
+ } else {
130
+ $user_email = '';
131
+ }
132
+ ?>
133
+ <div class="berocket_subscribe">
134
+ <h3>OUR NEWSLETTER</h3>
135
+ <p>Get awesome content delivered straight to your inbox.</p>
136
+ <form class="berocket_subscribe_form" method="POST" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
137
+ <input type="hidden" name="action" value="berocket_subscribe_email">
138
+ <input class="berocket_subscribe_email" type="email" name="email" placeholder="Enter your email address" value="<?php echo $user_email; ?>">
139
+ <input type="submit" class="berocket_notice_submit" value="GET UPDATE">
140
+ </form>
141
  </div>
142
  <?php
143
+ berocket_admin_notices::echo_jquery_functions();
144
+ }
145
+ $text = '<h4 style="clear:both;">Both <a href="%plugin_link%" target="_blank">Free</a> and <a href="%link%" target="_blank">Paid</a> versions of %plugin_name% developed by <a href="http://berocket.com" target="_blank">BeRocket</a></h4>';
146
+ } else {
147
+ $text = '<h4 style="clear:both;"><a href="%plugin_link%" target="_blank">%plugin_name%</a> developed by <a href="http://berocket.com" target="_blank">BeRocket</a></h4>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
+ $text = str_replace('%link%', $dplugin_link, $text);
150
+ $text = str_replace('%plugin_name%', @ $plugin_info['Name'], $text);
151
+ $text = str_replace('%plugin_link%', @ $plugin_info['PluginURI'], $text);
152
+ echo $text;
153
+ ?>
woocommerce-filters.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Advanced AJAX Product Filter for WooCommerce
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/
5
  * Description: Take a look at this fantastic AJAX products filter plugin for WooCommerce. Add unlimited filters with one widget.
6
- * Version: 1.2.0
7
  * Author: BeRocket
8
  * Requires at least: 4.0
9
  * Author URI: http://berocket.com
@@ -11,7 +11,7 @@
11
  * Domain Path: /languages/
12
  */
13
 
14
- define( "BeRocket_AJAX_filters_version", '1.2.0' );
15
  define( "BeRocket_AJAX_domain", 'BeRocket_AJAX_domain' );
16
 
17
  define( "AAPF_TEMPLATE_PATH", plugin_dir_path( __FILE__ ) . "templates/" );
@@ -19,6 +19,7 @@ define( "AAPF_URL", plugin_dir_url( __FILE__ ) );
19
  load_plugin_textdomain('BeRocket_AJAX_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
20
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
21
 
 
22
  require_once dirname( __FILE__ ) . '/includes/widget.php';
23
  require_once dirname( __FILE__ ) . '/includes/functions.php';
24
  /**
@@ -91,6 +92,7 @@ class BeRocket_AAPF {
91
  add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
92
  $plugin_base_slug = plugin_basename( __FILE__ );
93
  add_filter( 'plugin_action_links_' . $plugin_base_slug, array( __CLASS__, 'plugin_action_links' ) );
 
94
  } else {
95
  if( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
96
  add_action( 'admin_notices', array( __CLASS__, 'update_woocommerce' ) );
@@ -99,6 +101,12 @@ class BeRocket_AAPF {
99
  }
100
  }
101
  }
 
 
 
 
 
 
102
  public static function plugin_action_links($links) {
103
  $action_links = array(
104
  'settings' => '<a href="' . admin_url( 'admin.php?page='.self::$values['option_page'] ) . '" title="' . __( 'View Plugin Settings', 'BeRocket_products_label_domain' ) . '">' . __( 'Settings', 'BeRocket_products_label_domain' ) . '</a>',
@@ -455,3 +463,26 @@ class BeRocket_AAPF {
455
  }
456
 
457
  new BeRocket_AAPF;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Plugin Name: Advanced AJAX Product Filter for WooCommerce
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/
5
  * Description: Take a look at this fantastic AJAX products filter plugin for WooCommerce. Add unlimited filters with one widget.
6
+ * Version: 1.2.1
7
  * Author: BeRocket
8
  * Requires at least: 4.0
9
  * Author URI: http://berocket.com
11
  * Domain Path: /languages/
12
  */
13
 
14
+ define( "BeRocket_AJAX_filters_version", '1.2.1' );
15
  define( "BeRocket_AJAX_domain", 'BeRocket_AJAX_domain' );
16
 
17
  define( "AAPF_TEMPLATE_PATH", plugin_dir_path( __FILE__ ) . "templates/" );
19
  load_plugin_textdomain('BeRocket_AJAX_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
20
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
21
 
22
+ require_once dirname( __FILE__ ) . '/includes/admin_notices.php';
23
  require_once dirname( __FILE__ ) . '/includes/widget.php';
24
  require_once dirname( __FILE__ ) . '/includes/functions.php';
25
  /**
92
  add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
93
  $plugin_base_slug = plugin_basename( __FILE__ );
94
  add_filter( 'plugin_action_links_' . $plugin_base_slug, array( __CLASS__, 'plugin_action_links' ) );
95
+ add_filter( 'is_berocket_settings_page', array( __CLASS__, 'is_settings_page' ) );
96
  } else {
97
  if( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
98
  add_action( 'admin_notices', array( __CLASS__, 'update_woocommerce' ) );
101
  }
102
  }
103
  }
104
+ public static function is_settings_page($settings_page) {
105
+ if( ! empty($_GET['page']) && $_GET['page'] == self::$values[ 'option_page' ] ) {
106
+ $settings_page = true;
107
+ }
108
+ return $settings_page;
109
+ }
110
  public static function plugin_action_links($links) {
111
  $action_links = array(
112
  'settings' => '<a href="' . admin_url( 'admin.php?page='.self::$values['option_page'] ) . '" title="' . __( 'View Plugin Settings', 'BeRocket_products_label_domain' ) . '">' . __( 'Settings', 'BeRocket_products_label_domain' ) . '</a>',
463
  }
464
 
465
  new BeRocket_AAPF;
466
+
467
+ berocket_admin_notices::generate_subscribe_notice();
468
+ new berocket_admin_notices(array(
469
+ 'start' => 1498413376, // timestamp when notice start
470
+ 'end' => 1504223940, // timestamp when notice end
471
+ 'name' => 'name', //notice name must be unique for this time period
472
+ 'html' => 'Only <strong>$10</strong> for <strong>Premium</strong> WooCommerce Load More Products plugin!
473
+ <a class="berocket_button" href="http://berocket.com/product/woocommerce-load-more-products" target="_blank">Buy Now</a>
474
+ &nbsp; <span>Get your <strong class="red">50% discount</strong> and save <strong>$10</strong> today</span>
475
+ ', //text or html code as content of notice
476
+ 'righthtml' => '<a class="berocket_no_thanks">No thanks</a>', //content in the right block, this is default value. This html code must be added to all notices
477
+ 'rightwidth' => 80, //width of right content is static and will be as this value. berocket_no_thanks block is 60px and 20px is additional
478
+ 'nothankswidth' => 60, //berocket_no_thanks width. set to 0 if block doesn't uses. Or set to any other value if uses other text inside berocket_no_thanks
479
+ 'contentwidth' => 400, //width that uses for mediaquery is image_width + contentwidth + rightwidth
480
+ 'subscribe' => false, //add subscribe form to the righthtml
481
+ 'priority' => 10, //priority of notice. 1-5 is main priority and displays on settings page always
482
+ 'height' => 50, //height of notice. image will be scaled
483
+ 'repeat' => false, //repeat notice after some time. time can use any values that accept function strtotime
484
+ 'repeatcount' => 1, //repeat count. how many times notice will be displayed after close
485
+ 'image' => array(
486
+ 'local' => plugin_dir_url( __FILE__ ) . 'images/ad_white_on_orange.png', //notice will be used this image directly
487
+ ),
488
+ ));