Q2W3 Fixed Widget - Version 4.0.2

Version Description

  • Optimized code to resolve plugin crash after 4.0.1 update.
Download this release

Release Info

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

Code changes from version 4.0.1 to 4.0.2

js/q2w3-fixed-widget.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function q2w3_sidebar(e){function t(){}function f(t){var n=t.offset_top-t.fixed_margin_top;var s=i-e.margin_bottom;var o=t.obj.css("width");var u=t.obj.css("margin");var a=t.obj.css("padding");var f=false;var l=false;var c=false;jQuery(window).on("scroll."+e.sidebar,function(e){var i=jQuery(this).scrollTop();if(i+t.fixed_margin_bottom>=s){if(!l){t.obj.css("position","fixed");t.obj.css("top","");t.obj.css("width",o);t.obj.css("margin",u);t.obj.css("padding",a);if(jQuery("#"+t.clone_id).length<=0)t.obj.before(t.clone);l=true;f=false;c=false}t.obj.css("bottom",i+r+t.next_widgets_height-s)}else if(i>=n){if(!f){t.obj.css("position","fixed");t.obj.css("top",t.fixed_margin_top);t.obj.css("bottom","");t.obj.css("width",o);t.obj.css("margin",u);t.obj.css("padding",a);if(jQuery("#"+t.clone_id).length<=0)t.obj.before(t.clone);f=true;l=false;c=false}}else{if(!c){t.obj.css("position","");t.obj.css("top","");t.obj.css("width","");t.obj.css("margin","");t.obj.css("padding","");if(jQuery("#"+t.clone_id).length>0)jQuery("#"+t.clone_id).remove();c=true;f=false;l=false}}}).trigger("scroll."+e.sidebar);jQuery(window).on("resize",function(){if(jQuery(window).width()<=e.screen_max_width){jQuery(window).off("load scroll."+e.sidebar);t.obj.css("position","");t.obj.css("top","");t.obj.css("width","");t.obj.css("margin","");t.obj.css("padding","");if(jQuery("#"+t.clone_id).length>0)jQuery("#"+t.clone_id).remove();c=true;f=false;l=false}}).trigger("resize")}if(!e.widgets)return false;if(e.widgets.length<1)return false;if(!e.sidebar)e.sidebar="q2w3-default-sidebar";var n=new Array;var r=jQuery(window).height();var i=jQuery(document).height();var s=e.margin_top;jQuery(".q2w3-widget-clone").remove();for(var o=0;o<e.widgets.length;o++){widget_obj=jQuery("#"+e.widgets[o]);widget_obj.css("position","");if(widget_obj.attr("id")){n[o]=new t;n[o].obj=widget_obj;n[o].clone=widget_obj.clone();n[o].clone.children().remove();n[o].clone_id=widget_obj.attr("id")+"_clone";n[o].clone.addClass("q2w3-widget-clone");n[o].clone.attr("id",n[o].clone_id);n[o].clone.css("height",widget_obj.height());n[o].clone.css("visibility","hidden");n[o].offset_top=widget_obj.offset().top;n[o].fixed_margin_top=s;n[o].height=widget_obj.outerHeight(true);n[o].fixed_margin_bottom=s+n[o].height;s+=n[o].height}else{n[o]=false}}var u=0;var a;for(var o=n.length-1;o>=0;o--){if(n[o]){n[o].next_widgets_height=u;n[o].fixed_margin_bottom+=u;u+=n[o].height;if(!a){a=widget_obj.parent();a.css("height","");a.height(a.height())}}}jQuery(window).off("load scroll."+e.sidebar);for(var o=0;o<n.length;o++){if(n[o])f(n[o])}}
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: 4.0.1
8
  Author URI: http://www.q2w3.ru/
9
  */
10
 
