WP Gallery Custom Links - Version 1.10.0

Version Description

  • By popular demand, added the ability to add additional css classes to each image link in the gallery.
  • Added a translation for German, courtesy of Martin Stehle (thanks!)
Download this release

Release Info

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

Code changes from version 1.9.0 to 1.10.0

languages/wp-gallery-custom-links-de_DE.mo ADDED
Binary file
languages/wp-gallery-custom-links-de_DE.po ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: wp-gallery-custom-links\n"
4
+ "POT-Creation-Date: 2013-08-09 16:39+0100\n"
5
+ "PO-Revision-Date: 2014-03-27 13:47+0100\n"
6
+ "Last-Translator: Martin Stehle <m.stehle@gmx.de>\n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.6.4\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "Language: de_DE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: wp-gallery-custom-links.php:68
20
+ msgid "Gallery Link URL"
21
+ msgstr "URL des Links in Galerien"
22
+
23
+ #: wp-gallery-custom-links.php:71
24
+ msgid ""
25
+ "Will replace \"Image File\" or \"Attachment Page\" link for this image in "
26
+ "galleries. Use [none] to remove the link from this image in galleries."
27
+ msgstr ""
28
+ "Ersetzt den Link auf \"Medien-Datei\" oder \"Anhang-Seite\" für dieses Bild "
29
+ "in Galerien. Verwende \"Keine\", um den Link dieses Bildes in Galerien zu "
30
+ "entfernen."
31
+
32
+ #: wp-gallery-custom-links.php:76
33
+ msgid "Gallery Link Target"
34
+ msgstr "Ziel des Links in Galerien"
35
+
36
+ #: wp-gallery-custom-links.php:80
37
+ msgid "Same Window"
38
+ msgstr "Selbes Fenster"
39
+
40
+ #: wp-gallery-custom-links.php:81
41
+ msgid "New Window"
42
+ msgstr "Neues Fenster"
43
+
44
+ #: wp-gallery-custom-links.php:83
45
+ msgid ""
46
+ "This setting will be applied to this image in galleries regardless of "
47
+ "whether or not a Gallery Link URL has been specified."
48
+ msgstr ""
49
+ "Diese Einstellung wird auf dieses Bild in allen Galerien angewendet "
50
+ "ungeachtet dessen, ob eine URL für den Link angegeben wurde oder nicht."
51
+
52
+ #: wp-gallery-custom-links.php:88
53
+ msgid "Gallery Link OnClick Effect"
54
+ msgstr "OnClick-Effekt des Galerie-Links"
55
+
56
+ #: wp-gallery-custom-links.php:92
57
+ msgid "Remove"
58
+ msgstr "Entfernen"
59
+
60
+ #: wp-gallery-custom-links.php:93
61
+ msgid "Keep"
62
+ msgstr "Beibehalten"
63
+
64
+ #: wp-gallery-custom-links.php:95
65
+ msgid ""
66
+ "Lightbox and other OnClick events are removed by default from this image in "
67
+ "galleries. This setting will only be applied to this image in galleries if "
68
+ "this image has a Gallery Link URL specified."
69
+ msgstr ""
70
+ "Lightbox und andere OnClick-Ereignisse werden standardmäßig von Bildern in "
71
+ "Galerien entfernt. Diese Einstellung wird auf dieses Bild in Galerien nur "
72
+ "dann angewendet, falls eine Galerie-Link-URL angegeben wurde."
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: fourlightsweb
3
  Donate link: http://www.fourlightsweb.com/wordpress-plugins/wp-gallery-custom-links/#donate
4
  Tags: gallery links, gallery link, gallery
5
  Requires at least: 3.3.1
6
- Tested up to: 3.8.0
7
- Stable tag: 1.9.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -52,6 +52,7 @@ function my_gallery_link_url_filter( $link, $attachment_id, $post_id ) { return
52
 
53
  1. Upload the 'wp-gallery-custom-links' folder to the '/wp-content/plugins/' directory
54
  1. Activate the plugin through the 'Plugins' menu in WordPress
 
55
 
56
  == Frequently Asked Questions ==
57
 
@@ -93,6 +94,13 @@ see #5 in the old version's readme file here: http://plugins.svn.wordpress.org/w
93
 
94
  = #6) When I enable the plugin, nothing in my gallery changes, even though I have custom links set. Why? =
95
 
 
 
 
 
 
 
 
96
  Thing to try #1: make sure your gallery is set to use either attachment or file links. If the gallery is set to link to "none" there
97
  will be no links to match on, thus this plugin won't be able to swap in custom values.
98
 
@@ -132,6 +140,10 @@ the same styles to `<img>` tags without a link around them.
132
 
133
  == Changelog ==
134
 
 
 
 
 
135
  = 1.9.0 =
136
  * By popular demand, moved the help notes under each field into tooltips so the form won't be so tall.
137
  * The javascript that attempts to disable lightboxes now runs in window.onload in addition to document.ready.
@@ -224,6 +236,10 @@ directly attached to the post.
224
 
225
  == Upgrade Notice ==
226
 
 
 
 
 
227
  = 1.9.0 =
228
  * By popular demand, moved the help notes under each field into tooltips so the form won't be so tall.
229
  * The javascript that attempts to disable lightboxes now runs in window.onload in addition to document.ready.
3
  Donate link: http://www.fourlightsweb.com/wordpress-plugins/wp-gallery-custom-links/#donate
4
  Tags: gallery links, gallery link, gallery
5
  Requires at least: 3.3.1
6
+ Tested up to: 3.8.1
7
+ Stable tag: 1.10.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
52
 
53
  1. Upload the 'wp-gallery-custom-links' folder to the '/wp-content/plugins/' directory
54
  1. Activate the plugin through the 'Plugins' menu in WordPress
55
+ 1. You should now be able to see settings for each image like in the plugin screenshot when editing a gallery.
56
 
57
  == Frequently Asked Questions ==
58
 
94
 
95
  = #6) When I enable the plugin, nothing in my gallery changes, even though I have custom links set. Why? =
96
 
97
+ Thing to try #0.5: make sure your gallery is using the [gallery] shortcode (i.e. you've created the gallery by clicking
98
+ the "Add Media" button and then "Create Gallery" on the side of the media pop-up window). If you don't see a [gallery] shortcode
99
+ in your content and/or you've created the gallery by using a custom form or shortcode generated by your theme (e.g. "I selected
100
+ 'Gallery' as a page template option in a dropdown" or "I'm seeing [somethemename_gallery] in my content"),
101
+ chances are this plugin will not work with that custom code - you would need to contact the author of that custom code to request
102
+ they add their own version of custom links that will work with their code.
103
+
104
  Thing to try #1: make sure your gallery is set to use either attachment or file links. If the gallery is set to link to "none" there
105
  will be no links to match on, thus this plugin won't be able to swap in custom values.
106
 
140
 
141
  == Changelog ==
142
 
143
+ = 1.10.0 =
144
+ * By popular demand, added the ability to add additional css classes to each image link in the gallery.
145
+ * Added a translation for German, courtesy of Martin Stehle (thanks!)
146
+
147
  = 1.9.0 =
148
  * By popular demand, moved the help notes under each field into tooltips so the form won't be so tall.
149
  * The javascript that attempts to disable lightboxes now runs in window.onload in addition to document.ready.
236
 
237
  == Upgrade Notice ==
238
 
239
+ = 1.10.0 =
240
+ * By popular demand, added the ability to add additional css classes to each image link in the gallery.
241
+ * Added a translation for German, courtesy of Martin Stehle (thanks!)
242
+
243
  = 1.9.0 =
244
  * By popular demand, moved the help notes under each field into tooltips so the form won't be so tall.
245
  * The javascript that attempts to disable lightboxes now runs in window.onload in addition to document.ready.
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.9.0
7
  Author: Four Lights Web Development
8
  Author URI: http://www.fourlightsweb.com
9
  License: GPL2
@@ -113,6 +113,17 @@ class WPGalleryCustomLinks {
113
  <option value="preserve"'.($preserve_click_value == 'preserve' ? ' selected="selected"' : '').'>'.__( 'Keep', self::$textdomain_id ).'</option>
114
  </select>'
115
  );
 
 
 
 
 
 
 
 
 
 
 
116
  return $form_fields;
117
  } // End function apply_filter_attachment_fields_to_edit()
118
 
@@ -127,6 +138,9 @@ class WPGalleryCustomLinks {
127
  if( isset( $attachment['gallery_link_preserve_click'] ) ) {
128
  update_post_meta( $post['ID'], '_gallery_link_preserve_click', $attachment['gallery_link_preserve_click'] );
129
  }
 
 
 
130
  return $post;
131
  } // End function apply_filter_attachment_fields_to_save()
132
 
@@ -200,6 +214,7 @@ class WPGalleryCustomLinks {
200
  $target = '';
201
  $preserve_click = '';
202
  $remove_link = false;
 
203
  $attachment_id = intval( $attachment_id );
204
 
205
  // See if we have a custom url for this attachment image
@@ -241,6 +256,11 @@ class WPGalleryCustomLinks {
241
  // This should allow _blank by default lady to set her gallery to _self at once
242
  $target = '_self';
243
  }
 
 
 
 
 
244
 
245
  // See how to handle click events for this attachment image
246
  $attachment_meta = get_post_meta( $attachment_id, '_gallery_link_preserve_click', true );
@@ -257,14 +277,14 @@ class WPGalleryCustomLinks {
257
  $remove_link = true;
258
  }
259
 
260
- if( $link != '' || $target != '' || $remove_link ) {
261
  // Replace the attachment href
262
  $needle = get_attachment_link( $attachment_id );
263
- $output = self::replace_link( $needle, $link, $target, $preserve_click, $remove_link, $output );
264
 
265
  // Replace the file href
266
  list( $needle ) = wp_get_attachment_image_src( $attachment_id, '' );
267
- $output = self::replace_link( $needle, $link, $target, $preserve_click, $remove_link, $output );
268
  // Also, in case of jetpack photon with tiled galleries...
269
  if( function_exists( 'jetpack_photon_url' ) ) {
270
  // The CDN url currently is generated with "$subdomain = rand( 0, 2 );",
@@ -280,7 +300,7 @@ class WPGalleryCustomLinks {
280
  $needle_part_1 = preg_replace( '/\d+$/', '', $needle_parts[0] );
281
  $needle_part_2 = '.wp.com' . $needle_parts[1];
282
  $needle_reassembled = $needle_part_1 . $j . $needle_part_2;
283
- $output = self::replace_link( $needle_reassembled, $link, $target, $preserve_click, $remove_link, $output );
284
  }
285
  }
286
  }
@@ -293,7 +313,7 @@ class WPGalleryCustomLinks {
293
  if( is_array( $attachment_sizes ) && count( $attachment_sizes ) > 0 ) {
294
  foreach( $attachment_sizes as $attachment_size => $attachment_info ) {
295
  list( $needle ) = wp_get_attachment_image_src( $attachment_id, $attachment_size );
296
- $output = self::replace_link( $needle, $link, $target, $preserve_click, $remove_link, $output );
297
  } // End of foreach attachment size
298
  } // End if we have attachment sizes
299
  } // End if we have attachment metadata (specifically sizes)
@@ -303,13 +323,17 @@ class WPGalleryCustomLinks {
303
  return $output;
304
  } // End function apply_filter_post_gallery()
305
 
306
- private static function replace_link( $default_link, $custom_link, $target, $preserve_click, $remove_link, $output ) {
307
  // Build the regex for matching/replacing
308
  $needle = preg_quote( $default_link );
309
  $needle = str_replace( '/', '\/', $needle );
310
  $needle = '/href\s*=\s*["\']' . $needle . '["\']/';
311
  if( preg_match( $needle, $output ) > 0 ) {
312
- $classes_to_add = '';
 
 
 
 
313
 
314
  // Remove Link
315
  if( $remove_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.10.0
7
  Author: Four Lights Web Development
8
  Author URI: http://www.fourlightsweb.com
9
  License: GPL2
113
  <option value="preserve"'.($preserve_click_value == 'preserve' ? ' selected="selected"' : '').'>'.__( 'Keep', self::$textdomain_id ).'</option>
114
  </select>'
115
  );
116
+ // Gallery Link additional css classes field
117
+ $form_fields['gallery_link_additional_css_classes'] = array(
118
+ 'label' => __( 'Gallery Link Additional CSS Classes', self::$textdomain_id ) .
119
+ ' <a href="#" onclick="jQuery(\'#wpgcl_gallery_link_additional_css_classes_help\').show(); return false;" onblur="jQuery(\'#wpgcl_gallery_link_additional_css_classes_help\').hide();">[?]</a>' .
120
+ '<div id="wpgcl_gallery_link_additional_css_classes_help" style="'.$help_css.'">' .
121
+ __( 'Additional CSS classes specified here will be applied to the <strong><em>link</em></strong> around this image in galleries regardless of whether or not a Gallery Link URL has been specified.', self::$textdomain_id ) .
122
+ ' <a href="#" onclick="jQuery(\'#wpgcl_gallery_link_additional_css_classes_help\').hide(); return false;">[X]</a>' .
123
+ '</div>',
124
+ 'input' => 'text',
125
+ 'value' => get_post_meta( $post->ID, '_gallery_link_additional_css_classes', true )
126
+ );
127
  return $form_fields;
128
  } // End function apply_filter_attachment_fields_to_edit()
129
 
138
  if( isset( $attachment['gallery_link_preserve_click'] ) ) {
139
  update_post_meta( $post['ID'], '_gallery_link_preserve_click', $attachment['gallery_link_preserve_click'] );
140
  }
141
+ if( isset( $attachment['gallery_link_additional_css_classes'] ) ) {
142
+ update_post_meta( $post['ID'], '_gallery_link_additional_css_classes', $attachment['gallery_link_additional_css_classes'] );
143
+ }
144
  return $post;
145
  } // End function apply_filter_attachment_fields_to_save()
146
 
214
  $target = '';
215
  $preserve_click = '';
216
  $remove_link = false;
217
+ $additional_css_classes = '';
218
  $attachment_id = intval( $attachment_id );
219
 
220
  // See if we have a custom url for this attachment image
256
  // This should allow _blank by default lady to set her gallery to _self at once
257
  $target = '_self';
258
  }
259
+ // See if we have additional css classes for this attachment image
260
+ $attachment_meta = get_post_meta( $attachment_id, '_gallery_link_additional_css_classes', true );
261
+ if( $attachment_meta ) {
262
+ $additional_css_classes = trim( $attachment_meta );
263
+ }
264
 
265
  // See how to handle click events for this attachment image
266
  $attachment_meta = get_post_meta( $attachment_id, '_gallery_link_preserve_click', true );
277
  $remove_link = true;
278
  }
279
 
280
+ if( $link != '' || $target != '' || $remove_link || $additional_css_classes != '' ) {
281
  // Replace the attachment href
282
  $needle = get_attachment_link( $attachment_id );
283
+ $output = self::replace_link( $needle, $link, $target, $preserve_click, $remove_link, $additional_css_classes, $output );
284
 
285
  // Replace the file href
286
  list( $needle ) = wp_get_attachment_image_src( $attachment_id, '' );
287
+ $output = self::replace_link( $needle, $link, $target, $preserve_click, $remove_link, $additional_css_classes, $output );
288
  // Also, in case of jetpack photon with tiled galleries...
289
  if( function_exists( 'jetpack_photon_url' ) ) {
290
  // The CDN url currently is generated with "$subdomain = rand( 0, 2 );",
300
  $needle_part_1 = preg_replace( '/\d+$/', '', $needle_parts[0] );
301
  $needle_part_2 = '.wp.com' . $needle_parts[1];
302
  $needle_reassembled = $needle_part_1 . $j . $needle_part_2;
303
+ $output = self::replace_link( $needle_reassembled, $link, $target, $preserve_click, $remove_link, $additional_css_classes, $output );
304
  }
305
  }
306
  }
313
  if( is_array( $attachment_sizes ) && count( $attachment_sizes ) > 0 ) {
314
  foreach( $attachment_sizes as $attachment_size => $attachment_info ) {
315
  list( $needle ) = wp_get_attachment_image_src( $attachment_id, $attachment_size );
316
+ $output = self::replace_link( $needle, $link, $target, $preserve_click, $remove_link, $additional_css_classes, $output );
317
  } // End of foreach attachment size
318
  } // End if we have attachment sizes
319
  } // End if we have attachment metadata (specifically sizes)
323
  return $output;
324
  } // End function apply_filter_post_gallery()
325
 
326
+ private static function replace_link( $default_link, $custom_link, $target, $preserve_click, $remove_link, $additional_css_classes, $output ) {
327
  // Build the regex for matching/replacing
328
  $needle = preg_quote( $default_link );
329
  $needle = str_replace( '/', '\/', $needle );
330
  $needle = '/href\s*=\s*["\']' . $needle . '["\']/';
331
  if( preg_match( $needle, $output ) > 0 ) {
332
+ if( $additional_css_classes != '' ) {
333
+ $classes_to_add = $additional_css_classes . ' ';
334
+ } else {
335
+ $classes_to_add = '';
336
+ }
337
 
338
  // Remove Link
339
  if( $remove_link ) {