Finnish Quotes. Author: Николай Бачийски Version: 0.1 Author URI: http://debian.fmi.uni-sofia.bg/~nb/ */ class bg_quotes { function bg_quotes() { global $wp_filter; // go through all filters and add our quote-fixer after wptexturize foreach ($wp_filter as $tag => $filter) { $found_wptxt = 0; foreach ($wp_filter[$tag] as $priority => $functions) { if (!is_null($functions)) { foreach ($functions as $function) { if ("wptexturize" == $function['function']) { add_filter($tag, array(&$this, 'bgtexturize'), $priority+1); $found_wptxt = 1; break; } } } } if ($found_wptxt) continue; } } /* Goes after wptexturize and changes the quotes to match the Bulgarian style Most of the code of this function is taken from Kimmo Suominen's 'Finnish Quotes' plugin and can be found here: http://kimmo.suominen.com/sw/finquote/finquote.php */ function bgtexturize($text) { $output = ''; // Capture tags and everything inside them $tarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // loop stuff $stop = count($tarr); $next = true; for ($i = 0; $i < $stop; $i++) { $curl = $tarr[$i]; if (isset($curl{0}) && '<' != $curl{0} && $next) { // wptexturize uses the combination: “ some text ” // the Bulgarian style quotes are: „ the same text “ $curl = str_replace('“', '„', $curl); $curl = str_replace('”', '“', $curl); } elseif (strstr($curl, '