Skip to content

Instantly share code, notes, and snippets.

@jberndsen
Created March 8, 2017 17:14
Show Gist options
  • Save jberndsen/5b997a1d9e05512a8a500c061837adb5 to your computer and use it in GitHub Desktop.
Save jberndsen/5b997a1d9e05512a8a500c061837adb5 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Tools Loader
Description: A plugin to load project-specific AngularJS snippets (mini apps) using shortcodes.
Version: 0.1 alpha
Author: Jeroen Berndsen
Author URI: http://www.jberndsen.nl
*/
// load requirejs
function init_requirejs() {
echo '<script type="text/javascript" src="/assets/scripts/require.js" data-main="/assets/scripts/main"></script>';
}
add_action('wp_head', 'init_requirejs');
// [tool name="funnel"]
function sc_tool($atts, $content = null) {
// extract supplied params in vars
extract(shortcode_atts(array(
'name' => 'empty',
'location' => '/tools',
), $atts));
// return the shortcode html output
return "<div data-ng-include=\"'{$location}/{$name}/{$name}.html'\"></div>";
}
add_shortcode('tool', 'sc_tool');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment