WP Gallery Custom Links - Version 1.2.2

Version Description

  • Moved javascript to a separate file so jquery could be required as a dependency.
Download this release

Release Info

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

Code changes from version 1.2.1 to 1.2.2

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.4.1
7
- Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -55,6 +55,9 @@ that function outside of the WordPress [gallery] shortcode.
55
 
56
  == Changelog ==
57
 
 
 
 
58
  = 1.2.1 =
59
  * Fixed a bug where javascript hover effects were not working properly on images.
60
 
@@ -92,6 +95,9 @@ that function outside of the WordPress [gallery] shortcode.
92
 
93
  == Upgrade Notice ==
94
 
 
 
 
95
  = 1.2.1 =
96
  * Fixed a bug where javascript hover effects were not working properly on images.
97
 
4
  Tags: gallery links, gallery link, gallery
5
  Requires at least: 3.3.2
6
  Tested up to: 3.4.1
7
+ Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
55
 
56
  == Changelog ==
57
 
58
+ = 1.2.2 =
59
+ * Moved javascript to a separate file so jquery could be required as a dependency.
60
+
61
  = 1.2.1 =
62
  * Fixed a bug where javascript hover effects were not working properly on images.
63
 
95
 
96
  == Upgrade Notice ==
97
 
98
+ = 1.2.2 =
99
+ * Moved javascript to a separate file so jquery could be required as a dependency.
100
+
101
  = 1.2.1 =
102
  * Fixed a bug where javascript hover effects were not working properly on images.
103
 
wp-gallery-custom-links.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function () {
2
+ jQuery('a.no-lightbox').unbind('click');
3
+ jQuery('a.no-lightbox').off('click');
4
+ jQuery('a.no-lightbox').click(wp_gallery_custom_links_click);
5
+ jQuery('a.set-target').unbind('click');
6
+ jQuery('a.set-target').off('click');
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);
14
+ return false;
15
+ }
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.2.1
7
  Author: Four Lights Web Development
8
  Author URI: http://www.fourlightsweb.com
9
  License: GPL2
@@ -41,7 +41,7 @@ class WPGalleryCustomLinks {
41
  // return "filter" $output to original $GLOBALS['shortcode_tags']['gallery'] call
42
  private static $first_call = true;
43
 
44
- public static function init() {
45
  // Add the filter for editing the custom url field
46
  add_filter( 'attachment_fields_to_edit', array( 'WPGalleryCustomLinks', 'apply_filter_attachment_fields_to_edit' ), null, 2);
47
 
@@ -50,6 +50,15 @@ class WPGalleryCustomLinks {
50
 
51
  // Add the filter for when the post_gallery is written out
52
  add_filter( 'post_gallery', array( 'WPGalleryCustomLinks', 'apply_filter_post_gallery' ), 999, 2 );
 
 
 
 
 
 
 
 
 
53
  } // End function init()
54
 
55
  public static function apply_filter_attachment_fields_to_edit( $form_fields, $post ) {
@@ -166,31 +175,6 @@ class WPGalleryCustomLinks {
166
  } // End if we have a link to swap in or a target to add
167
 
168
  } // End foreach post attachment
169
-
170
- // Javascript to override lightboxes
171
- // Note: Make sure this don't go into feeds, since it could
172
- // cause Mailchimp etc. to not work properly.
173
- if( ! is_feed() ) {
174
- $output .= "<script type=\"text/javascript\">\n";
175
- $output .= "/* <![CDATA[ */\n";
176
- $output .= "jQuery(document).ready(function () {\n";
177
- $output .= " jQuery('a.no-lightbox').unbind('click');\n";
178
- $output .= " jQuery('a.no-lightbox').off('click');\n";
179
- $output .= " jQuery('a.no-lightbox').click(wp_gallery_custom_links_click);\n";
180
- $output .= " jQuery('a.set-target').unbind('click');\n";
181
- $output .= " jQuery('a.set-target').off('click');\n";
182
- $output .= " jQuery('a.set-target').click(wp_gallery_custom_links_click);\n";
183
- $output .= "});\n";
184
- $output .= "function wp_gallery_custom_links_click() {\n";
185
- $output .= " if(!this.target || this.target == '')\n";
186
- $output .= " window.location = this.href;\n";
187
- $output .= " else\n";
188
- $output .= " window.open(this.href,this.target);\n";
189
- $output .= " return false;\n";
190
- $output .= "}\n";
191
- $output .= "/* ]]> */\n";
192
- $output .= "</script>";
193
- } // End if it's not a feed
194
 
195
  return $output;
196
  } // End function apply_filter_post_gallery()
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.2.2
7
  Author: Four Lights Web Development
8
  Author URI: http://www.fourlightsweb.com
9
  License: GPL2
41
  // return "filter" $output to original $GLOBALS['shortcode_tags']['gallery'] call
42
  private static $first_call = true;
43
 
44
+ public static function init() {
45
  // Add the filter for editing the custom url field
46
  add_filter( 'attachment_fields_to_edit', array( 'WPGalleryCustomLinks', 'apply_filter_attachment_fields_to_edit' ), null, 2);
47
 
50
 
51
  // Add the filter for when the post_gallery is written out
52
  add_filter( 'post_gallery', array( 'WPGalleryCustomLinks', 'apply_filter_post_gallery' ), 999, 2 );
53
+
54
+ // Require the javascript to disable lightbox
55
+ wp_enqueue_script(
56
+ 'wp-gallery-custom-links-js',
57
+ plugins_url( '/wp-gallery-custom-links.js', __FILE__ ),
58
+ array( 'jquery' ),
59
+ '1.0',
60
+ true
61
+ );
62
  } // End function init()
63
 
64
  public static function apply_filter_attachment_fields_to_edit( $form_fields, $post ) {
175
  } // End if we have a link to swap in or a target to add
176
 
177
  } // End foreach post attachment
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  return $output;
180
  } // End function apply_filter_post_gallery()