<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Oracle of ONE1 &#187; attributes</title>
	<atom:link href="http://dvector.com/oracle/tag/attributes/feed/" rel="self" type="application/rss+xml" />
	<link>http://dvector.com/oracle</link>
	<description>Obscure words of unity</description>
	<lastBuildDate>Wed, 31 Aug 2011 21:25:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Prevent Stripped Attributes</title>
		<link>http://dvector.com/oracle/2008/03/29/prevent-stripped-attributes/</link>
		<comments>http://dvector.com/oracle/2008/03/29/prevent-stripped-attributes/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 20:18:58 +0000</pubDate>
		<dc:creator>oracle</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[kses]]></category>

		<guid isPermaLink="false">http://dvector.com/oracle/2008/03/29/prevent-stripped-attributes/</guid>
		<description><![CDATA[By default, WordPress strips out the class and id attributes from all tags entered in a post. There are some security reasons for doing this so exercise caution before over-riding this behavior.
What is the Need?
You might ask why would I need to have class or id attributes in my tags. Well, the answer is that [...]]]></description>
			<content:encoded><![CDATA[<p>By default, WordPress strips out the class and id attributes from all tags entered in a post. There are some security reasons for doing this so exercise caution before over-riding this behavior.</p>
<h2>What is the Need?</h2>
<p>You might ask why would I need to have class or id attributes in my tags. Well, the answer is that for most users and for most of your posts you do not need the attributes. There are, however; some circumstances where these provide additional layout options.</p>
<p>As an example; one of my clients wanted quotes from newspapers to have a special newspaper-like background. In standard HTML/CSS, this is relatively easy to do using &lt;div id=&#8221;newspaper&#8221;&gt;&lt;/div&gt; in your HTML and setting the style in your style sheet. This would work fine in WordPress, except for the fact that the id attribute will be stripped out when saving the post.</p>
<p><span id="more-16"></span></p>
<h2>How to Allow the Attribute?</h2>
<p>The file wp-includes/kses.php is an HTML/XHTML filter that only allows some elements and attributes. Therefore either this file or the legacy my-hacks.php file must be hacked. My choice was to modify the kses.php.</p>
<p>There are many solutions to allow the attributes to pass. A universal one <a href="http://ocaoimh.ie/2007/09/10/wordpress-mu-125" title="Donncha enable attributes">created by  Donncha</a> is to add the following to kses.php;</p>
<pre>function addabitofclass( $tags ) {
  global $allowedposttags;
  foreach( $allowedposttags as $tag =&gt; $attr ) {
    $attr[ 'class' ] = array();
    $attr[ 'id' ] = array();
    $allowedposttags[ $tag ] = $attr;
  }
  return $allowedposttags;
}
add_filter( 'edit_allowedposttags', 'addabitofclass' );</pre>
<p>My solution was to just allow the id attribute in the div tag, since this fulfilled all I would likely need. So I modified lines 58-61 in the $allowedposttags array from;</p>
<pre>
'div' =&gt; array(
      'align' =&gt; array(), 'xml:lang' =&gt; array(),
      'lang' =&gt; array()
),</pre>
<p>to</p>
<pre>
'div' =&gt; array(
      'align' =&gt; array(), 'xml:lang' =&gt; array(),
      'id' =&gt; array(), 'lang' =&gt; array()
),</pre>
<h2>Anything Else</h2>
<p>Absolutely! If you intend on working directly with HTML and code in your posts, then you should disable the Visual Editor in your profile.</p>
]]></content:encoded>
			<wfw:commentRss>http://dvector.com/oracle/2008/03/29/prevent-stripped-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

