Home > Software design >  For wp_register_style() and wp_register_script() do the handles need to be unique across both or jus
For wp_register_style() and wp_register_script() do the handles need to be unique across both or jus

Time:07-28

Does anybody know if the handles given to both wp_register_style and wp_register_script functions need to be unique across both of the functions or do they just need to be unique in their own function?

For example, is this code going to cause problems?

wp_register_style( 'bootstrap-twitter', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css', array(), '5.1.3');
wp_register_script( 'bootstrap-twitter' 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/js/bootstrap.bundle.min.js', array( 'jquery' ) '5.1.3');

wp_enqueue_style( 'bootstrap-twitter' );
wp_enqueue_script( 'bootstrap-twitter' );

I'm not finding any answer in the documentation or some searches online here for this. I might be having trouble just searching for it though.

CodePudding user response:

The handles of styles and scripts are kept in separate places in WordPress, so they don't collide with one another. Your code is fine.

  • Related