• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Foliovision

Making the web work for you

Main navigation

  • Weblog
    • FV Player
    • WordPress
    • Video of the Week
    • Case Studies
    • Business
  • About
    • Testimonials
    • Meet the Team
    • We Support
    • Careers
    • Contact
    • Pricing
  • Products
  • Support
    • FV Player Docs
    • Pro Support
  • Login
  • Basket is empty
Affordable VAST/VPAID for Wordpress has arrived. Serve ads with your videos starting today!

Why WordPress won’t validate

14 October 2009 / Martin / Leave a Comment

We recently checked our site in W3C Markup Validation Service and find out that some of our inline javascript in the posts is not properly enclosed in CDATA tags. Read about the details of the issue, reason for it and a bit of hope in future WordPress releases.

Everything inside a CDATA section is ignored by the XML parser and all the inline javascript should be in it. This is how you do it:
 

<script>
<![CDATA<strong>[ </strong>function anything(a,b)
{ }
]]>
</script>

So we fixed all of our plugins which are putting any javascript into the posts and there was another error coming out of the Validation Service saying that the CDATA section is not properly closed.

The generated source code of the page was looking like this:
 

<script>
<![CDATA[
function anything(a,b)
{ }
]]&gt;
</script>

The greater than symbol in CDATA closing tag was replaced by the HTML entity.

We disable both wpautop (this is a function which is automatically inserting paragraphs and newlines into the post - that's why we hate the default WordPress editor which can't live without it and use Foliopress WYSIWYG instead) and wptexturize (another nice WordPress function, which used to mess up all of our HTML comments) all the time, so we were very unhappy that there is some other plugin destroying our posts.

After a while I discovered that it's the WordPress core who is doing this. Let's take a peek at the structure of the responsible WordPress template tag code:
 

function the_content() {
    1. Get the post content;
    2. Apply all the filters on it;
    3. Replace ]]> with ]]&gt;
    4. Display it;
}

So there's an extra line of code just to mess the CDATA tags. No php comments around it to explain why it's there. Nothing in the WordPress Codex about it, no sensible answers in support forums.

I had to search the WordPress bug tracking system for an hour to find more about the problem: That single line of code is there for RSS. CDATA closing tag would just break the feeds. That's is.

Seems like the WordPress guys are aware of this as the issue is planed to be solved for WordPress 2.9 - https://core.trac.wordpress.org/ticket/3670. That means the tag will be converted only in the feeds. Until then our pages are not 100% valid.

However the ticket is 5 years old now with last change 5 weeks ago. I can't believe WordPress community is fighting this nearly from the beginnings of WordPress.

  • Read more about CDATA on w3schools or Wikipedia.
  • Read about problems people have with this WordPress issue.
  • Take a look at the fix.
Martin Vicenik

Martin Viceník

Martin graduated as an engineer in Computer Science from Slovak Technical University in Bratislava. He grew up in Liptovský Mikuláš in northern Slovakia next to the beautiful Tatra mountains. He is the developer behind our FV Player.

Share
Tweet
Share
0 Shares

Categories: WordPress

Related Posts

  1. How to Comment Code in WordPress Templates

    How to Comment Code in WordPress Templates

  2. FV Testimonials: Embedding

    FV Testimonials: Embedding

  3. FV Testimonials: Guide to Templates – old

    FV Testimonials: Guide to Templates – old

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You can click here to Subscribe without commenting

Primary Sidebar

Categories

  • Business
  • Cameras
  • Case Studies
  • Design
  • Flowplayer
  • Internet Marketing
  • IT
  • Life
  • SEO
  • Slovak
  • Video of the Week
  • WordPress

Footer

Our Plugins

  • FV WordPress Flowplayer
  • FV Thoughtful Comments
  • FV Simpler SEO
  • FV Antispam
  • FV Gravatar Cache
  • FV Testimonials

Free Tools

  • Pandoc Online
  • Article spinner
  • WordPress Password Finder
  • Delete LinkedIn Account
  • Responsive Design Calculator
Foliovision logo
All materials © 2021 Foliovision s.r.o. | Panská 12 - 81101 Bratislava - Slovakia | info@foliovision.com
  • This Site Uses Cookies
  • Privacy Policy
  • Terms of Service
  • Site Map
  • Contact
  • Tel. +1 518 412 4600