Gallery Custom Links - Version 1.0.7

Version Description

  • Update: Not using OB anymore; going through the content filter (this behavior can be changed internally), better and faster this way.
  • Fix: Avoid issues with static variables which are not registered on older PHP versions.
Download this release

Release Info

Developer TigrouMeow
Plugin Icon 128x128 Gallery Custom Links
Version 1.0.7
Comparing to
See all releases

Code changes from version 1.0.6 to 1.0.7

Files changed (4) hide show
  1. gallery_custom_links.php +2 -2
  2. mgcl_core.php +11 -4
  3. mgcl_extra.php +8 -0
  4. readme.txt +11 -3
gallery_custom_links.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Gallery Custom Links
4
  Plugin URI: https://meowapps.com
5
  Description: Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
6
- Version: 1.0.6
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: gallery-custom-links
@@ -23,7 +23,7 @@ if ( class_exists( 'Meow_Gallery_Custom_Links' ) ) {
23
  }
24
 
25
  global $mgcl_version;
26
- $mgcl_version = '1.0.6';
27
 
28
  // Admin
29
  // include "mgcl_admin.php";
3
  Plugin Name: Gallery Custom Links
4
  Plugin URI: https://meowapps.com
5
  Description: Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
6
+ Version: 1.0.7
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: gallery-custom-links
23
  }
24
 
25
  global $mgcl_version;
26
+ $mgcl_version = '1.0.7';
27
 
28
  // Admin
29
  // include "mgcl_admin.php";
mgcl_core.php CHANGED
@@ -8,6 +8,7 @@ use DiDom\Element;
8
  class Meow_Gallery_Custom_Links
9
  {
10
  public $isEnabled = true;
 
11
 
12
  public function __construct() {
13
 
@@ -19,10 +20,15 @@ class Meow_Gallery_Custom_Links
19
  // Extra support
20
  add_action( 'init', array( $this, 'init' ) );
21
 
 
 
22
  // Processing
23
  add_action( 'init', array( $this, 'start' ) );
 
 
 
 
24
  add_action( 'wp_footer', array( $this, 'unlink_lightboxes_script' ) ) ;
25
- add_action( 'shutdown', array( $this, 'shutdown' ) );
26
  }
27
  }
28
 
@@ -61,7 +67,8 @@ class Meow_Gallery_Custom_Links
61
  $this->isEnabled = apply_filters( 'gallery_custom_links_enabled', true );
62
  if ( !$this->isEnabled )
63
  return;
64
- ob_start( array( $this, "linkify" ) );
 
65
  }
66
 
67
  // Clean the path from the domain and common folders
@@ -153,11 +160,11 @@ class Meow_Gallery_Custom_Links
153
  }
154
 
155
  function linkify( $buffer ) {
156
- if ( !isset( $buffer ) || trim( $buffer ) === '' )
157
  return $buffer;
158
  $html = new Document();
159
  $html->preserveWhiteSpace();
160
- $html->loadHtml( $buffer, LIBXML_HTML_NOIMPLIED );
161
  $hasChanges = false;
162
  $classes = apply_filters( 'gallery_custom_links_classes', array( '.gallery', '.wp-block-gallery' ) );
163
  foreach ( $classes as $class ) {
8
  class Meow_Gallery_Custom_Links
9
  {
10
  public $isEnabled = true;
11
+ public $isOb = false;
12
 
13
  public function __construct() {
14
 
20
  // Extra support
21
  add_action( 'init', array( $this, 'init' ) );
22
 
23
+ $this->isOb = false;
24
+
25
  // Processing
26
  add_action( 'init', array( $this, 'start' ) );
27
+ if ( $this->isOb )
28
+ add_action( 'shutdown', array( $this, 'shutdown' ) );
29
+ else
30
+ add_filter( 'the_content', array( $this, 'linkify' ), 20 );
31
  add_action( 'wp_footer', array( $this, 'unlink_lightboxes_script' ) ) ;
 
32
  }
33
  }
34
 
67
  $this->isEnabled = apply_filters( 'gallery_custom_links_enabled', true );
68
  if ( !$this->isEnabled )
69
  return;
70
+ if ( $this->isOb )
71
+ ob_start( array( $this, "linkify" ) );
72
  }
73
 
74
  // Clean the path from the domain and common folders
160
  }
161
 
