Skip to content

Instantly share code, notes, and snippets.

@MjHead
Created September 25, 2017 14:55
Show Gist options
  • Save MjHead/ee07616badc10e07f2862f5f53a19ce0 to your computer and use it in GitHub Desktop.
Save MjHead/ee07616badc10e07f2862f5f53a19ce0 to your computer and use it in GitHub Desktop.
add_filter( 'shortcode_atts_vc_btn', '__tm_vc_button_macros', 10, 3 );
function __tm_vc_button_macros( $out, $pairs, $atts ) {
if ( ! isset( $out['link'] ) ) {
return $out;
}
$link = $out['link'];
if ( false === strpos( $link, '__home_url__' ) ) {
return $out;
}
$home_url = esc_url( home_url( '/' ) );
$home_url = untrailingslashit( $home_url );
$home_url = preg_replace( '/http[s]?:\/\//', '', $home_url );
$out['link'] = str_replace( '__home_url__', $home_url, $link );
return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment