PluginProbe
Themify Builder / 7.7.0
Themify Builder v7.7.0
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / includes / plugin-compat / gallerycustomlinks.php

gallerycustomlinks.php in Themify Builder 7.7.0, at includes/plugin-compat/gallerycustomlinks.php

34 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Builder Plugin Compatibility Code
4 *
5 * @package Themify_Builder
6 * @subpackage Themify_Builder/classes
7 */
8
9 class Themify_Builder_Plugin_Compat_GalleryCustomLinks {
10
11 static function init() {
12 add_filter( 'themify_builder_image_link_before', array( __CLASS__, 'wp_gallery_custom_links' ), 10, 3 );
13 }
14
15 /**
16 * Compatibility with WP Gallery Custom Links plugin
17 * @link https://wordpress.org/plugins/wp-gallery-custom-links
18 * Apply Link and Target fields to gallery images in Grid layout
19 *
20 * @return string
21 */
22 public static function wp_gallery_custom_links(string $link_before, $image, $settings ):string {
23 $attachment_meta = get_post_meta( $image->ID, '_gallery_link_url', true );
24 if( $attachment_meta ) {
25 $link_before = preg_replace( '/href="(.*)"/', 'href="' . $attachment_meta . '"', $link_before );
26 }
27 $attachment_meta = get_post_meta( $image->ID, '_gallery_link_target', true );
28 if( $attachment_meta ) {
29 $link_before = str_replace( '>', ' target="' . $attachment_meta . '">', $link_before );
30 }
31
32 return $link_before;
33 }
34 }