<?php
/*
Plugin Name: text2html-wordpress
Plugin URI: http://www.tenman.info/
Description:text2html
Version: 1
Author:akio tenman
Author URI: http://www.tenman.info/
*/

/* wp-includes/formatting.php
 * pタグをwordpress で　自動付与し内容に、許可を取り消す。
 *---------------------------------------------------------*/
unset($allowedposttags['p']); 
remove_filter ('the_content',  'wpautop');
remove_filter ('the_content',  'wptexturize');

add_filter('the_content','apply');
add_filter('the_excerpt','apply');
add_filter('the_content_rss','apply');

add_filter ('the_content',  'wpautop');
add_filter ('the_content',  'wptexturize');


function apply($text){

	$text2html_url 		= WP_PLUGIN_URL."/text2html/";
	$text2html_dir_path = WP_PLUGIN_DIR."/text2html/";
	//$text 			= mb_convert_encoding($text,"UTF-8","auto");

/*	wp-includes/formatting.php
 *$static_characters 変換対象が記法に影響する場合は、元に戻す。
 *
 *eval>[date("ymd")]は、date(&#8221;ymd&#8221;)になり機能しません
 *<<は&lt; <に置換されますから、ワードプレスでは、記法として使えません。
 *---------------------------------------------------------*/
$text = str_replace(array("&#8212;","&#8211;","&#8221;","<p>","</p>","<br />","\:","&gt;"),array("---","--",'"',"","","\n",':','>'),$text);

		include_once($text2html_dir_path."scripts/trans.php");
	
		$change_text = file($text2html_url."data/change.txt");
		
		foreach($change_text as $loop){
		
			if(strpos($loop,'#')){
			list($before,$after) = explode('#',$loop);
				$a[] = $after;
				$b[] = $before;
			}
			
		}
		$text = str_replace($b,$a,$text);

		$use_web_option 		= true;
		$ini_array				= parse_ini_file($text2html_dir_path."scripts/html.ini", true);
		$ini_array ="";
		$benchmark 				= false;
		$source = false;
		$obj 					= new trans($text);
		$content_name 			= "main";
		$documents				= $obj->text2html();
		
		return $documents;

    }


?>