GetSimple Support Forum

Full Version: Processing whole page content before output
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
During Affiliate Product Manager Plugin I face with one problem. I want page content xhtml code to have proper indentation or to be all in one line. But I can not figure how to process complete page code before output.

I realize that :

Quote:exec_action('index-posttemplate');

Do final work but I can not find where this function exists.
'index-posttemplate' hook is fired *after* the page is rendered. If you want to alter the page content before it is displayed, you'll probably need to use the 'content' filter: see http://get-simple.info/wiki/plugins:hook...re_filters
I do not know what is problem I try:

Quote:add_filter('content','xhtml_one_line');

and function:

Quote:function xhtml_one_line($contents){

$temp = $contents;
$temp = preg_replace('/^\s+|\n|\r|\s+$/m', '', $temp);
$temp = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $temp);
$temp = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $temp);
$temp = preg_replace(array('(( )+{)','({( )+)'), '{', $temp);
$temp = preg_replace(array('(( )+})','(}( )+)','(;( )*})'), '}', $temp);
$temp = preg_replace(array('(;( )+)','(( )+Wink'), ';', $temp);
$temp = preg_replace(array('(Sad )+)','(( )+Smile'), ':', $temp);
$temp = preg_replace('/(\s|)\,(\s|)/', ',', $temp);

return $temp;
}

But I do not see results for some reason, GSDEBUG enabled. No errors.
It's $content I believe, not $contents.
It doesn't make difference I look at Plugins that do more less same like Replacer and External commenting. They use this naming for function.
bogyvet Wrote:I do not know what is problem I try:

I've tried a simpler test, code based on yours:
Code:
add_filter('content','stoz');
Code:
function stoz($contents){
            $temp = $contents;
            $temp = str_replace('s', 'z', $temp);
            return $temp;
    }

Thiz workz. :-)

So it may be something wrong in your str_replace or preg_replace lines. (No idea what, I haven't examined them...)
I've tried your code again. I don't know if it does all you expected, but looking at the page source, the page content is stuffed in just one line. So it does something.
Thanks I will try another installation!!!