Version Description
- New: Disable lightbox for single images with data-rel="norl" attribute
- Tweak: Keep rel attribute intact if used in post content links
- Tweak: Vimeo regex improvements
Download this release
Release Info
Developer | dfactory |
Plugin | Responsive Lightbox & Gallery |
Version | 1.6.2 |
Comparing to | |
See all releases |
Code changes from version 1.6.1 to 1.6.2
- includes/class-frontend.php +51 -64
- includes/class-settings.php +12 -12
- js/front.js +45 -50
- readme.txt +11 -5
- responsive-lightbox.php +13 -13
includes/class-frontend.php
CHANGED
@@ -18,11 +18,11 @@ class Responsive_Lightbox_Frontend {
|
|
18 |
Responsive_Lightbox()->frontend = $this;
|
19 |
|
20 |
// filters
|
21 |
-
add_filter( 'post_gallery', array(
|
22 |
-
add_filter( '
|
23 |
-
add_filter( '
|
24 |
-
add_filter( 'the_content', array(
|
25 |
-
add_filter( '
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -34,32 +34,32 @@ class Responsive_Lightbox_Frontend {
|
|
34 |
public function add_videos_lightbox_selector( $content ) {
|
35 |
|
36 |
if ( Responsive_Lightbox()->options['settings']['videos'] === true ) {
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
41 |
foreach ( $links[0] as $id => $link ) {
|
42 |
-
if ( preg_match( '/<a.*?(?:
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
} else
|
55 |
-
$content = str_replace( $link, preg_replace( '/(?:rel|data-rel)=(?:\'|")(.*?)(?:\'|")/', 'data-rel="' . ( $result[1] !== '' ? $result[1] . ' ' : '' ) . Responsive_Lightbox()->options['settings']['selector'] . '-video-' . $id . '"', $link ), $content );
|
56 |
-
}
|
57 |
} else {
|
58 |
// swipebox video fix
|
59 |
-
if ( Responsive_Lightbox()->options['settings']['script'] === 'swipebox' && strpos( $links[2][$id], 'vimeo') !== false )
|
60 |
$links[2][$id] = $links[2][$id] . '?width=' . Responsive_Lightbox()->options['configuration']['swipebox']['video_max_width'];
|
61 |
-
|
62 |
-
|
|
|
63 |
}
|
64 |
}
|
65 |
}
|
@@ -76,56 +76,44 @@ class Responsive_Lightbox_Frontend {
|
|
76 |
* @return mixed
|
77 |
*/
|
78 |
public function add_links_lightbox_selector( $content ) {
|
79 |
-
|
80 |
if ( Responsive_Lightbox()->options['settings']['image_links'] === true || Responsive_Lightbox()->options['settings']['images_as_gallery'] === true ) {
|
81 |
-
|
|
|
82 |
preg_match_all( '/<a(.*?)href=(?:\'|")([^<]*?).(bmp|gif|jpeg|jpg|png)(?:\'|")(.*?)>/i', $content, $links );
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
// generate hash for single images gallery
|
87 |
if ( Responsive_Lightbox()->options['settings']['images_as_gallery'] === true )
|
88 |
$rel_hash = '-gallery-' . $this->generate_password( 4 );
|
89 |
-
|
90 |
foreach ( $links[0] as $id => $link ) {
|
91 |
-
|
92 |
// single image title
|
93 |
$title = '';
|
94 |
-
|
95 |
-
if ( ( $title_arg = Responsive_Lightbox()->options['settings']['image_title'] ) !== 'default' ) {
|
96 |
|
|
|
97 |
$image_id = (int) $this->get_attachment_id_by_url( $links[2][$id] . '.' . $links[3][$id] );
|
98 |
|
99 |
-
if ( $image_id )
|
100 |
-
$
|
101 |
-
$title = wp_strip_all_tags( trim( $this->get_attachment_title( $image_id, $title_arg ) ) );
|
102 |
-
}
|
103 |
}
|
104 |
|
105 |
-
// link contains
|
106 |
-
if ( preg_match( '/<a.*?(?:
|
|
|
|
|
|
|
|
|
107 |
|
108 |
// single images gallery
|
109 |
-
if ( Responsive_Lightbox()->options['settings']['images_as_gallery'] === true )
|
110 |
-
$content = str_replace( $link, preg_replace( '/(?:
|
111 |
// single image
|
112 |
-
|
113 |
-
|
114 |
-
$new_rels = array();
|
115 |
-
$rels = explode( ' ', $result[1] );
|
116 |
-
|
117 |
-
if ( in_array( Responsive_Lightbox()->options['settings']['selector'], $rels, true ) ) {
|
118 |
-
foreach ( $rels as $no => $rel ) {
|
119 |
-
if ( $rel !== Responsive_Lightbox()->options['settings']['selector'] )
|
120 |
-
$new_rels[] = $rel;
|
121 |
-
}
|
122 |
-
|
123 |
-
$content = str_replace( $link, preg_replace( '/(?:rel|data-rel)=(?:\'|")(.*?)(?:\'|")/', 'data-rel="' . ( ! empty( $new_rels ) ? implode( ' ', $new_rels ) . ' ' : '' ) . Responsive_Lightbox()->options['settings']['selector'] . '-' . $id . '"' . ( Responsive_Lightbox()->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ' title="' . $title . '"', $link ), $content );
|
124 |
-
} else
|
125 |
-
$content = str_replace( $link, preg_replace( '/(?:rel|data-rel)=(?:\'|")(.*?)(?:\'|")/', 'data-rel="' . ( $result[1] !== '' ? $result[1] . ' ' : '' ) . Responsive_Lightbox()->options['settings']['selector'] . '-' . $id . '"' . ( Responsive_Lightbox()->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ' title="' . $title . '"', $link ), $content );
|
126 |
-
}
|
127 |
}
|
128 |
-
// link without
|
129 |
} else {
|
130 |
$content = str_replace( $link, '<a' . $links[1][$id] . 'href="' . $links[2][$id] . '.' . $links[3][$id] . '"' . $links[4][$id] . ' data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . ( Responsive_Lightbox()->options['settings']['images_as_gallery'] === true ? $rel_hash : '-' . $id ) . '"' . ( Responsive_Lightbox()->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ' title="' . $title . '">', $content );
|
131 |
}
|
@@ -154,11 +142,10 @@ class Responsive_Lightbox_Frontend {
|
|
154 |
$title_arg = apply_filters( 'rl_lightbox_attachment_image_title_arg', $title_arg, $link, $id );
|
155 |
$title = wp_strip_all_tags( trim( $this->get_attachment_title( $id, $title_arg ) ) );
|
156 |
}
|
157 |
-
|
158 |
-
if ( $title )
|
159 |
$link = str_replace( '<a href', '<a title="'. $title .'" href', $link );
|
160 |
-
|
161 |
-
|
162 |
$link = ( preg_match( '/<a.*? (?:rel|data-rel)=("|\').*?("|\')>/', $link ) === 1 ? preg_replace( '/(<a.*? data-rel=(?:"|\').*?)((?:"|\').*?>)/', '$1 ' . Responsive_Lightbox()->options['settings']['selector'] . '-gallery-' . $this->gallery_no . '$2', $link ) : preg_replace( '/(<a.*?)>/', '$1 data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . '-gallery-' . $this->gallery_no . '">', $link ) );
|
163 |
|
164 |
// gallery image size
|
18 |
Responsive_Lightbox()->frontend = $this;
|
19 |
|
20 |
// filters
|
21 |
+
add_filter( 'post_gallery', array( $this, 'gallery_attributes' ), 1000, 10, 2 );
|
22 |
+
add_filter( 'post_gallery', array( $this, 'add_custom_gallery_lightbox_selector' ), 2000, 10, 2 );
|
23 |
+
add_filter( 'wp_get_attachment_link', array( $this, 'add_gallery_lightbox_selector' ), 1000, 6 );
|
24 |
+
add_filter( 'the_content', array( $this, 'add_videos_lightbox_selector' ) );
|
25 |
+
add_filter( 'the_content', array( $this, 'add_links_lightbox_selector' ) );
|
26 |
}
|
27 |
|
28 |
/**
|
34 |
public function add_videos_lightbox_selector( $content ) {
|
35 |
|
36 |
if ( Responsive_Lightbox()->options['settings']['videos'] === true ) {
|
37 |
+
|
38 |
+
// search for image-links
|
39 |
+
preg_match_all( '/<a(.*?)href=(?:\'|")((?:http|https|)(?::\/\/|)(?:www.|)(?:(?:(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))(?:[\w\-]{11})[a-z0-9;:@#?&%=+\/\$_.-]*)|(?:vimeo\.com\/[0-9]+)))(?:\'|")(.*?)>/i', $content, $links );
|
40 |
+
|
41 |
+
// found?
|
42 |
+
if ( ! empty ( $links[0] ) ) {
|
43 |
foreach ( $links[0] as $id => $link ) {
|
44 |
+
if ( preg_match( '/<a.*?(?:data-rel)=(?:\'|")(.*?)(?:\'|").*?>/', $link, $result ) === 1 ) {
|
45 |
+
|
46 |
+
// do not modify this link
|
47 |
+
if ( $result[1] === 'norl' )
|
48 |
+
continue;
|
49 |
+
|
50 |
+
// swipebox video fix
|
51 |
+
if ( Responsive_Lightbox()->options['settings']['script'] === 'swipebox' && strpos( $links[2][$id], 'vimeo.com') !== false )
|
52 |
+
$content = str_replace( $link, str_replace( $links[2][$id], $links[2][$id] . '?width=' . Responsive_Lightbox()->options['configuration']['swipebox']['video_max_width'], $link ), $content );
|
53 |
+
|
54 |
+
// replace data-rel
|
55 |
+
$content = str_replace( $link, preg_replace( '/(?:data-rel)=(?:\'|")(.*?)(?:\'|")/', 'data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . '-video-' . $id . '"', $link ), $content );
|
|
|
|
|
|
|
56 |
} else {
|
57 |
// swipebox video fix
|
58 |
+
if ( Responsive_Lightbox()->options['settings']['script'] === 'swipebox' && strpos( $links[2][$id], 'vimeo.com') !== false )
|
59 |
$links[2][$id] = $links[2][$id] . '?width=' . Responsive_Lightbox()->options['configuration']['swipebox']['video_max_width'];
|
60 |
+
|
61 |
+
// replace data-rel
|
62 |
+
$content = str_replace( $link, '<a' . $links[1][$id] . 'href="' . $links[2][$id] . '" data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . '-video-' . $id . '"' . $links[3][$id] . '>', $content );
|
63 |
}
|
64 |
}
|
65 |
}
|
76 |
* @return mixed
|
77 |
*/
|
78 |
public function add_links_lightbox_selector( $content ) {
|
|
|
79 |
if ( Responsive_Lightbox()->options['settings']['image_links'] === true || Responsive_Lightbox()->options['settings']['images_as_gallery'] === true ) {
|
80 |
+
|
81 |
+
// search for image-links
|
82 |
preg_match_all( '/<a(.*?)href=(?:\'|")([^<]*?).(bmp|gif|jpeg|jpg|png)(?:\'|")(.*?)>/i', $content, $links );
|
83 |
+
|
84 |
+
// found?
|
85 |
+
if ( ! empty ( $links[0] ) ) {
|
86 |
// generate hash for single images gallery
|
87 |
if ( Responsive_Lightbox()->options['settings']['images_as_gallery'] === true )
|
88 |
$rel_hash = '-gallery-' . $this->generate_password( 4 );
|
89 |
+
|
90 |
foreach ( $links[0] as $id => $link ) {
|
91 |
+
|
92 |
// single image title
|
93 |
$title = '';
|
|
|
|
|
94 |
|
95 |
+
if ( ( $title_arg = Responsive_Lightbox()->options['settings']['image_title'] ) !== 'default' ) {
|
96 |
$image_id = (int) $this->get_attachment_id_by_url( $links[2][$id] . '.' . $links[3][$id] );
|
97 |
|
98 |
+
if ( $image_id )
|
99 |
+
$title = wp_strip_all_tags( trim( $this->get_attachment_title( $image_id, apply_filters( 'rl_lightbox_attachment_image_title_arg', $title_arg, $image_id, $links[2][$id] . '.' . $links[3][$id] ) ) ) );
|
|
|
|
|
100 |
}
|
101 |
|
102 |
+
// link contains data-rel attribute
|
103 |
+
if ( preg_match( '/<a.*?(?:data-rel)=(?:\'|")(.*?)(?:\'|").*?>/', $link, $result ) === 1 ) {
|
104 |
+
|
105 |
+
// do not modify this link
|
106 |
+
if ( $result[1] === 'norl' )
|
107 |
+
continue;
|
108 |
|
109 |
// single images gallery
|
110 |
+
if ( Responsive_Lightbox()->options['settings']['images_as_gallery'] === true )
|
111 |
+
$content = str_replace( $link, preg_replace( '/(?:data-rel)=(?:\'|")(?:.*?)(?:\'|")/', 'data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . $rel_hash . '"' . ( Responsive_Lightbox()->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ' title="' . $title . '"', $link ), $content );
|
112 |
// single image
|
113 |
+
else {
|
114 |
+
$content = str_replace( $link, preg_replace( '/(?:data-rel)=(?:\'|")(?:.*?)(?:\'|")/', 'data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . '-' . $id . '"' . ( Responsive_Lightbox()->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ' title="' . $title . '"', $link ), $content );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
+
// link without data-rel
|
117 |
} else {
|
118 |
$content = str_replace( $link, '<a' . $links[1][$id] . 'href="' . $links[2][$id] . '.' . $links[3][$id] . '"' . $links[4][$id] . ' data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . ( Responsive_Lightbox()->options['settings']['images_as_gallery'] === true ? $rel_hash : '-' . $id ) . '"' . ( Responsive_Lightbox()->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ' title="' . $title . '">', $content );
|
119 |
}
|
142 |
$title_arg = apply_filters( 'rl_lightbox_attachment_image_title_arg', $title_arg, $link, $id );
|
143 |
$title = wp_strip_all_tags( trim( $this->get_attachment_title( $id, $title_arg ) ) );
|
144 |
}
|
145 |
+
|
146 |
+
if ( $title )
|
147 |
$link = str_replace( '<a href', '<a title="'. $title .'" href', $link );
|
148 |
+
|
|
|
149 |
$link = ( preg_match( '/<a.*? (?:rel|data-rel)=("|\').*?("|\')>/', $link ) === 1 ? preg_replace( '/(<a.*? data-rel=(?:"|\').*?)((?:"|\').*?>)/', '$1 ' . Responsive_Lightbox()->options['settings']['selector'] . '-gallery-' . $this->gallery_no . '$2', $link ) : preg_replace( '/(<a.*?)>/', '$1 data-rel="' . Responsive_Lightbox()->options['settings']['selector'] . '-gallery-' . $this->gallery_no . '">', $link ) );
|
150 |
|
151 |
// gallery image size
|
includes/class-settings.php
CHANGED
@@ -24,9 +24,9 @@ class Responsive_Lightbox_Settings {
|
|
24 |
Responsive_Lightbox()->settings = $this;
|
25 |
|
26 |
// actions
|
27 |
-
add_action( 'admin_init', array(
|
28 |
-
add_action( 'admin_menu', array(
|
29 |
-
add_action( 'after_setup_theme', array(
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -139,7 +139,7 @@ class Responsive_Lightbox_Settings {
|
|
139 |
'settings' => array(
|
140 |
'option_group' => 'responsive_lightbox_settings',
|
141 |
'option_name' => 'responsive_lightbox_settings',
|
142 |
-
// 'callback' => array(
|
143 |
'sections' => array(
|
144 |
'responsive_lightbox_settings' => array(
|
145 |
'title' => __( 'General settings', 'responsive-lightbox' ),
|
@@ -259,7 +259,7 @@ class Responsive_Lightbox_Settings {
|
|
259 |
'configuration' => array(
|
260 |
'option_group' => 'responsive_lightbox_configuration',
|
261 |
'option_name' => 'responsive_lightbox_configuration',
|
262 |
-
// 'callback' => array(
|
263 |
'sections' => array(
|
264 |
'responsive_lightbox_configuration' => array(
|
265 |
'title' => __( 'Lightbox settings', 'responsive-lightbox' ) . ': ' . $this->scripts[Responsive_Lightbox()->options['settings']['script']]['name'],
|
@@ -893,7 +893,7 @@ class Responsive_Lightbox_Settings {
|
|
893 |
$this->tabs['addons'] = array(
|
894 |
'name' => __( 'Add-ons', 'responsive-lightbox' ),
|
895 |
'key' => 'responsive_lightbox_configuration',
|
896 |
-
'callback' => array(
|
897 |
);
|
898 |
|
899 |
}
|
@@ -905,7 +905,7 @@ class Responsive_Lightbox_Settings {
|
|
905 |
*/
|
906 |
public function admin_menu_options() {
|
907 |
add_options_page(
|
908 |
-
__( 'Responsive Lightbox', 'responsive-lightbox' ), __( 'Responsive Lightbox', 'responsive-lightbox' ), 'manage_options', 'responsive-lightbox', array(
|
909 |
);
|
910 |
}
|
911 |
|
@@ -1002,7 +1002,7 @@ class Responsive_Lightbox_Settings {
|
|
1002 |
register_setting(
|
1003 |
esc_attr( $setting_id ),
|
1004 |
! empty( $setting['option_name'] ) ? esc_attr( $setting['option_name'] ) : $setting_id,
|
1005 |
-
! empty( $setting['callback'] ) ? $setting['callback'] : array(
|
1006 |
);
|
1007 |
|
1008 |
// register sections
|
@@ -1065,7 +1065,7 @@ class Responsive_Lightbox_Settings {
|
|
1065 |
add_settings_field(
|
1066 |
esc_attr( $field_id ),
|
1067 |
! empty( $field['title'] ) ? esc_html( $field['title'] ) : '',
|
1068 |
-
array(
|
1069 |
! empty( $field['page'] ) ? esc_attr( $field['page'] ) : $setting_id,
|
1070 |
! empty( $field['section'] ) ? esc_attr( $field['section'] ) : '',
|
1071 |
$args
|
@@ -1085,13 +1085,13 @@ class Responsive_Lightbox_Settings {
|
|
1085 |
register_setting(
|
1086 |
'responsive_lightbox_licenses',
|
1087 |
'responsive_lightbox_licenses',
|
1088 |
-
array(
|
1089 |
);
|
1090 |
|
1091 |
add_settings_section(
|
1092 |
'responsive_lightbox_licenses',
|
1093 |
__( 'Licenses', 'responsive-lightbox' ),
|
1094 |
-
array(
|
1095 |
'responsive_lightbox_licenses'
|
1096 |
);
|
1097 |
|
@@ -1099,7 +1099,7 @@ class Responsive_Lightbox_Settings {
|
|
1099 |
add_settings_field(
|
1100 |
esc_attr( $id ),
|
1101 |
$extension['name'],
|
1102 |
-
array(
|
1103 |
'responsive_lightbox_licenses',
|
1104 |
'responsive_lightbox_licenses',
|
1105 |
$extension
|
24 |
Responsive_Lightbox()->settings = $this;
|
25 |
|
26 |
// actions
|
27 |
+
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
28 |
+
add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
|
29 |
+
add_action( 'after_setup_theme', array( $this, 'load_defaults' ) );
|
30 |
}
|
31 |
|
32 |
/**
|
139 |
'settings' => array(
|
140 |
'option_group' => 'responsive_lightbox_settings',
|
141 |
'option_name' => 'responsive_lightbox_settings',
|
142 |
+
// 'callback' => array( $this, 'validate_options' ),
|
143 |
'sections' => array(
|
144 |
'responsive_lightbox_settings' => array(
|
145 |
'title' => __( 'General settings', 'responsive-lightbox' ),
|
259 |
'configuration' => array(
|
260 |
'option_group' => 'responsive_lightbox_configuration',
|
261 |
'option_name' => 'responsive_lightbox_configuration',
|
262 |
+
// 'callback' => array( $this, 'validate_options' ),
|
263 |
'sections' => array(
|
264 |
'responsive_lightbox_configuration' => array(
|
265 |
'title' => __( 'Lightbox settings', 'responsive-lightbox' ) . ': ' . $this->scripts[Responsive_Lightbox()->options['settings']['script']]['name'],
|
893 |
$this->tabs['addons'] = array(
|
894 |
'name' => __( 'Add-ons', 'responsive-lightbox' ),
|
895 |
'key' => 'responsive_lightbox_configuration',
|
896 |
+
'callback' => array( $this, 'addons_tab_cb' )
|
897 |
);
|
898 |
|
899 |
}
|
905 |
*/
|
906 |
public function admin_menu_options() {
|
907 |
add_options_page(
|
908 |
+
__( 'Responsive Lightbox', 'responsive-lightbox' ), __( 'Responsive Lightbox', 'responsive-lightbox' ), 'manage_options', 'responsive-lightbox', array( $this, 'options_page' )
|
909 |
);
|
910 |
}
|
911 |
|
1002 |
register_setting(
|
1003 |
esc_attr( $setting_id ),
|
1004 |
! empty( $setting['option_name'] ) ? esc_attr( $setting['option_name'] ) : $setting_id,
|
1005 |
+
! empty( $setting['callback'] ) ? $setting['callback'] : array( $this, 'validate_settings' )
|
1006 |
);
|
1007 |
|
1008 |
// register sections
|
1065 |
add_settings_field(
|
1066 |
esc_attr( $field_id ),
|
1067 |
! empty( $field['title'] ) ? esc_html( $field['title'] ) : '',
|
1068 |
+
array( $this, 'render_field' ),
|
1069 |
! empty( $field['page'] ) ? esc_attr( $field['page'] ) : $setting_id,
|
1070 |
! empty( $field['section'] ) ? esc_attr( $field['section'] ) : '',
|
1071 |
$args
|
1085 |
register_setting(
|
1086 |
'responsive_lightbox_licenses',
|
1087 |
'responsive_lightbox_licenses',
|
1088 |
+
array( $this, 'validate_licenses' )
|
1089 |
);
|
1090 |
|
1091 |
add_settings_section(
|
1092 |
'responsive_lightbox_licenses',
|
1093 |
__( 'Licenses', 'responsive-lightbox' ),
|
1094 |
+
array( $this, 'licenses_section_cb' ),
|
1095 |
'responsive_lightbox_licenses'
|
1096 |
);
|
1097 |
|
1099 |
add_settings_field(
|
1100 |
esc_attr( $id ),
|
1101 |
$extension['name'],
|
1102 |
+
array( $this, 'license_field_cb' ),
|
1103 |
'responsive_lightbox_licenses',
|
1104 |
'responsive_lightbox_licenses',
|
1105 |
$extension
|
js/front.js
CHANGED
@@ -9,24 +9,24 @@
|
|
9 |
selector : rlArgs.selector,
|
10 |
args : rlArgs
|
11 |
} );
|
12 |
-
|
13 |
} );
|
14 |
-
|
15 |
// this is similar to the WP function add_action();
|
16 |
$( document ).on( 'doResponsiveLightbox', function( event ) {
|
17 |
|
18 |
var script = event.script,
|
19 |
selector = event.selector
|
20 |
args = event.args;
|
21 |
-
|
22 |
if ( script === undefined || selector === undefined ) {
|
23 |
return false;
|
24 |
}
|
25 |
-
|
26 |
switch( script ) {
|
27 |
-
|
28 |
case 'swipebox':
|
29 |
-
|
30 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).swipebox( {
|
31 |
useCSS : ( rlArgs.animation === '1' ? true : false ),
|
32 |
useSVG : ( rlArgs.useSVG === '1' ? true : false ),
|
@@ -36,11 +36,11 @@
|
|
36 |
videoMaxWidth : parseInt( rlArgs.videoMaxWidth ),
|
37 |
loopAtEnd : ( rlArgs.loopAtEnd === '1' ? true : false )
|
38 |
} );
|
39 |
-
|
40 |
break;
|
41 |
-
|
42 |
case 'prettyphoto':
|
43 |
-
|
44 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).prettyPhoto( {
|
45 |
hook : 'data-rel',
|
46 |
animation_speed : rlArgs.animationSpeed,
|
@@ -69,11 +69,11 @@
|
|
69 |
},
|
70 |
ie6_fallback : true
|
71 |
} );
|
72 |
-
|
73 |
break;
|
74 |
-
|
75 |
case 'fancybox':
|
76 |
-
|
77 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).fancybox( {
|
78 |
modal : ( rlArgs.modal === '1' ? true : false ),
|
79 |
overlayShow : ( rlArgs.showOverlay === '1' ? true : false ),
|
@@ -104,30 +104,30 @@
|
|
104 |
width : parseInt( rlArgs.videoWidth ),
|
105 |
height : parseInt( rlArgs.videoHeight )
|
106 |
} );
|
107 |
-
|
108 |
break;
|
109 |
-
|
110 |
case 'nivo':
|
111 |
-
|
112 |
$.each( $( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ), function () {
|
113 |
-
|
114 |
var attr = $( this ).attr( 'data-rel' );
|
115 |
-
|
116 |
-
if ( typeof attr ==
|
117 |
// backward rel compatibility
|
118 |
-
|
119 |
}
|
120 |
-
|
121 |
// for some browsers, `attr` is undefined; for others,
|
122 |
// `attr` is false. Check for both.
|
123 |
-
if ( typeof attr !==
|
124 |
var match = attr.match( new RegExp( rlArgs.selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) );
|
125 |
-
|
126 |
if ( match !== null ) {
|
127 |
$( this ).attr( 'data-lightbox-gallery', match[0] );
|
128 |
}
|
129 |
}
|
130 |
-
|
131 |
} );
|
132 |
|
133 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).nivoLightbox( {
|
@@ -136,32 +136,32 @@
|
|
136 |
keyboardNav : ( rlArgs.keyboardNav === '1' ? true : false ),
|
137 |
errorMessage : rlArgs.errorMessage
|
138 |
} );
|
139 |
-
|
140 |
break;
|
141 |
-
|
142 |
case 'imagelightbox':
|
143 |
-
|
144 |
var selectors = [];
|
145 |
-
|
146 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).each( function ( i, item ) {
|
147 |
var attr = $( item ).attr( 'data-rel' );
|
148 |
-
|
149 |
-
if ( typeof attr !==
|
150 |
selectors.push( attr );
|
151 |
}
|
152 |
-
|
153 |
// backward rel compatibility
|
154 |
var attr = $( item ).attr( 'rel' );
|
155 |
-
|
156 |
-
if ( typeof attr !==
|
157 |
selectors.push( attr );
|
158 |
}
|
159 |
} );
|
160 |
-
|
161 |
if ( selectors.length > 0 ) {
|
162 |
// make unique
|
163 |
selectors = $.unique( selectors );
|
164 |
-
|
165 |
$( selectors ).each( function ( i, item ) {
|
166 |
$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).imageLightbox( {
|
167 |
animationSpeed : parseInt( rlArgs.animationSpeed ),
|
@@ -173,28 +173,28 @@
|
|
173 |
} );
|
174 |
} );
|
175 |
}
|
176 |
-
|
177 |
break;
|
178 |
-
|
179 |
case 'tosrus':
|
180 |
-
|
181 |
var selectors = [];
|
182 |
-
|
183 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).each( function ( i, item ) {
|
184 |
var attr = $( item ).attr( 'data-rel' );
|
185 |
-
|
186 |
-
if ( typeof attr !==
|
187 |
selectors.push( attr );
|
188 |
}
|
189 |
-
|
190 |
// backward rel compatibility
|
191 |
var attr = $( item ).attr( 'rel' );
|
192 |
-
|
193 |
-
if ( typeof attr !==
|
194 |
selectors.push( attr );
|
195 |
}
|
196 |
} );
|
197 |
-
|
198 |
if ( selectors.length > 0 ) {
|
199 |
// make unique
|
200 |
selectors = $.unique( selectors );
|
@@ -228,13 +228,8 @@
|
|
228 |
} );
|
229 |
} );
|
230 |
}
|
231 |
-
|
232 |
break;
|
233 |
-
|
234 |
-
default :
|
235 |
-
|
236 |
-
break;
|
237 |
-
|
238 |
}
|
239 |
|
240 |
} );
|
9 |
selector : rlArgs.selector,
|
10 |
args : rlArgs
|
11 |
} );
|
12 |
+
|
13 |
} );
|
14 |
+
|
15 |
// this is similar to the WP function add_action();
|
16 |
$( document ).on( 'doResponsiveLightbox', function( event ) {
|
17 |
|
18 |
var script = event.script,
|
19 |
selector = event.selector
|
20 |
args = event.args;
|
21 |
+
|
22 |
if ( script === undefined || selector === undefined ) {
|
23 |
return false;
|
24 |
}
|
25 |
+
|
26 |
switch( script ) {
|
27 |
+
|
28 |
case 'swipebox':
|
29 |
+
|
30 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).swipebox( {
|
31 |
useCSS : ( rlArgs.animation === '1' ? true : false ),
|
32 |
useSVG : ( rlArgs.useSVG === '1' ? true : false ),
|
36 |
videoMaxWidth : parseInt( rlArgs.videoMaxWidth ),
|
37 |
loopAtEnd : ( rlArgs.loopAtEnd === '1' ? true : false )
|
38 |
} );
|
39 |
+
|
40 |
break;
|
41 |
+
|
42 |
case 'prettyphoto':
|
43 |
+
|
44 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).prettyPhoto( {
|
45 |
hook : 'data-rel',
|
46 |
animation_speed : rlArgs.animationSpeed,
|
69 |
},
|
70 |
ie6_fallback : true
|
71 |
} );
|
72 |
+
|
73 |
break;
|
74 |
+
|
75 |
case 'fancybox':
|
76 |
+
|
77 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).fancybox( {
|
78 |
modal : ( rlArgs.modal === '1' ? true : false ),
|
79 |
overlayShow : ( rlArgs.showOverlay === '1' ? true : false ),
|
104 |
width : parseInt( rlArgs.videoWidth ),
|
105 |
height : parseInt( rlArgs.videoHeight )
|
106 |
} );
|
107 |
+
|
108 |
break;
|
109 |
+
|
110 |
case 'nivo':
|
111 |
+
|
112 |
$.each( $( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ), function () {
|
113 |
+
|
114 |
var attr = $( this ).attr( 'data-rel' );
|
115 |
+
|
116 |
+
if ( typeof attr == undefined || attr == false ) {
|
117 |
// backward rel compatibility
|
118 |
+
attr = $( this ).attr( 'rel' );
|
119 |
}
|
120 |
+
|
121 |
// for some browsers, `attr` is undefined; for others,
|
122 |
// `attr` is false. Check for both.
|
123 |
+
if ( typeof attr !== undefined && attr !== false ) {
|
124 |
var match = attr.match( new RegExp( rlArgs.selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) );
|
125 |
+
|
126 |
if ( match !== null ) {
|
127 |
$( this ).attr( 'data-lightbox-gallery', match[0] );
|
128 |
}
|
129 |
}
|
130 |
+
|
131 |
} );
|
132 |
|
133 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).nivoLightbox( {
|
136 |
keyboardNav : ( rlArgs.keyboardNav === '1' ? true : false ),
|
137 |
errorMessage : rlArgs.errorMessage
|
138 |
} );
|
139 |
+
|
140 |
break;
|
141 |
+
|
142 |
case 'imagelightbox':
|
143 |
+
|
144 |
var selectors = [];
|
145 |
+
|
146 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).each( function ( i, item ) {
|
147 |
var attr = $( item ).attr( 'data-rel' );
|
148 |
+
|
149 |
+
if ( typeof attr !== undefined && attr !== false ) {
|
150 |
selectors.push( attr );
|
151 |
}
|
152 |
+
|
153 |
// backward rel compatibility
|
154 |
var attr = $( item ).attr( 'rel' );
|
155 |
+
|
156 |
+
if ( typeof attr !== undefined && attr !== false ) {
|
157 |
selectors.push( attr );
|
158 |
}
|
159 |
} );
|
160 |
+
|
161 |
if ( selectors.length > 0 ) {
|
162 |
// make unique
|
163 |
selectors = $.unique( selectors );
|
164 |
+
|
165 |
$( selectors ).each( function ( i, item ) {
|
166 |
$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).imageLightbox( {
|
167 |
animationSpeed : parseInt( rlArgs.animationSpeed ),
|
173 |
} );
|
174 |
} );
|
175 |
}
|
176 |
+
|
177 |
break;
|
178 |
+
|
179 |
case 'tosrus':
|
180 |
+
|
181 |
var selectors = [];
|
182 |
+
|
183 |
$( 'a[rel*="' + rlArgs.selector + '"], a[data-rel*="' + rlArgs.selector + '"]' ).each( function ( i, item ) {
|
184 |
var attr = $( item ).attr( 'data-rel' );
|
185 |
+
|
186 |
+
if ( typeof attr !== undefined && attr !== false ) {
|
187 |
selectors.push( attr );
|
188 |
}
|
189 |
+
|
190 |
// backward rel compatibility
|
191 |
var attr = $( item ).attr( 'rel' );
|
192 |
+
|
193 |
+
if ( typeof attr !== undefined && attr !== false ) {
|
194 |
selectors.push( attr );
|
195 |
}
|
196 |
} );
|
197 |
+
|
198 |
if ( selectors.length > 0 ) {
|
199 |
// make unique
|
200 |
selectors = $.unique( selectors );
|
228 |
} );
|
229 |
} );
|
230 |
}
|
231 |
+
|
232 |
break;
|
|
|
|
|
|
|
|
|
|
|
233 |
}
|
234 |
|
235 |
} );
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: dfactory
|
|
3 |
Donate link: http://www.dfactory.eu/
|
4 |
Tags: gallery, images, lightbox, links, photos, template, theme, photo, image, picture, slideshow, modal, overlay, YouTube, Vimeo, video, videos
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.3
|
7 |
-
Stable tag: 1.6.
|
8 |
License: MIT License
|
9 |
License URI: http://opensource.org/licenses/MIT
|
10 |
|
@@ -74,6 +74,11 @@ No questions yet.
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
|
|
|
|
|
|
|
|
|
|
77 |
= 1.6.1 =
|
78 |
* Fix: prettyPhoto and Nivo gallery navigation broken
|
79 |
* Tweak: Added another way to close the extensions notification
|
@@ -254,6 +259,7 @@ Initial release
|
|
254 |
|
255 |
== Upgrade Notice ==
|
256 |
|
257 |
-
= 1.6.
|
258 |
-
*
|
259 |
-
* Tweak:
|
|
3 |
Donate link: http://www.dfactory.eu/
|
4 |
Tags: gallery, images, lightbox, links, photos, template, theme, photo, image, picture, slideshow, modal, overlay, YouTube, Vimeo, video, videos
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.3.1
|
7 |
+
Stable tag: 1.6.2
|
8 |
License: MIT License
|
9 |
License URI: http://opensource.org/licenses/MIT
|
10 |
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 1.6.2 =
|
78 |
+
* New: Disable lightbox for single images with data-rel="norl" attribute
|
79 |
+
* Tweak: Keep rel attribute intact if used in post content links
|
80 |
+
* Tweak: Vimeo regex improvements
|
81 |
+
|
82 |
= 1.6.1 =
|
83 |
* Fix: prettyPhoto and Nivo gallery navigation broken
|
84 |
* Tweak: Added another way to close the extensions notification
|
259 |
|
260 |
== Upgrade Notice ==
|
261 |
|
262 |
+
= 1.6.2 =
|
263 |
+
* New: Disable lightbox for single images with data-rel="norl" attribute
|
264 |
+
* Tweak: Keep rel attribute intact is used in post content links
|
265 |
+
* Tweak: Vimeo regex improvements
|
responsive-lightbox.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Responsive Lightbox
|
4 |
Description: Responsive Lightbox allows users to view larger versions of images and galleries in a lightbox (overlay) effect optimized for mobile devices.
|
5 |
-
Version: 1.6.
|
6 |
Author: dFactory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
|
@@ -36,7 +36,7 @@ include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes/class-settings.php' );
|
|
36 |
* Responsive Lightbox class.
|
37 |
*
|
38 |
* @class Responsive_Lightbox
|
39 |
-
* @version 1.6.
|
40 |
*/
|
41 |
class Responsive_Lightbox {
|
42 |
|
@@ -146,7 +146,7 @@ class Responsive_Lightbox {
|
|
146 |
'pagination_type' => 'thumbnails'
|
147 |
)
|
148 |
),
|
149 |
-
'version' => '1.6.
|
150 |
);
|
151 |
public $options = array();
|
152 |
private $notices = array();
|
@@ -166,8 +166,8 @@ class Responsive_Lightbox {
|
|
166 |
}
|
167 |
|
168 |
public function __construct() {
|
169 |
-
register_activation_hook( __FILE__, array(
|
170 |
-
register_deactivation_hook( __FILE__, array(
|
171 |
|
172 |
// change from older versions
|
173 |
$db_version = get_option( 'responsive_lightbox_version' );
|
@@ -197,14 +197,14 @@ class Responsive_Lightbox {
|
|
197 |
}
|
198 |
|
199 |
// actions
|
200 |
-
add_action( 'plugins_loaded', array(
|
201 |
-
add_action( 'wp_enqueue_scripts', array(
|
202 |
-
add_action( 'admin_enqueue_scripts', array(
|
203 |
-
add_action( 'admin_init', array(
|
204 |
-
add_action( 'admin_print_scripts', array(
|
205 |
|
206 |
// filters
|
207 |
-
add_filter( 'plugin_action_links', array(
|
208 |
}
|
209 |
|
210 |
/**
|
@@ -330,10 +330,10 @@ class Responsive_Lightbox {
|
|
330 |
'paragraph' => $paragraph
|
331 |
);
|
332 |
|
333 |
-
add_action( 'admin_notices', array(
|
334 |
|
335 |
if( $network )
|
336 |
-
add_action( 'network_admin_notices', array(
|
337 |
}
|
338 |
|
339 |
/**
|
2 |
/*
|
3 |
Plugin Name: Responsive Lightbox
|
4 |
Description: Responsive Lightbox allows users to view larger versions of images and galleries in a lightbox (overlay) effect optimized for mobile devices.
|
5 |
+
Version: 1.6.2
|
6 |
Author: dFactory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
|
36 |
* Responsive Lightbox class.
|
37 |
*
|
38 |
* @class Responsive_Lightbox
|
39 |
+
* @version 1.6.2
|
40 |
*/
|
41 |
class Responsive_Lightbox {
|
42 |
|
146 |
'pagination_type' => 'thumbnails'
|
147 |
)
|
148 |
),
|
149 |
+
'version' => '1.6.2'
|
150 |
);
|
151 |
public $options = array();
|
152 |
private $notices = array();
|
166 |
}
|
167 |
|
168 |
public function __construct() {
|
169 |
+
register_activation_hook( __FILE__, array( $this, 'activate_multisite' ) );
|
170 |
+
register_deactivation_hook( __FILE__, array( $this, 'deactivate_multisite' ) );
|
171 |
|
172 |
// change from older versions
|
173 |
$db_version = get_option( 'responsive_lightbox_version' );
|
197 |
}
|
198 |
|
199 |
// actions
|
200 |
+
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
201 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts_styles' ) );
|
202 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_styles' ) );
|
203 |
+
add_action( 'admin_init', array( $this, 'update_notices' ) );
|
204 |
+
add_action( 'admin_print_scripts', array( $this, 'admin_inline_js' ), 999 );
|
205 |
|
206 |
// filters
|
207 |
+
add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
|
208 |
}
|
209 |
|
210 |
/**
|
330 |
'paragraph' => $paragraph
|
331 |
);
|
332 |
|
333 |
+
add_action( 'admin_notices', array( $this, 'display_notice') );
|
334 |
|
335 |
if( $network )
|
336 |
+
add_action( 'network_admin_notices', array( $this, 'display_notice') );
|
337 |
}
|
338 |
|
339 |
/**
|