Take the 2-minute tour ×  I have a WordPress plugin, and I must
load scripts from my plugin to the front of the site.  class
My_Plugin {  function __construct()
add_action('admin_menu', array(&$this, 'add_submenu'));
add_action('admin_init', array(&$this, 'admin_init'))   function
load_my_scripts(){     wp_enqueue_script('script',
'js/myscript.js');  I would like to load my script, so using the
right hook which will be able to add the script into all the
page of the site.  I've already tried with
add_action('wp_head', array(&$this, 'load_my_scripts'));
add_action('init', array(&$this, 'load_my_scripts'));  etc, ...
but I don't find any solution... Could you help me please ?
share|improve this question  2 Answers 2  up vote 2 down vote
accepted  Use wp_enqueue_scripts and admin_enqueue_scripts
actions to enqueue your scripts:  // for front end
add_action('wp_enqueue_scripts', array(&$this,
'load_my_scripts')); // for back end
add_action('admin_enqueue_scripts', array(&$this,
'load_my_scripts'));  A