/** * Sets the global settings required by the JSON API: * * @access public * @return void */ function confitSetSettings() { $plugin_url = trailingslashit(WP_PLUGIN_URL) . '/json-rest-api/wp-api'; //register the global object needed by the api & confiture: $settings = array('root' => esc_url_raw(get_json_url()), 'nonce' => wp_create_nonce('wp_json'), 'api' => esc_url_raw($plugin_url), 'theme' => esc_url_raw(confitUrl('theme', false)), 'scripts' => esc_url_raw(confitUrl('scripts', false)), 'vendors' => esc_url_raw(confitUrl('vendors', false))); echo '<script>'; echo 'var Confit_Settings = ' . json_encode($settings) . ';'; echo 'var WP_API_Settings = Confit_Settings;'; echo '</script>'; }
<!-- load everything in the #yield wrapper --> <div class="wrapper" id="yield"></div> <?php //print js vars: confitSetSettings(); wp_footer(); ?> <!-- script loading via requirejs --> <script data-main="<?php confitUrl('config'); ?> " src="<?php confitUrl('requirejs'); ?> "></script> <!-- analytics --> <script> (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]= function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date; e=o.createElement(i);r=o.getElementsByTagName(i)[0]; e.src='//www.google-analytics.com/analytics.js'; r.parentNode.insertBefore(e,r)}(window,document,'script','ga')); ga('create','UA-XXXXX-X','auto');ga('send','pageview'); </script> </body> </html>