Twitter for Wordpress 1.9.7 by Ricardo González. Author: Alexander Hofbauer Author URI: http://derhofbauer.at/blog */ /* Copyright 2007 Ricardo González Castro (rick[in]jinlabs.com) * Copyright 2010 Alexander Hofbauer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ define('MAGPIE_CACHE_ON', 1); //2.7 Cache Bug define('MAGPIE_CACHE_AGE', 180); define('MAGPIE_INPUT_ENCODING', 'UTF-8'); define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); if (!class_exists("AJAXedTwitter")) { class AJAXedTwitter { public static function init() { // this will automatically add the MooTools Class "Twitter" to wp_head(); if (!is_admin()) wp_enqueue_script('ajaxed-twitter', self::plugin_path().'/js/Twitter.js'); } /** * Get Twitter messages */ public static function messages(array $options = array()) { include_once(ABSPATH.WPINC.'/rss.php'); $options = array_merge(array( 'username' => '', 'num' => 1, 'list' => false, 'update' => true, 'linked' => '#', 'hyperlinks' => true, 'twitter_users' => true, 'encode_utf8' => false, 'error_id' => '' ), $options); $options['error_id'] = ($options['error_id']) ? 'id="'.$options['error_id'].'"' : ''; $output = ''; $messages = fetch_rss('http://twitter.com/statuses/user_timeline/'.$options['username'].'.rss'); if ($options['list']) $output = ''; return $output; } private static function hyperlink($text) { // Props to Allen Shaw & webmancers.com // match protocol://address/path/file.extension?some=variable&another=asf% //$text = preg_replace("/\b([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)\b/i","$1", $text); $text = preg_replace( '/\b([a-zA-Z]+:\/\/[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&%#+$*!]*)\b/i', '$1', $text ); // match www.something.domain/path/file.extension?some=variable&another=asf% //$text = preg_replace("/\b(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)\b/i","$1", $text); $text = preg_replace( '/\b(?$1', $text ); // match name@address $text = preg_replace( '/\b([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})\b/i', '$1', $text ); //mach #trendingtopics. Props to Michael Voigt $text = preg_replace( '/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)#{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', '$1#$2$3 ', $text ); return $text; } private static function userlink($text) { $text = preg_replace( '/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', '$1@$2$3 ', $text ); return $text; } private static function plugin_path() { return '/'.path_join(PLUGINDIR, basename(dirname(__FILE__))); } }} if (class_exists("AJAXedTwitter")) { // initialize plugin add_action('init', array('AJAXedTwitter', 'init')); }