Last active
May 12, 2020 21:50
-
-
Save westonruter/6880918d45deb39c89e17f3b76583521 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Plugin Name: Bad Shortcode | |
* Description: Shortcode which outputs a script. | |
* Version: 0.7 | |
* Plugin URI: https://gist.github.com/westonruter/6880918d45deb39c89e17f3b76583521 | |
* Author: Weston Ruter | |
*/ | |
namespace Bad\Shortcode; | |
add_action( | |
'wp_enqueue_scripts', | |
function () { | |
wp_register_script( 'bad-shortcode', home_url( '/bad-shortcode.js' ), [ 'jquery' ], '1', true ); | |
} | |
); | |
function shortcode() { | |
wp_enqueue_script( 'bad-shortcode' ); | |
return '<script>document.write("Bad shortcode!!!");</script><noscript>Bad shortcode fallback!</noscript>'; | |
} | |
\add_shortcode( 'bad', __NAMESPACE__ . '\shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment