Created
March 31, 2021 15:29
-
-
Save matdave/1bef566a6af108305bde7a2dbce40504 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* FixedPreLite plugin | |
* | |
* * | |
* Updated by matdave <https://matdave.com> | |
* * | |
* Original author Bob Ray <http://bobsguides.com> | |
* Copyright 2011-2014 Bob Ray | |
* 3/23/11 | |
* | |
* FixedPre is free software; you can redistribute it and/or modify it | |
* under the terms of the GNU General Public License as published by the Free | |
* Software Foundation; either version 2 of the License, or (at your option) any | |
* later version. | |
* | |
* FixedPreLite is distributed in the hope that it will be useful, but WITHOUT ANY | |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |
* A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License along with | |
* FixedPre; if not, write to the Free Software Foundation, Inc., 59 Temple | |
* Place, Suite 330, Boston, MA 02111-1307 USA | |
* | |
* @package fixedprelite | |
*/ | |
/** | |
* MODx FixedPreLite plugin | |
* | |
* Description: MODx tags inside <code> blocks will be displayed | |
* when referenced with {{ }} instead of [[ ]]. | |
* | |
* Events: OnWebPagePrerender | |
* | |
* @package fixedprelite | |
* | |
* @property | |
*/ | |
if (! function_exists('quote_meta') ) { | |
function quote_meta($a) { | |
$lhs = array("{{", "}}"); | |
$rhs = array("[[", "]]"); | |
$b = str_replace("&", "\255", $a[2]); //save "&" | |
$lhs_preg = array('|<!(!*)code>|', '|<!(!*)/code>|'); | |
$rhs_preg = array('<$1code>', '<$1/code>'); | |
//$b = preg_replace($lhs_preg, $rhs_preg, $b); | |
$b = str_replace($lhs, $rhs, $b); | |
/* restore '&' as '&' and wrap in span tag */ | |
//return '<span class="fxp">' . str_replace("\255", "&", $b) . '</span>'; | |
return '<code>'.str_replace("\255", "&", $b).'</code>'; | |
} | |
} | |
/** @var $modx modX */ | |
$modx->resource->_output = preg_replace_callback("#(<code>)(.*?)(</code>)#s", | |
"quote_meta", $modx->resource->_output); | |
return ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment