Shows warning when enable "wp_gallery_custom_links" plugin with Themify Builder

When I have installed this plugin with one of my site which use Themify Builder, it shows below error.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘wp_gallery_custom_links' not found or invalid function name in /home/content/xxxxx/wp-includes/class-wp-hook.php on line 298

Did you or anyone face this error before? Is there any quick solution?

Also, I have checked Themify and found that they have added plugin code in compatible file as below.

    // WP Gallery Custom Links
if( $this->is_plugin_active( 'wp-gallery-custom-links/wp-gallery-custom-links.php' ) ) {
add_filter( 'themify_builder_image_link_before', 'wp_gallery_custom_links', 10, 3 );
}

function wp_gallery_custom_links( $link_before, $image, $settings ) {
        $attachment_meta = get_post_meta( $image->ID, '_gallery_link_url', true );
        if( $attachment_meta ) {
            $link_before = preg_replace( '/href="(.*)"/', 'href="' . $attachment_meta . '"', $link_before );
        }
        $attachment_meta = get_post_meta( $image->ID, '_gallery_link_target', true );
        if( $attachment_meta ) {
            $link_before = str_replace( '>', ' target="' . $attachment_meta . '">', $link_before );
        }

        return $link_before;
    }

Please look into this and let me know solution asap.

Thanks

Read more here: Shows warning when enable "wp_gallery_custom_links" plugin with Themify Builder

Leave a Reply

Your email address will not be published. Required fields are marked *