I am trying to prepend my a php template in wordpress into my wordpress login form.
They only way I can edit markup in the body of wordpess login is to prepend via jquery.
This is my php template load: <?php load_template_part('menu'); ?>
This is my load template filter that filters get_template_part();
...
// LOAD TEMPLATE PART
function load_template_part($template_name, $part_name=null) {
ob_start();
get_template_part($template_name, $part_name);
$var = preg_replace('/\s\s+/', "", ob_get_contents());
ob_end_clean();
return $var;
}
In this filter I am removing all spaces between elements using this... preg_replace('/\s\s+/', "", ob_get_contents());
I am then trying to append this template part using this jquery...
var menu = '<?php echo load_template_part('menu'); ?>';
$("body").prepend(menu);
But it gets a javascript syntax error because of line breaks in my php load_template_part string.
Can any one please help me either remove line breaks from the php string or suggest another method of getting my php block inside my body safely.
Outputted source: https://gist.github.com/jcranny/5363379
Thanks Josh