Recent Tweets Widget
[resolved] 'Cannot redeclare class OAuthException' (8 posts)

  1. padcreative
    Posted 2 years ago #

    Hi there

    I'm getting this error when I use your plugin. I've tried disabling all other plugins, but message still appears.

    Fatal error: Cannot redeclare class OAuthException in /home/sites/mydomainname.co.uk/public_html/wp-content/plugins/recent-tweets-widget/twitteroauth.php on line 15

    mydomainname.co.uk replacing the actual domain name.



  2. ThemePrince
    Posted 2 years ago #


    It means that the class OAuthException already exists. Maybe you're using a theme which already uses this class?

  3. padcreative
    Posted 2 years ago #

    Thanks for getting back to me.

    I'm also getting the error with the Twenty Twelve theme and all plug-ins bar yours deactivated.

  4. sakib000
    Posted 2 years ago #

    This possible happens when you place 2 instances of widget on same page.

    Open recent-tweets.php file and move this code to the top of the file right after '<?' (before registering the class):

    function convert_links($status,$targetBlank=true,$linkMaxLen=250){
    	// the target
    		$target=$targetBlank ? " target=\"_blank\" " : "";
    	// convert link to url
    		$status = preg_replace("/((http:\/\/|https:\/\/)[^ )
    ]+)/e", "'<a href=\"$1\" title=\"$1\" $target >'. ((strlen('$1')>=$linkMaxLen ? substr('$1',0,$linkMaxLen).'...':'$1')).'</a>'", $status);
    	// convert @ to follow
    		$status = preg_replace("/(@([_a-z0-9\-]+))/i","<a href=\"http://twitter.com/$2\" title=\"Follow $2\" $target >$1</a>",$status);
    	// convert # to search
    		$status = preg_replace("/(#([_a-z0-9\-]+))/i","<a href=\"https://twitter.com/search?q=$2\" title=\"Search $1\" $target >$1</a>",$status);
    	// return the status
    		return $status;
    //convert dates to readable format
    function relative_time($a) {
    	//get current timestampt
    	$b = strtotime("now");
    	//get timestamp when tweet created
    	$c = strtotime($a);
    	//get difference
    	$d = $b - $c;
    	//calculate different time values
    	$minute = 60;
    	$hour = $minute * 60;
    	$day = $hour * 24;
    	$week = $day * 7;
    	if(is_numeric($d) && $d > 0) {
    		//if less then 3 seconds
    		if($d < 3) return "right now";
    		//if less then minute
    		if($d < $minute) return floor($d) . " seconds ago";
    		//if less then 2 minutes
    		if($d < $minute * 2) return "about 1 minute ago";
    		//if less then hour
    		if($d < $hour) return floor($d / $minute) . " minutes ago";
    		//if less then 2 hours
    		if($d < $hour * 2) return "about 1 hour ago";
    		//if less then day
    		if($d < $day) return floor($d / $hour) . " hours ago";
    		//if more then day, but less then 2 days
    		if($d > $day && $d < $day * 2) return "yesterday";
    		//if less then year
    		if($d < $day * 365) return floor($d / $day) . " days ago";
    		//else return more than a year
    		return "over a year ago";
  5. JimExp
    Posted 2 years ago #

    I'm having a similar problem.
    I'm getting this error:

    Fatal error: Cannot redeclare convert_links() (previously declared in /home/users/spaclftp/mydomain.nl/test/wp-content/plugins/recent-tweets-widget/widget.php:87) in /home/users/spaclftp/mydomain.nl/test/wp-content/plugins/recent-tweets-widget/widget.php on line 87

    So i tried adding this code to the recent-tweets.php file but that didn't work form me...

    Thanks, Jim

  6. ThemePrince
    Posted 2 years ago #


    In the upcoming version I added a function_exists() code to check for existing functions. I also added a special naming for these functions to avoid function name dupes.

    Next version is coming real soon!

  7. froduss
    Posted 1 year ago #

    I'm getting the same issue as well:

    Cannot redeclare class OAuthException .../twitteroauth.php on line 15

    I'm fairly perplexed because it worked initially, then last night it stopped working after a few hours.

    There are no multiple instances running, and I've switched themes as well with no luck. I've even reset my keys, recreated tokens, and even tried a different Twitter username. Any idea?

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    @froduss: If you require assistance then, as per the Forum Welcome, please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Recent Tweets Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic