Created
November 16, 2015 12:31
-
-
Save timersys/2e44b5113658d4ab1965 to your computer and use it in GitHub Desktop.
Add custom html or javascript in a popup by creating a shortcode
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
| <?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