Gallery Custom Links - Version 1.2.2

Version Description

  • Add: CTA Buttons for Meow Gallery, Native Galleries and Gutenberg Galleries.
  • Add: Filter to... filter which images are actually managed by the plugin :)
  • Fix: Hopefully, the Reusable Blocks aren't broken anymore in the editor (I couldn't replicate the bug on this new version).
  • Info: If you like the plugin, your reviews are welcome here :) Thank you!
Download this release

Release Info

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

Code changes from version 1.2.0 to 1.2.2

button/gutenberg.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_Gallery_Custom_Links_Button_Gutenberg {
4
+
5
+ public function __construct( $core ) {
6
+ $this->core = $core;
7
+ add_filter( 'mgcl_linkers', array( $this, 'linker' ), 100, 7 );
8
+ }
9
+
10
+ function linker( $handled, $element, $parent, $mediaId, $url, $rel, $target ) {
11
+ // Let's look for the closest link tag enclosing the image
12
+
13
+ $anotherParent = $parent->parent();
14
+
15
+ if ( $handled || $anotherParent->class !== 'blocks-gallery-item' ) {
16
+ return $handled;
17
+ }
18
+
19
+ $potentialLinkNode = $parent;
20
+ $css = 'position: absolute; height: auto; font-size: 15px; text-decoration: none;
21
+ padding: 2px 10px; bottom: 5px; left: 5px; box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.5);
22
+ border-radius: 10px; width: calc(100% - 10px); text-align: center; background: rgba(15, 115, 239, 0.80); color: white;';
23
+ $css_hover = 'background: rgba(15, 115, 239, 0.9);';
24
+
25
+ $id = uniqid();
26
+ $style = "<style>#mgcl-${id} a { ${css} } #mgcl-${id} a:hover { ${css_hover} }</style>";
27
+
28
+ if ( $this->core->enableLogs ) {
29
+ error_log( 'Linker: Will embed the IMG tag.' );
30
+ }
31
+ if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
32
+ $element->outertext = $style . '<div id="mgcl-' . $id . '">' . $element . '<a href="' . $url .
33
+ '" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
34
+ Click here</a></div>';
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ return true;
40
+ }
41
+ }
42
+
43
+ ?>
button/meow_gallery.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_Gallery_Custom_Links_Button_Meow_Gallery {
4
+
5
+ public function __construct( $core ) {
6
+ $this->core = $core;
7
+ add_filter( 'mgcl_linkers', array( $this, 'linker' ), 100, 7 );
8
+ }
9
+
10
+ function linker( $handled, $element, $parent, $mediaId, $url, $rel, $target ) {
11
+ // Let's look for the closest link tag enclosing the image
12
+
13
+ $anotherParent = $parent->parent();
14
+
15
+ if ( $handled || $anotherParent->class !== 'mgl-icon' ) {
16
+ return $handled;
17
+ }
18
+
19
+ $potentialLinkNode = $parent;
20
+ $css = 'position: absolute; height: auto; font-size: 15px; text-decoration: none;
21
+ padding: 2px 10px; bottom: 5px; left: 5px; box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.5);
22
+ border-radius: 10px; width: calc(100% - 10px); text-align: center; background: rgba(15, 115, 239, 0.80); color: white;';
23
+ $css_hover = 'background: rgba(15, 115, 239, 0.9);';
24
+
25
+ $id = uniqid();
26
+ $style = "<style>#mgcl-${id} a { ${css} } #mgcl-${id} a:hover { ${css_hover} }</style>";
27
+
28
+ if ( $this->core->enableLogs ) {
29
+ error_log( 'Linker: Will embed the IMG tag.' );
30
+ }
31
+ if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
32
+ $element->outertext = $style . '<div id="mgcl-' . $id . '">' . $element . '<a href="' . $url .
33
+ '" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
34
+ Click here</a></div>';
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ return true;
40
+ }
41
+ }
42
+
43
+ ?>
button/native_gallery.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_Gallery_Custom_Links_Button_Native_Gallery {
4
+
5
+ public function __construct( $core ) {
6
+ $this->core = $core;
7
+ add_filter( 'mgcl_linkers', array( $this, 'linker' ), 100, 7 );
8
+ }
9
+
10
+ function linker( $handled, $element, $parent, $mediaId, $url, $rel, $target ) {
11
+ // Let's look for the closest link tag enclosing the image
12
+
13
+ $anotherParent = $parent->parent();
14
+
15
+ if ( $handled || $anotherParent->class !== 'blocks-gallery-item' ) {
16
+ return $handled;
17
+ }
18
+
19
+ $potentialLinkNode = $parent;
20
+ $css = 'position: absolute; height: auto; font-size: 15px; text-decoration: none;
21
+ padding: 2px 10px; bottom: 5px; left: 5px; box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.5);
22
+ border-radius: 10px; width: calc(100% - 10px); text-align: center; background: rgba(15, 115, 239, 0.80); color: white;';
23
+ $css_hover = 'background: rgba(15, 115, 239, 0.9);';
24
+
25
+ $id = uniqid();
26
+ $style = "<style>#mgcl-${id} a { ${css} } #mgcl-${id} a:hover { ${css_hover} }</style>";
27
+
28
+ if ( $this->core->enableLogs ) {
29
+ error_log( 'Linker: Will embed the IMG tag.' );
30
+ }
31
+ if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
32
+ $element->outertext = $style . '<div id="mgcl-' . $id . '">' . $element . '<a href="' . $url .
33
+ '" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
34
+ Click here</a></div>';
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ return true;
40
+ }
41
+ }
42
+
43
+ ?>
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.2.0
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.2.0';
27
 
