Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Processing whole page content before output
#1
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.
Reply
#2
'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
Reply
#3
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.
Reply
#4
It's $content I believe, not $contents.
Reply
#5
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.
Reply
#6
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...)
Reply
#7
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.
Reply
#8
Thanks I will try another installation!!!
Reply




Users browsing this thread: 1 Guest(s)