is\\u widget\\u active是您想要的,例如。
function sidedish_slide_script() {
wp_register_script(\'add-sd-js\', get_template_directory_uri() . \'/form-slider/jquery-1.8.2.min.js\', array(\'jquery\'),\'null\', true );
wp_register_script(\'add-sd-custom\', get_template_directory_uri() . \'/form-slider/formslider.js\', array(\'jquery\'),\'null\', true );
wp_register_style(\'add-sd-css\',get_stylesheet_directory_uri() . \'/form-slider/styles.css\', \'\',\'\',\'screen\' );
if ( is_active_widget( false, \'widget_id\', $this->id_base, true ) ) {
wp_enqueue_script (\'add-sd-js\');
wp_enqueue_script (\'add-sd-custom\');
wp_enqueue_style (\'add-sd-css\');
}
}
add_action(\'wp_enqueue_scripts\',\'sidedish_slide_script\');
https://codex.wordpress.org/Function_Reference/is_active_widget