Skip to content

Instantly share code, notes, and snippets.

@geoffreycrofte
Forked from stephanie-walter/gist:5014232
Last active July 6, 2016 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffreycrofte/5014240 to your computer and use it in GitHub Desktop.
Save geoffreycrofte/5014240 to your computer and use it in GitHub Desktop.
Add a Branch shortcode to WordPress
// Adds [branch id="" noscript="branch-url"] shortcode in WordPress
if ( ! function_exists( 'branch_embedded' ) ) {
function branch_embedded( $atts ) {
$atts = shortcode_atts( array( 'id' => '', noscript=> '' ), $atts );
$output = '<script type="text/javascript" src="http://embed-script.branch.com/assets/embed/embed.m.js?body=0" data-branch-embedid="' . esc_attr( $atts['id'] ) . '" ></script>';
if( $atts['noscript'] !== "" ) {
$output .= "<noscript>Visit <a href="' . esc_attr( $atts['noscript'] ) . '">this branch</a></noscript>";
}
return $output ;
}
add_shortcode('branch', 'branch_embedded');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment