Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter sakib000

    (@sakib000)

    Convert_link() and relative_time() are the functions located in recent-tweets.php file. Function code as of version 1.0.6 is:

    //convert links to clickable format
    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=\"https://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";
    	}
    }

    You need to move these function code out of the tp_widget_recent_tweets class.

    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=\"https://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";
    	}
    }

    Hello,

    First of all, you also need to place twitteroauth.php in the same directory where recent-tweets.php file is included.

    Secondly, open recent-tweets.php and replace widget registration code with this (code is located at bottom of file)

    // register	widget
    function register_tp_twitter_widget(){
    	register_widget('tp_widget_recent_tweets');
    }
    add_action('widgets_init', 'register_tp_twitter_widget');

    You may also need to replace whole construct function with this code:

    function tp_widget_recent_tweets()
    		{
    			$widget_ops = array('classname' => 'tweets', 'description' => '');
    
    			$control_ops = array('id_base' => 'tweets-widget');
    
    			$this->WP_Widget('tweets-widget', 'Twitter tweets', $widget_ops, $control_ops);
    		}

    Forum: Fixing WordPress
    In reply to: menu item limit

    If anyone is still searching. I suppose this solution is for php 5.3 onwards.

    Open php.ini file and add this line

    max_input_vars = 9000

    Now you should be able to add more menu items.

    Thread Starter sakib000

    (@sakib000)

    thanks moshu

Viewing 5 replies - 1 through 5 (of 5 total)