@@ -38,7 +38,7 @@ class q2w3_fixed_widget {
38
 
39
  const ID = 'q2w3_fixed_widget';
40
 
41
- const VERSION = '4.0.1';
42
 
43
  protected static $sidebars_widgets;
44
 
@@ -48,11 +48,13 @@ class q2w3_fixed_widget {
48
 
49
  public static function init() {
50
 
 
 
51
  $options = self::load_options();
52
 
53
  add_filter('widget_display_callback', array( 'q2w3_fixed_widget', 'check' ), $options['widget_display_callback_priority'], 3);
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
 
@@ -312,7 +314,13 @@ class q2w3_fixed_widget {
312
 
313
  if ( strpos($sidebar['before_widget'], 'id="%1$s"') !== false || strpos($sidebar['before_widget'], 'id=\'%1$s\'') !== false ) return;
314
 
315
- if ( strpos($sidebar['before_widget'], 'id=') === false ) {
 
 
 
 
 
 
316
 
317
  $tag_end_pos = strpos($sidebar['before_widget'], '>');
318
 
@@ -330,9 +338,21 @@ class q2w3_fixed_widget {
330
 
331
  foreach ( $str_array as $str_part_id => $str_part ) {
332
 
333
- if ( strpos($str_part, 'id=') !== false ) {
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
- $str_array[$str_part_id] = 'id="%1$s"';
336
 
337
  }
338
 
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: 4.0.2
8
  Author URI: http://www.q2w3.ru/
9
  */
10
 
38
 
39
  const ID = 'q2w3_fixed_widget';
40
 
41
+ const VERSION = '4.0.2';
42
 
43
  protected static $sidebars_widgets;
44
 
48
 
49
  public static function init() {
50
 
51
+ if ( !is_user_logged_in() ) return;
52
+
53
  $options = self::load_options();
54
 
55
  add_filter('widget_display_callback', array( 'q2w3_fixed_widget', 'check' ), $options['widget_display_callback_priority'], 3);
56
 
57
+ wp_enqueue_script('q2w3-fixed-widget', plugin_dir_url( __FILE__ ) . 'js/q2w3-fixed-widget.min.js', array('jquery'), self::VERSION);
58
 
59
  self::check_custom_ids();
60
 
314
 
315
  if ( strpos($sidebar['before_widget'], 'id="%1$s"') !== false || strpos($sidebar['before_widget'], 'id=\'%1$s\'') !== false ) return;
316
 
317
+ if ( $sidebar['before_widget'] == '' || $sidebar['before_widget'] == ' ' ) {
318
+
319
+ $wp_registered_sidebars[$sidebar['id']]['before_widget'] = '<div id="%1$s">';
320
+
321
+ $wp_registered_sidebars[$sidebar['id']]['after_widget'] = '</div>';
322
+
323
+ } elseif ( strpos($sidebar['before_widget'], 'id=') === false ) {
324
 
325
  $tag_end_pos = strpos($sidebar['before_widget'], '>');
326
 
338
 
339
  foreach ( $str_array as $str_part_id => $str_part ) {
340
 
341
+ if ( strpos($str_part, 'id="') !== false ) {
342
+
343
+ $p1 = strpos($str_part, 'id="');
344
+
345
+ $p2 = strpos($str_part, '"', $p1 + 4);
346
+
347
+ $str_array[$str_part_id] = substr_replace($str_part, 'id="%1$s"', $p1, $p2 + 1);
348
+
349
+ } elseif ( strpos($str_part, 'id=\'') !== false ) {
350
+
351
+ $p1 = strpos($str_part, 'id=\'');
352
+
353
+ $p2 = strpos($str_part, "'", $p1 + 4);
354
 
355
+ $str_array[$str_part_id] = substr_replace($str_part, 'id=\'%1$s\'', $p1, $p2);
356
 
357
  }
358
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Max Bond
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q36H2MHNVVP7U
4
  Tags: sidebar, widget, scroll, scrolling, fixed, floating, sticky, russian, q2w3
5
  Requires at least: 3.0
6
- Tested up to: 3.6
7
- Stable tag: 4.0.1
8
 
9
  Fixes positioning of the selected widgets, when the page is scrolled down.
10
 
@@ -84,8 +84,11 @@ Goto [http://www.q2w3.ru/contacts/](http://www.q2w3.ru/contacts/)
84
 
85
  == Changelog ==
86
 
 
 
 
87
  = 4.0.1 =
88
- * Hotfix! Remove problem with duplicated widgets code.
89
 
90
  = 4.0 =
91
  * Resolved [widget jumping](http://wordpress.org/support/topic/widgets-below-fixed-widgets-jump-up)
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q36H2MHNVVP7U
4
  Tags: sidebar, widget, scroll, scrolling, fixed, floating, sticky, russian, q2w3
5
  Requires at least: 3.0
6
+ Tested up to: 3.6.1
7
+ Stable tag: 4.0.2
8
 
9
  Fixes positioning of the selected widgets, when the page is scrolled down.
10
 
84
 
85
  == Changelog ==
86
 
87
+ = 4.0.2 =
88
+ * Optimized code to resolve [plugin crash after 4.0.1 update](http://wordpress.org/support/topic/the-plugin-crash-after-401-update).
89
+
90
  = 4.0.1 =
91
+ * Hotfix! Removes problem with duplicated widget code.
92
 
93
  = 4.0 =
94
  * Resolved [widget jumping](http://wordpress.org/support/topic/widgets-below-fixed-widgets-jump-up)