web/wp-content/plugins/Text_Cutter.php
author Anthony Ly <anthonyly.com@gmail.com>
Tue, 12 Mar 2013 18:21:39 +0100
changeset 206 919b4ddb13fa
parent 136 bde1974c263b
permissions -rw-r--r--
modification logo footer cccb

<?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);

?>