[wp-hackers] Re: Introduce some type of no-parse tag ?
Otto
otto at ottodestruct.com
Thu Sep 6 02:51:04 GMT 2007
That's pretty much what I did:
if (preg_match_all("{\<script(.*)\<\/script\>}siU", $text, $temp)) {
while (list($k, $v) = each($temp[0])) {
$text = str_replace($v, '<!-- h'.$k.'h -->', $text);
$inlinescripts[$k] = $temp[1][$k];
}
}
...
while (list($k, $v) = each($inlinescripts)) {
$text = str_replace('<!-- h'.$k.'h -->', '<script'.$v.'</script>', $text);
}
I used the <!-- --> comments so that if I did miss something, I
wouldn't get weird crap in my page.
On 9/5/07, Viper007Bond <viper at viper007bond.com> wrote:
> Heh, that's actually what I ended up doing later:
>
>
> $hash = sha1( $match[1] );
> $this->encodedtemplates[$hash] = $match[1];
> $content = str_replace( $match[0], $template_opener . '[templatediaencoded]'
> . $hash . '[/templatediaencoded]' . $template_closer, $content );
>
>
> $content = str_replace( $match[0], $template_opener .
> $this->encodedtemplates[$match[1]] . $template_closer, $content );
>
>
> Works well and now that I'm thinking about it, I probably could probably
> even just use like uniqid() or even an auto-incrementing value (1, 2, 3,
> etc.) to reduce the overhead further.
>
> On 9/5/07, Otto <otto at ottodestruct.com> wrote:
> >
> > Yikes. I can see where that works, but why go to that much trouble?
> > Just pull the relevant text out of the post content entirely, stick it
> > in a global array, and put a placeholder in it's place. Then at the
> > higher level, find the placeholder, replace it with the text in the
> > global array. Less overhead of encoding and decoding and such.
> >
> > This is similar to how the plugin I posted before works:
> > http://ottodestruct.com/wpstuff/scriptenabler.zip
> >
> >
> > On 9/4/07, Viper007Bond <viper at viper007bond.com> wrote:
> > > I ended up doing a base64_encode() on the users input, {{this part
> > here}},
> > > and then decoding it at a high filter level. Not the prettiest thing in
> > the
> > > world, but it works perfectly.
> > >
> > > --
> > > Viper007Bond | http://www.viper007bond.com/
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
> Viper007Bond | http://www.viper007bond.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list