您可以使用admin_*/wp_print_scripts
挂钩或admin_*/wp_print_styles
钩样式挂钩位于打印脚本挂钩之前,因此它可能比只使用优先级0
对于*_print_scripts
钩子(可能有一个函数的名称在优先级的前面被钩住了0
).
function wpse61635_remove_all_scripts()
{
global $wp_scripts;
$leave_alone = array(
// Put the scripts you don\'t want to remove in here.
);
foreach ( $wp_scripts->queue as $handle )
{
// Here we skip/leave-alone those, that we added above ↑
if ( in_array( $handle, $leave_alone ) )
continue;
$wp_scripts->remove( $handle );
}
}
add_action( \'wp_print_styles\', \'wpse61635_remove_all_scripts\', 0 );