Skip to content

Instantly share code, notes, and snippets.

@matgargano
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matgargano/8853478 to your computer and use it in GitHub Desktop.
Save matgargano/8853478 to your computer and use it in GitHub Desktop.
function __construct() {
add_action( 'admin_print_scripts-widgets.php', function(){
if (is_admin()){ //test fails b/c the admin_print_scripts-widget.php is not aware that is_admin() is true...
wp_enqueue_style( 'spw-admin', plugins_url( 'css/' . 'spw-admin.min.css', dirname( __FILE__ ) ), false, 1 );
wp_enqueue_script( 'spw-admin', plugins_url( 'javascripts/' . 'spw-admin.min.js', dirname( __FILE__ ) ), array( 'jquery' ), 1, true );
}
} );
}
function testSpwScriptsLoaded() {
$this->assertFalse( wp_script_is( 'spw-admin' ) );
do_action( 'admin_print_scripts-widgets.php' );
$this->assertTrue( wp_script_is( 'spw-admin' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment