我使用template\\u redirect操作将用户重定向到没有页眉、边栏或页脚的自定义模板(目的是将其作为对话框放在iframe中)。在我完成重定向之后,我似乎无法列出所有排队的JS和CSS。
代码如下:
<?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>
编辑:下面是我如何包括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\');
}
下面是模板重定向的代码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();
}