Created
April 20, 2023 21:30
-
-
Save wpexplorer/a32235fd5286b11ab0323b84363959d6 to your computer and use it in GitHub Desktop.
WPBakery column links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add link option to columns. | |
add_action( 'vc_after_init', function() { | |
vc_add_param( 'vc_column', array( | |
'type' => 'textfield', | |
'param_name' => 'link', | |
'heading' => esc_html__( 'Link', 'total'), | |
) ); | |
} ); | |
// Insert link into columns. | |
add_filter( 'wpex_hook_vc_column_inner_top', function( string $content, array $atts ) { | |
// Don't add links in the front-end editor as this can break things. | |
if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) { | |
return $content; | |
} | |
// Insert link. | |
if ( ! empty( $atts['link'] ) ) { | |
$link_safe = esc_url( $atts['link'] ); | |
$content .= "<a href='{$link_safe}' class='wpex-absolute wpex-block wpex-inset-0'></a>"; | |
} | |
// Return hook content. | |
return $content; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment