Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First point: that tutorial is based on an old version of WordPress; don't follow that one. Now:</p> <p>The handle you specify in <a href="http://codex.wordpress.org/Function_Reference/wp_register_script" rel="noreferrer">wp_register_script()</a> must be unique. You are reusing the same handle (fancybox) for all scripts; this won't work. Give each one a different handle, e.g. 'jquery-mousewheel', 'jquery-fancybox', 'jquery-fancybox-buttons', etc. Try to stick to established naming habits that WordPress uses, see <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress" rel="noreferrer">wp_enqueue_script() default scripts</a> for examples.</p> <p>If you want your scripts to be output in the footer, just say so in wp_register_script() (which you have); there is no need to use the wp_footer action. Styles should be output in the header anyway, not the footer.</p> <p>You can tell WordPress to register and enqueue scripts and stylesheets for output with one call each: <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="noreferrer">wp_enqueue_script()</a> and <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style" rel="noreferrer">wp_enqueue_style()</a>. There is no need to register, then enqueue, in your simple case.</p> <p>The best action hook for registering and enqueueing scripts is '<a href="http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts" rel="noreferrer">wp_enqueue_scripts</a>'. Try to only use that one except in special circumstances.</p> <p>Bonus points: where a script name already includes the version number, you can suppress the extra '?ver=nnn' that WordPress tacks on by passing null as the version string.</p> <p>And finally, <a href="http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri" rel="noreferrer">get_stylesheet_directory_uri()</a> doesn't take any arguments.</p> <p>NB: this gets your script working. One thing your linked tutorial does differently is only output your scripts conditionally, but there are better tutorials on that subject linked at the bottom of the wp_enqueue_scripts() manual page. First, get your site working!</p> <pre><code>class fancy{ static function init() { add_shortcode('lightbox', array(__CLASS__, 'handle_shortcode')); add_action('wp_enqueue_scripts', array(__CLASS__, 'wp_enqueue_scripts')); } static function handle_shortcode($atts) { self::$add_script = true; // actual shortcode handling here } static function wp_enqueue_scripts() { $base = get_stylesheet_directory_uri(); wp_enqueue_script('jquery-mousewheel', $base . '/js/jquery.mousewheel-3.0.6.pack.js', array('jquery'), null, true); wp_enqueue_script('jquery-fancybox', $base . '/js/jquery.fancybox.pack.js', array('jquery'), '1.0', true); wp_enqueue_script('jquery-fancybox-buttons', $base . '/js/jquery.fancybox-buttons.js', array('jquery-fancybox'), '1.0', true); wp_enqueue_script('jquery-fancybox-media', $base . '/js/jquery.fancybox-media.js', array('jquery-fancybox'), '1.0', true); wp_enqueue_script('jquery-fancybox-thumbs', $base . '/js/jquery.fancybox-thumbs.js', array('jquery-fancybox'), '1.0', true); wp_enqueue_style('jquery-fancybox', $base . '/css/jquery.fancybox.css', false, '1.0', true); wp_enqueue_style('jquery-fancybox-buttons', $base . '/css/jquery.fancybox-buttons.css', array('jquery-fancybox'), '1.0', true); wp_enqueue_style('jquery-fancybox-thumbs', $base . '/css/jquery.fancybox-thumbs.css', array('jquery-fancybox'), '1.0', true); } } fancy::init(); </code></pre> <p>PS: I suspect that jquery.fancybox.pack.js is a packed (i.e. minified) version of jquery.fancybox.js, so use that one as 'jquery-fancybox' if it is; you don't need both.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload