WP Lightbox 2 - Version 3.0.6.2

Version Description

  • Add checks for images without rel tags and fix all the things.
Download this release

Release Info

Developer dvinson
Plugin Icon 128x128 WP Lightbox 2
Version 3.0.6.2
Comparing to
See all releases

Code changes from version 3.0.6.1 to 3.0.6.2

Files changed (2) hide show
  1. readme.txt +6 -3
  2. wp-lightbox-2.php +22 -4
readme.txt CHANGED
@@ -94,10 +94,13 @@ This plugin was created by <a href="https://syedbalkhi.com" rel="friend" title="
94
  5. [WordPress Lightbox](https://wordpress.org/plugins/wp-lightbox-2) Front-end
95
 
96
  == Changelog ==
97
-
98
- = 3.0.6.1 =
 
 
 
99
  * Prevent double quotes on automatic rel attributes
100
-
101
  = 3.0.6 =
102
  * Fix: WordPress 4.4 compatibility
103
 
94
  5. [WordPress Lightbox](https://wordpress.org/plugins/wp-lightbox-2) Front-end
95
 
96
  == Changelog ==
97
+
98
+ = 3.0.6.2 =
99
+ * Add checks for images without rel tags and fix all the things.
100
+
101
+ = 3.0.6.1 =
102
  * Prevent double quotes on automatic rel attributes
103
+
104
  = 3.0.6 =
105
  * Fix: WordPress 4.4 compatibility
106
 
wp-lightbox-2.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP Lightbox 2
4
  * Plugin URI: http://wpdevart.com/wordpress-lightbox-plugin
5
  * Description: WP Lightbox 2 is awesome tool for adding responsive lightbox (overlay) effect for images and also create lightbox for photo albums/galleries on your WordPress blog. WordPress Lightbox is one of the most useful plugins for your website.
6
- * Version: 3.0.6.1
7
  * Author:Syed Balkhi
8
  * Author URI: http://syedbalkhi.com
9
  * License: GNU General Public License, v2 (or newer)
@@ -153,7 +153,8 @@ function jqlb_autoexpand_rel_wlightbox($content) {
153
  if(get_option('jqlb_automate') == 1){
154
  global $post;
155
  $id = ($post->ID) ? $post->ID : -1;
156
- $content = jqlb_do_regexp($content, $id);
 
157
  }
158
  return $content;
159
  }
@@ -164,10 +165,27 @@ function jqlb_apply_lightbox($content, $id = -1){
164
  return jqlb_do_regexp($content, $id);
165
  }
166
 
167
- /* automatically insert rel="lightbox[nameofpost]" to every image with no manual work.
168
- if there are already rel="lightbox[something]" attributes, they are not clobbered.
169
  Michael Tyson, you are a regular expressions god! - http://atastypixel.com */
170
  function jqlb_do_regexp($content, $id){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  $id = esc_attr($id);
172
  $pattern = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)\?{0,1}\S{0,}['\"][^\>]*)(rel=['\"])(.*?)>/i";
173
  $replacement = '$1 $2lightbox['.$id.'] $3>';
3
  * Plugin Name: WP Lightbox 2
4
  * Plugin URI: http://wpdevart.com/wordpress-lightbox-plugin
5
  * Description: WP Lightbox 2 is awesome tool for adding responsive lightbox (overlay) effect for images and also create lightbox for photo albums/galleries on your WordPress blog. WordPress Lightbox is one of the most useful plugins for your website.
6
+ * Version: 3.0.6.2
7
  * Author:Syed Balkhi
8
  * Author URI: http://syedbalkhi.com
9
  * License: GNU General Public License, v2 (or newer)
153
  if(get_option('jqlb_automate') == 1){
154
  global $post;
155
  $id = ($post->ID) ? $post->ID : -1;
156
+ $content = jqlb_do_regexp($content, $id); //legacy regex function when images don't have rel tags
157
+ $content = wplbtwo_do_regexp($content, $id);
158
  }
159
  return $content;
160
  }
165
  return jqlb_do_regexp($content, $id);
166
  }
167
 
168
+ /* automatically insert rel="lightbox[nameofpost]" to every image with no manual work.
169
+ if there are already rel="lightbox[something]" attributes, they are not clobbered.
170
  Michael Tyson, you are a regular expressions god! - http://atastypixel.com */
171
  function jqlb_do_regexp($content, $id){
172
+ $id = esc_attr($id);
173
+ $pattern = "/(<a(?![^>]*?rel=['\"]lightbox.*)(?![^>]*?rel=.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)\?{0,1}\S{0,}['\"][^\>]*)>/i";
174
+ $replacement = '$1 rel="lightbox['.$id.']">';
175
+ return preg_replace($pattern, $replacement, $content);
176
+ }
177
+
178
+ /**
179
+ * Automatically includes 'lightbox[$id]' into rel tag of images.
180
+ *
181
+ * @param $content
182
+ * @param $id
183
+ *
184
+ * @return mixed
185
+ *
186
+ * @since 3.0.6.2
187
+ */
188
+ function wplbtwo_do_regexp($content, $id){
189
  $id = esc_attr($id);
190
  $pattern = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)\?{0,1}\S{0,}['\"][^\>]*)(rel=['\"])(.*?)>/i";
191
  $replacement = '$1 $2lightbox['.$id.'] $3>';