Re: PHP Script - Validator Soap Request Producing Endless Slope?

Hi Brett,

thanks for your quick answer.

> > Currently, I want to build a PHP plugin for Wordpress that simply
> > checks on loading of each page if it is XHTML 1.0 valid.
> This sounds like a noble effort, but I really think you should
> re-consider this implementation. The contents of the page should not
> change on each load, therefore, checking validity *once*, only when
> new posts are published should be sufficient. I think we all should be
> careful when considering the use of a shared resource, as in the case
> of the W3C's html validation service. Re-validation on every load of
> the same page is excessive and unnecessary if the content is the same.
> I would think there must be some way to only run a plugin when a new
> post is added, and store the results of the validation once.

Right.. I have already thought about this, myself. Thanks to your
explanation, I now see that just checking once and keeping that
information would be the better solution. Checking each page each time
seems an unnecessary use of that shared resource.

So, here is what I am gonna try:
The Batch Validator plugin already tests each page/post, but just on
request from the admin panel. It then stores the results in the

I think I'd either take this information (last check by Batch
Validator compared against last modified of page/post) to see if I
have to do a check of the page (a page usually contains the posts, but
there is also the header, sidebar and footer that have to be checked),
or I will build a plugin that is not dependant on the Batch Validator
and that hooks into the "publish post" action, storing this
information in the database itself.

Another possibility would be to use AJAX to check the page just on a
user's request ("Click here to validate page"). This is a VERY simple
solution, I admit... :-)

Consider: in Wordpress, XHTML validity can not only be destroyed by
posts but also by changing site templates. Therefore, I think I'd have
to check their modification date, also.

> > For this reason, I implemented an if-condition that gets the
> > IP-address of the remote host  - in case of the validator, this should
> > be, right?
> I think this is incorrect, the W3C maintains multiple servers running
> the validator service. I do not know all the IP addresses, but in this
> case you could check the user agent string for W3C_Validator -----

Hm... that's funny. The access.log just shows that one IP.
I tried your suggestion and found out that the Validator user agent is
"W3C_Validator/" followed by a number, so to check for it, I just see

eregi("W3C_Validator", $_SERVER['HTTP_USER_AGENT'])

is true. That should cover all Validator requests.
Worked fine while testing, thanks a lot for the tip!

> You might also look into the PEAR package Services_W3C_HTMLValidator,
> which you can simply use something like:
> $validator = new Services_W3C_HTMLValidator();
> $result = $validator->validate($uri);
> if ($result->isValid()) echo 'The page is valid.';

Yes, I guess that would be easier, but anyone using my plugin would
have to download that one. The Snoopy()-Class is already embedded into
Wordpress. Thanks, anyway!

Best wishes
Marco Luthe

Received on Monday, 29 October 2007 12:33:28 UTC