I am using the template_redirect action to redirect a user to a custom template which has no header, sidebar or footer (the intent is for it to be in an iframe as a dialog box). After I done the redirect though, I could not seem to get all the enqueued JS and CSS to list.
Here’s the code:
<?php
/**
* This theme file is accessed by template redirect
* No header, sidebar or footer
*/
?>
<!DOCTYPE html>
<head>
<title>Customize Product</title>
<?php wp_head()?>
</head>
<body>
<div id="container">
<div id="content" role="main">
<?php
/**
* Output the content of the template
*/
do_action('product_customize_display_customization_content');
?>
</div><!-- #content -->
</div><!-- #container -->
</body>
Edit: Here’s how I am including the JS
// bootstrap code, will refactor later as necessary
if (is_admin())
{
global $admin_class;
$admin_class = new product_customize_admin();
$admin_class->init_admin_actions();
$admin_class->init_ajax_actions();
add_action('admin_menu', 'init_admin_menu');
add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');
}
else
{
add_action('wp_head', 'include_frontend_scripts');
// setup frontend
global $frontend_class;
$frontend_class = new product_customize();
}
function include_frontend_scripts()
{
// preset scripts
wp_register_script('product-customize-preset', plugin_dir_url(__FILE__).'js/preset.js');
wp_enqueue_script('product-customize-preset');
}
Here’s the code for the template redirect
function theme_redirect()
{
global $wp;
$plugin_dir = dirname(__FILE__);
//echo '<pre>'.print_r($_GET, true).'</pre>';
// if we are doing product customization
if ($_GET['prod_cust_do_customize'] == 1)
{
$return_template = $plugin_dir.'/themefiles/customize_preset_page.php';
echo "template = $return_template";
$this->do_theme_redirect($return_template);
}
}
function do_theme_redirect($url)
{
include ($url);
exit();
}