• I’m using the lightbox balupton plugin – http://wordpress.org/extend/plugins/jquery-lightbox-balupton-edition/

    It works great, but it loads the javascript on every single page instead of just the specific pages that use this lightbox. The main file in this plugin is a ‘jquery-lightbox.php’ file which has this code:

    <?php
    
    if (!class_exists("jQueryLightbox")) {
    
      class jQueryLightbox {
    
        function jQueryLightbox()
    
        {
    
          if (is_admin() || !function_exists('plugins_url')) return;
    
          global $wp_version;
    
          $path = plugins_url('/jquery-lightbox-balupton-edition/js/');
    
          if (version_compare($wp_version, '2.8', '<')) {
    
            wp_deregister_script('jquery');
    
            wp_enqueue_script('jquery', $path.'jquery-1.3.2.min.js', false, '1.3.2');
    
          }
    
          wp_enqueue_script('jquery-lightbox', $path.'jquery.lightbox.min.js?ie6_upgrade=false&auto_resize=false', array('jquery'), '1.3.7');
    
          wp_enqueue_script('jquery-lightbox-plugin', $path.'jquery.lightbox.plugin.min.js', array('jquery', 'jquery-lightbox'), '1.0');
    
          add_filter('attachment_link', array(&$this, 'FixLink'), 10, 2);
    
        }
    
        function FixLink() {
    
          $post = get_post($id);
    
          if (substr($post->post_mime_type, 0, 6) == 'image/')
    
            return wp_get_attachment_url($id);
    
          else
    
            return $link;
    
        }
    
      }
    
    }
    
    if (class_exists("jQueryLightbox")) {
    
      //$jQueryLightbox = new jQueryLightbox();
    
      add_action('plugins_loaded', create_function('', 'global $jQueryLightbox; $jQueryLightbox = new jQueryLightbox();'));
    
    }
    
    ?>

    Anyone know how to modify this file in order to make the javascript load only on the pages I want it to?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Anyone know how to modify this php file?’ is closed to new replies.