Where is the right place to register/enqueue scripts & styles

I am using WordPress 3.1.4 by now. I am confused with where (which hook) do I use: to register and/or enqueue scripts and styles on front- and back-ends? Questions: Which are right hooks to use? All front end register/enqueue scripts/styles in init? Why is there no admin_print_styles-{xxx}? 1 Why registering and queuing properly matters it … Read more

When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()?

I’m having trouble understanding when you need to use wp_register_script(). Currently, I just use something like: add_action( ‘admin_enqueue_scripts’, array( $this, ‘enqueue’ ) ); function enqueue() { $handle=”some-handle”; $js=”http://example.com/my.js”; wp_register_script( $handle, $js ); wp_enqueue_script( $handle ); } I’ve done a lot of reading (Codex, blogs, etc.), but can’t quite understand when I should register first, or … Read more

How do I Enqueue styles/scripts on Certain /wp-admin Pages?

I have two simple functions that load stuff using wp_enqueue_style() and wp_enqueue_script(), something like these: function admin_custom_css() { wp_enqueue_style( ‘stylesheet_name’, ‘stylesheet.css’) }; function admin_custom_js { wp_enqueue_script( ‘javascript_file’, ‘script.js’) }; … and a few admin pages, created with add_menu_page() and add_submenu_page() function my_menu() { add_menu_page(‘Page 1’, ‘bar’, ‘something’, ‘else’, ‘foo’); add_submenu_page( ‘theme_menu’, ‘Subpage 1’, ‘Subpage’, ‘something’, … Read more

Enqueue Scripts / Styles when shortcode is present

What is the idea way to register/enqueue scripts and/or styles for use in plugins? I recently made a plugin simple plugin to add the user avatar/gravatar with a shortcode. I have different style options for displaying the avatar (square, round, etc.) and decided to put the css directly in the shortcode itself. However, I realize … Read more