Viewing 7 replies - 1 through 7 (of 7 total)
  • Could you provide a link to your site so I can look at it? Thanks!

    Thread Starter velikasha

    (@velikasha)

    Well, actually I can’t since the site hasn’t launched yet. But I’ve commented out those lines to make IE8 work. Chrome was rendering the page, but there was still an error in the console log. This error is blocking rendering in IE8 completely:

    The value of the property ‘jQuery’ is null or undefined, not a Function object

    referring to this code:

    <script type="text/javascript">
    /* <![CDATA[ */
    jQuery(document).ready(function () {
    	jQuery('a.no-lightbox').unbind('click');
    	jQuery('a.no-lightbox').off('click');
    	jQuery('a.no-lightbox').click(wp_gallery_custom_links_click);
    	jQuery('a.set-target').unbind('click');
    	jQuery('a.set-target').off('click');
    	jQuery('a.set-target').click(wp_gallery_custom_links_click);
    });
    function wp_gallery_custom_links_click() {
    	if(!this.target || this.target == '')
    		window.location = this.href;
    	else
    		window.open(this.href,this.target);
    	return false;
    }
    /* ]]> */
    </script>

    That script is before the jquery defined on the page; I attempted to add a defer attribute to the script tag, but that hasn’t resolved the issue. Have you looked at possibly using wp_enqueue_script and then set a dependency for jquery ?

    Thanks for looking into this.

    I’ve uploaded a modified version of the plugin with a wp_enqueue_script() for jquery in the plugin init here:

    https://www.fourlightsweb.com/temp/wp-gallery-custom-links.php.txt

    so please try that version and let me know if that fixes it for you – if so, I’ll release it as a bug fix.

    Thread Starter velikasha

    (@velikasha)

    I have attempted to use the updated code, but the error is still there.

    Try adding:

    https://www.fourlightsweb.com/temp/wp-gallery-custom-links.php.txt
    https://www.fourlightsweb.com/temp/wp-gallery-custom-links.js

    to the plugin folder and see if that works. I moved the javascript to its own file and enqueued it with jquery as a dependency.

    My fear is that if a lightbox script (and there are so many out there I don’t have a reliable way of accounting for all of them) runs after this plugin script, the lightbox click function will replace the plugin click function, and the link will open in a lightbox window. But I guess we’ll see how it goes.

    Thread Starter velikasha

    (@velikasha)

    Made it to work by slightly changing your code:

    wp_enqueue_script(
    			'wp-gallery-custom-links-js',
    			plugins_url( '/wp-gallery-custom-links.js', __FILE__ ),
    			array( 'jquery' ),
    			false,
    			true
    		);

    That error is gone now. Thanks for your help!

    okay cool, i’ll make that change (oops) and push it. thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: WP Gallery Custom Links] jQuery’ is closed to new replies.