/** * Hooks into wp_enqueue_scripts to bring everything to the front-end. * * Loads in our main styles and scripts for the /Me front-end. * Uses wp_localize_script to pass along a few parameters to our Marionette app. * * @since 0.1.0 * * @uses wp_enqueue_scripts() * * @see localize_modules * */ function load_all_scripts() { global $wp_query; if (isset($wp_query->query_vars['me'])) { // This clears all current scripts and styles. Open to more elegant solutions here global $wp_scripts; global $wp_styles; $adminBar = $wp_styles->registered['admin-bar']; $openSans = $wp_styles->registered['open-sans']; $dashicons = $wp_styles->registered['dashicons']; $wp_scripts->registered = array(); $wp_styles->queue = array("admin-bar"); wp_enqueue_style('me_css', ME__PLUGIN_URL . 'app/css/style.css'); // wp_register_script( 'main', ME__PLUGIN_URL . '/app/dist/main.js', '', '', true); wp_register_script('main', ME__PLUGIN_URL . '/app/build/index.bundle.js', '', '', true); wp_localize_script('main', 'meVars', array('js_url' => ME__PLUGIN_URL . '/app/js', 'root_url' => wp_make_link_relative(home_url('/me')) . '/', 'api_url' => home_url('/wp-json/me/v1'), 'active_modules' => Me::localize_modules(), 'plugin_url' => ME__PLUGIN_URL)); wp_enqueue_script('main'); } }