if (typeof jQuery == 'function') { jQuery.twitter = { getTweets: function(el, options) { if (options.retries < 0) return; options.retries--; var existing = el.children('ul.twitter'); if (existing.length != 0) existing.remove(); jQuery.ajax({ url: options.url, error: function() { jQuery.twitter.getTweets(el, options); }, success: function(data) { data = jQuery(data); if (data.attr('id') == options.errorID) { jQuery.twitter.getTweets(el, options); } else { if (options.animate) data.css('display', 'none'); el.append(data); if (options.animate) data.fadeIn(800); } } }); } } jQuery.fn.twitter = function(options) { options = jQuery.extend({ url: null, retries: 0, animate: false, errorID: 'twitter-error', autostart: true }, options); jQuery.twitter.retries = options.retries; jQuery.twitter.getTweets(this, options); return this; }; jQuery(document).ready(function() { jQuery('#ajaxed-twitter-for-wordpress') //.css('opacity', 0) .twitter({ url: 'http://www.watermind.cn/wp-content/plugins/ajaxed-twitter-for-wordpress/request/tweets.php', errorID: 'twitter-error', retries: 2, animate: true }) ; }); } // end check if jQuery exists