WordPress.org

Support

Support » Plugins and Hacks » Slimbox » Properly enqueue scripts

Properly enqueue scripts

  • Hello,

    Thank you for plugin but consider update a way for enqueue scripts and styles.

    function slimbox_enqueue() {
    	wp_enqueue_script('jquery');
    
    	wp_enqueue_script('jquery.slimbox', WP_PLUGIN_URL."/slimbox/javascript/jquery.slimbox.js", array('jquery'), '2.03');
    
    	wp_enqueue_style('jquery.slimbox', WP_PLUGIN_URL."/slimbox/stylesheets/jquery.slimbox.css", false, '2.03');
    
    		add_action('wp_head', 'slimbox');
    	}
    add_action('wp_enqueue_scripts', 'slimbox_enqueue');

    I am PHP noob but i don’t want violate any Notifications by wordpress.

    Thanks

    http://wordpress.org/extend/plugins/slimbox/

Viewing 1 replies (of 1 total)
  • Just to elaborate on this issue:

    If you have warnings switched on, then WordPress complains about scripts not being enqueued at the ‘wp_enqueue_scripts’ hook and this stop the slimbox from working – you just get a darkened screen when the lighbox is activated.

    The patch is to replace

    if (!is_admin()) :
    	wp_enqueue_script('jquery');
    	wp_enqueue_script('jquery.slimbox', WP_PLUGIN_URL."/slimbox/javascript/jquery.slimbox.js", array('jquery'), '2.03');
    	wp_enqueue_style('jquery.slimbox', WP_PLUGIN_URL."/slimbox/stylesheets/jquery.slimbox.css", false, '2.03');
    	add_action('wp_head', 'slimbox');
    endif;

    By

    function slimbox_enqueue_scripts() {
    	wp_enqueue_script('jquery');
    	wp_enqueue_script('jquery.slimbox', WP_PLUGIN_URL."/slimbox/javascript/jquery.slimbox.js", array('jquery'), '2.03');
    	wp_enqueue_style('jquery.slimbox', WP_PLUGIN_URL."/slimbox/stylesheets/jquery.slimbox.css", false, '2.03');
    	add_action('wp_head', 'slimbox');
    }
    
    if (!is_admin()) :
    	add_action('wp_enqueue_scripts','slimbox_enqueue_scripts');
    endif;
Viewing 1 replies (of 1 total)
  • The topic ‘Properly enqueue scripts’ is closed to new replies.
Skip to toolbar