0

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

0

I have resolved this issue finally by making changes directly in “/wp-content/themes/themify-ultra/themify/themify-builder/templates/template-gallery-grid.php”.

Try to find below lines.

$link_before = '' != $link ? sprintf( '', esc_attr( $image->post_title ), esc_url( $link ) ) : '';
$link_before = apply_filters( 'themify_builder_image_link_before', $link_before, $image, $settings );

And replace with,

$custom_link = get_post_meta( $image->ID, '_gallery_link_url', true );
$custom_link_target = get_post_meta( $image->ID, '_gallery_link_target', true );
if($custom_link){
   $link = $custom_link;
}
$link_before = '' != $link ? sprintf( '', esc_attr( $image->post_title ), esc_url( $link ), $custom_link_target ) : '';
//$link_before = apply_filters( 'themify_builder_image_link_before', $link_before, $image, $settings );

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.