首先,您试图取消注册太晚了。您需要使用wp_enqueue_scripts
, 而不是wp_print_scripts
.
其次,您只需向wp_deregister_script()
对于每个需要注销的脚本:
<?php
add_action( \'wp_enqueue_scripts\', \'my_deregister_javascript\', 100 );
function my_deregister_javascript() {
if ( !is_page(array(\'order\', \'shopping-cart\', \'checkout\') ) ) {
wp_deregister_script( \'tcp_scripts\' );
// If you need to deregister more scripts when
// this same conditional is true, just add them here
wp_deregister_script( \'some-script\' );
wp_deregister_script( \'some-other-script\' );
}
// If you need to deregister other scripts generally,
// just do so here, outside the conditional:
wp_deregister_script( \'some-third-script\' );
wp_deregister_script( \'some-fourth-script\' );
}
?>