/** * adapted from https://github.com/stephenharris/Event-Organiser/blob/master/includes/event-organiser-utility-functions.php */ function eo_php2xdate($phpformat) { $php2xdate = array('Y' => 'yyyy', 'y' => 'yy', 'L' => '', 'o' => 'I', 'j' => 'd', 'd' => 'dd', 'D' => 'ddd', 'l' => 'dddd', 'N' => '', 'S' => 'S', 'w' => '', 'z' => '', 'W' => 'w', 'F' => 'MMMM', 'm' => 'MM', 'M' => 'MMM', 'n' => 'M', 't' => '', 'a' => 'tt', 'A' => 'TT', 'B' => '', 'g' => 'h', 'G' => 'H', 'h' => 'hh', 'H' => 'HH', 'u' => 'fff', 'i' => 'mm', 's' => 'ss', 'O' => 'zz ', 'P' => 'zzz', 'c' => 'u'); $xdateformat = ""; for ($i = 0; $i < myStrLen($phpformat); $i++) { //Handle backslash excape if ($phpformat[$i] == "\\") { $xdateformat .= "'" . $phpformat[$i + 1] . "'"; $i++; continue; } if (myIsset($php2xdate[$phpformat[$i]])) { $xdateformat .= $php2xdate[$phpformat[$i]]; } else { $xdateformat .= $phpformat[$i]; } } return $xdateformat; }
function convert_smilies($text, $wp_smiliessearch) { $output = ''; if (get_option('use_smilies') && !myEmpty($wp_smiliessearch)) { // HTML loop taken from texturize function, could possible be consolidated $textarr = myPregSplit('/(<.*>)/U', $text, -1, 1); // capture the tags as well as in between $stop = myCount($textarr); // loop stuff // Ignore proessing of specific tags $tags_to_ignore = 'code|pre|style|script|textarea'; $ignore_block_element = ''; for ($i = 0; $i < $stop; $i++) { $content = $textarr[$i]; $matches = []; // If we're in an ignore block, wait until we find its closing tag if ('' == $ignore_block_element && myPregMatch('/^<(' . $tags_to_ignore . ')>/', $content, $matches)) { $ignore_block_element = $matches[1]; } // If it's not a tag and not in ignore block if ('' == $ignore_block_element && myStrLen($content) > 0 && '<' != $content[0]) { // $content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); } // did we exit ignore block if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) { $ignore_block_element = ''; } $output .= $content; } } else { // return default text. $output = $text; } return $output; }