$psg"; } /** * Scripturize a text string. * * @param text Original text to be scripturized. * @param version Translation of the scripture. * @return Scripturized text. */ function scripturize($text, $version=0) { $version = Scripturizer::get_version(); if ($version == '0') return $text; if (preg_match('/esv/i', $version)) { $title = 'English Standard Version Bible'; $link = 'http://www.gnpcb.org/esv/search/?go=Go&q='; } else { $title = 'Bible Gateway'; $link = "http://biblegateway.com/cgi-bin/bible?language=english&". "version=$version&passage="; } $callback = create_function('$match', "return Scripturizer::addLinkCallback(".'$match'.", '$link', '$title');"); $text = preg_split("/(|||<.+?>)/ms", $text, -1, PREG_SPLIT_DELIM_CAPTURE); $newtext = array(); foreach ($text as $chunk) { if (!preg_match('/<.*>/', $chunk)) { $chunk = Scripturizer::addLink($chunk, $callback); } $newtext[] = $chunk; } return implode('', $newtext); } } // If 'add_filter' function exists, then we assume that we are initialised as // a WordPress plugin. We will try to create a new global scope function, and // add it to filter main/comment content. if (function_exists('add_filter')) { function __scripturize($content) { return Scripturizer::scripturize($content); } add_filter('the_content', '__scripturize'); add_filter('comment_text', '__scripturize'); } ?>