Q2W3 Fixed Widget - Version 5.1.6

Version Description

  • linguistic corrections
  • cleanup of the options page
Download this release

Release Info

Developer advancedads
Plugin Icon 128x128 Q2W3 Fixed Widget
Version 5.1.6
Comparing to
See all releases

Code changes from version 5.1.5 to 5.1.6

Files changed (3) hide show
  1. css/backend.css +47 -0
  2. q2w3-fixed-widget.php +616 -590
  3. readme.txt +6 -3
css/backend.css ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #q2w3_fixed_widget-recommend {
2
+ background: linear-gradient(to right, #42bcf3 0%,#1892eb 100%); background: #1892eb;
3
+ border: 1px solid #ffffff;
4
+ box-shadow: inset 0px 0px 35px 10px rgba(0,0,0,0.15), 0px 0px 5px rgba(0,0,0,0.25);
5
+ color: #ffffff;
6
+ text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
7
+ font-size: 1.2em;
8
+ }
9
+
10
+ #q2w3_fixed_widget-recommend.closed { border-bottom: 0; }
11
+
12
+ #q2w3_fixed_widget-recommend h2, #q2w3_fixed_widget-recommend .inside a, #q2w3_fixed_widget-recommend .handlediv, #q2w3_fixed_widget-recommend .toggle-indicator { color: #ffffff; }
13
+
14
+ #q2w3_fixed_widget-recommend h2 { font-size: 15px; }
15
+
16
+ #q2w3_fixed_widget-recommend .inside p { font-size: 14px; }
17
+
18
+ #q2w3_fixed_widget-recommend .inside div.review { text-align: center; margin: 20px 0px 0px 0px; }
19
+ #q2w3_fixed_widget-recommend .inside div.review h5 { font-weight: 400; font-size: 16px; margin: 0px 0px 5px 0px; font-style: italic; }
20
+ #q2w3_fixed_widget-recommend .inside div.review p { margin: 0px 0px 5px 0px; }
21
+ #q2w3_fixed_widget-recommend .inside div.review p.content { font-style: italic; font-size: 12px; }
22
+ #q2w3_fixed_widget-recommend .inside div.review p.subline { font-size: 12px; }
23
+
24
+ #q2w3_fixed_widget-recommend .inside .button-var1:hover { background: rgba(0,0,0,0.60); border-color: rgba(0,0,0,0.75); }
25
+ #q2w3_fixed_widget-recommend .inside .button-var1 {
26
+ display: inline-block;
27
+ padding: 5px 10px;
28
+ border: 1px solid #333333; border-color: rgba(0,0,0,0.95);
29
+ box-shadow: 0px 0px 10px rgba(0,0,0,0.25);
30
+ background: #000000; background: rgba(0,0,0,0.80);
31
+ color: #ffffff;
32
+ text-decoration: none;
33
+ font-weight: bold;
34
+ line-height: normal;
35
+ border-radius: 2px;
36
+ }
37
+
38
+ #q2w3_fixed_widget-recommend .inside div.review:before {
39
+ display: block;
40
+ content: " ";
41
+ /* https://www.iconfinder.com/icons/326703/favorite_rate_star_icon */
42
+ background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAPCAYAAADtc08vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAADEQAAAxEBQphATgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAElSURBVCiRldI/T5NRFMfxz30aCzI4mJaJMpgYwKYmpdYYd3gHLiy+AgcmBth4Awy+C0fCIC+AaH1a4gCJgwMJDA5ER1OwlwFs+mifh/YkN7n5nXO+58+9FFjseB2PPC6KSYqcErtmbBWFhNzqX7wUfMZv156GV86n6yCxfXeb9cDOVB3EVANfR/xXokZo+/YfIH6yoKQhqGMZdTzDozHsHzgbnsR+iB1tiQNUc8cZb1196wFi14roI2oTJ5ethed+DncQU4s4xNKkyfyzxNhTNXCKSk7yHyWV0PTrr5B9xqZLzBVUL+mbHxWygGO1ewAkWvmAQWb+vuC9YBMXQzVYzQfc/oOID4J6aHkXWvY89ET0Ft/JAjIWUxux50Wu/0Q5pt6Majcm/kSYKQos8gAAAABJRU5ErkJggg==') top left repeat-x;
43
+ color: #ffffff;
44
+ height: 15px;
45
+ width: 80px;
46
+ margin: 0px auto 5px auto;
47
+ }
q2w3-fixed-widget.php CHANGED
@@ -1,590 +1,616 @@
1
- <?php
2
- /*
3
- Plugin Name: Q2W3 Fixed Widget
4
- Plugin URI: https://wpadvancedads.com/fixed-widget-wordpress/
5
- Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
- Text Domain: q2w3-fixed-widget
7
- Author: Thomas Maier, Max Bond
8
- Version: 5.1.5
9
- Author URI: https://wpadvancedads.com/fixed-widget-wordpress/
10
- */
11
-
12
- add_action('init', array( 'q2w3_fixed_widget', 'init' )); // Main Hook
13
-
14
- if ( class_exists('q2w3_fixed_widget', false) ) return; // if class is allready loaded return control to the main script
15
-
16
- class q2w3_fixed_widget { // Plugin class
17
-
18
- const ID = 'q2w3_fixed_widget';
19
-
20
- const VERSION = '5.1.5';
21
-
22
- protected static $sidebars_widgets;
23
-
24
- protected static $fixed_widgets;
25
-
26
- protected static $settings_page_hook;
27
-
28
-
29
- public static function init() {
30
-
31
- $options = self::load_options();
32
-
33
- if ( $options['logged_in_req'] && !is_user_logged_in() ) return;
34
-
35
- if ( is_admin() ) {
36
-
37
- self::load_language();
38
-
39
- add_action('in_widget_form', array( __CLASS__, 'add_widget_option' ), 10, 3);
40
-
41
- add_filter('widget_update_callback', array( __CLASS__, 'update_widget_option' ), 10, 3);
42
-
43
- add_action('admin_init', array( __CLASS__, 'register_settings' ));
44
-
45
- add_action('admin_menu', array( __CLASS__, 'admin_menu' ), 5);
46
-
47
- add_action('admin_enqueue_scripts', array( __CLASS__, 'settings_page_js' ));
48
-
49
- } else {
50
-
51
- if ( $options['fix-widget-id'] ) self::registered_sidebars_filter();
52
-
53
- add_action('wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ));
54
-
55
- add_filter('widget_display_callback', array( __CLASS__, 'is_widget_fixed' ), 99, 3);
56
-
57
- //add_filter('widget_display_callback', array( __CLASS__, 'is_widget_fixed' ), $options['widget_display_callback_priority'], 3);
58
-
59
- //add_action('wp_loaded', array( __CLASS__, 'custom_ids' ));
60
-
61
- //add_action('wp_footer', array( __CLASS__, 'js_settings' ));
62
-
63
-
64
-
65
- }
66
-
67
- }
68
-
69
- public static function enqueue_scripts() {
70
-
71
- self::custom_ids();
72
-
73
- self::fixed_wigets();
74
-
75
- wp_enqueue_script('jquery');
76
-
77
- wp_enqueue_script(self::ID, plugin_dir_url( __FILE__ ) . 'js/q2w3-fixed-widget.min.js', array('jquery'), self::VERSION, true);
78
-
79
- self::wp_localize_script();
80
-
81
- }
82
-
83
-
84
- protected static function wp_localize_script() {
85
-
86
- $options = self::load_options();
87
-
88
- if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
89
-
90
- if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) $window_load_hook = true; else $window_load_hook = false;
91
-
92
- if ( isset($options['width-inherit']) && $options['width-inherit'] ) $width_inherit = true; else $width_inherit = false;
93
-
94
- if ( isset($options['disable-mo-api']) && $options['disable-mo-api'] ) $disable_mo_api = true; else $disable_mo_api = false;
95
-
96
- if ( $options['refresh-interval'] > 0 ) $refresh_interval = $options['refresh-interval']; else $refresh_interval = 0;
97
-
98
- $i = 0;
99
- $sidebar_options = array();
100
-
101
- self::$fixed_widgets = apply_filters( 'q2w3-fixed-widgets', self::$fixed_widgets ); // this filter was requested by users
102
-
103
- foreach ( self::$fixed_widgets as $sidebar => $widgets ) {
104
-
105
- $sidebar_options[ $i ] = array(
106
- 'sidebar' => $sidebar,
107
- 'margin_top' => $options['margin-top'],
108
- 'margin_bottom' => $options['margin-bottom'],
109
- 'stop_id' => $options['stop-id'],
110
- 'screen_max_width' => $options['screen-max-width'],
111
- 'screen_max_height' => $options['screen-max-height'],
112
- 'width_inherit' => $width_inherit,
113
- 'refresh_interval' => $refresh_interval,
114
- 'window_load_hook' => $window_load_hook,
115
- 'disable_mo_api' => $disable_mo_api,
116
- 'widgets' => array_values( $widgets )
117
- );
118
-
119
- $i++;
120
-
121
- }
122
-
123
- wp_localize_script( self::ID, 'q2w3_sidebar_options', $sidebar_options );
124
-
125
- }
126
-
127
- }
128
-
129
-
130
- protected static function fixed_wigets() {
131
-
132
- $sidebars = wp_get_sidebars_widgets();
133
-
134
- if ( $sidebars && is_array($sidebars) ) foreach ( $sidebars as $sidebar_id => $sidebar_widgets ) {
135
-
136
- if ( ! (stristr($sidebar_id, 'orphaned_widgets') !== false || $sidebar_id == 'wp_inactive_widgets') ) {
137
-
138
- if ( $sidebar_widgets && is_array($sidebar_widgets) ) foreach ( $sidebar_widgets as $widget ) {
139
-
140
- $widget_id = substr(strrchr($widget, '-'), 1);
141
-
142
- $widget_type = stristr($widget, '-'.$widget_id, true);
143
-
144
- $widget_options = get_option('widget_' . $widget_type);
145
-
146
- if ( isset($widget_options[$widget_id]['q2w3_fixed_widget']) && $widget_options[$widget_id]['q2w3_fixed_widget']) self::$fixed_widgets[$sidebar_id][$widget] = $widget;
147
-
148
- }
149
-
150
- }
151
-
152
- }
153
-
154
- }
155
-
156
-
157
- public static function is_widget_fixed($instance, $widget, $args) { // deprecated
158
-
159
- if ( isset($instance['q2w3_fixed_widget']) && $instance['q2w3_fixed_widget'] && ! isset(self::$fixed_widgets[$args['id']][$widget->id]) ) {
160
-
161
- //self::$fixed_widgets[$args['id']][$widget->id] = "'". $widget->id ."'";
162
-
163
- //echo '<!-- fixed widget -->';
164
-
165
- self::$fixed_widgets[$args['id']][$widget->id] = $widget->id;
166
-
167
- self::wp_localize_script();
168
-
169
- }
170
-
171
- return $instance;
172
-
173
- }
174
-
175
-
176
- protected static function custom_ids() {
177
-
178
- $options = self::load_options();
179
-
180
- if ( isset($options['custom-ids']) && $options['custom-ids'] ) {
181
-
182
- $ids = explode(PHP_EOL, $options['custom-ids']);
183
-
184
- foreach ( $ids as $id ) {
185
-
186
- $id = trim($id);
187
-
188
- //if ( $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = "'". $id ."'";
189
-
190
- if ( $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = $id;
191
-
192
- }
193
-
194
- }
195
-
196
- }
197
-
198
- protected static function get_widget_sidebar($widget_id) {
199
-
200
- if ( !self::$sidebars_widgets ) {
201
-
202
- self::$sidebars_widgets = wp_get_sidebars_widgets();
203
-
204
- unset(self::$sidebars_widgets['wp_inactive_widgets']);
205
-
206
- }
207
-
208
- if ( is_array(self::$sidebars_widgets) ) {
209
-
210
- foreach ( self::$sidebars_widgets as $sidebar => $widgets ) {
211
-
212
- $key = array_search($widget_id, $widgets);
213
-
214
- if ( $key !== false ) return $sidebar;
215
-
216
- }
217
-
218
- }
219
-
220
- return 'q2w3-default-sidebar';
221
-
222
- }
223
-
224
- /*public static function js_settings() { // deprecated
225
-
226
- $options = self::load_options();
227
-
228
- $js = '';
229
-
230
- if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
231
-
232
- $js .= 'var q2w3_sidebar_options = new Array();'.PHP_EOL;
233
-
234
- if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) $window_load_hook = 'true'; else $window_load_hook = 'false';
235
-
236
- if ( isset($options['width-inherit']) && $options['width-inherit'] ) $width_inherit = 'true'; else $width_inherit = 'false';
237
-
238
- if ( isset($options['disable-mo-api']) && $options['disable-mo-api'] ) $disable_mo_api = 'true'; else $disable_mo_api = 'false';
239
-
240
- if ( $options['refresh-interval'] > 0 ) $refresh_interval = $options['refresh-interval']; else $refresh_interval = 0;
241
-
242
- $i = 0;
243
-
244
- foreach ( self::$fixed_widgets as $sidebar => $widgets ) {
245
-
246
- $widgets_array = implode(',', $widgets);
247
-
248
- $js .= 'q2w3_sidebar_options['. $i .'] = { "sidebar" : "'. $sidebar .'", "margin_top" : '. $options['margin-top'] .', "margin_bottom" : '. $options['margin-bottom'] .', "stop_id" : "' . $options['stop-id'] .'", "screen_max_width" : '. $options['screen-max-width'] .', "screen_max_height" : '. $options['screen-max-height'] .', "width_inherit" : '. $width_inherit .', "refresh_interval" : '. $refresh_interval .', "window_load_hook" : '. $window_load_hook .', "disable_mo_api" : '. $disable_mo_api .', "widgets" : ['. $widgets_array .'] };'.PHP_EOL;
249
-
250
- $i++;
251
-
252
- }
253
-
254
- }
255
-
256
- if ( $js && function_exists('wp_add_inline_script') && ! class_exists('BWP_MINIFY') ) {
257
-
258
- wp_add_inline_script(self::ID, $js, 'before');
259
-
260
- } elseif ( $js ) {
261
-
262
- echo '<script type="text/javascript">'. $js .'</script>';
263
-
264
- }
265
-
266
- }*/
267
-
268
- public static function add_widget_option($widget, $return, $instance) {
269
-
270
- if ( isset($instance['q2w3_fixed_widget']) ) $iqfw = $instance['q2w3_fixed_widget']; else $iqfw = 0;
271
-
272
- echo '<p>'.PHP_EOL;
273
-
274
- echo '<input type="checkbox" name="'. $widget->get_field_name('q2w3_fixed_widget') .'" value="1" '. checked( $iqfw, 1, false ) .'/>'.PHP_EOL;
275
-
276
- echo '<label for="'. $widget->get_field_id('q2w3_fixed_widget') .'">'. __('Fixed widget', 'q2w3-fixed-widget') .'</label>'.PHP_EOL;
277
-
278
- echo '</p>'.PHP_EOL;
279
-
280
- }
281
-
282
- public static function update_widget_option($instance, $new_instance, $old_instance){
283
-
284
- if ( isset($new_instance['q2w3_fixed_widget']) && $new_instance['q2w3_fixed_widget'] ) {
285
-
286
- $instance['q2w3_fixed_widget'] = 1;
287
-
288
- } else {
289
-
290
- $instance['q2w3_fixed_widget'] = false;
291
-
292
- }
293
-
294
- return $instance;
295
-
296
- }
297
-
298
- protected static function load_language() {
299
-
300
- $languages_path = plugin_basename( dirname(__FILE__).'/lang' );
301
-
302
- load_plugin_textdomain( 'q2w3-fixed-widget', false, $languages_path );
303
-
304
- }
305
-
306
- public static function admin_menu() {
307
-
308
- remove_action('admin_menu', array( 'q2w3_fixed_widget', 'admin_menu' )); // Remove free version plugin
309
-
310
- self::$settings_page_hook = add_submenu_page( 'themes.php', __('Fixed Widget Options', 'q2w3-fixed-widget'), __('Fixed Widget Options', 'q2w3-fixed-widget'), 'activate_plugins', self::ID, array( __CLASS__, 'settings_page' ) );
311
-
312
- }
313
-
314
- protected static function defaults() {
315
-
316
- $d['margin-top'] = 10;
317
-
318
- $d['margin-bottom'] = 0;
319
-
320
- $d['stop-id'] = '';
321
-
322
- $d['refresh-interval'] = 1500;
323
-
324
- $d['screen-max-width'] = 0;
325
-
326
- $d['screen-max-height'] = 0;
327
-
328
- $d['fix-widget-id'] = 'yes';
329
-
330
- $d['window-load-enabled'] = false;
331
-
332
- $d['logged_in_req'] = false;
333
-
334
- $d['width-inherit'] = false;
335
-
336
- //$d['widget_display_callback_priority'] = 30;
337
-
338
- $d['disable-mo-api'] = false;
339
-
340
- return $d;
341
-
342
- }
343
-
344
- protected static function load_options() {
345
-
346
- $options = get_option(self::ID);
347
-
348
- $options_old = get_option('q2w3_fixed_widget');
349
-
350
- return array_merge(self::defaults(), (array)$options_old, (array)$options);
351
-
352
- }
353
-
354
- public static function register_settings() {
355
-
356
- register_setting(self::ID, self::ID, array( __CLASS__, 'save_options_filter' ) );
357
-
358
- }
359
-
360
- public static function save_options_filter($input) { // Sanitize user input
361
-
362
- $input['margin-top'] = (int)$input['margin-top'];
363
-
364
- $input['margin-bottom'] = (int)$input['margin-bottom'];
365
-
366
- $input['refresh-interval'] = (int)$input['refresh-interval'];
367
-
368
- $input['screen-max-width'] = (int)$input['screen-max-width'];
369
-
370
- $input['screen-max-height'] = (int)$input['screen-max-height'];
371
-
372
- $input['custom-ids'] = trim(wp_strip_all_tags($input['custom-ids']));
373
-
374
- $input['stop-id'] = trim(wp_strip_all_tags($input['stop-id']));
375
-
376
- if ( !isset($input['fix-widget-id']) ) $input['fix-widget-id'] = false;
377
-
378
- if ( !isset($input['window-load-enabled']) ) $input['window-load-enabled'] = false;
379
-
380
- if ( !isset($input['logged_in_req']) ) $input['logged_in_req'] = false;
381
-
382
- if ( !isset($input['width-inherit']) ) $input['width-inherit'] = false;
383
-
384
- if ( !isset($input['disable-mo-api']) ) $input['disable-mo-api'] = false;
385
-
386
- return $input;
387
-
388
- }
389
-
390
- public static function settings_page_js($hook) {
391
-
392
- if( self::$settings_page_hook != $hook ) return;
393
-
394
- wp_enqueue_script('postbox');
395
-
396
- }
397
-
398
- public static function settings_page() {
399
-
400
- $screen = get_current_screen();
401
-
402
- add_meta_box(self::ID.'-general', __('General Options', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_general_box' ), $screen, 'normal');
403
-
404
- add_meta_box(self::ID.'-compatibility', __('Compatibility', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_compatibility_box' ), $screen, 'normal');
405
-
406
- add_meta_box(self::ID.'-custom-ids', __('Custom IDs', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_custom_ids_box' ), $screen, 'normal');
407
-
408
- add_meta_box(self::ID.'-recommend', __('Recommended plugins', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_recommend_box' ), $screen, 'side', 'high');
409
-
410
- add_meta_box(self::ID.'-help', __('Help for users', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_help_box' ), $screen, 'side');
411
-
412
- add_meta_box(self::ID.'-donate', __('Help for developer', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_donate_box' ), $screen, 'side');
413
-
414
- $options = self::load_options();
415
-
416
- echo '<div class="wrap"><div id="icon-themes" class="icon32"><br /></div><h2>'. __('Fixed Widget Options', 'q2w3-fixed-widget') .'</h2>'.PHP_EOL;
417
-
418
- if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' ) {
419
-
420
- echo '<div id="message" class="updated"><p>'. __('Settings saved.') .'</p></div>'.PHP_EOL;
421
-
422
- }
423
-
424
- echo '<form method="post" action="options.php">'.PHP_EOL;
425
-
426
- settings_fields(self::ID);
427
-
428
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
429
-
430
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
431
-
432
- echo '<div id="poststuff" class="metabox-holder has-right-sidebar">'.PHP_EOL;
433
-
434
- echo '<div class="inner-sidebar" id="side-info-column">'.PHP_EOL;
435
-
436
- do_meta_boxes( $screen, 'side', $options );
437
-
438
- echo '</div>'.PHP_EOL;
439
-
440
- echo '<div id="post-body-content">'.PHP_EOL;
441
-
442
- do_meta_boxes( $screen, 'normal', $options );
443
-
444
- echo '</div>'.PHP_EOL;
445
-
446
- echo '<p><em>'. __("Note for cache plugin users. Don't forget to clear the cache after options change!", 'q2w3-fixed-widget') .'</em></p>'.PHP_EOL;
447
-
448
- echo '<p class="submit"><input type="submit" class="button-primary" value="'. __('Save Changes') .'" /></p>'.PHP_EOL;
449
-
450
- echo '</div><!-- #poststuff -->'.PHP_EOL;
451
-
452
- echo '</form>'.PHP_EOL;
453
-
454
- echo '<script>jQuery(document).ready(function(){ postboxes.add_postbox_toggles(pagenow); });</script>'.PHP_EOL;
455
-
456
- echo '</div><!-- .wrap -->'.PHP_EOL;
457
-
458
- }
459
-
460
- public static function settings_page_general_box($options) {
461
-
462
- echo '<p><span style="display: inline-block; width: 150px;">'. __('Margin Top:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[margin-top]" value="'. $options['margin-top'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
463
-
464
- echo '<p><span style="display: inline-block; width: 150px;">'. __('Margin Bottom:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[margin-bottom]" value="'. $options['margin-bottom'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
465
-
466
- echo '<p><span style="display: inline-block; width: 150px;">'. __('Stop ID:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[stop-id]" value="'. $options['stop-id'] .'" style="width: 150px;">&nbsp;'. __('Here you need to provide html tag id. The position of that html element will determine margin bottom value.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
467
-
468
- echo '<p><span style="display: inline-block; width: 150px;">'. __('Refresh interval:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[refresh-interval]" value="'. $options['refresh-interval'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('milliseconds', 'q2w3-fixed-widget') .' / '. __('Used only for compatibility with browsers without MutationObserver API support! Set 0 to completely disable.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
469
-
470
- echo '<p><span style="display: inline-block; width: 150px;">'. __('Disable Width:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[screen-max-width]" value="'. $options['screen-max-width'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .' / '. __('Use this option to disable plugin on portable devices. When the browser screen width is less then specified value, the plugin is disabled!', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
471
-
472
- echo '<p><span style="display: inline-block; width: 150px;">'. __('Disable Height:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[screen-max-height]" value="'. $options['screen-max-height'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .' / '. __('Works the same way as Disable Width option.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
473
-
474
- }
475
-
476
- public static function settings_page_custom_ids_box($options) {
477
-
478
- echo '<p><span >'. __('Custom HTML IDs (each one on a new line):', 'q2w3-fixed-widget') .'</span><br/><br/><textarea name="'. self::ID .'[custom-ids]" style="width: 320px; height: 120px;">'. $options['custom-ids'] .'</textarea>'.PHP_EOL;
479
-
480
- }
481
-
482
- public static function settings_page_compatibility_box($options) {
483
-
484
- echo '<p><span style="display: inline-block; width: 280px;">'. __('Auto fix widget id:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[fix-widget-id]" value="yes" '. checked('yes', $options['fix-widget-id'], false) .' /> </p>'.PHP_EOL;
485
-
486
- echo '<p><span style="display: inline-block; width: 280px;">'. __('Disable MutationObserver:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-mo-api]" value="yes" '. checked('yes', $options['disable-mo-api'], false) .' /> '. __('If MutationObserver disabled, plugin will use Refresh Interval to reflect page changes (version 4 behavior)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
487
-
488
- echo '<p><span style="display: inline-block; width: 280px;">'. __('Enable plugin for logged in users only:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[logged_in_req]" value="yes" '. checked('yes', $options['logged_in_req'], false) .' /> '. __('Enable this option for debug purposes (frontend problems and etc.)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
489
-
490
- echo '<p><span style="display: inline-block; width: 280px;">'. __('Inherit widget width from the parent container:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[width-inherit]" value="yes" '. checked('yes', $options['width-inherit'], false) .' /> '. __('Enable this option for themes with responsive sidebar', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
491
-
492
- echo '<p><span style="display: inline-block; width: 280px;">'. __('Use jQuery(window).load() hook:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[window-load-enabled]" value="yes" '. checked('yes', $options['window-load-enabled'], false) .' /> '. __('Enable this option only if you have problems with other scroll oriented javascript code', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
493
-
494
- //echo '<p><span style="display: inline-block; width: 280px;">'. __('widget_display_callback hook priority:', 'q2w3-fixed-widget') .'</span><select name="'. self::ID .'[widget_display_callback_priority]"><option value="1" '. selected('1', $options['widget_display_callback_priority'], false) .'>1</option><option value="10" '. selected('10', $options['widget_display_callback_priority'], false) .'>10</option><option value="20" '. selected('20', $options['widget_display_callback_priority'], false) .'>20</option><option value="30" '. selected('30', $options['widget_display_callback_priority'], false) .'>30</option><option value="50" '. selected('50', $options['widget_display_callback_priority'], false) .'>50</option><option value="100" '. selected('100', $options['widget_display_callback_priority'], false) .'>100</option></select></p>'.PHP_EOL;
495
-
496
- }
497
-
498
- public static function settings_page_recommend_box($options) {
499
-
500
- echo '<ul><li><a href="https://wordpress.org/plugins/advanced-ads/" target="_blank"><b>Advanced Ads</b></a> - best Ad manager. Works perfect with Q2W3!</li>'.PHP_EOL;
501
-
502
- echo '<li><a href="https://wordpress.org/plugins/autoptimize/" target="_blank"><b>Autoptimize</b></a> - best minificator and site optimizator. Fully compatible with Q2W3!</li></ul>'.PHP_EOL;
503
-
504
- }
505
-
506
- public static function settings_page_help_box($options) {
507
-
508
- echo '<p>'. __('Support forums:', 'q2w3-fixed-widget') .'</p>';
509
-
510
- echo '<ul><li><a href="http://wordpress.org/support/plugin/q2w3-fixed-widget/" target="_blank">'. __('English (wordpress.org)', 'q2w3-fixed-widget') .'</a></li>'.PHP_EOL;
511
-
512
- echo '<li><a href="http://www.q2w3.ru/2012/12/12/4827/" target="_blank">'. __('Russian (www.q2w3.ru)', 'q2w3-fixed-widget') .'</a></li></ul>'.PHP_EOL;
513
-
514
- }
515
-
516
- public static function settings_page_donate_box($options) {
517
-
518
- echo '<p style="text-align: center"><a href="https://wordpress.org/support/plugin/q2w3-fixed-widget/reviews/?rate=5#new-post" target="_blank">'. __('RATE THE PLUGIN', 'q2w3-fixed-widget') .'</a></p>';
519
-
520
- echo '<p style="text-align: center"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q36H2MHNVVP7U" target="_blank"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" alt="PayPal - The safer, easier way to pay online!" /></a></p>'.PHP_EOL;
521
-
522
- }
523
-
524
- public static function registered_sidebars_filter() {
525
-
526
- global $wp_registered_sidebars;
527
-
528
- if ( !is_array($wp_registered_sidebars) ) return;
529
-
530
- foreach ( $wp_registered_sidebars as $id => $sidebar ) {
531
-
532
- if ( strpos($sidebar['before_widget'], 'id="%1$s"') === false && strpos($sidebar['before_widget'], 'id=\'%1$s\'') === false ) {
533
-
534
- if ( $sidebar['before_widget'] == '' || $sidebar['before_widget'] == ' ' ) {
535
-
536
- $wp_registered_sidebars[$id]['before_widget'] = '<div id="%1$s">';
537
-
538
- $wp_registered_sidebars[$id]['after_widget'] = '</div>';
539
-
540
- } elseif ( strpos($sidebar['before_widget'], 'id=') === false ) {
541
-
542
- $tag_end_pos = strpos($sidebar['before_widget'], '>');
543
-
544
- if ( $tag_end_pos !== false ) {
545
-
546
- $wp_registered_sidebars[$id]['before_widget'] = substr_replace($sidebar['before_widget'], ' id="%1$s"', $tag_end_pos, 0);
547
-
548
- }
549
-
550
- } else {
551
-
552
- $str_array = explode(' ', $sidebar['before_widget']);
553
-
554
- if ( is_array($str_array) ) {
555
-
556
- foreach ( $str_array as $str_part_id => $str_part ) {
557
-
558
- if ( strpos($str_part, 'id="') !== false ) {
559
-
560
- $p1 = strpos($str_part, 'id="');
561
-
562
- $p2 = strpos($str_part, '"', $p1 + 4);
563
-
564
- $str_array[$str_part_id] = substr_replace($str_part, 'id="%1$s"', $p1, $p2 + 1);
565
-
566
- } elseif ( strpos($str_part, 'id=\'') !== false ) {
567
-
568
- $p1 = strpos($str_part, 'id=\'');
569
-
570
- $p2 = strpos($str_part, "'", $p1 + 4);
571
-
572
- $str_array[$str_part_id] = substr_replace($str_part, 'id=\'%1$s\'', $p1, $p2);
573
-
574
- }
575
-
576
- }
577
-
578
- $wp_registered_sidebars[$id]['before_widget'] = implode(' ', $str_array);
579
-
580
- }
581
-
582
- }
583
-
584
- } // if id is wrong
585
-
586
- } // foreach
587
-
588
- } // registered_sidebars_filter()
589
-
590
- } // q2w3_fixed_widget_pro class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Q2W3 Fixed Widget
4
+ Plugin URI: https://wpadvancedads.com/fixed-widget-wordpress/
5
+ Description: Use the fixed widget plugin to create sticky widgets that stay in the visible screen area when the page is scrolled up or down and boost your conversions.
6
+ Text Domain: q2w3-fixed-widget
7
+ Author: Thomas Maier, Max Bond
8
+ Version: 5.1.6
9
+ Author URI: https://wpadvancedads.com/fixed-widget-wordpress/
10
+ */
11
+
12
+ add_action('init', array( 'q2w3_fixed_widget', 'init' )); // Main Hook
13
+
14
+ if ( class_exists('q2w3_fixed_widget', false) ) return; // if class is allready loaded return control to the main script
15
+
16
+ class q2w3_fixed_widget { // Plugin class
17
+
18
+ const ID = 'q2w3_fixed_widget';
19
+
20
+ const VERSION = '5.1.6';
21
+
22
+ protected static $sidebars_widgets;
23
+
24
+ protected static $fixed_widgets;
25
+
26
+ protected static $settings_page_hook;
27
+
28
+
29
+ public static function init() {
30
+
31
+ $options = self::load_options();
32
+
33
+ if ( $options['logged_in_req'] && !is_user_logged_in() ) return;
34
+
35
+ if ( is_admin() ) {
36
+
37
+ self::load_language();
38
+
39
+ add_action('in_widget_form', array( __CLASS__, 'add_widget_option' ), 10, 3);
40
+
41
+ add_filter('widget_update_callback', array( __CLASS__, 'update_widget_option' ), 10, 3);
42
+
43
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( __CLASS__, 'add_plugin_links' ) );
44
+
45
+ add_action('admin_init', array( __CLASS__, 'register_settings' ));
46
+
47
+ add_action('admin_menu', array( __CLASS__, 'admin_menu' ), 5);
48
+
49
+ add_action('admin_enqueue_scripts', array( __CLASS__, 'settings_page_js' ));
50
+
51
+ // add stylesheets for the plugin's backend
52
+ add_action('admin_enqueue_scripts', array( __CLASS__, 'load_custom_be_styles' ));
53
+
54
+ } else {
55
+
56
+ if ( $options['fix-widget-id'] ) self::registered_sidebars_filter();
57
+
58
+ add_action('wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ));
59
+
60
+ add_filter('widget_display_callback', array( __CLASS__, 'is_widget_fixed' ), 99, 3);
61
+
62
+ //add_filter('widget_display_callback', array( __CLASS__, 'is_widget_fixed' ), $options['widget_display_callback_priority'], 3);
63
+
64
+ //add_action('wp_loaded', array( __CLASS__, 'custom_ids' ));
65
+
66
+ //add_action('wp_footer', array( __CLASS__, 'js_settings' ));
67
+
68
+
69
+
70
+ }
71
+
72
+ }
73
+
74
+ public static function load_custom_be_styles() {
75
+ wp_register_style('fixedWidgetBEStyles', plugin_dir_url( __FILE__ ) . 'css/backend.css', false, '0.0.1' );
76
+ wp_enqueue_style( 'fixedWidgetBEStyles' );
77
+ }
78
+
79
+ public static function enqueue_scripts() {
80
+
81
+ self::custom_ids();
82
+
83
+ self::fixed_wigets();
84
+
85
+ wp_enqueue_script('jquery');
86
+
87
+ wp_enqueue_script(self::ID, plugin_dir_url( __FILE__ ) . 'js/q2w3-fixed-widget.min.js', array('jquery'), self::VERSION, true);
88
+
89
+ self::wp_localize_script();
90
+
91
+ }
92
+
93
+
94
+ protected static function wp_localize_script() {
95
+
96
+ $options = self::load_options();
97
+
98
+ if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
99
+
100
+ if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) $window_load_hook = true; else $window_load_hook = false;
101
+
102
+ if ( isset($options['width-inherit']) && $options['width-inherit'] ) $width_inherit = true; else $width_inherit = false;
103
+
104
+ if ( isset($options['disable-mo-api']) && $options['disable-mo-api'] ) $disable_mo_api = true; else $disable_mo_api = false;
105
+
106
+ if ( $options['refresh-interval'] > 0 ) $refresh_interval = $options['refresh-interval']; else $refresh_interval = 0;
107
+
108
+ $i = 0;
109
+ $sidebar_options = array();
110
+
111
+ self::$fixed_widgets = apply_filters( 'q2w3-fixed-widgets', self::$fixed_widgets ); // this filter was requested by users
112
+
113
+ foreach ( self::$fixed_widgets as $sidebar => $widgets ) {
114
+
115
+ $sidebar_options[ $i ] = array(
116
+ 'sidebar' => $sidebar,
117
+ 'margin_top' => $options['margin-top'],
118
+ 'margin_bottom' => $options['margin-bottom'],
119
+ 'stop_id' => $options['stop-id'],
120
+ 'screen_max_width' => $options['screen-max-width'],
121
+ 'screen_max_height' => $options['screen-max-height'],
122
+ 'width_inherit' => $width_inherit,
123
+ 'refresh_interval' => $refresh_interval,
124
+ 'window_load_hook' => $window_load_hook,
125
+ 'disable_mo_api' => $disable_mo_api,
126
+ 'widgets' => array_values( $widgets )
127
+ );
128
+
129
+ $i++;
130
+
131
+ }
132
+
133
+ wp_localize_script( self::ID, 'q2w3_sidebar_options', $sidebar_options );
134
+
135
+ }
136
+
137
+ }
138
+
139
+
140
+ protected static function fixed_wigets() {
141
+
142
+ $sidebars = wp_get_sidebars_widgets();
143
+
144
+ if ( $sidebars && is_array($sidebars) ) foreach ( $sidebars as $sidebar_id => $sidebar_widgets ) {
145
+
146
+ if ( ! (stristr($sidebar_id, 'orphaned_widgets') !== false || $sidebar_id == 'wp_inactive_widgets') ) {
147
+
148
+ if ( $sidebar_widgets && is_array($sidebar_widgets) ) foreach ( $sidebar_widgets as $widget ) {
149
+
150
+ $widget_id = substr(strrchr($widget, '-'), 1);
151
+
152
+ $widget_type = stristr($widget, '-'.$widget_id, true);
153
+
154
+ $widget_options = get_option('widget_' . $widget_type);
155
+
156
+ if ( isset($widget_options[$widget_id]['q2w3_fixed_widget']) && $widget_options[$widget_id]['q2w3_fixed_widget']) self::$fixed_widgets[$sidebar_id][$widget] = $widget;
157
+
158
+ }
159
+
160
+ }
161
+
162
+ }
163
+
164
+ }
165
+
166
+
167
+ public static function is_widget_fixed($instance, $widget, $args) { // deprecated
168
+
169
+ if ( isset($instance['q2w3_fixed_widget']) && $instance['q2w3_fixed_widget'] && ! isset(self::$fixed_widgets[$args['id']][$widget->id]) ) {
170
+
171
+ //self::$fixed_widgets[$args['id']][$widget->id] = "'". $widget->id ."'";
172
+
173
+ //echo '<!-- fixed widget -->';
174
+
175
+ self::$fixed_widgets[$args['id']][$widget->id] = $widget->id;
176
+
177
+ self::wp_localize_script();
178
+
179
+ }
180
+
181
+ return $instance;
182
+
183
+ }
184
+
185
+
186
+ protected static function custom_ids() {
187
+
188
+ $options = self::load_options();
189
+
190
+ if ( isset($options['custom-ids']) && $options['custom-ids'] ) {
191
+
192
+ $ids = explode(PHP_EOL, $options['custom-ids']);
193
+
194
+ foreach ( $ids as $id ) {
195
+
196
+ $id = trim($id);
197
+
198
+ //if ( $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = "'". $id ."'";
199
+
200
+ if ( $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = $id;
201
+
202
+ }
203
+
204
+ }
205
+
206
+ }
207
+
208
+ protected static function get_widget_sidebar($widget_id) {
209
+
210
+ if ( !self::$sidebars_widgets ) {
211
+
212
+ self::$sidebars_widgets = wp_get_sidebars_widgets();
213
+
214
+ unset(self::$sidebars_widgets['wp_inactive_widgets']);
215
+
216
+ }
217
+
218
+ if ( is_array(self::$sidebars_widgets) ) {
219
+
220
+ foreach ( self::$sidebars_widgets as $sidebar => $widgets ) {
221
+
222
+ $key = array_search($widget_id, $widgets);
223
+
224
+ if ( $key !== false ) return $sidebar;
225
+
226
+ }
227
+
228
+ }
229
+
230
+ return 'q2w3-default-sidebar';
231
+
232
+ }
233
+
234
+ /*public static function js_settings() { // deprecated
235
+
236
+ $options = self::load_options();
237
+
238
+ $js = '';
239
+
240
+ if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
241
+
242
+ $js .= 'var q2w3_sidebar_options = new Array();'.PHP_EOL;
243
+
244
+ if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) $window_load_hook = 'true'; else $window_load_hook = 'false';
245
+
246
+ if ( isset($options['width-inherit']) && $options['width-inherit'] ) $width_inherit = 'true'; else $width_inherit = 'false';
247
+
248
+ if ( isset($options['disable-mo-api']) && $options['disable-mo-api'] ) $disable_mo_api = 'true'; else $disable_mo_api = 'false';
249
+
250
+ if ( $options['refresh-interval'] > 0 ) $refresh_interval = $options['refresh-interval']; else $refresh_interval = 0;
251
+
252
+ $i = 0;
253
+
254
+ foreach ( self::$fixed_widgets as $sidebar => $widgets ) {
255
+
256
+ $widgets_array = implode(',', $widgets);
257
+
258
+ $js .= 'q2w3_sidebar_options['. $i .'] = { "sidebar" : "'. $sidebar .'", "margin_top" : '. $options['margin-top'] .', "margin_bottom" : '. $options['margin-bottom'] .', "stop_id" : "' . $options['stop-id'] .'", "screen_max_width" : '. $options['screen-max-width'] .', "screen_max_height" : '. $options['screen-max-height'] .', "width_inherit" : '. $width_inherit .', "refresh_interval" : '. $refresh_interval .', "window_load_hook" : '. $window_load_hook .', "disable_mo_api" : '. $disable_mo_api .', "widgets" : ['. $widgets_array .'] };'.PHP_EOL;
259
+
260
+ $i++;
261
+
262
+ }
263
+
264
+ }
265
+
266
+ if ( $js && function_exists('wp_add_inline_script') && ! class_exists('BWP_MINIFY') ) {
267
+
268
+ wp_add_inline_script(self::ID, $js, 'before');
269
+
270
+ } elseif ( $js ) {
271
+
272
+ echo '<script type="text/javascript">'. $js .'</script>';
273
+
274
+ }
275
+
276
+ }*/
277
+
278
+ public static function add_widget_option($widget, $return, $instance) {
279
+
280
+ if ( isset($instance['q2w3_fixed_widget']) ) $iqfw = $instance['q2w3_fixed_widget']; else $iqfw = 0;
281
+
282
+ echo '<p>'.PHP_EOL;
283
+
284
+ echo '<input type="checkbox" name="'. $widget->get_field_name('q2w3_fixed_widget') .'" value="1" '. checked( $iqfw, 1, false ) .'/>'.PHP_EOL;
285
+
286
+ echo '<label for="'. $widget->get_field_id('q2w3_fixed_widget') .'">'. __('Fixed widget', 'q2w3-fixed-widget') .'</label>'.PHP_EOL;
287
+
288
+ echo '</p>'.PHP_EOL;
289
+
290
+ }
291
+
292
+ public static function update_widget_option($instance, $new_instance, $old_instance){
293
+
294
+ if ( isset($new_instance['q2w3_fixed_widget']) && $new_instance['q2w3_fixed_widget'] ) {
295
+
296
+ $instance['q2w3_fixed_widget'] = 1;
297
+
298
+ } else {
299
+
300
+ $instance['q2w3_fixed_widget'] = false;
301
+
302
+ }
303
+
304
+ return $instance;
305
+
306
+ }
307
+
308
+ protected static function load_language() {
309
+
310
+ $languages_path = plugin_basename( dirname(__FILE__).'/lang' );
311
+
312
+ load_plugin_textdomain( 'q2w3-fixed-widget', false, $languages_path );
313
+
314
+ }
315
+
316
+ public static function admin_menu() {
317
+
318
+ remove_action('admin_menu', array( 'q2w3_fixed_widget', 'admin_menu' )); // Remove free version plugin
319
+
320
+ self::$settings_page_hook = add_submenu_page( 'themes.php', __('Fixed Widget Options', 'q2w3-fixed-widget'), __('Fixed Widget Options', 'q2w3-fixed-widget'), 'activate_plugins', self::ID, array( __CLASS__, 'settings_page' ) );
321
+
322
+ }
323
+
324
+ protected static function defaults() {
325
+
326
+ $d['margin-top'] = 10;
327
+
328
+ $d['margin-bottom'] = 0;
329
+
330
+ $d['stop-id'] = '';
331
+
332
+ $d['refresh-interval'] = 1500;
333
+
334
+ $d['screen-max-width'] = 0;
335
+
336
+ $d['screen-max-height'] = 0;
337
+
338
+ $d['fix-widget-id'] = 'yes';
339
+
340
+ $d['window-load-enabled'] = false;
341
+
342
+ $d['logged_in_req'] = false;
343
+
344
+ $d['width-inherit'] = false;
345
+
346
+ //$d['widget_display_callback_priority'] = 30;
347
+
348
+ $d['disable-mo-api'] = false;
349
+
350
+ return $d;
351
+
352
+ }
353
+
354
+ protected static function load_options() {
355
+
356
+ $options = get_option(self::ID);
357
+
358
+ $options_old = get_option('q2w3_fixed_widget');
359
+
360
+ return array_merge(self::defaults(), (array)$options_old, (array)$options);
361
+
362
+ }
363
+
364
+ public static function register_settings() {
365
+
366
+ register_setting(self::ID, self::ID, array( __CLASS__, 'save_options_filter' ) );
367
+
368
+ }
369
+
370
+ public static function save_options_filter($input) { // Sanitize user input
371
+
372
+ $input['margin-top'] = (int)$input['margin-top'];
373
+
374
+ $input['margin-bottom'] = (int)$input['margin-bottom'];
375
+
376
+ $input['refresh-interval'] = (int)$input['refresh-interval'];
377
+
378
+ $input['screen-max-width'] = (int)$input['screen-max-width'];
379
+
380
+ $input['screen-max-height'] = (int)$input['screen-max-height'];
381
+
382
+ $input['custom-ids'] = trim(wp_strip_all_tags($input['custom-ids']));
383
+
384
+ $input['stop-id'] = trim(wp_strip_all_tags($input['stop-id']));
385
+
386
+ if ( !isset($input['fix-widget-id']) ) $input['fix-widget-id'] = false;
387
+
388
+ if ( !isset($input['window-load-enabled']) ) $input['window-load-enabled'] = false;
389
+
390
+ if ( !isset($input['logged_in_req']) ) $input['logged_in_req'] = false;
391
+
392
+ if ( !isset($input['width-inherit']) ) $input['width-inherit'] = false;
393
+
394
+ if ( !isset($input['disable-mo-api']) ) $input['disable-mo-api'] = false;
395
+
396
+ return $input;
397
+
398
+ }
399
+
400
+ public static function settings_page_js($hook) {
401
+
402
+ if( self::$settings_page_hook != $hook ) return;
403
+
404
+ wp_enqueue_script('postbox');
405
+
406
+ }
407
+
408
+ public static function settings_page() {
409
+
410
+ $screen = get_current_screen();
411
+
412
+ add_meta_box(self::ID.'-general', __('General Options', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_general_box' ), $screen, 'normal');
413
+
414
+ add_meta_box(self::ID.'-compatibility', __('Compatibility', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_compatibility_box' ), $screen, 'normal');
415
+
416
+ add_meta_box(self::ID.'-custom-ids', __('Custom IDs', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_custom_ids_box' ), $screen, 'normal');
417
+
418
+ add_meta_box(self::ID.'-recommend', __('Recommended Integration', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_recommend_box' ), $screen, 'side', 'high');
419
+
420
+ add_meta_box(self::ID.'-help', __('Documentation and Support', 'q2w3-fixed-widget'), array( __CLASS__, 'settings_page_help_box' ), $screen, 'side');
421
+
422
+ $options = self::load_options();
423
+
424
+ echo '<div class="wrap"><div id="icon-themes" class="icon32"><br /></div><h2>'. __('Fixed Widget Options', 'q2w3-fixed-widget') .'</h2>'.PHP_EOL;
425
+
426
+ if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' ) {
427
+
428
+ echo '<div id="message" class="updated"><p>'. __('Settings saved.') .'</p></div>'.PHP_EOL;
429
+
430
+ }
431
+
432
+ echo '<form method="post" action="options.php">'.PHP_EOL;
433
+
434
+ settings_fields(self::ID);
435
+
436
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
437
+
438
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
439
+
440
+ echo '<div id="poststuff" class="metabox-holder has-right-sidebar">'.PHP_EOL;
441
+
442
+ echo '<div class="inner-sidebar" id="side-info-column">'.PHP_EOL;
443
+
444
+ do_meta_boxes( $screen, 'side', $options );
445
+
446
+ echo '</div>'.PHP_EOL;
447
+
448
+ echo '<div id="post-body-content">'.PHP_EOL;
449
+
450
+ do_meta_boxes( $screen, 'normal', $options );
451
+
452
+ echo '</div>'.PHP_EOL;
453
+
454
+ echo '<p><em>'. __(" Note for users of caching plugins. Please, don’t forget to clear the cache after changing options.", 'q2w3-fixed-widget') .'</em></p>'.PHP_EOL;
455
+
456
+ echo '<p class="submit"><input type="submit" class="button-primary" value="'. __('Save Changes') .'" /></p>'.PHP_EOL;
457
+
458
+ echo '</div><!-- #poststuff -->'.PHP_EOL;
459
+
460
+ echo '</form>'.PHP_EOL;
461
+
462
+ echo '<script>jQuery(document).ready(function(){ postboxes.add_postbox_toggles(pagenow); });</script>'.PHP_EOL;
463
+
464
+ echo '</div><!-- .wrap -->'.PHP_EOL;
465
+
466
+ }
467
+
468
+ public static function settings_page_general_box($options) {
469
+
470
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Margin Top:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[margin-top]" value="'. $options['margin-top'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
471
+
472
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Margin Bottom:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[margin-bottom]" value="'. $options['margin-bottom'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
473
+
474
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Stop ID:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[stop-id]" value="'. $options['stop-id'] .'" style="width: 150px;">&nbsp;'. __('You need to provide the HTML tag ID here. The position of that HTML element will determine the margin-bottom value.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
475
+
476
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Refresh interval:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[refresh-interval]" value="'. $options['refresh-interval'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('milliseconds', 'q2w3-fixed-widget') .' / '. __('Used only for compatibility with browsers without MutationObserver API support. Set 0 to disable it completely.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
477
+
478
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Disable Width:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[screen-max-width]" value="'. $options['screen-max-width'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .' / '. __('Use this option to disable the plugin on portable devices. When the browser screen width is less than the specified value, the plugin will be disabled.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
479
+
480
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Disable Height:', 'q2w3-fixed-widget') .'</span><input type="text" name="'. self::ID .'[screen-max-height]" value="'. $options['screen-max-height'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3-fixed-widget') .' / '. __(' Works like the Disable Width option.', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
481
+
482
+ }
483
+
484
+ public static function settings_page_custom_ids_box($options) {
485
+ $custom_ids = isset($options['custom-ids']) ? $options['custom-ids'] : '' ;
486
+ echo '<p><span >'. __('Custom HTML IDs (each one on a new line):', 'q2w3-fixed-widget') .'</span><br/><br/><textarea name="'. self::ID .'[custom-ids]" style="width: 320px; height: 120px;">'. $custom_ids .'</textarea>'.PHP_EOL;
487
+ }
488
+
489
+ public static function settings_page_compatibility_box($options) {
490
+
491
+ echo '<p><span style="display: inline-block; width: 280px;">'. __('Auto fix widget ID:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[fix-widget-id]" value="yes" '. checked('yes', $options['fix-widget-id'], false) .' /> </p>'.PHP_EOL;
492
+
493
+ echo '<p><span style="display: inline-block; width: 280px;">'. __('Disable MutationObserver:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-mo-api]" value="yes" '. checked('yes', $options['disable-mo-api'], false) .' /> '. __('If MutationObserver is disabled, the plugin will use the refresh interval to reflect page changes (version 4 behavior)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
494
+
495
+ echo '<p><span style="display: inline-block; width: 280px;">'. __('Enable the plugin for logged-in users only:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[logged_in_req]" value="yes" '. checked('yes', $options['logged_in_req'], false) .' /> '. __('Enable this option for debug purposes (frontend problems and etc.)', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
496
+
497
+ echo '<p><span style="display: inline-block; width: 280px;">'. __('Inherit widget width from the parent container:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[width-inherit]" value="yes" '. checked('yes', $options['width-inherit'], false) .' /> '. __('Enable this option for themes with a responsive sidebar', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
498
+
499
+ echo '<p><span style="display: inline-block; width: 280px;">'. __('Use jQuery(window).load() hook:', 'q2w3-fixed-widget') .'</span><input type="checkbox" name="'. self::ID .'[window-load-enabled]" value="yes" '. checked('yes', $options['window-load-enabled'], false) .' /> '. __('Enable this option only if you have problems with other scroll oriented javascript code', 'q2w3-fixed-widget') .'</p>'.PHP_EOL;
500
+
501
+ //echo '<p><span style="display: inline-block; width: 280px;">'. __('widget_display_callback hook priority:', 'q2w3-fixed-widget') .'</span><select name="'. self::ID .'[widget_display_callback_priority]"><option value="1" '. selected('1', $options['widget_display_callback_priority'], false) .'>1</option><option value="10" '. selected('10', $options['widget_display_callback_priority'], false) .'>10</option><option value="20" '. selected('20', $options['widget_display_callback_priority'], false) .'>20</option><option value="30" '. selected('30', $options['widget_display_callback_priority'], false) .'>30</option><option value="50" '. selected('50', $options['widget_display_callback_priority'], false) .'>50</option><option value="100" '. selected('100', $options['widget_display_callback_priority'], false) .'>100</option></select></p>'.PHP_EOL;
502
+
503
+ }
504
+
505
+ public static function settings_page_recommend_box($options) {
506
+ echo '<p>';
507
+ echo '<a href="https://wordpress.org/plugins/advanced-ads/" target="_blank"><b>Advanced Ads</b></a>: ';
508
+ echo __('This ad management plugin provides many features to optimize your ads and to boost your conversions. It works perfectly with the Q2W3 Fixed Widget plugin.', 'q2w3-fixed-widget');
509
+ echo '</p>';
510
+ echo '<div class="review">';
511
+ echo '<h5>"Perfect plugin"</h5>';
512
+ echo '<p class="content">"The plugin contains everything I need for the ads management and publishing. Fair price, stable and functional."</p>';
513
+ echo '<p class="subline">from David H. on wordpress.org</p>';
514
+ echo '</div>';
515
+ echo ''.PHP_EOL;
516
+
517
+ if (! defined('ADVADS_VERSION')) {
518
+ // check whether is's installed
519
+ $plugins = get_plugins();
520
+ if( isset( $plugins['advanced-ads/advanced-ads.php'] ) ){
521
+ // advanced-ads is deactivated
522
+ $link = '<a class="button-var1" href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=advanced-ads/advanced-ads.php&amp', 'activate-plugin_advanced-ads/advanced-ads.php' ) . '">'. __('Activate Now', 'q2w3-fixed-widget') .'</a>';
523
+ }
524
+ else{
525
+ // advanced-ads is not installed
526
+ $link = '<a class="button-var1" href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . 'advanced-ads'), 'install-plugin_' . 'advanced-ads') . '">'. __('Install Now', 'q2w3-fixed-widget') .'</a>';
527
+ }
528
+ echo '<div style="margin-top:20px; text-align:center;">' . $link . '</div>';
529
+ }
530
+ }
531
+
532
+ public static function settings_page_help_box($options) {
533
+ echo '<ul>';
534
+ echo '<li><a href="https://wpadvancedads.com/fixed-widget-wordpress/?utm_source=fixed-widget&utm_medium=link&utm_campaign=BackendSidebar" target="_blank">FAQ</a></li>';
535
+ echo '<li><a href="https://wordpress.org/support/plugin/q2w3-fixed-widget/" target="_blank">Support</a></li>';
536
+ echo '</ul>';
537
+ echo ''.PHP_EOL;
538
+ }
539
+
540
+ public static function add_plugin_links( $links ) {
541
+ if ( ! is_array( $links ) ) {
542
+ return $links;
543
+ }
544
+ // add link to the settings
545
+ $extend_link = '<a href="' . get_site_url() . '/wp-admin/themes.php?page=' . self::ID . '">' . __( 'Settings', 'q2w3-fixed-widget' ) . '</a>';
546
+ array_unshift( $links, $extend_link );
547
+ return $links;
548
+ }
549
+
550
+ public static function registered_sidebars_filter() {
551
+
552
+ global $wp_registered_sidebars;
553
+
554
+ if ( !is_array($wp_registered_sidebars) ) return;
555
+
556
+ foreach ( $wp_registered_sidebars as $id => $sidebar ) {
557
+
558
+ if ( strpos($sidebar['before_widget'], 'id="%1$s"') === false && strpos($sidebar['before_widget'], 'id=\'%1$s\'') === false ) {
559
+
560
+ if ( $sidebar['before_widget'] == '' || $sidebar['before_widget'] == ' ' ) {
561
+
562
+ $wp_registered_sidebars[$id]['before_widget'] = '<div id="%1$s">';
563
+
564
+ $wp_registered_sidebars[$id]['after_widget'] = '</div>';
565
+
566
+ } elseif ( strpos($sidebar['before_widget'], 'id=') === false ) {
567
+
568
+ $tag_end_pos = strpos($sidebar['before_widget'], '>');
569
+
570
+ if ( $tag_end_pos !== false ) {
571
+
572
+ $wp_registered_sidebars[$id]['before_widget'] = substr_replace($sidebar['before_widget'], ' id="%1$s"', $tag_end_pos, 0);
573
+
574
+ }
575
+
576
+ } else {
577
+
578
+ $str_array = explode(' ', $sidebar['before_widget']);
579
+
580
+ if ( is_array($str_array) ) {
581
+
582
+ foreach ( $str_array as $str_part_id => $str_part ) {
583
+
584
+ if ( strpos($str_part, 'id="') !== false ) {
585
+
586
+ $p1 = strpos($str_part, 'id="');
587
+
588
+ $p2 = strpos($str_part, '"', $p1 + 4);
589
+
590
+ $str_array[$str_part_id] = substr_replace($str_part, 'id="%1$s"', $p1, $p2 + 1);
591
+
592
+ } elseif ( strpos($str_part, 'id=\'') !== false ) {
593
+
594
+ $p1 = strpos($str_part, 'id=\'');
595
+
596
+ $p2 = strpos($str_part, "'", $p1 + 4);
597
+
598
+ $str_array[$str_part_id] = substr_replace($str_part, 'id=\'%1$s\'', $p1, $p2);
599
+
600
+ }
601
+
602
+ }
603
+
604
+ $wp_registered_sidebars[$id]['before_widget'] = implode(' ', $str_array);
605
+
606
+ }
607
+
608
+ }
609
+
610
+ } // if id is wrong
611
+
612
+ } // foreach
613
+
614
+ } // registered_sidebars_filter()
615
+
616
+ } // q2w3_fixed_widget_pro class
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Q2W3 Fixed Widget for WordPress ===
2
- Contributors: webzunft, max-bond
3
  Tags: fixed widget, sticky widget, sidebar, ads, widget
4
  Requires at least: 4.0
5
  Tested up to: 5.1
6
- Stable tag: 5.1.5
7
 
8
  More attention and a higher ad performance with fixed sticky widgets.
9
 
@@ -73,8 +73,11 @@ There are two options: `Disable Width` and `Disable Height`. They works the same
73
 
74
  == Changelog ==
75
 
76
- = 5.1.5 =
 
 
77
 
 
78
  * author change
79
 
80
  = 5.1.4 =
1
  === Q2W3 Fixed Widget for WordPress ===
2
+ Contributors: webzunft, max-bond, advancedads
3
  Tags: fixed widget, sticky widget, sidebar, ads, widget
4
  Requires at least: 4.0
5
  Tested up to: 5.1
6
+ Stable tag: 5.1.6
7
 
8
  More attention and a higher ad performance with fixed sticky widgets.
9
 
73
 
74
  == Changelog ==
75
 
76
+ = 5.1.6 =
77
+ * linguistic corrections
78
+ * cleanup of the options page
79
 
80
+ = 5.1.5 =
81
  * author change
82
 
83
  = 5.1.4 =