Version Description
- Add: Label for CTA buttons.
- Fix: Moved the position of the CTA buttons in the DOM.
Download this release
Release Info
Developer | TigrouMeow |
Plugin | Gallery Custom Links |
Version | 1.2.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.2.3
- button/gutenberg.php +5 -4
- button/meow_gallery.php +2 -1
- button/native_gallery.php +17 -10
- gallery_custom_links.php +2 -2
- mgcl_admin.php +16 -6
- readme.txt +5 -1
button/gutenberg.php
CHANGED
@@ -10,9 +10,9 @@ class Meow_Gallery_Custom_Links_Button_Gutenberg {
|
|
10 |
function linker( $handled, $element, $parent, $mediaId, $url, $rel, $target ) {
|
11 |
// Let's look for the closest link tag enclosing the image
|
12 |
|
13 |
-
$
|
14 |
|
15 |
-
if ( $handled || $
|
16 |
return $handled;
|
17 |
}
|
18 |
|
@@ -28,10 +28,11 @@ class Meow_Gallery_Custom_Links_Button_Gutenberg {
|
|
28 |
if ( $this->core->enableLogs ) {
|
29 |
error_log( 'Linker: Will embed the IMG tag.' );
|
30 |
}
|
|
|
31 |
if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
|
32 |
-
$
|
33 |
'" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
|
34 |
-
|
35 |
}
|
36 |
else {
|
37 |
return false;
|
10 |
function linker( $handled, $element, $parent, $mediaId, $url, $rel, $target ) {
|
11 |
// Let's look for the closest link tag enclosing the image
|
12 |
|
13 |
+
$elemBlocksGalleryItem = $parent->parent();
|
14 |
|
15 |
+
if ( $handled || $elemBlocksGalleryItem->class !== 'blocks-gallery-item' ) {
|
16 |
return $handled;
|
17 |
}
|
18 |
|
28 |
if ( $this->core->enableLogs ) {
|
29 |
error_log( 'Linker: Will embed the IMG tag.' );
|
30 |
}
|
31 |
+
$label = $value = get_option( 'mgcl_button_label', "Click here" );
|
32 |
if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
|
33 |
+
$elemBlocksGalleryItem->innertext = $elemBlocksGalleryItem->innertext . $style . '<div id="mgcl-' . $id . '"><a href="' . $url .
|
34 |
'" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
|
35 |
+
' . $label . '</a></div>';
|
36 |
}
|
37 |
else {
|
38 |
return false;
|
button/meow_gallery.php
CHANGED
@@ -28,10 +28,11 @@ class Meow_Gallery_Custom_Links_Button_Meow_Gallery {
|
|
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 |
-
|
35 |
}
|
36 |
else {
|
37 |
return false;
|
28 |
if ( $this->core->enableLogs ) {
|
29 |
error_log( 'Linker: Will embed the IMG tag.' );
|
30 |
}
|
31 |
+
$label = $value = get_option( 'mgcl_button_label', "Click here" );
|
32 |
if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
|
33 |
$element->outertext = $style . '<div id="mgcl-' . $id . '">' . $element . '<a href="' . $url .
|
34 |
'" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
|
35 |
+
' . $label . '</a></div>';
|
36 |
}
|
37 |
else {
|
38 |
return false;
|
button/native_gallery.php
CHANGED
@@ -8,30 +8,37 @@ class Meow_Gallery_Custom_Links_Button_Native_Gallery {
|
|
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 |
-
|
|
|
|
|
16 |
return $handled;
|
17 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
$potentialLinkNode = $parent;
|
20 |
-
$css = 'position:
|
21 |
-
padding: 2px 10px;
|
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 |
-
$
|
33 |
-
|
34 |
-
|
35 |
}
|
36 |
else {
|
37 |
return false;
|
8 |
}
|
9 |
|
10 |
function linker( $handled, $element, $parent, $mediaId, $url, $rel, $target ) {
|
|
|
|
|
|
|
11 |
|
12 |
+
// Let's look for the closest link tag enclosing the image
|
13 |
+
$elemGalleryIcon = $parent->parent();
|
14 |
+
if ( $handled ) {
|
15 |
return $handled;
|
16 |
}
|
17 |
+
|
18 |
+
// Check if it's the Native Gallery
|
19 |
+
$hasGalleryIcon = strpos( $elemGalleryIcon->class, 'gallery-icon' ) !== false;
|
20 |
+
if ( !$hasGalleryIcon ) {
|
21 |
+
return $handled;
|
22 |
+
}
|
23 |
+
$elemGalleryItem = $elemGalleryIcon->parent();
|
24 |
|
25 |
$potentialLinkNode = $parent;
|
26 |
+
$css = 'position: relative; left: 5px; font-size: 15px; text-decoration: none; line-height: inherit;
|
27 |
+
padding: 2px 10px; box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.5);
|
28 |
border-radius: 10px; width: calc(100% - 10px); text-align: center; background: rgba(15, 115, 239, 0.80); color: white;';
|
29 |
$css_hover = 'background: rgba(15, 115, 239, 0.9);';
|
30 |
|
31 |
$id = uniqid();
|
32 |
+
$style = "<style>#mgcl-${id} { position: relative; } #mgcl-${id} a { ${css} } #mgcl-${id} a:hover { ${css_hover} }</style>";
|
33 |
|
34 |
if ( $this->core->enableLogs ) {
|
35 |
error_log( 'Linker: Will embed the IMG tag.' );
|
36 |
}
|
37 |
+
$label = $value = get_option( 'mgcl_button_label', "Click here" );
|
38 |
if ( $this->core->parsingEngine === 'HtmlDomParser' ) {
|
39 |
+
$elemGalleryItem->innertext = $elemGalleryItem->innertext . $style . '<div id="mgcl-' . $id . '"><a href="' . $url .
|
40 |
+
'" class="custom-link-button no-lightbox" onclick="event.stopPropagation()" target="' . $target . '" rel="' . $rel . '">
|
41 |
+
' . $label . '</a></div>';
|
42 |
}
|
43 |
else {
|
44 |
return false;
|
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.
|
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.
|
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.3
|
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.3';
|
27 |
|
28 |
include "mgcl_admin.php";
|
29 |
$mgcl_admin = new Meow_Gallery_Custom_Links_Admin( 'mgcl', __FILE__, 'gallery-custom-links' );
|
mgcl_admin.php
CHANGED
@@ -84,14 +84,16 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
|
|
84 |
'mgcl_settings-menu', 'mgcl_settings' );
|
85 |
|
86 |
// SUBMENU > Settings > Button
|
87 |
-
|
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 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
|
96 |
|
97 |
// SETTINGS
|
@@ -100,6 +102,7 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
|
|
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 |
|
@@ -142,7 +145,7 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
|
|
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
|
146 |
<form method="post" action="options.php">
|
147 |
<?php settings_fields( 'mgcl_settings_button' ); ?>
|
148 |
<?php do_settings_sections( 'mgcl_settings_button-menu' ); ?>
|
@@ -195,6 +198,13 @@ class Meow_Gallery_Custom_Links_Admin extends MeowApps_Admin { // extends MeowAp
|
|
195 |
echo $html;
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
?>
|
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_label', "Label", array( $this, 'admin_button_label_callback' ),
|
93 |
+
'mgcl_settings_button-menu', 'mgcl_settings_button' );
|
94 |
+
// add_settings_field( 'mgcl_button_style', "Style (CSS)", array( $this, 'admin_map_style_callback' ),
|
95 |
+
// 'mgcl_settings_button-menu', 'mgcl_settings_button' );
|
96 |
+
}
|
97 |
|
98 |
|
99 |
// SETTINGS
|
102 |
register_setting( 'mgcl_settings', 'mgcl_log' );
|
103 |
|
104 |
register_setting( 'mgcl_settings_button', 'mgcl_button_enabled' );
|
105 |
+
register_setting( 'mgcl_settings_button', 'mgcl_button_label' );
|
106 |
//register_setting( 'mgcl_settings_button', 'mgcl_button_style' );
|
107 |
}
|
108 |
|
145 |
<div class="meow-box">
|
146 |
<h3>CTA Buttons</h3>
|
147 |
<div class="inside">
|
148 |
+
<p><b>Currently works with the <a href='https://wordpress.org/plugins/meow-gallery/' target='_blank'>Meow Gallery</a> and Gutenberg Galleries</b>. In a future Pro version, support for additional galleries might be added (please contact <a href='https://meowapps.com/contact/' target='_blank'>Meow Apps</a> for this).</p>
|
149 |
<form method="post" action="options.php">
|
150 |
<?php settings_fields( 'mgcl_settings_button' ); ?>
|
151 |
<?php do_settings_sections( 'mgcl_settings_button-menu' ); ?>
|
198 |
echo $html;
|
199 |
}
|
200 |
|
201 |
+
function admin_button_label_callback( $args ) {
|
202 |
+
$value = get_option( 'mgcl_button_label', "Click here" );
|
203 |
+
$html = '<input type="text" id="mgcl_button_label" name="mgcl_button_label" value="' . $value . '" />';
|
204 |
+
$html .= '<br /><span class="description">A call-to-action button will be used of a clickable image.</label>';
|
205 |
+
echo $html;
|
206 |
+
}
|
207 |
+
|
208 |
}
|
209 |
|
210 |
?>
|
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.
|
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,6 +42,10 @@ Replace all the files. Nothing else to do.
|
|
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 :)
|
5 |
Requires at least: 5.0
|
6 |
Tested up to: 5.2
|
7 |
Requires PHP: 7.0
|
8 |
+
Stable tag: 1.2.3
|
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.3 =
|
46 |
+
* Add: Label for CTA buttons.
|
47 |
+
* Fix: Moved the position of the CTA buttons in the DOM.
|
48 |
+
|
49 |
= 1.2.2 =
|
50 |
* Add: CTA Buttons for Meow Gallery, Native Galleries and Gutenberg Galleries.
|
51 |
* Add: Filter to... filter which images are actually managed by the plugin :)
|