WP Gallery Custom Links - Version 1.7.0

Version Description

  • By popular demand, added support for the "open_all_in_new_window" and "open_all_in_same_window" gallery shortcode attributes to set all images in a gallery to open in a new/the same window, respectively.
  • By popular demand, made it so "Same Window" will set the target to "_self", thus forcing the same window, instead of doing whatever the theme does by default.
Download this release

Release Info

Developer fourlightsweb
Plugin Icon wp plugin WP Gallery Custom Links
Version 1.7.0
Comparing to
See all releases

Code changes from version 1.6.1 to 1.7.0

readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.fourlightsweb.com/wordpress-plugins/wp-gallery-custom-li
4
  Tags: gallery links, gallery link, gallery
5
  Requires at least: 3.3.2
6
  Tested up to: 3.5.1
7
- Stable tag: 1.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -36,6 +36,7 @@ will be removed to allow them to function as regular links.
36
  * For each gallery image, you can select a Gallery Link Target ("Same Window" or "New Window").
37
  * For each gallery image, you can select how to handle Lightbox and other onClick events ("Remove" or "Keep").
38
  * Use [gallery ignore_gallery_link_urls="true"] to ignore the custom links on an entire gallery.
 
39
  * Use [gallery preserve_click_events="true"] to keep Lightbox or other onClick events on all custom-linked images in an entire gallery.
40
  * Use [gallery remove_links="true"] to remove links on all images in an entire gallery.
41
 
@@ -82,6 +83,12 @@ Check your HTML and CSS for these changes and adjust accordingly.
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
85
  = 1.6.1 =
86
  * Fixed an issue where items with the same custom link were not having lightbox
87
  removed properly
@@ -151,6 +158,12 @@ directly attached to the post.
151
 
152
  == Upgrade Notice ==
153
 
 
 
 
 
 
 
154
  = 1.6.1 =
155
  * Fixed an issue where multiple items with the same custom links were not having lightbox
156
  removed properly
4
  Tags: gallery links, gallery link, gallery
5
  Requires at least: 3.3.2
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
36
  * For each gallery image, you can select a Gallery Link Target ("Same Window" or "New Window").
37
  * For each gallery image, you can select how to handle Lightbox and other onClick events ("Remove" or "Keep").
38
  * Use [gallery ignore_gallery_link_urls="true"] to ignore the custom links on an entire gallery.
39
+ * Use [gallery open_all_in_new_window="true"] and [gallery open_all_in_same_window="true"] to open all images in an entire gallery in a new window/the same window, respectively.
40
  * Use [gallery preserve_click_events="true"] to keep Lightbox or other onClick events on all custom-linked images in an entire gallery.
41
  * Use [gallery remove_links="true"] to remove links on all images in an entire gallery.
42
 
83
 
84
  == Changelog ==
85
 
86
+ = 1.7.0 =
87
+ * By popular demand, added support for the "open_all_in_new_window" and "open_all_in_same_window"
88
+ gallery shortcode attributes to set all images in a gallery to open in a new/the same window, respectively.
89
+ * By popular demand, made it so "Same Window" will set the target to "_self", thus
90
+ forcing the same window, instead of doing whatever the theme does by default.
91
+
92
  = 1.6.1 =
93
  * Fixed an issue where items with the same custom link were not having lightbox
94
  removed properly
158
 
159
  == Upgrade Notice ==
160
 
161
+ = 1.7.0 =
162
+ * By popular demand, added support for the "open_all_in_new_window" and "open_all_in_same_window"
163
+ gallery shortcode attributes to set all images in a gallery to open in a new/the same window, respectively.
164
+ * By popular demand, made it so "Same Window" will set the target to "_self", thus
165
+ forcing the same window, instead of doing whatever the theme does by default.
166
+
167
  = 1.6.1 =
168
  * Fixed an issue where multiple items with the same custom links were not having lightbox
169
  removed properly
wp-gallery-custom-links.js CHANGED
@@ -7,7 +7,7 @@ jQuery(document).ready(function () {
7
  jQuery('a.set-target').click(wp_gallery_custom_links_click);
8
  });
9
  function wp_gallery_custom_links_click() {
10
- if(!this.target || this.target == '')
11
  window.location = this.href;
12
  else
13
  window.open(this.href,this.target);
7
  jQuery('a.set-target').click(wp_gallery_custom_links_click);
8
  });
9
  function wp_gallery_custom_links_click() {
10
+ if(!this.target || this.target == '' || this.target == '_self')
11
  window.location = this.href;
12
  else
13
  window.open(this.href,this.target);
wp-gallery-custom-links.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Gallery Custom Links
4
  Plugin URI: http://www.fourlightsweb.com/wordpress-plugins/wp-gallery-custom-links/
5
  Description: Specifiy custom links for WordPress gallery images (instead of attachment or file only).
6
- Version: 1.6.1
7
  Author: Four Lights Web Development
8
  Author URI: http://www.fourlightsweb.com
9
  License: GPL2
@@ -66,7 +66,7 @@ class WPGalleryCustomLinks {
66
  'label' => __( 'Gallery Link URL' ),
67
  'input' => 'text',
68
  'value' => get_post_meta( $post->ID, '_gallery_link_url', true ),
69
- 'helps' => 'Will replace "Image File" or "Attachment Page" link for this image in the gallery. Use [none] to remove the link from this image.'
70
  );
71
  $target_value = get_post_meta( $post->ID, '_gallery_link_target', true );
72
  $form_fields['gallery_link_target'] = array(
@@ -76,7 +76,8 @@ class WPGalleryCustomLinks {
76
  <select name="attachments['.$post->ID.'][gallery_link_target]" id="attachments['.$post->ID.'][gallery_link_target]">
77
  <option value="">Same Window</option>
78
  <option value="_blank"'.($target_value == '_blank' ? ' selected="selected"' : '').'>New Window</option>
79
- </select>'
 
80
  );
81
  $preserve_click_value = get_post_meta( $post->ID, '_gallery_link_preserve_click', true );
82
  $form_fields['gallery_link_preserve_click'] = array(
@@ -87,7 +88,7 @@ class WPGalleryCustomLinks {
87
  <option value="remove">Remove</option>
88
  <option value="preserve"'.($preserve_click_value == 'preserve' ? ' selected="selected"' : '').'>Keep</option>
89
  </select>',
90
- 'helps' => 'Lightbox and other OnClick events are removed by default.'
91
  );
92
  return $form_fields;
93
  } // End function apply_filter_attachment_fields_to_edit()
@@ -179,6 +180,31 @@ class WPGalleryCustomLinks {
179
  if( $attachment_meta ) {
180
  $target = $attachment_meta;
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
  // See how to handle click events for this attachment image
184
  $attachment_meta = get_post_meta( $attachment_id, '_gallery_link_preserve_click', true );
@@ -284,8 +310,11 @@ class WPGalleryCustomLinks {
284
  $output = self::add_target( $default_link, $target, $output );
285
 
286
  // Add a class to the link so we can manipulate it with
287
- // javascript later
288
- $output = self::add_class( $default_link, 'set-target', $output );
 
 
 
289
  }
290
 
291
  // Custom Link
3
  Plugin Name: WP Gallery Custom Links
4
  Plugin URI: http://www.fourlightsweb.com/wordpress-plugins/wp-gallery-custom-links/
5
  Description: Specifiy custom links for WordPress gallery images (instead of attachment or file only).
6
+ Version: 1.7.0
7
  Author: Four Lights Web Development
8
  Author URI: http://www.fourlightsweb.com
9
  License: GPL2
66
  'label' => __( 'Gallery Link URL' ),
67
  'input' => 'text',
68
  'value' => get_post_meta( $post->ID, '_gallery_link_url', true ),
69
+ 'helps' => 'Will replace "Image File" or "Attachment Page" link for this image in galleries. Use [none] to remove the link from this image in galleries.'
70
  );
71
  $target_value = get_post_meta( $post->ID, '_gallery_link_target', true );
72
  $form_fields['gallery_link_target'] = array(
76
  <select name="attachments['.$post->ID.'][gallery_link_target]" id="attachments['.$post->ID.'][gallery_link_target]">
77
  <option value="">Same Window</option>
78
  <option value="_blank"'.($target_value == '_blank' ? ' selected="selected"' : '').'>New Window</option>
79
+ </select>',
80
+ 'helps' => 'This setting will be applied to this image in galleries regardless of whether or not a Gallery Link URL has been specified.'
81
  );
82
  $preserve_click_value = get_post_meta( $post->ID, '_gallery_link_preserve_click', true );
83
  $form_fields['gallery_link_preserve_click'] = array(
88
  <option value="remove">Remove</option>
89
  <option value="preserve"'.($preserve_click_value == 'preserve' ? ' selected="selected"' : '').'>Keep</option>
90
  </select>',
91
+ 'helps' => 'Lightbox and other OnClick events are removed by default from this image in galleries. This setting will only be applied to this image in galleries if this image has a Gallery Link URL specified.'
92
  );
93
  return $form_fields;
94
  } // End function apply_filter_attachment_fields_to_edit()
180
  if( $attachment_meta ) {
181
  $target = $attachment_meta;
182
  }
183
+ if( trim( $target ) == '' ) {
184
+ // If empty string ("Same Window") is selected, set target to _self
185
+ $target = '_self';
186
+ // ^^ I'm still a little iffy on the above:
187
+ // Most people's galleries open things in the same window, except that one lady's theme,
188
+ // but if I default empty string ("Same Window") to mean "same window" instead of "whatever it normally does" then
189
+ // she'd have to override every gallery if she wanted to keep her theme's normal behavior.
190
+ // Shouldn't it be the other way around? But if I leave it the way it is, the alternative
191
+ // is she'd have to modify her theme to default to new window in order to open in the same
192
+ // window at all, and most people don't have that skill level. But I also don't want
193
+ // the text "Same Window" to be misleading if it really means "just do what you normally do."
194
+ // Am I thinking too hard about this? I guess this is what happens when you don't distinguish
195
+ // between "default" and "separate override option."
196
+ }
197
+ if( isset( $attr['open_all_in_new_window'] ) && strtolower( trim( $attr['open_all_in_new_window'] ) ) === 'true' ) {
198
+ // Override setting if the gallery shortcode says to open everything in a new window
199
+ // This should accommodate both "3000 images in new window" guy (to some extent) and allow _blank
200
+ // by default lady to reset her gallery to _blank at once
201
+ $target = '_blank';
202
+ }
203
+ if( isset( $attr['open_all_in_same_window'] ) && strtolower( trim( $attr['open_all_in_same_window'] ) ) === 'true' ) {
204
+ // Override setting if the gallery shortcode says to open everything in the same window
205
+ // This should allow _blank by default lady to set her gallery to _self at once
206
+ $target = '_self';
207
+ }
208
 
209
  // See how to handle click events for this attachment image
210
  $attachment_meta = get_post_meta( $attachment_id, '_gallery_link_preserve_click', true );
310
  $output = self::add_target( $default_link, $target, $output );
311
 
312
  // Add a class to the link so we can manipulate it with
313
+ // javascript later (only if we're opening it in a new window -
314
+ // don't want to auto-unbind lightbox if it's the same window)
315
+ if( $target == '_blank' ) {
316
+ $output = self::add_class( $default_link, 'set-target', $output );
317
+ }
318
  }
319
 
320
  // Custom Link