Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active May 12, 2020 21:50
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 westonruter/6880918d45deb39c89e17f3b76583521 to your computer and use it in GitHub Desktop.
Save westonruter/6880918d45deb39c89e17f3b76583521 to your computer and use it in GitHub Desktop.
<?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