Content Callback
The function content callback located in etc/content_callback.php you can modify the source code before sending it to the browser.
The function content callback located in etc/content_callback.php you can modify the source code before sending it to the browser.
etc/content_callback.php
If the file does not exist, or if the file is empty, the function content_callback() is not executed.
Here is an example of use, the variable $out contains all the page, header content footer.
<?php
function content_callback($out){
return str_replace('http://','https://',$out);
}
Example a little more push used on this site : If HTML content is present in a tag PRE and that it is not properly encoded, replaced by his version of the encoded :
function content_callback($out){
# we fetch all the pieces of code in preformatés
preg_match('|(< pre ><code class="language[^"]*">)(.*)(</code></ pre >)|isU',$out,$m,PREG_SET_ORDER);
foreach($m as $k=>$match){
# if the content is not htmlencodé, it is htmlentities
if(isset($match[2]) && !strstr($match[2], '>')){
$out = str_replace($match[0], $match[1].htmlentities($match[2]).$match[3], $out);
}
}
$out = preg_replace('|<span id="line[0-9]*"></span>|isU',",$out);
return $out;
}