162
  function linkify( $buffer ) {
163
+ if ( !$this->isEnabled || !isset( $buffer ) || trim( $buffer ) === '' )
164
  return $buffer;
165
  $html = new Document();
166
  $html->preserveWhiteSpace();
167
+ $html->loadHtml( $buffer, 0 );
168
  $hasChanges = false;
169
  $classes = apply_filters( 'gallery_custom_links_classes', array( '.gallery', '.wp-block-gallery' ) );
170
  foreach ( $classes as $class ) {
mgcl_extra.php CHANGED
@@ -7,6 +7,9 @@ class Meow_Gallery_Custom_Links_Extra
7
  add_filter( 'gallery_custom_links_classes', array( $this, 'meow_gallery' ), 10, 1 );
8
  if ( function_exists( 'kadence_gallery' ) )
9
  add_filter( 'gallery_custom_links_classes', array( $this, 'kadence_gallery' ), 10, 1 );
 
 
 
10
  }
11
 
12
  function meow_gallery( $classes ) {
@@ -18,6 +21,11 @@ class Meow_Gallery_Custom_Links_Extra
18
  array_push( $classes, '.kad-wp-gallery' );
19
  return $classes;
20
  }
 
 
 
 
 
21
  }
22
 
23
  ?>
7
  add_filter( 'gallery_custom_links_classes', array( $this, 'meow_gallery' ), 10, 1 );
8
  if ( function_exists( 'kadence_gallery' ) )
9
  add_filter( 'gallery_custom_links_classes', array( $this, 'kadence_gallery' ), 10, 1 );
10
+ if ( class_exists( 'Vc_Manager' ) ) {
11
+ add_filter( 'gallery_custom_links_classes', array( $this, 'wpbakery' ), 10, 1 );
12
+ }
13
  }
14
 
15
  function meow_gallery( $classes ) {
21
  array_push( $classes, '.kad-wp-gallery' );
22
  return $classes;
23
  }
24
+
25
+ function wpbakery( $classes ) {
26
+ array_push( $classes, '.w-gallery' );
27
+ return $classes;
28
+ }
29
  }
30
 
31
  ?>
readme.txt CHANGED
@@ -3,13 +3,13 @@ Contributors: TigrouMeow
3
  Tags: custom, links, gallery, gutenberg
4
  Requires at least: 4.9
5
  Tested up to: 5.0
6
- Stable tag: 1.0.6
7
 
8
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
9
 
10
  == Description ==
11
 
12
- Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
13
 
14
  === Usage ===
15
 
@@ -17,7 +17,11 @@ Two fields are added to your images, in your Media Library: Link URL and Link Ta
17
 
18
  === Compatibility ===
19
 
20
- It currently works with the native WP Gallery, the Gutenberg Gallery, and the Meow Gallery. It should actually work with any gallery plugin using the 'gallery' class and Responsive Images (src-set). Let me know if you would like more galleries to be supported, it should be easy.
 
 
 
 
21
 
22
  === Thanks ===
23
 
@@ -36,6 +40,10 @@ Replace all the files. Nothing else to do.
36
 
37
  == Changelog ==
38
 
 
 
 
 
39
  = 1.0.6 =
40
  * Fix: Now works with the most tenacious lightboxes.
41
  * Update: The way the HTML was modified to make sure it is compliant.
3
  Tags: custom, links, gallery, gutenberg
4
  Requires at least: 4.9
5
  Tested up to: 5.0
6
+ Stable tag: 1.0.7
7
 
8
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
9
 
10
  == Description ==
11
 
12
+ Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others. The official page is here: [Gallery Custom Links](https://meowapps.com/plugin/gallery-custom-links/).
13
 
14
  === Usage ===
15
 
17
 
18
  === Compatibility ===
19
 
20
+ It currently works with the native WP Gallery, the Gutenberg Gallery, and the [Meow Gallery](https://wordpress.org/plugins/meow-gallery/). It should actually work with any gallery plugin using the 'gallery' class and Responsive Images (src-set). Let me know if you would like more galleries to be supported, it should be easy.
21
+
22
+ === Filters ===
23
+
24
+ You can optimize (run the plugin only on the pages where you need it) and support more galleries (through CSS classes) easily by using filters. To know more about this, visit the official page, here: [Gallery Custom Links](https://meowapps.com/plugin/gallery-custom-links/).
25
 
26
  === Thanks ===
27
 
40
 
41
  == Changelog ==
42
 
43
+ = 1.0.7 =
44
+ * Update: Not using OB anymore; going through the content filter (this behavior can be changed internally), better and faster this way.
45
+ * Fix: Avoid issues with static variables which are not registered on older PHP versions.
46
+
47
  = 1.0.6 =
48
  * Fix: Now works with the most tenacious lightboxes.
49
  * Update: The way the HTML was modified to make sure it is compliant.