[wp-hackers] Replace default doctype on one page only through plugin

Lynne Pope lynne.pope at gmail.com
Mon Jan 19 04:15:05 GMT 2009


Well, what I am trying to do is this...

I am using a contact form plugin on my contact page. I have cleaned up XHTML
validation errors on the form but the form uses Recaptcha for anti-spam
assistance and the no-script fallback for Recaptcha is an iframe.

Since DOCTYPE applies to the document and not to an overall site, I decided
to get pendantic and change my XHTML 1.0 STRICT to XHTML 1.0 TRANSITIONAL
for that one page alone.
Now, for my own site I can simply make the contact page into a template and
call a different header, but having got the bit between my teeth I decided
it would be more useful if I could find a way to add a DOCTYPE override to
the plugin.

I didn't write the plugin (too lazy to write my own contact form) but
realise that if I have issues with validation for it then others will have
too. Ergo, if I can find a way to do this safely within the plugin itself
the code then becomes reusable and worth contributing back.

I'm not going to hassle the plugin developer over this as I realise not
everyone cares if they have one page that doesn't validate. Besides, once I
work out a way to do it without creating more than negligable performance
issues this will be something I can reuse.

Lynne

2009/1/19 Mike Schinkel <mikeschinkel at newclarity.net>

> Lynee:
>
> Does it even need to be in a plugin?  It this for this site only, or are
> you trying to create generic functionality?  Can't you do just do something
> like (in ~psudeo-code):
>
> <?php
>
> if ($_SERVER['REQUEST_URI']=='special_url') {
>   echo '<Special DocType>';
> } else {
>   echo '<Regular DocType>';
> }
>
> ?>
>
> -Mike Schinkel
> http://mikeschinkel.com/custom-wordpress-plugins/
>
>
> Lynne Pope wrote:
> > Hi all,
> > I am working on a site that is using XHTML 1.0 Strict but want to serve
> > XHTML 1.0 Transitional on one page only. The page uses a plugin so the
> > change to the doctype could go into the plugin.
> >
> > I can do a query in header.php but want to avoid unnecessary queries (why
> > add an additional query to 300+ pages when only one is affected?) but
> cannot
> > get an override working for the plugin.
> >
> > Any ideas?
> >
> > Lynne
> _______________________________________________
> 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