<?php
/**
 * @package Title_Cutter
 * @author Samuel Huron
 * @version 0.1
 */
/*
Plugin Name: Text Cutter
Plugin URI: http://www.iri.centrepompidou.fr
Description: This is just a simple thing to cut the title visible in navigation and in the page of post.
Author: Samuel Huron 
Version: 0.1
Author URI: http://www.cybunk.com/
*/

function Expert_without_BR ($content){

	$symbole= "<br/>";

	return (str_replace($symbole, "", $content)." YO");
}

function Title_Cutter($content){
	
	$length = 200;
	$symbole= "<!-- cut -->";

	if(!is_single(get_the_ID())){
		
		$lastpos = strrpos($content,$symbole); 	
		
		if($lastpos!=FALSE){
			return (substr($content, 0, $lastpos)."");
			
		} else {
			if(strlen($content)>$length){
				return (substr($content, 0, $length)."[...]");
			} else {
				return ($content);
			}
		}
	}else{
		return ("".str_replace($symbole, "", $content));
	}
	
}

// Cut 
add_action ( 'the_title', 'Title_Cutter');
//add_action ( 'the_excerpt', 'Expert_without_BR',1);

?>
