Last active
January 28, 2018 18:17
-
-
Save leotop/1837342ab09b36aeb3dd05947d5f8583 to your computer and use it in GitHub Desktop.
MODX плагин, на событие OnLoadWebDocument. Преобразует теги MODX и экранирует html символы внутри конструкции <pre><code> </code></pre>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function replace_modxtags($matches){ | |
$code_entities_match = array('[', ']','{', '}', '!', '`', '*', '~'); | |
$code_entities_replace = array('[',']','{','}', '!', '`', '*', '~'); | |
$code = str_replace( | |
$code_entities_match, | |
$code_entities_replace, | |
htmlentities($matches[1], ENT_QUOTES) | |
); | |
return '<pre><code>'.$code.'</code></pre>'; | |
} | |
$content = preg_replace_callback("#<pre><code>(.*?)</code></pre>#s", "replace_modxtags", $modx->resource->get('content')); | |
$modx->resource->set('content', $content); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment