Skip to content
Browse files

Serialize wp_head and wp_footer using JSON

  • Loading branch information...
1 parent badd00d commit da7e677c3075f6313c4a505e212bd8121f0d8e26 @wayoutmind committed May 30, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 templates/meta.php
View
10 templates/meta.php
@@ -3,16 +3,18 @@
* Supply metadata
*/
-/** Header */
+/** Header
+ */
ob_start();
wp_head();
-$header = preg_replace(array('/\s{2,}/', '/[\t\n]/'), '|', ob_get_contents());
+$header = json_encode(ob_get_contents(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
ob_end_clean();
-/** Footer */
+/** Footer
+ */
ob_start();
wp_footer();
-$footer = preg_replace(array('/\s{2,}/', '/[\t\n]/'), '|', ob_get_contents());
+$footer = json_encode(ob_get_contents(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
ob_end_clean();
/** Return HTTP headers

2 comments on commit da7e677

@zslabs
zslabs commented on da7e677 May 30, 2012

Getting some odd output on page-load:

"\u003Cscript type=\u0027text\/javascript\u0027 src=\u0027\/roots-ajax\/wp-content\/themes\/roots-child\/js\/vendor\/pjax\/jquery.pjax.js?ver=3.3.2\u0027\u003E\u003C\/script\u003E\n\u003Cscript type=\u0027text\/javascript\u0027 src=\u0027\/roots-ajax\/wp-content\/themes\/roots-child\/js\/vendor\/crackle\/crackle.min.js?ver=3.3.2\u0027\u003E\u003C\/script\u003E\n\u003Cscript type=\u0027text\/javascript\u0027 src=\u0027\/roots-ajax\/wp-content\/themes\/roots-child\/rp.min.js?ver=3.3.2\u0027\u003E\u003C\/script\u003E\n\u003Cscript type=\u0027text\/javascript\u0027 src=\u0027\/roots-ajax\/wp-content\/themes\/roots-child\/js\/main.js?ver=3.3.2\u0027\u003E\u003C\/script\u003E\n"

I'm assuming it has something to do with the latest commit. Also - wp_head() and wp_footer() do not seem to be loading scripts properly at the moment (going back to the Gravity Forms example). Thanks!

@wayoutmind
Owner

05c37d9 and 5f58997 should bring this up to speed

Please sign in to comment.
Something went wrong with that request. Please try again.