Skip to content

Instantly share code, notes, and snippets.

@timersys
Created November 16, 2015 12:31
Show Gist options
  • Select an option

  • Save timersys/2e44b5113658d4ab1965 to your computer and use it in GitHub Desktop.

Select an option

Save timersys/2e44b5113658d4ab1965 to your computer and use it in GitHub Desktop.
Add custom html or javascript in a popup by creating a shortcode
<?php
/**
* Creates a shortcode [popups-code] that will print some html or js code
* We use buffer to capture raw html so you can paste it normally
**/
function popup_custom_code_func( $atts ) {
$atts = shortcode_atts( array(
'foo' => 'no foo',
), $atts, 'bartag' );
ob_start();?>
<your html here>
<?php
$html = ob_get_contents();
ob_clean();
return $html;
}
add_shortcode( 'popups-code', 'popup_custom_code_func' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment