function wpr_translate($text, $t1 = "", $t2 = "", $t3 = "") { if (empty($text)) { $return["error"]["module"] = "Translation"; $return["error"]["reason"] = "Translation Failed"; $return["error"]["message"] = __("Empty text given.", "wprobot"); return $return; } if (empty($t2)) { $return["error"]["module"] = "Translation"; $return["error"]["reason"] = "Translation Failed"; $return["error"]["message"] = __("No target language specified.", "wprobot"); return $return; } if ($t1 == $t2) { $return["error"]["module"] = "Translation"; $return["error"]["reason"] = "Translation Failed"; $return["error"]["message"] = __("Same languages specified.", "wprobot"); return $return; } // SAVE URLS preg_match_all('#\\href="(.*)"\\]#iU', $text, $matches, PREG_SET_ORDER); if ($matches) { //foreach($matches as $match) { // HREF = $match[1] //} } if ($t1 != 'no' & $t2 != 'no') { $transtext = wpr_gtrns($text, $t1, $t2); if (!empty($transtext["error"]["reason"])) { return $transtext; } } if ($t1 != 'no' & $t2 != 'no' & $t3 != 'no') { $transtext = wpr_gtrns($transtext, $t2, $t3); if (!empty($transtext["error"]["reason"])) { return $transtext; } } if ($t1 != 'no' & $t2 != 'no' & $t3 != 'no' & $t4 != 'no') { $transtext = wpr_gtrns($transtext, $t3, $t4); if (!empty($transtext["error"]["reason"])) { return $transtext; } } $pos = strpos($transtext, "302 Moved"); $pos2 = strpos($transtext, "301 Moved"); $pos3 = strpos($transtext, "404 Not Found"); if ($pos === false && $pos2 === false && $pos3 === false) { $moved = 2; } else { $moved = 1; } if (!empty($transtext) && $transtext != ' ' && $moved != 1) { // REPLACE URLS preg_match_all('#\\href="(.*)"\\]#iU', $transtext, $rmatches, PREG_SET_ORDER); if ($rmatches) { $i = 0; foreach ($rmatches as $rmatch) { // HREF = $match[1] echo "<br/>REPLACE: " . $matches[$i][1]; echo "<br/>WITH: " . $rmatch[1]; $transtext = str_replace($rmatch[1], $matches[$i][1], $transtext); $i++; } } // TO DO: // - HTMLFIXER CLASS NECESSARY? $transtext = str_replace('< / ', '</', $transtext); $transtext = str_replace('</ ', '</', $transtext); $transtext = str_replace('< /', '</', $transtext); $transtext = str_replace('< ', '<', $transtext); $transtext = str_replace('num = "', 'num="', $transtext); $transtext = str_replace('kw = "', 'kw="', $transtext); $transtext = str_replace('ebcat = "', 'ebcat="', $transtext); $transtext = str_replace('[Wprebay', '[wprebay', $transtext); $transtext = str_replace('[/ ', '[/', $transtext); $transtext = str_replace('Has_rating', 'has_rating', $transtext); //echo $transtext . "<br/>--------------------------------------------<br/>"; $transtext = html_entity_decode($transtext); //echo $transtext . "<br/>--------------------------------------------<br/>"; $transtext = stripslashes($transtext); $a = new HtmlFixer(); $transtext = $a->getFixedHtml($transtext); //echo $transtext . "<br/>--------------------------------------------<br/>"; return $transtext; } else { $return["error"]["module"] = "Translation"; $return["error"]["reason"] = "Translation Failed"; $return["error"]["message"] = __("The post could not be translated.", "wprobot"); return $return; } }
get_template_part('template/single', 'social'); ?> <!-- end social share --> <div class="clear"></div> </div> </div> <div class="main-center padding-top30"> <div class="main-column"> <div class="job-detail tinymce-style"> <div class="description" id="job_description"> <?php $html = new HtmlFixer(); echo $html->getFixedHtml(get_the_content()); ?> </div> </div> <div class="form_container"> <?php if ($job->post_status == 'publish' || $user_ID == $job->post_author || current_user_can('edit_others_posts')) { ?> <div class="bg-job-frame job-apply submit-apply" id="job_action"> <a rel="nofollow" target="_blank" title="<?php _e("APPLY FOR THIS JOB", ET_DOMAIN); ?> " class="bg-btn-action border-radius btn-default btn-apply btn-apply-rss applyJob" href="<?php echo get_post_meta($job->ID, 'et_rss_url', true);
public function format_comment($comment, $for_email = false) { $comment = preg_replace('@(\r\n|\n|\r)@', '!!QQZZXX!!', $comment); // replace all newlines with placeholder - hopefully no-one will type !!QQZZXX!! into a comment preg_match_all('@<pre>(.*?)</pre>@', $comment, $matches); // Find all <pre> code blocks and match stuff inside if (count($matches[1] > 0)) { foreach ($matches[1] as $match) { $r = str_replace(array('!!QQZZXX!!', '<', '>'), array("\n", '<', '>'), $match); // replace < and > in contents of each <pre> block if ($for_email) $r = $this->wordwrap_multiline($r, 80 + ((int)$for_email * 30)); // break long lines in <pre> blocks $replacement[] = $r; } $comment = str_replace($matches[1], $replacement, $comment); // now replace each <pre> block with its corresponsing cleansed version } if ($for_email) return str_replace(array('<', '>'), array('<', '>'), strip_tags(preg_replace('@(!!QQZZXX!!)+@', "\r\n\r\n", $comment), '<pre><code>')); // replace placeholders with newlines (for emailed comments) $comment = preg_replace('@(!!QQZZXX!!)+@', "</p>\n{$this->depth} <p>", $comment); // replace placeholders with paragraph tags if (strpos($comment, '<p') !== 0) $comment = "{$this->depth} <p>$comment"; // entire comment starts with <p> unless already starting with <p> or <pre> switch(strrchr($comment, '/')) { case '/pre>': case '/p>': break; default: $comment = "$comment</p>\n"; // if comment does not end with </p> or </pre>, stick a </p> on the end } $comment = $this->paragraphise($this->paragraphise($comment)); // two passes necessary, otherwise things like "</p> text </p>" result $comment = strip_tags($comment, (string)$this->allowed_html); // strip all disallowed tags if (strlen($this->allowed_html) > 0) { if (strpos($this->allowed_html, '<a>') !== false) { $tags = str_replace('<a>', '', $this->allowed_html); } $comment = preg_replace('@<(' . trim(str_replace('><', '|', $tags), '<>') . ')(?:\s+[^\s]*?)?>@', "<$1>", $comment); } $comment = preg_replace_callback('@<a(?:.+?href=(?:")?([^"]+)(?:"))?.*?>@im', array($this, 'format_links'), $comment); // add nofollow to links and change escaped attribute quotes back if (@include_once(dirname(__FILE__) . '/' . $GLOBALS['htmlfixer_file'])) { if (class_exists('HtmlFixer')) { $a = new HtmlFixer(); $comment = $a->getFixedHtml($comment); } } if (strrchr($comment, chr(10)) !== chr(10)) $comment .= chr(10); return $comment; }
/** * A simple function to clean a string to be SQL safe. */ function clean($string, $veryClean = false) { $htmlFixer = new HtmlFixer(); if ($veryClean) { return stripslashes(htmlentities(strip_tags($htmlFixer->getFixedHtml(trim($string))))); } else { return stripslashes(strip_tags($htmlFixer->getFixedHtml(trim($string)), "<img><u><i><p><span><div><strong><q><blockquote><b><a><ul><ol><li><h1><h2><h3><h4><h5><h6>")); } }