WordPress.org

Ready to get started?Download WordPress

Forums

YOURLS: WordPress to Twitter
small change to prevent JS error (1 post)

  1. sboisvert
    Member
    Posted 2 years ago #

    on 1.5.4 With a custom post type that has no title even if the short url is unchecked yourls_update_count() will still fire and since jQuery('#titlewrap #title').val() is undefined and .length is called on it Firefox doesn'T like that and stops parsing JS for other things, it leaves a uge gap at the top of the page.
    Adding an if to the function fixes this. Here is the function with the if statement:

    function yourls_update_count() {
    	if (jQuery('#titlewrap #title').val()){
    		var len = 140 - jQuery('#titlewrap #title').val().length;
    		jQuery('#yourls_count').html(len);
    		jQuery('#yourls_count').removeClass();
    		if (len < 60) {jQuery('#yourls_count').removeClass().addClass('len60');}
    		if (len < 30) {jQuery('#yourls_count').removeClass().addClass('len30');}
    		if (len < 15) {jQuery('#yourls_count').removeClass().addClass('len15');}
    		if (len < 0) {jQuery('#yourls_count').removeClass().addClass('len0');}
    	}
    }

    http://wordpress.org/extend/plugins/yourls-wordpress-to-twitter/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic