Q2W3 Fixed Widget - Version 3.0

Version Description

  • This version brings you a long waited capability to stick widgets located in different sidebars! Enjoy!
  • Fixed conflict with WP Page Widget plugin
  • A few small bugs cleaned
  • Warning! "Disable plugin on mobile devices" and "Disable plugin on tablet devices" options now are depricated and will be removed in the next release. Use "Screen Max Width" option instead!
Download this release

Release Info

Developer Max Bond
Plugin Icon 128x128 Q2W3 Fixed Widget
Version 3.0
Comparing to
See all releases

Code changes from version 2.3 to 3.0

Files changed (5) hide show
  1. js/q2w3-fixed-widget.js +2 -2
  2. lang/ru_RU.mo +0 -0
  3. lang/ru_RU.po +53 -21
  4. q2w3-fixed-widget.php +94 -40
  5. readme.txt +26 -18
js/q2w3-fixed-widget.js CHANGED
@@ -2,7 +2,7 @@ function q2w3_sidebar(options) {
2
 
3
  if ( !options.widgets) return false;
4
 
5
- if ( !options.sidebar) options.sidebar = 'q2w3_default';
6
 
7
  var widgets = new Array();
8
 
@@ -118,7 +118,7 @@ function q2w3_sidebar(options) {
118
  }).trigger('scroll.' + options.sidebar);
119
 
120
  jQuery(window).on('resize', function() {
121
- if ( jQuery(window).width() <= options.min_window_width ) {
122
  jQuery(window).off('load scroll.' + options.sidebar);
123
  widget.obj.css('position', '');
124
  widget.obj.css('top', '');
2
 
3
  if ( !options.widgets) return false;
4
 
5
+ if ( !options.sidebar) options.sidebar = 'q2w3-default-sidebar';
6
 
7
  var widgets = new Array();
8
 
118
  }).trigger('scroll.' + options.sidebar);
119
 
120
  jQuery(window).on('resize', function() {
121
+ if ( jQuery(window).width() <= options.screen_max_width ) {
122
  jQuery(window).off('load scroll.' + options.sidebar);
123
  widget.obj.css('position', '');
124
  widget.obj.css('top', '');
lang/ru_RU.mo CHANGED
Binary file
lang/ru_RU.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Q2W3 Fixed Widget\n"
4
- "POT-Creation-Date: 2013-05-21 21:47+0400\n"
5
- "PO-Revision-Date: 2013-05-21 21:48+0400\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
@@ -15,77 +15,109 @@ msgstr ""
15
  "ru-dev\\wp-content\\plugins\\q2w3-fixed-widget\n"
16
 
17
  #: c:\Program Files
18
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:135
19
  msgid "Fixed widget"
20
  msgstr "Зафиксировать виджет"
21
 
22
  #: c:\Program Files
23
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:175
24
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:223
25
  msgid "Fixed Widget Options"
26
  msgstr "Фикс. Виджеты"
27
 
28
  #: c:\Program Files
29
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:227
30
  msgid "Settings saved."
31
  msgstr ""
32
 
33
  #: c:\Program Files
34
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:239
35
  msgid "Margin Top:"
36
  msgstr "Верхний отступ:"
37
 
38
  #: c:\Program Files
39
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:239
40
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:241
41
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:247
42
  msgid "px"
43
  msgstr "пикс."
44
 
45
  #: c:\Program Files
46
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:241
47
  msgid "Margin Bottom:"
48
  msgstr "Нижний отступ:"
49
 
50
  #: c:\Program Files
51
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:243
52
  msgid "Refresh interval:"
53
  msgstr "Интервал обновления:"
54
 
55
  #: c:\Program Files
56
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:243
57
  msgid "milliseconds"
58
  msgstr "миллисекунды"
59
 
60
  #: c:\Program Files
61
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:243
62
  msgid "Set 0 to disable."
63
  msgstr "Установите 0, чтобы отключить пересчет параметров"
64
 
65
  #: c:\Program Files
66
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:245
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  msgid "Custom HTML IDs (each one on a new line):"
68
  msgstr ""
69
  "HTML-идентификаторы статических виджетов и прочих<br/> нестандартных "
70
  "элементов (каждый на новой строке):"
71
 
72
  #: c:\Program Files
73
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:247
74
- msgid "Disable plugin, when browser window width is less then:"
75
- msgstr "Отключить плагин, если ширина окна браузера меньше чем:"
76
 
77
  #: c:\Program Files
78
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:249
 
 
 
 
 
 
 
 
 
 
 
79
  msgid "Disable plugin on phone devices:"
80
  msgstr "Отключить плагин на мобильных:"
81
 
82
  #: c:\Program Files
83
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:251
 
 
 
 
 
 
 
 
84
  msgid "Disable plugin on tablet devices:"
85
  msgstr "Отключить плагин на планшетах:"
86
 
87
  #: c:\Program Files
88
- #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:253
89
  msgid "Save Changes"
90
  msgstr ""
91
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Q2W3 Fixed Widget\n"
4
+ "POT-Creation-Date: 2013-05-30 21:15+0400\n"
5
+ "PO-Revision-Date: 2013-05-30 21:17+0400\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
15
  "ru-dev\\wp-content\\plugins\\q2w3-fixed-widget\n"
16
 
17
  #: c:\Program Files
18
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:187
19
  msgid "Fixed widget"
20
  msgstr "Зафиксировать виджет"
21
 
22
  #: c:\Program Files
23
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:227
24
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:279
25
  msgid "Fixed Widget Options"
26
  msgstr "Фикс. Виджеты"
27
 
28
  #: c:\Program Files
29
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:283
30
  msgid "Settings saved."
31
  msgstr ""
32
 
33
  #: c:\Program Files
34
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:291
35
  msgid "Margin Top:"
36
  msgstr "Верхний отступ:"
37
 
38
  #: c:\Program Files
39
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:291
40
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:293
41
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:297
42
  msgid "px"
43
  msgstr "пикс."
44
 
45
  #: c:\Program Files
46
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:293
47
  msgid "Margin Bottom:"
48
  msgstr "Нижний отступ:"
49
 
50
  #: c:\Program Files
51
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:295
52
  msgid "Refresh interval:"
53
  msgstr "Интервал обновления:"
54
 
55
  #: c:\Program Files
56
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:295
57
  msgid "milliseconds"
58
  msgstr "миллисекунды"
59
 
60
  #: c:\Program Files
61
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:295
62
  msgid "Set 0 to disable."
63
  msgstr "Установите 0, чтобы отключить пересчет параметров"
64
 
65
  #: c:\Program Files
66
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:297
67
+ msgid "Screen Max Width:"
68
+ msgstr "Ширина окна браузера"
69
+
70
+ #: c:\Program Files
71
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:297
72
+ msgid ""
73
+ "Plugin will be disabled when browser window width equals or less then "
74
+ "specified value"
75
+ msgstr ""
76
+ "Плагин будет отключен, если ширина окна браузера меньше указанного значения"
77
+
78
+ #: c:\Program Files
79
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:299
80
  msgid "Custom HTML IDs (each one on a new line):"
81
  msgstr ""
82
  "HTML-идентификаторы статических виджетов и прочих<br/> нестандартных "
83
  "элементов (каждый на новой строке):"
84
 
85
  #: c:\Program Files
86
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:301
87
+ msgid "Use jQuery(window).load() hook:"
88
+ msgstr "Вкл. jQuery(window).load():"
89
 
90
  #: c:\Program Files
91
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:301
92
+ msgid ""
93
+ "Use this option only if you have problems with <a href=\"http://wordpress."
94
+ "org/support/topic/doesnt-work-with-infinte-scroll-for-widget-scripts\" "
95
+ "target=\"_blank\">other scroll oriented javascript code</a>"
96
+ msgstr ""
97
+ "Используйте эту опцию только в случае проблем с <a href=\"http://wordpress."
98
+ "org/support/topic/doesnt-work-with-infinte-scroll-for-widget-scripts\" "
99
+ "target=\"_blank\">другими скриптами</a>"
100
+
101
+ #: c:\Program Files
102
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:303
103
  msgid "Disable plugin on phone devices:"
104
  msgstr "Отключить плагин на мобильных:"
105
 
106
  #: c:\Program Files
107
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:303
108
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:305
109
+ msgid "Option depricated. Use Screen Max Width instead!"
110
+ msgstr ""
111
+ "Опция устарела и будет удалена в следующей версии! Вместо нее используйте "
112
+ "опцию \"Ширина окна браузера\""
113
+
114
+ #: c:\Program Files
115
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:305
116
  msgid "Disable plugin on tablet devices:"
117
  msgstr "Отключить плагин на планшетах:"
118
 
119
  #: c:\Program Files
120
+ #: (x86)\Zend\Apache2\htdocs\q2w3.ru-dev\wp-content\plugins\q2w3-fixed-widget/q2w3-fixed-widget.php:307
121
  msgid "Save Changes"
122
  msgstr ""
123
 
q2w3-fixed-widget.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Q2W3 Fixed Widget
4
  Plugin URI: http://www.q2w3.ru/q2w3-fixed-widget-wordpress-plugin/
5
  Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
  Author: Max Bond
7
- Version: 2.3
8
  Author URI: http://www.q2w3.ru/
9
  */
10
 
@@ -26,11 +26,11 @@ if ( is_admin() ) {
26
 
27
  add_action('wp_enqueue_scripts', array( 'q2w3_fixed_widget', 'init' ));
28
 
29
- add_filter('widget_display_callback', array( 'q2w3_fixed_widget', 'check' ), 10, 3);
30
-
31
  add_action('wp_footer', array( 'q2w3_fixed_widget', 'action' ), 1);
32
 
33
- }
34
 
35
  // if class allready loaded return control to the main script
36
 
@@ -42,13 +42,17 @@ class q2w3_fixed_widget {
42
 
43
  const ID = 'q2w3_fixed_widget';
44
 
 
 
 
 
45
  protected static $fixed_widgets;
46
 
47
 
48
 
49
  public static function init() {
50
 
51
- wp_enqueue_script('q2w3-fixed-widget', plugin_dir_url( __FILE__ ) . 'js/q2w3-fixed-widget.js', array('jquery'), '2.3');
52
 
53
  self::check_custom_ids();
54
 
@@ -56,8 +60,12 @@ class q2w3_fixed_widget {
56
 
57
  public static function check($instance, $widget, $args){
58
 
59
- if ( isset($instance['q2w3_fixed_widget']) && $instance['q2w3_fixed_widget'] ) self::$fixed_widgets[$widget->id] = "'". $widget->id ."'";
60
-
 
 
 
 
61
  return $instance;
62
 
63
  }
@@ -66,11 +74,39 @@ class q2w3_fixed_widget {
66
 
67
  $options = self::load_options();
68
 
69
- if ( !$options['custom-ids'] ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
- $ids = explode(PHP_EOL, $options['custom-ids']);
72
 
73
- foreach ( $ids as $id ) self::$fixed_widgets[$id] = "'". $id ."'";
 
 
 
 
 
 
 
 
74
 
75
  }
76
 
@@ -100,28 +136,44 @@ class q2w3_fixed_widget {
100
 
101
  if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
102
 
103
- $array = implode(',', self::$fixed_widgets);
104
-
105
  echo '<script type="text/javascript">'.PHP_EOL;
 
 
 
 
 
 
106
 
107
- echo 'jQuery(document).ready(function(){'.PHP_EOL;
108
 
109
- echo ' var q2w3_sidebar_options = { "sidebar" : "q2w3_default", "margin_top" : '. $options['margin-top'] .', "margin_bottom" : '. $options['margin-bottom'] .', "min_window_width" : '. $options['min-window-width'] .', "widgets" : ['. $array .'] }'.PHP_EOL;
110
 
111
- if ( $options['refresh-interval'] > 0 ) {
112
-
113
- echo ' setInterval(function () { q2w3_sidebar(q2w3_sidebar_options); }, '. $options['refresh-interval'] .');'.PHP_EOL;
114
-
115
- } else {
 
 
116
 
117
- echo ' q2w3_sidebar(q2w3_sidebar_options);'.PHP_EOL;
 
 
 
 
 
 
 
 
 
 
118
 
119
  }
120
 
121
  echo '});'.PHP_EOL;
122
-
123
- echo '</script>'.PHP_EOL;
124
 
 
 
125
  }
126
 
127
  }
@@ -182,9 +234,9 @@ class q2w3_fixed_widget {
182
 
183
  $d['margin-bottom'] = 0;
184
 
185
- $d['refresh-interval'] = 1000;
186
 
187
- $d['min-window-width'] = 0;
188
 
189
  return $d;
190
 
@@ -204,14 +256,18 @@ class q2w3_fixed_widget {
204
 
205
  }
206
 
207
- public static function save_options_filter($input) {
208
-
209
- // Sanitize user input
210
 
211
  $input['margin-top'] = (int)$input['margin-top'];
212
 
213
  $input['margin-bottom'] = (int)$input['margin-bottom'];
214
-
 
 
 
 
 
 
215
  return $input;
216
 
217
  }
@@ -230,25 +286,23 @@ class q2w3_fixed_widget {
230
 
231
  echo '<form method="post" action="options.php">'.PHP_EOL;
232
 
233
- echo wp_nonce_field('update-options', '_wpnonce', true, false).PHP_EOL;
234
-
235
- echo '<input type="hidden" name="action" value="update" />'.PHP_EOL;
236
-
237
- echo '<input type="hidden" name="page_options" value="'. self::ID .'" />'.PHP_EOL;
238
 
239
- echo '<p><span style="display: inline-block; width: 100px;">'. __('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;
240
 
241
- echo '<p><span style="display: inline-block; width: 100px;">'. __('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;
242
 
243
- echo '<p><span style="display: inline-block; width: 100px;">'. __('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') .' / '. __('Set 0 to disable.', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
 
 
244
 
245
  echo '<p><span >'. __('Custom HTML IDs (each one on a new line):', 'q2w3_fixed_widget') .'</span><br/><textarea name="'. self::ID .'[custom-ids]" style="width: 320px; height: 120px;">'. $options['custom-ids'] .'</textarea>'.PHP_EOL;
246
-
247
- echo '<p><span style="display: inline-block; width: 195px;">'. __('Disable plugin, when browser window width is less then:', 'q2w3_fixed_widget') .'</span><input type="text" name="'. self::ID .'[min-window-width]" value="'. $options['min-window-width'] .'" style="width: 50px; text-align: center;" />&nbsp;'. __('px', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
248
 
249
- echo '<p><span style="display: inline-block; width: 195px;">'. __('Disable plugin on phone devices:', 'q2w3_fixed_widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-phone]" value="yes" '. checked('yes', $options['disable-phone'], false) .' /></p>'.PHP_EOL;
250
 
251
- echo '<p><span style="display: inline-block; width: 195px;">'. __('Disable plugin on tablet devices:', 'q2w3_fixed_widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-tablet]" value="yes" '. checked('yes', $options['disable-tablet'], false) .' /></p>'.PHP_EOL;
252
 
253
  echo '<p class="submit"><input type="submit" class="button-primary" value="'. __('Save Changes') .'" /></p>'.PHP_EOL;
254
 
4
  Plugin URI: http://www.q2w3.ru/q2w3-fixed-widget-wordpress-plugin/
5
  Description: Fixes positioning of the selected widgets, when the page is scrolled down.
6
  Author: Max Bond
7
+ Version: 3.0
8
  Author URI: http://www.q2w3.ru/
9
  */
10
 
26
 
27
  add_action('wp_enqueue_scripts', array( 'q2w3_fixed_widget', 'init' ));
28
 
29
+ add_filter('widget_display_callback', array( 'q2w3_fixed_widget', 'check' ), 30, 3); // priority 30 is set for compatibility with WP Page Widget plugin
30
+
31
  add_action('wp_footer', array( 'q2w3_fixed_widget', 'action' ), 1);
32
 
33
+ }
34
 
35
  // if class allready loaded return control to the main script
36
 
42
 
43
  const ID = 'q2w3_fixed_widget';
44
 
45
+ const VERSION = '3.0';
46
+
47
+ protected static $sidebars_widgets;
48
+
49
  protected static $fixed_widgets;
50
 
51
 
52
 
53
  public static function init() {
54
 
55
+ wp_enqueue_script('q2w3-fixed-widget', plugin_dir_url( __FILE__ ) . 'js/q2w3-fixed-widget.js', array('jquery'), self::VERSION);
56
 
57
  self::check_custom_ids();
58
 
60
 
61
  public static function check($instance, $widget, $args){
62
 
63
+ if ( isset($instance['q2w3_fixed_widget']) && $instance['q2w3_fixed_widget'] ) {
64
+
65
+ self::$fixed_widgets[$args['id']][$widget->id] = "'". $widget->id ."'";
66
+
67
+ }
68
+
69
  return $instance;
70
 
71
  }
74
 
75
  $options = self::load_options();
76
 
77
+ if ( isset($options['custom-ids']) && $options['custom-ids'] ) {
78
+
79
+ $ids = explode(PHP_EOL, $options['custom-ids']);
80
+
81
+ foreach ( $ids as $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = "'". $id ."'";
82
+
83
+ }
84
+
85
+ }
86
+
87
+ public static function get_widget_sidebar($widget_id) {
88
+
89
+ if ( !self::$sidebars_widgets ) {
90
+
91
+ self::$sidebars_widgets = wp_get_sidebars_widgets();
92
+
93
+ unset(self::$sidebars_widgets['wp_inactive_widgets']);
94
+
95
+ }
96
+
97
+ if ( is_array(self::$sidebars_widgets) ) {
98
 
99
+ foreach ( self::$sidebars_widgets as $sidebar => $widgets ) {
100
 
101
+ $key = array_search($widget_id, $widgets);
102
+
103
+ if ( $key !== false ) return $sidebar;
104
+
105
+ }
106
+
107
+ }
108
+
109
+ return 'q2w3-default-sidebar';
110
 
111
  }
112
 
136
 
137
  if ( is_array(self::$fixed_widgets) && !empty(self::$fixed_widgets) ) {
138
 
 
 
139
  echo '<script type="text/javascript">'.PHP_EOL;
140
+
141
+ if ( isset($options['window-load-enabled']) && $options['window-load-enabled'] == 'yes' ) {
142
+
143
+ echo 'jQuery(window).load(function(){'.PHP_EOL;
144
+
145
+ } else {
146
 
147
+ echo 'jQuery(document).ready(function(){'.PHP_EOL;
148
 
149
+ }
150
 
151
+ $i = 0;
152
+
153
+ foreach ( self::$fixed_widgets as $sidebar => $widgets ) {
154
+
155
+ $i++;
156
+
157
+ $widgets_array = implode(',', $widgets);
158
 
159
+ echo ' var q2w3_sidebar_'. $i .'_options = { "sidebar" : "'. $sidebar .'", "margin_top" : '. $options['margin-top'] .', "margin_bottom" : '. $options['margin-bottom'] .', "screen_max_width" : '. $options['screen-max-width'] .', "widgets" : ['. $widgets_array .'] }'.PHP_EOL;
160
+
161
+ if ( $options['refresh-interval'] > 0 ) {
162
+
163
+ echo ' setInterval(function () { q2w3_sidebar(q2w3_sidebar_'. $i .'_options); }, '. $options['refresh-interval'] .');'.PHP_EOL;
164
+
165
+ } else {
166
+
167
+ echo ' q2w3_sidebar(q2w3_sidebar_'. $i .'_options);'.PHP_EOL;
168
+
169
+ }
170
 
171
  }
172
 
173
  echo '});'.PHP_EOL;
 
 
174
 
175
+ echo '</script>'.PHP_EOL;
176
+
177
  }
178
 
179
  }
234
 
235
  $d['margin-bottom'] = 0;
236
 
237
+ $d['refresh-interval'] = 1500;
238
 
239
+ $d['screen-max-width'] = 0;
240
 
241
  return $d;
242
 
256
 
257
  }
258
 
259
+ public static function save_options_filter($input) { // Sanitize user input
 
 
260
 
261
  $input['margin-top'] = (int)$input['margin-top'];
262
 
263
  $input['margin-bottom'] = (int)$input['margin-bottom'];
264
+
265
+ $input['refresh-interval'] = (int)$input['refresh-interval'];
266
+
267
+ $input['screen-max-width'] = (int)$input['screen-max-width'];
268
+
269
+ $input['custom-ids'] = trim(wp_strip_all_tags($input['custom-ids']));
270
+
271
  return $input;
272
 
273
  }
286
 
287
  echo '<form method="post" action="options.php">'.PHP_EOL;
288
 
289
+ settings_fields(self::ID);
 
 
 
 
290
 
291
+ 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;
292
 
293
+ 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;
294
 
295
+ 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') .' / '. __('Set 0 to disable.', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
296
+
297
+ echo '<p><span style="display: inline-block; width: 150px;">'. __('Screen Max 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') .' / '. __('Plugin will be disabled when browser window width equals or less then specified value', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
298
 
299
  echo '<p><span >'. __('Custom HTML IDs (each one on a new line):', 'q2w3_fixed_widget') .'</span><br/><textarea name="'. self::ID .'[custom-ids]" style="width: 320px; height: 120px;">'. $options['custom-ids'] .'</textarea>'.PHP_EOL;
300
+
301
+ echo '<p><span style="display: inline-block; width: 195px;">'. __('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) .' /> '. __('Use this option only if you have problems with <a href="http://wordpress.org/support/topic/doesnt-work-with-infinte-scroll-for-widget-scripts" target="_blank">other scroll oriented javascript code</a>', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
302
 
303
+ echo '<p><span style="display: inline-block; width: 195px;">'. __('Disable plugin on phone devices:', 'q2w3_fixed_widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-phone]" value="yes" '. checked('yes', $options['disable-phone'], false) .' /> '. __('Option depricated. Use Screen Max Width instead!', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
304
 
305
+ echo '<p><span style="display: inline-block; width: 195px;">'. __('Disable plugin on tablet devices:', 'q2w3_fixed_widget') .'</span><input type="checkbox" name="'. self::ID .'[disable-tablet]" value="yes" '. checked('yes', $options['disable-tablet'], false) .' /> '. __('Option depricated. Use Screen Max Width instead!', 'q2w3_fixed_widget') .'</p>'.PHP_EOL;
306
 
307
  echo '<p class="submit"><input type="submit" class="button-primary" value="'. __('Save Changes') .'" /></p>'.PHP_EOL;
308
 
readme.txt CHANGED
@@ -4,36 +4,31 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: sidebar, widget, scroll, fixed, floating, sticky, russian, q2w3
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
- Stable tag: 2.3
8
 
9
  Fixes positioning of the selected widgets, when the page is scrolled down.
10
 
11
  == Description ==
12
 
13
- Enable "Fixed widget" option in widget settings (see [screenshot](http://wordpress.org/extend/plugins/q2w3-fixed-widget/screenshots/)) and it will be always in sight when page is scrolled down.
 
14
 
15
- There is no problem to "Fix" (or "Stick") more than one widget in a single sidebar.
16
-
17
- New in version 2.2. Now the plugin is able to reflect dynamic page content changes (infinite scroll, ajax basket and other javascript stuff)!!!
18
-
19
- New in version 2.1. Added option to disable plugin on mobile devices.
20
- Mobile detection is based on [Mobile-Detect project](https://github.com/serbanghita/Mobile-Detect/).
21
 
22
  [Watch the demo](http://store.places-finder.com/cp-ajax-post-load).
23
  Right sidebar, last three widgets. Scroll down to the bottom.
24
 
25
- Supported languages: English, Russian
26
-
27
- Note. The plugin is doing its best in "single sidebar -> multiple widgets" environment. You may try to fix widgets in different sidebars, but in most cases the result will be
28
- inadequate.
29
 
30
- Note two. The plugin is not working with all themes. Theme requirements:
 
 
 
31
 
32
- * Widgets must have unique IDs (see FAQ).
33
- * No JavaScript errors
34
- * jQuery 1.7 or later
35
 
36
- In some cases theme CSS changes required.
37
 
38
  == Installation ==
39
 
@@ -52,11 +47,18 @@ There are several reasons:
52
  2. Javascript errors on page. Commonly caused by buggy plugins. Check javascript console of your browser. If you find errors, try to locate and fix its source.
53
  3. No `wp_head()` and `wp_footer()` functions in template. Check header.php and footer.php files of your active theme.
54
 
 
 
 
 
 
 
 
55
  = How to prevent overlapping with the footer? =
56
 
57
  Make sure you have updated plugin to version 2.x. Go to WP admin area, Appearance -> Fixed Widget Options. Here you can define top and bottom margins. Set bottom margin value >= footer height. Check the result.
58
 
59
- = What does Refresh Interval option? =
60
 
61
  This option defines (in milliseconds, 1 sec = 1000 ms) how often plugin recalculates sticky widgets parameters. Required by sites with dynamic content (infinite scroll, image lazy load and other javascript stuff). The option have impact on the site performance (client side). Recommended values: 250 - 1500 milliseconds. If you don't have dynamic content, set Refresh interval = 0.
62
 
@@ -74,6 +76,12 @@ This option defines (in milliseconds, 1 sec = 1000 ms) how often plugin recalcul
74
 
75
  == Changelog ==
76
 
 
 
 
 
 
 
77
  = 2.3 =
78
  * Now user can disable plugin, when browser window width is less then specified value (check plugin options).
79
 
4
  Tags: sidebar, widget, scroll, fixed, floating, sticky, russian, q2w3
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
+ Stable tag: 3.0
8
 
9
  Fixes positioning of the selected widgets, when the page is scrolled down.
10
 
11
  == Description ==
12
 
13
+ Enable "Fixed widget" option in the widget settings (see [screenshot](http://wordpress.org/extend/plugins/q2w3-fixed-widget/screenshots/))
14
+ and it will be always in sight when page is scrolled down or up.
15
 
16
+ There is no problem to "Fix" or "Stick" more than one widget.
17
+ Version 3.0 brings you a long waited capability to stick widgets located in different sidebars!
 
 
 
 
18
 
19
  [Watch the demo](http://store.places-finder.com/cp-ajax-post-load).
20
  Right sidebar, last three widgets. Scroll down to the bottom.
21
 
22
+ Compatibility note. The plugin is not working with all themes. Theme requirements:
 
 
 
23
 
24
+ * Widgets must have unique id attributes in html code (see [FAQ](http://wordpress.org/extend/plugins/q2w3-fixed-widget/faq/)).
25
+ * jQuery 1.7 required. jQuery 1.8.3 (or later) is recommended.
26
+ * No JavaScript errors, coused by other plugins and scripts.
27
+ * `wp_head()` and `wp_footer()` functions in header.php and footer.php files.
28
 
29
+ In some cases (widget "jumping" during scroll and etc.) theme CSS changes may be required.
 
 
30
 
31
+ Supported languages: English, Russian
32
 
33
  == Installation ==
34
 
47
  2. Javascript errors on page. Commonly caused by buggy plugins. Check javascript console of your browser. If you find errors, try to locate and fix its source.
48
  3. No `wp_head()` and `wp_footer()` functions in template. Check header.php and footer.php files of your active theme.
49
 
50
+ = I have a responsive theme. How can I make the plugin compatible with it? =
51
+
52
+ For responsive compatibility I found only one approach: to disable plugin when mobile device detected or when browser window width is less then specified value.
53
+ There are several options to accomplish this task. The latest (and recommended!) is to enable "Screen Max Width" option.
54
+ For example you have a responsive styles: `@media screen and (max-width: 940px) {...}`. Set "Screen Max Width" = 940 - to disable plugin in responsive mode.
55
+ The other options are: "Disable plugin on mobile devices" and "Disable plugin on tablet devices". From version 3.0 these options are depricated and will be removed in the near future.
56
+
57
  = How to prevent overlapping with the footer? =
58
 
59
  Make sure you have updated plugin to version 2.x. Go to WP admin area, Appearance -> Fixed Widget Options. Here you can define top and bottom margins. Set bottom margin value >= footer height. Check the result.
60
 
61
+ = Refresh Interval option =
62
 
63
  This option defines (in milliseconds, 1 sec = 1000 ms) how often plugin recalculates sticky widgets parameters. Required by sites with dynamic content (infinite scroll, image lazy load and other javascript stuff). The option have impact on the site performance (client side). Recommended values: 250 - 1500 milliseconds. If you don't have dynamic content, set Refresh interval = 0.
64
 
76
 
77
  == Changelog ==
78
 
79
+ = 3.0 =
80
+ * This version brings you a long waited capability to stick widgets located in different sidebars! Enjoy!
81
+ * Fixed conflict with WP Page Widget plugin
82
+ * A few small bugs cleaned
83
+ * Warning! "Disable plugin on mobile devices" and "Disable plugin on tablet devices" options now are depricated and will be removed in the next release. Use "Screen Max Width" option instead!
84
+
85
  = 2.3 =
86
  * Now user can disable plugin, when browser window width is less then specified value (check plugin options).
87