• Resolved pander

    (@pander)


    Using the WP TWitter Feeds widget more than once results in the following error:

    [Sun May 11 19:51:15.768560 2014] [:error] [pid 27125] [client xx.xx.xx.xx:48052] PHP Fatal error: Cannot redeclare twitter_time_diff() (previously declared in /var/www/xx.xx/wp-content/plugins/wp-twitter-feeds/controller/twitter_widget.class.php:226) in /var/www/xx.xx/wp-content/plugins/wp-twitter-feeds/controller/twitter_widget.class.php on line 226, referer: https://xx.xx/

    https://www.ads-software.com/plugins/wp-twitter-feeds/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Fatal error when using this plugin in more than one widget:
    Cannot redeclare twitter_time_diff()

    The function is being declared twice when multiple instances of the widget are loaded.

    Go to line 226 in twitter_widget.class.php in the controller folder and wrap the twitter_time_diff function with

    if(!function_exists('twitter_time_diff')){ }

    so you have

    if(!function_exists('twitter_time_diff')){
    	function twitter_time_diff( $from, $to = '' ) {
    		$diff = human_time_diff($from,$to);
    		$replace = array(
    			' hour' => 'h',
    			' hours' => 'h',
    			' day' => 'd',
    			' days' => 'd',
    			' minute' => 'm',
    			' minutes' => 'm',
    			' second' => 's',
    			' seconds' => 's',
    		);
    		return strtr($diff,$replace);
    	}
    }
    Plugin Author Team Startbit

    (@vivacityinfotechjaipur)

    Hi,

    The issue has now been resolved.Now you can add the widget multiple times in the sidebar.

    I am putting it out as a bug fix in the latest version 1.4 .
    So Please update your plugin to get it fixed.

    If you still have any issues after updating the plugin, Please let me know.

    ——————————————————–
    Please do give 5 start Rating if you get your issue fixed

    Thanks

    Thanks. Now I get this error with the second widget:
    Warning: Invalid argument supplied for foreach() in xxx\wp-content\plugins\wp-twitter-feeds\controller\twitter_widget.class.php on line 266

    Edit: this error occurs with a specific Twitter account. One out of 10 times it shows the tweets, 9 out of 10 I get the error.

    Anyway, the solution is this (posted by dariogene):

    In twitter_widget.class.php change:
    if(false === ($tweets = get_transient($transName) ) ) {
    to this
    if(false === ($tweets = unserialize(base64_decode(get_transient($transName))) ) ) {
    and then change:
    set_transient($transName, $tweets, 60 * $timeto_store);
    to this
    set_transient($transName, base64_encode(serialize($tweets)), 60 * $timeto_store);

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can't use widget twice’ is closed to new replies.