28
  include "mgcl_admin.php";
29
  $mgcl_admin = new Meow_Gallery_Custom_Links_Admin( 'mgcl', __FILE__, 'gallery-custom-links' );
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.2.2
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.2.2';
27
 
28
  include "mgcl_admin.php";
29
  $mgcl_admin = new Meow_Gallery_Custom_Links_Admin( 'mgcl', __FILE__, 'gallery-custom-links' );
mgcl_admin.php CHANGED
@@ -76,19 +76,31 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
76
 
77
  // SUBMENU > Settings > Basic Settings
78
  add_settings_section( 'mgcl_settings', null, null, 'mgcl_settings-menu' );
79
- add_settings_field( 'mgcl_obmode', "OB Mode",
80
- array( $this, 'admin_obmode_callback' ),
81
  'mgcl_settings-menu', 'mgcl_settings' );
82
- add_settings_field( 'mgcl_parsing_engine', "Parsing Engine",
83
- array( $this, 'admin_parsing_engine_callback' ),
84
  'mgcl_settings-menu', 'mgcl_settings' );
85
- add_settings_field( 'mgcl_log', "Logs",
86
- array( $this, 'admin_log_callback' ),
87
  'mgcl_settings-menu', 'mgcl_settings' );
88
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  register_setting( 'mgcl_settings', 'mgcl_obmode' );
90
  register_setting( 'mgcl_settings', 'mgcl_parsing_engine' );
91
  register_setting( 'mgcl_settings', 'mgcl_log' );
 
 
 
92
  }
93
 
94
  function admin_settings() {
@@ -127,6 +139,18 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
127
  </div>
128
  </div>
129
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  </div>
131
 
132
  </div>
@@ -152,9 +176,7 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
152
  $image_size = get_option( 'mgcl_parsing_engine', 'HtmlDomParser' );
153
  foreach ( $layouts as $key => $arg )
154
  $html .= '<input type="radio" class="radio" id="mgcl_parsing_engine" name="mgcl_parsing_engine" value="' . $key . '"' .
155
- checked( $key, $image_size, false ) . ' > ' .
156
- ( empty( $arg ) ? 'None' : $arg['name'] ) .
157
- '<br />';
158
  echo $html;
159
  }
160
 
@@ -165,6 +187,14 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
165
  echo $html;
166
  }
167
 
 
 
 
 
 
 
 
 
168
  }
169
 
170
  ?>
76
 
77
  // SUBMENU > Settings > Basic Settings
78
  add_settings_section( 'mgcl_settings', null, null, 'mgcl_settings-menu' );
79
+ add_settings_field( 'mgcl_obmode', "OB Mode", array( $this, 'admin_obmode_callback' ),
 
80
  'mgcl_settings-menu', 'mgcl_settings' );
81
+ add_settings_field( 'mgcl_parsing_engine', "Parsing Engine", array( $this, 'admin_parsing_engine_callback' ),
 
82
  'mgcl_settings-menu', 'mgcl_settings' );
83
+ add_settings_field( 'mgcl_log', "Logs", array( $this, 'admin_log_callback' ),
 
84
  'mgcl_settings-menu', 'mgcl_settings' );
85
 
86
+ // SUBMENU > Settings > Button
87
+ //$button_enabled = get_option( 'mgcl_button_enabled', false );
88
+ add_settings_section( 'mgcl_settings_button', null, null, 'mgcl_settings_button-menu' );
89
+ add_settings_field( 'mgcl_button_enabled', "Use Buttons", array( $this, 'admin_button_enabled_callback' ),
90
+ 'mgcl_settings_button-menu', 'mgcl_settings_button' );
91
+ // if ( $button_enabled ) {
92
+ // add_settings_field( 'mgcl_button_style', "Style (CSS)", array( $this, 'admin_map_style_callback' ),
93
+ // 'mgcl_settings_button-menu', 'mgcl_settings_button' );
94
+ // }
95
+
96
+
97
+ // SETTINGS
98
  register_setting( 'mgcl_settings', 'mgcl_obmode' );
99
  register_setting( 'mgcl_settings', 'mgcl_parsing_engine' );
100
  register_setting( 'mgcl_settings', 'mgcl_log' );
101
+
102
+ register_setting( 'mgcl_settings_button', 'mgcl_button_enabled' );
103
+ //register_setting( 'mgcl_settings_button', 'mgcl_button_style' );
104
  }
105
 
106
  function admin_settings() {
139
  </div>
140
  </div>
141
 
142
+ <div class="meow-box">
143
+ <h3>CTA Buttons</h3>
144
+ <div class="inside">
145
+ <p><b>Currently works with the <a href='https://wordpress.org/plugins/meow-gallery/' target='_blank'>Meow Gallery</a>, WP Native Galleries and Gutenberg Galleries</b>. In a future Pro version, support for additional galleries might be added (please contact Meow Apps for this).</p>
146
+ <form method="post" action="options.php">
147
+ <?php settings_fields( 'mgcl_settings_button' ); ?>
148
+ <?php do_settings_sections( 'mgcl_settings_button-menu' ); ?>
149
+ <?php submit_button(); ?>
150
+ </form>
151
+ </div>
152
+ </div>
153
+
154
  </div>
155
 
156
  </div>
176
  $image_size = get_option( 'mgcl_parsing_engine', 'HtmlDomParser' );
177
  foreach ( $layouts as $key => $arg )
178
  $html .= '<input type="radio" class="radio" id="mgcl_parsing_engine" name="mgcl_parsing_engine" value="' . $key . '"' .
179
+ checked( $key, $image_size, false ) . ' > ' . $arg['name'] . '<br />';
 
 
180
  echo $html;
181
  }
182
 
187
  echo $html;
188
  }
189
 
190
+ function admin_button_enabled_callback( $args ) {
191
+ $html = '<input type="checkbox" id="mgcl_button_enabled" name="mgcl_button_enabled" value="1" ' .
192
+ checked( 1, get_option( 'mgcl_button_enabled', false ), false ) . '/>';
193
+ $html .= '<label>' . __( 'Enabled', 'gallery-custom-links' ) . '</label>';
194
+ $html .= '<br /><span class="description">A call-to-action button will be used of a clickable image.</label>';
195
+ echo $html;
196
+ }
197
+
198
  }
199
 
200
  ?>
mgcl_core.php CHANGED
@@ -12,7 +12,6 @@ class Meow_Gallery_Custom_Links
12
  public $enableLogs = false;
13
 
14
  public function __construct() {
15
-
16
  if ( is_admin() || $this->is_rest() ) {
17
  return;
18
  }
@@ -28,6 +27,16 @@ class Meow_Gallery_Custom_Links
28
  add_filter( 'the_content', array( $this, 'linkify' ), 100 );
29
  add_action( 'wp_footer', array( $this, 'unlink_lightboxes_script' ) ) ;
30
  }
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  function is_rest() {
@@ -108,69 +117,14 @@ class Meow_Gallery_Custom_Links
108
  if ( empty( $target ) )
109
  $target = '_self';
110
  $parent = $element->parent();
111
-
112
  if ( $this->enableLogs ) {
113
  error_log( 'Linker: Found Media ' . $mediaId . ' (URL: ' . $url . ')' );
114
  }
115
-
116
- // Let's look for the closest link tag enclosing the image
117
- $potentialLinkNode = $parent;
118
- $maxDepth = 5;
119
- do {
120
- if ( !empty( $potentialLinkNode ) && $potentialLinkNode->tag === 'a' ) {
121
-
122
- if ( $this->enableLogs ) {
123
- error_log( 'Linker: The current link (' . $potentialLinkNode->{'href'} . ') will be replaced.' );
124
- }
125
-
126
- if ( $this->parsingEngine === 'HtmlDomParser' ) {
127
- $potentialLinkNode->{'href'} = $url;
128
- $class = $potentialLinkNode->{'class'};
129
- $class = empty( $class ) ? 'custom-link no-lightbox' : ( $class . ' custom-link no-lightbox' );
130
- $potentialLinkNode->{'class'} = $class;
131
- $potentialLinkNode->{'onclick'} = 'event.stopPropagation()';
132
- $potentialLinkNode->{'target'} = $target;
133
- $potentialLinkNode->{'rel'} = $rel;
134
- }
135
- else {
136
- $potentialLinkNode->attr( 'href', $url );
137
- $class = $potentialLinkNode->attr( 'class' );
138
- $class = empty( $class ) ? 'custom-link no-lightbox' : ( $class . ' custom-link no-lightbox' );
139
- $potentialLinkNode->attr( 'class', $class );
140
- $potentialLinkNode->attr( 'onclick', 'event.stopPropagation()' );
141
- $potentialLinkNode->attr( 'target', $target );
142
- $potentialLinkNode->attr( 'rel', $rel );
143
- }
144
- return true;
145
- }
146
- if ( method_exists( $potentialLinkNode, 'parent' ) )
147
- $potentialLinkNode = $potentialLinkNode->parent();
148
- else
149
- break;
150
- }
151
- while ( $potentialLinkNode && $maxDepth-- >= 0 );
152
-
153
- // There is no link tag, so we add one and move the image under it
154
- if ( $this->enableLogs ) {
155
- error_log( 'Linker: Will embed the IMG tag.' );
156
- }
157
- if ( $this->parsingEngine === 'HtmlDomParser' ) {
158
- $element->outertext = '<a href="' . $url . '" class="custom-link no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">' . $element . '</a>';
159
- }
160
- else {
161
- if ( $parent->tag === 'figure' )
162
- $parent = $parent->parent();
163
- $a = new DiDom\Element('a');
164
- $a->attr( 'href', $url );
165
- $a->attr( 'class', 'custom-link no-lightbox' );
166
- $a->attr( 'onclick', 'event.stopPropagation()' );
167
- $a->attr( 'target', $target );
168
- $a->attr( 'rel', $rel );
169
- $a->appendChild( $parent->children() );
170
- foreach( $parent->children() as $img ) {
171
- $img->remove();
172
- }
173
- $parent->appendChild( $a );
174
  }
175
  return true;
176
  }
@@ -201,8 +155,8 @@ class Meow_Gallery_Custom_Links
201
  }
202
 
203
  $hasChanges = false;
204
- $classes = array( '' ); // Get all images
205
- //$classes = apply_filters( 'gallery_custom_links_classes', array( '.entry-content', '.gallery', '.wp-block-gallery' ) );
206
  foreach ( $classes as $class ) {
207
  foreach ( $html->find( $class . ' img' ) as $element ) {
208
  $hasChanges = $this->linkify_element( $element ) || $hasChanges;
12
  public $enableLogs = false;
13
 
14
  public function __construct() {
 
15
  if ( is_admin() || $this->is_rest() ) {
16
  return;
17
  }
27
  add_filter( 'the_content', array( $this, 'linkify' ), 100 );
28
  add_action( 'wp_footer', array( $this, 'unlink_lightboxes_script' ) ) ;
29
  }
30
+
31
+ $button_enabled = get_option( 'mgcl_button_enabled', false );
32
+ if ( $button_enabled ) {
33
+ require_once( 'button/gutenberg.php' );
34
+ new Meow_Gallery_Custom_Links_Button_Gutenberg( $this );
35
+ require_once( 'button/native_gallery.php' );
36
+ new Meow_Gallery_Custom_Links_Button_Native_Gallery( $this );
37
+ require_once( 'button/meow_gallery.php' );
38
+ new Meow_Gallery_Custom_Links_Button_Meow_Gallery( $this );
39
+ }
40
  }
41
 
42
  function is_rest() {
117
  if ( empty( $target ) )
118
  $target = '_self';
119
  $parent = $element->parent();
 
120
  if ( $this->enableLogs ) {
121
  error_log( 'Linker: Found Media ' . $mediaId . ' (URL: ' . $url . ')' );
122
  }
123
+ $handled = apply_filters( 'mgcl_linkers', false, $element, $parent, $mediaId, $url, $rel, $target );
124
+ if ( !$handled ) {
125
+ include_once( "mgcl_linker.php" );
126
+ $linker = new Meow_Gallery_Custom_Links_Linker( $this );
127
+ $linker->linker( $element, $parent, $mediaId, $url, $rel, $target );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
  return true;
130
  }
155
  }
156
 
157
  $hasChanges = false;
158
+ // array( '.entry-content', '.gallery', '.wp-block-gallery' )
159
+ $classes = apply_filters( 'gallery_custom_links_classes', array( '' ) );
160
  foreach ( $classes as $class ) {
161
  foreach ( $html->find( $class . ' img' ) as $element ) {
162
  $hasChanges = $this->linkify_element( $element ) || $hasChanges;
mgcl_linker.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Meow_Gallery_Custom_Links_Linker {
4
+
5
+ public function __construct( $core ) {
6
+ $this->core = $core;
7
+ //add_filter( 'mgcl_linkers', array( $this, 'linker' ), 100, 6 );
8
+ }
9
+
10
+ function linker( $element, $parent, $mediaId, $url, $rel, $target ) {
11
+ // Let's look for the closest link tag enclosing the image
12
+ $potentialLinkNode = $parent;
13
+ $maxDepth = 5;
14
+ do {
15
+ if ( !empty( $potentialLinkNode ) && $potentialLinkNode->tag === 'a' ) {
16
+
17
+ if ( $this->core->enableLogs ) {
18
+ error_log( 'Linker: The current link (' . $potentialLinkNode->{'href'} . ') will be replaced.' );
19
+ }
20
+
21
+ if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
22
+ $potentialLinkNode->{'href'} = $url;
23
+ $class = $potentialLinkNode->{'class'};
24
+ $class = empty( $class ) ? 'custom-link no-lightbox' : ( $class . ' custom-link no-lightbox' );
25
+ $potentialLinkNode->{'class'} = $class;
26
+ $potentialLinkNode->{'onclick'} = 'event.stopPropagation()';
27
+ $potentialLinkNode->{'target'} = $target;
28
+ $potentialLinkNode->{'rel'} = $rel;
29
+ }
30
+ else {
31
+ $potentialLinkNode->attr( 'href', $url );
32
+ $class = $potentialLinkNode->attr( 'class' );
33
+ $class = empty( $class ) ? 'custom-link no-lightbox' : ( $class . ' custom-link no-lightbox' );
34
+ $potentialLinkNode->attr( 'class', $class );
35
+ $potentialLinkNode->attr( 'onclick', 'event.stopPropagation()' );
36
+ $potentialLinkNode->attr( 'target', $target );
37
+ $potentialLinkNode->attr( 'rel', $rel );
38
+ }
39
+ return true;
40
+ }
41
+ if ( method_exists( $potentialLinkNode, 'parent' ) )
42
+ $potentialLinkNode = $potentialLinkNode->parent();
43
+ else
44
+ break;
45
+ }
46
+ while ( $potentialLinkNode && $maxDepth-- >= 0 );
47
+
48
+ // There is no link tag, so we add one and move the image under it
49
+ if ( $this->core->enableLogs ) {
50
+ error_log( 'Linker: Will embed the IMG tag.' );
51
+ }
52
+ if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
53
+ $element->outertext = '<a href="' . $url . '" class="custom-link no-lightbox" onclick="event.stopPropagation()" target="' .
54
+ $target . '" rel="' . $rel . '">' . $element . '</a>';
55
+ }
56
+ else {
57
+ if ( $parent->tag === 'figure' )
58
+ $parent = $parent->parent();
59
+ $a = new DiDom\Element('a');
60
+ $a->attr( 'href', $url );
61
+ $a->attr( 'class', 'custom-link no-lightbox' );
62
+ $a->attr( 'onclick', 'event.stopPropagation()' );
63
+ $a->attr( 'target', $target );
64
+ $a->attr( 'rel', $rel );
65
+ $a->appendChild( $parent->children() );
66
+ foreach( $parent->children() as $img ) {
67
+ $img->remove();
68
+ }
69
+ $parent->appendChild( $a );
70
+ }
71
+ return true;
72
+ }
73
+ }
74
+
75
+ ?>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a95
5
  Requires at least: 5.0
6
  Tested up to: 5.2
7
  Requires PHP: 7.0
8
- Stable tag: 1.2.0
9
 
10
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
11
 
@@ -42,9 +42,14 @@ Replace all the files. Nothing else to do.
42
 
43
  == Changelog ==
44
 
 
 
 
 
 
 
45
  = 1.2.0 =
46
  * Add: This was asked to me a lot, so I have adding the settings in order to change the parameters of the plugin easily. It will be much easier to make it faster now.
47
- * Info: If you like the plugin, your reviews are welcome [here](https://wordpress.org/support/plugin/gallery-custom-links/reviews/?rate=5#new-post) :) Thank you!
48
 
49
  = 1.1.5 =
50
  * Fix: Simpler and probably better REST detection.
5
  Requires at least: 5.0
6
  Tested up to: 5.2
7
  Requires PHP: 7.0
8
+ Stable tag: 1.2.2
9
 
10
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
11
 
42
 
43
  == Changelog ==
44
 
45
+ = 1.2.2 =
46
+ * Add: CTA Buttons for Meow Gallery, Native Galleries and Gutenberg Galleries.
47
+ * Add: Filter to... filter which images are actually managed by the plugin :)
48
+ * Fix: Hopefully, the Reusable Blocks aren't broken anymore in the editor (I couldn't replicate the bug on this new version).
49
+ * Info: If you like the plugin, your reviews are welcome [here](https://wordpress.org/support/plugin/gallery-custom-links/reviews/?rate=5#new-post) :) Thank you!
50
+
51
  = 1.2.0 =
52
  * Add: This was asked to me a lot, so I have adding the settings in order to change the parameters of the plugin easily. It will be much easier to make it faster now.
 
53
 
54
  = 1.1.5 =
55
  * Fix: Simpler and probably better REST detection.