I have this code in a plugin
class DashboardCustomizer {
public function __construct()
{
add_action( 'admin_enquque_scripts', array( $this, 'load_custom_scripts' ) );
}
/*
* Carico dipendenze CSS e JS da CDN
*/
public function load_custom_scripts()
{
wp_enqueue_style(
'bs-css',
'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css',
array(),
false,
);
wp_register_style( 'bs-css' );
wp_enqueue_script(
'popper-js',
'https://unpkg.com/@popperjs/core@2',
array(),
false,
false
);
wp_register_script( 'popper-js' );
wp_enqueue_scritp(
'bs-js',
'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js',
array( 'popper-js' ),
false,
false
);
wp_register_script( 'bs-js' );
}
}
new DashboardCustomizer();
I'm trying to load some scripts from CDN but when I inspect the page it seems that they are not loaded. Is there something wrong with the code?
plugins_url(__FILE__)correct?add_action( 'admin_enquque_scripts'is incorrect, for example, that's not the name of the action. It should beadmin_enqueue_scripts- WordPress has no idea what to do with your action. You also havewp_enqueue_scritp, thetand thepare in the wrong order.