web/wp-content/plugins/Text_Cutter.php
branchwordpress
changeset 123 561aa6d282f6
child 132 4d4862461b8d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/wp-content/plugins/Text_Cutter.php	Mon Feb 01 09:51:57 2010 +0000
@@ -0,0 +1,52 @@
+<?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);
+
+?>