<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>emrahgunduz</title>
	
	<link>http://emrahgunduz.com</link>
	<description>always eats his vegetables</description>
	<lastBuildDate>Sun, 06 Feb 2011 09:48:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19704</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/emrahgunduz/feed" /><feedburner:info uri="emrahgunduz/feed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>WordPress: Disable Auto Paragraphing, wpautop() and clean_pre() Functions</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/1lgdQsAPuoM/</link>
		<comments>http://emrahgunduz.com/categories/development/wordpress/wordpress-disable-auto-paragraphing/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 09:48:00 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[autop]]></category>
		<category><![CDATA[clean_pre]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[paragraph]]></category>
		<category><![CDATA[wpautop]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=344</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/AutoP-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="AutoP" title="AutoP" /></p>When it comes to paragraphs, we can all say that WordPress is in love with them. After publishing a post every text block turns into a &#60;p&#62; code, every double [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/AutoP-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="AutoP" title="AutoP" /></p><p>When it comes to paragraphs, we can all say that WordPress is in love with them. After publishing a post every text block turns into a &lt;p&gt; code, every double &lt;br /&gt; disappears. Your so much worked post design gets ruined. Or does it?</p>
<p>With AutoP WordPress tries to correct errors, and makes the posts much more readable. Even though I had my share of problems, I don&#8217;t hate the wpautop. But when it comes to my &lt;pre&gt; tags, I had to do something.</p>
<p>While designing my new theme, I looked and tested lots of code highlighters, php, jquery, mootools, pear, etc etc&#8230; The one I choose was, Geshi. Not because others were bad in coding, but I already had too many CSS and JS links, I did not want to add a lot more just for the code highlighting. So, in short, I accepted the server side coding path.</p>
<p>My problems started here. Even though Geshi was working great with HTML characters, WordPress&#8217;s <code>wpautop()</code> and <code>clean_pre()</code> were changing my php code which included some html. Both these functions are located in <code>wp-includes/formatting.php</code>. But don&#8217;t temper the core file, there is a better way.</p>
<p>First there is no way of disabling the clean_pre function single-handedly, as it is called inside wpautop. But wpautop is called in a few WordPress filters, and not as a direct function. So, disabling these actions will remove two functions together. You&#8217;ll need to put these lines in your theme&#8217;s <code>functions.php</code> file:</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Remove WordPress Auto P</span>
remove_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpautop'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Auto P is also called in these filters, I'm just adding these lines for your information.</span>
<span style="color: #666666; font-style: italic;">// If you want to disable them, uncomment</span>
<span style="color: #666666; font-style: italic;">// remove_filter( 'the_content', 'wpautop' );</span>
<span style="color: #666666; font-style: italic;">// remove_filter( 'the_excerpt', 'wpautop' );</span>
<span style="color: #666666; font-style: italic;">// remove_filter( 'comment_text', 'wpautop' ); // &lt;-- Be careful with this one</span></div>
</pre>
<h2>Great, no more auto p&#8230; but wait my blog is messed up!</h2>
<p>Now, all your double newlines, are double newlines, but not pharagraphs with breaks. If this is what you wanted, then great, mission accomplished. However, you might not be happy with what you are seeing. You can edit and enclose every pharagraph in every post you&#8217;ve published, or simply re-initialize a new wpautop function.</p>
<p>I&#8217;ll be using the slightly altered wpautop and clean_pre in here, so don&#8217;t get frightened by the length of the code.</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Remove WordPress Auto P</span>
remove_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpautop'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// And insert our new Auto P</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eg_wpautop'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> eg_wpautop<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pee</span><span style="color: #339933;">,</span> <span style="color: #000088;">$br</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a target="_blank" href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span>
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pee</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// just to make things a little easier, pad the end</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|&lt;br /&gt;\s*&lt;br /&gt;|'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #666666; font-style: italic;">// Space things out a little</span>
&nbsp; <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!(&lt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'[^&gt;]*&gt;)!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!(&lt;/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&gt;)!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// cross-platform newlines</span>
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a target="_blank" href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pee</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;object'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|\s*&lt;param([^&gt;]*)&gt;\s*|'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;param<span style="color: #006699; font-weight: bold;">$1</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// no pee inside object/embed</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|\s*&lt;/embed&gt;\s*|'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/embed&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>+/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// take care of duplicates</span>
&nbsp; <span style="color: #666666; font-style: italic;">// make paragraphs, including one at the end</span>
&nbsp; <span style="color: #000088;">$pees</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_split"><span style="color: #990000;">preg_split</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\n\s*\n/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> PREG_SPLIT_NO_EMPTY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$pees</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tinkle</span> <span style="color: #009900;">&#41;</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;p&gt;'</span> <span style="color: #339933;">.</span> <a target="_blank" href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tinkle</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|&lt;p&gt;\s*&lt;/p&gt;|'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// under certain strange conditions it could create a P of entirely whitespace</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!&lt;p&gt;([^&lt;]+)&lt;/(div|address|form)&gt;!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;p&gt;<span style="color: #006699; font-weight: bold;">$1</span>&lt;/p&gt;&lt;/<span style="color: #006699; font-weight: bold;">$2</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!&lt;p&gt;\s*(&lt;/?'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'[^&gt;]*&gt;)\s*&lt;/p&gt;!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// don't pee all over a tag</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;|&lt;p&gt;(&lt;li.+?)&lt;/p&gt;|&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// problem with nested lists</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|&lt;p&gt;&lt;blockquote([^&gt;]*)&gt;|i'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;blockquote<span style="color: #006699; font-weight: bold;">$1</span>&gt;&lt;p&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/blockquote&gt;&lt;/p&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/p&gt;&lt;/blockquote&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!&lt;p&gt;\s*(&lt;/?'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'[^&gt;]*&gt;)!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!(&lt;/?'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'[^&gt;]*&gt;)\s*&lt;/p&gt;!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$br</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace_callback"><span style="color: #990000;">preg_replace_callback</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;(script|style).*?&lt;\/\\1&gt;/s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_autop_newline_preservation_helper'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|(?&lt;!&lt;br /&gt;)\s*\n|'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// optionally make line breaks</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;WPPreserveNewline /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!(&lt;/?'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$allblocks</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'[^&gt;]*&gt;)\s*&lt;br /&gt;!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!&lt;br /&gt;(\s*&lt;/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^&gt;]*&gt;)!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'$1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pee</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;pre'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace_callback"><span style="color: #990000;">preg_replace_callback</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!(&lt;pre[^&gt;]*&gt;)(.*?)&lt;/pre&gt;!is'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eg_clean_pre'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;|<span style="color: #000099; font-weight: bold;">\n</span>&lt;/p&gt;$|&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>

&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$pee</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>

<span style="color: #000000; font-weight: bold;">function</span> eg_clean_pre<span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a target="_blank" href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
&nbsp; &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/pre&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #b1b100;">else</span>
&nbsp; &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">;</span>

&nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// I love this line, Geshi adds too many &lt;br /&gt; tags</span>
&nbsp; <span style="color: #666666; font-style: italic;">// I don't like this one -&gt; $text = str_replace('&lt;p&gt;', &quot;\n&quot;, $text);</span>
&nbsp; <span style="color: #666666; font-style: italic;">// I'm not fond of this one either -&gt; $text = str_replace('&lt;/p&gt;', '', $text);</span>

&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></div>
</pre>
<p>Now, I&#8217;ve removed the WordPress autop, and defined my own <code>eg_wpautop()</code>. I can change, remove or add new lines to the function.</p>
<p>You can see the clean_pre in work near the end:</p>
<pre>
<div class="php" style="font-family:monospace;">&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pee</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;pre'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
&nbsp; &nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace_callback"><span style="color: #990000;">preg_replace_callback</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!(&lt;pre[^&gt;]*&gt;)(.*?)&lt;/pre&gt;!is'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eg_clean_pre'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$pee</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;|<span style="color: #000099; font-weight: bold;">\n</span>&lt;/p&gt;$|&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pee</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div>
</pre>
<p>If you don&#8217;t want your pre tags get messed up, or your inline p and br tags -which even though are part of your code gets truncated- just remove these lines I commented out. You can also remove the pre tag from any preg_replace and $allblocks variable. For clean_pre, another solution is writing your very own function and assigning it to the preg_replace_callback. This was how I solved my code highlighting/Geshi problem.</p>
<p>Remove and change any line(s) you like from now on, experiment and see what difference it makes on your posts. I&#8217;m sure that 99% of the code, you&#8217;ll be keeping. It is a hell of a well written function <img src='http://emrahgunduz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/1lgdQsAPuoM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/wordpress/wordpress-disable-auto-paragraphing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/wordpress/wordpress-disable-auto-paragraphing/</feedburner:origLink></item>
		<item>
		<title>Javascript Libraries Deconstructed</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/h6CILGtgLq4/</link>
		<comments>http://emrahgunduz.com/categories/various-topics/resources/javascript-libraries-deconstructed/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 09:13:30 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[deconstructed]]></category>
		<category><![CDATA[jlibs]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=312</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/jslibs_deconstructed-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="jslibs_deconstructed" title="jslibs_deconstructed" /></p>Here is a great site if you want to check what is going on under Jquery, MooTool or Prototype libraries. This site is helping us to understand how the internal [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/jslibs_deconstructed-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="jslibs_deconstructed" title="jslibs_deconstructed" /></p><p>Here is a <a href="http://www.keyframesandcode.com/resources/javascript/deconstructed/">great site</a> if you want to check what is going on under Jquery, MooTool or Prototype libraries. This site is helping us to understand how the internal code of these libraries are constructed, usage advantages plus disadvantages and problems we might encounter.</p>
<p><a href="http://www.keyframesandcode.com/resources/javascript/deconstructed/">JS Libs Deconstructed</a> converts every function, object, block into easily navigatable visual blocks. Clicking a box views the internal code of the library, and the link goes directly to the library&#8217;s documentation.</p>
<p>Here are some quotes from the site&#8230;</p>
<blockquote><p><strong><em>jQuery</em></strong> is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.<br />
<strong><em>Prototype</em></strong> is a JavaScript Framework that aims to ease development of dynamic web applications, featuring a unique, easy-to-use toolkit for class-driven development and the nicest Ajax library around.<br />
<strong><em>MooTools</em></strong> is a compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API.</p></blockquote>
<p>PS. Mootools is not yet deconstructed&#8230;</p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/h6CILGtgLq4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/various-topics/resources/javascript-libraries-deconstructed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/various-topics/resources/javascript-libraries-deconstructed/</feedburner:origLink></item>
		<item>
		<title>WordPress: How To Show The Featured Image Of Posts In Social Sharing Sites</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/DifoDmJlywM/</link>
		<comments>http://emrahgunduz.com/categories/development/wordpress/wordpress-how-to-show-the-featured-image-of-posts-in-social-sharing-sites/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 14:53:04 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[friendfeed]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[image_src]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[share]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=281</guid>
		<description><![CDATA[We all see people sharing links with images attached to them, on Facebook and Friendfeed. Most other sharing sites also support adding an image to your shares automatically. This is [...]]]></description>
			<content:encoded><![CDATA[<p>We all see people sharing links with images attached to them, on Facebook and Friendfeed. Most other sharing sites also support adding an image to your shares automatically.</p>
<p>This is simply done by a meta link tag: <code>&lt;link rel="image_src" href="your_image_url" /&gt;</code></p>
<p>If your WordPress template supports featured images, it is relatively easy to add this meta tag. Open your template&#8217;s php file, which sends out the headers (meta tags, link tags, title, etc, everything between the <code>&lt;head&gt; &lt;/head&gt;</code> tags). The file you&#8217;ll be changing most probably is named header.php. Some themes have headers in index.php. So check these two files out.</p>
<p>Add these three lines of codes inside the head tags:</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> and <a target="_blank" href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'has_post_thumbnail'</span><span style="color: #009900;">&#41;</span> and has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;link rel=&quot;image_src&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> wp_get_attachment_image_src<span style="color: #009900;">&#40;</span>get_post_thumbnail_id<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'medium'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$thumb</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></div>
</pre>
<p>If your image has a post thumbnail (featured image) attached to it, this code will create the link tag. Now when anybody shares this post on social sites, your post thumbnail will appear. You can change the size of the image to thumbnail, medium, large or full. But sharing sites most probably will resize it.</p>
<p>If your theme comes with other thumbnail sizes, you can find them in functions.php file of your theme. Look for a line starting with <code>add_image_size()</code> wp function, and you can find the name of the attachment.</p>
<h2>But my theme does not support featured images?</h2>
<p>Then you have two solutions for the problem. First, you can force your theme to support post thumbnails. You&#8217;ll be able to add an image to your posts, but you&#8217;ll not be able to see it when you publish the post. However, the attachment will be made, and link tag will be created for you.</p>
<p>To enable the thumbnail support, open your theme&#8217;s functions.php file, and add these lines at the beginning.</p>
<pre>
<div class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_image_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'link-thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span></div>
</pre>
<p>Now you have thumbnail support. Plus, the second line adds a new kind of image size called &#8220;link-thumbnail&#8221; with size of 200px width and height, which you can use in the link tag creation. You can change the &#8220;true&#8221; part at the end, if you do not want to smart-crop your images.</p>
<p>Remember, you&#8217;ll also need to insert the first code I gave into your header.php (or again to index.php depending on your theme) file.</p>
<h2>Don&#8217;t need thumbnail support, what is the second solution?</h2>
<p>Well, you can check for images in the post content, and use the first image as a link tag. Again in the head section of your theme (either in your theme&#8217;s header.php or index.php as I mentioned earlier) you&#8217;ll need to add these lines of code:</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
&nbsp; <span style="color: #000088;">$postimages</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <a target="_blank" href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@&lt;img.+src=&quot;(.*)&quot;.*&gt;@Uims'</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$postimages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/end"><span style="color: #990000;">end</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postimages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;link rel=&quot;image_src&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></div>
</pre>
<p>This will get the post&#8217;s attachments, and create the link tag from the first one.</p>
<h2>An addition for those who have the post thumbnails support</h2>
<p>You can also add the last code I gave here. Even if you did not attach any post thumbnails but included some images in your posts, your post will be shared with an image.</p>
<h2>And the end&#8230;</h2>
<p>It is possible to have more than one link image tag in your posts. You can alter the last code to include all your images (you might have seen how on Facebook some links come with more than one thumbnails while you are adding a link). To accomplish this, the last code I gave you becomes:</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
&nbsp; <span style="color: #000088;">$postimages</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <a target="_blank" href="http://www.php.net/preg_match_all"><span style="color: #990000;">preg_match_all</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@&lt;img.+src=&quot;(.*)&quot;.*&gt;@Uims'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$postimages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postimages</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;link rel=&quot;image_src&quot; href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$image</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></div>
</pre>
<p>After you arranged your files with the new code, try sharing one of your posts on Facebook, Friendfeed or some other site that supports images with links. If it is not working for you, you might be doing something wrong, leave a comment.</p>
<p>Have fun <img src='http://emrahgunduz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/DifoDmJlywM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/wordpress/wordpress-how-to-show-the-featured-image-of-posts-in-social-sharing-sites/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/wordpress/wordpress-how-to-show-the-featured-image-of-posts-in-social-sharing-sites/</feedburner:origLink></item>
		<item>
		<title>Take 2 on UTF8 BOM : Remove BOM with PHP</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/4zzSh1yO6x8/</link>
		<comments>http://emrahgunduz.com/categories/development/php/take-2-on-utf8-bom-remove-bom-with-php/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 20:49:02 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[bom]]></category>
		<category><![CDATA[byte order mark]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[how to remove]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[remove with php]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=267</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/utf8bom-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="UTF8 BOM" title="UTF8 BOM" /></p>Some people asked me about my UTF8 BOM problems in PHP and XML post. They were wondering if it was possible to remove the BOM from the files, without damaging [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/utf8bom-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="UTF8 BOM" title="UTF8 BOM" /></p><p>Some people asked me about my <a href="http://emrahgunduz.com/categories/development/php/utf8-bom-problems-in-php-and-xml/">UTF8 BOM problems in PHP and XML</a> post. They were wondering if it was possible to remove the BOM from the files, without damaging it. And if PHP could do this. They had hundreds of files with UTF8 BOM in them and it would be time consuming to remove by hand, if they weren&#8217;t able to find a solution.</p>
<p>My answer was, &#8220;of course&#8221;. PHP can read <em>and</em> remove BOM from every file. As we encounter this problem only in text based files, a string remover will do the trick. Applause for <code>substr()</code>.</p>
<p>At the end of the post, you can find my old BOM php code tweaked a little. This time it finds plus removes the UTF8 BOM problems out of your life.</p>
<h2>Remember</h2>
<p><strong><span style="color: #ff0000;">GET A COMPLETE BACKUP OF YOUR FILES BEFORE YOU RUN THIS SCRIPT</span>. Some files and software depend on the BOM to understand the content encoding. I won&#8217;t accept any responsibilities on how you used the code or what happened with it. So, be careful.</strong></p>
<p>After this paranoid paragraph, here is the refurbished code. Just copy paste it to a text file, save as .php and run. Don&#8217;t use notepad. Oh what the hell, use it if you like, this baby will remove BOM from itself too <img src='http://emrahgunduz.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">// Tell me the root folder path.</span>
<span style="color: #666666; font-style: italic;">// You can also try this one</span>
<span style="color: #666666; font-style: italic;">// $HOME = $_SERVER[&quot;DOCUMENT_ROOT&quot;];</span>
<span style="color: #666666; font-style: italic;">// Or this</span>
<span style="color: #666666; font-style: italic;">// dirname(__FILE__)</span>
<span style="color: #000088;">$HOME</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>

<span style="color: #666666; font-style: italic;">// Is this a Windows host ? If it is, change this line to $WIN = 1;</span>
<span style="color: #000088;">$WIN</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>

<span style="color: #666666; font-style: italic;">// That's all I need</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;UTF8 BOM FINDER and REMOVER&lt;/title&gt;
&lt;style&gt;
body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; background: #FFF; color: #000; }
.FOUND { color: #F30; font-size: 14px; font-weight: bold; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$BOMBED</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
RecursiveFolder<span style="color: #009900;">&#40;</span><span style="color: #000088;">$HOME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;h2&gt;These files had UTF8 BOM, but i cleaned them:&lt;/h2&gt;&lt;p class=&quot;FOUND&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$BOMBED</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$utf</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$utf</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>

<span style="color: #666666; font-style: italic;">// Recursive finder</span>
<span style="color: #000000; font-weight: bold;">function</span> RecursiveFolder<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sHOME</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$BOMBED</span><span style="color: #339933;">,</span> <span style="color: #000088;">$WIN</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #000088;">$win32</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$WIN</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #000088;">$folder</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/dir"><span style="color: #990000;">dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sHOME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #000088;">$foundfolders</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$folder</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> and <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/filetype"><span style="color: #990000;">filetype</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sHOME</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$win32</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;dir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$foundfolders</span><span style="color: #009900;">&#91;</span><a target="_blank" href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$foundfolders</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sHOME</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$win32</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sHOME</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$win32</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$BOM</span> <span style="color: #339933;">=</span> SearchBOM<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$BOM</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$BOMBED</span><span style="color: #009900;">&#91;</span><a target="_blank" href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$BOMBED</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sHOME</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$win32</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Remove first three chars from the file</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Write to file </span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a target="_blank" href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sHOME</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$win32</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; <span style="color: #000088;">$folder</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$foundfolders</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$foundfolders</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$folder</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; &nbsp; RecursiveFolder<span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span><span style="color: #339933;">,</span> <span style="color: #000088;">$win32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>

<span style="color: #666666; font-style: italic;">// Searching for BOM in files</span>
<span style="color: #000000; font-weight: bold;">function</span> SearchBOM<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <a target="_blank" href="http://www.php.net/pack"><span style="color: #990000;">pack</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CCC&quot;</span><span style="color: #339933;">,</span><span style="color: #208080;">0xef</span><span style="color: #339933;">,</span><span style="color: #208080;">0xbb</span><span style="color: #339933;">,</span><span style="color: #208080;">0xbf</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/body&gt;
&lt;/html&gt;</div>
</pre>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/4zzSh1yO6x8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/php/take-2-on-utf8-bom-remove-bom-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/php/take-2-on-utf8-bom-remove-bom-with-php/</feedburner:origLink></item>
		<item>
		<title>WordPress: Include your featured post image in RSS feeds</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/mHv2UwESQts/</link>
		<comments>http://emrahgunduz.com/categories/development/wordpress/wordpress-include-your-featured-post-image-in-rss-feeds/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 16:35:41 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[featured image]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[post image]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=254</guid>
		<description><![CDATA[If you want to see your featured post image in your feeds, and want them to appear when your share it in social sites, all you need is to include [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to see your featured post image in your feeds, and want them to appear when your share it in social sites, all you need is to include this code in your theme&#8217;s functions.php file:</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Featured image in RSS feeds</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_excerpt_rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eg_insertthumbnailrss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content_feed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'eg_insertthumbnailrss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> eg_insertthumbnailrss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp; &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> has_post_thumbnail<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;p&gt;&quot;</span> <span style="color: #339933;">.</span> get_the_post_thumbnail <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&lt;br /&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></div>
</pre>
<p>If your post has thumbnail pictures, they will appear on the top in paragraph tags. You can change how you want to see it, by manipulation the <code>$content</code> part in the <code>if ( has_post_thumbnail( $post->ID ))</code> statement.</p>
<p>You can also change which post image size you&#8217;d like to see. WordPress comes with three sizes by default, and one selection for the full image (thumbnail, medium, large or full). Your theme can also assign its own post thumbnail image sizes. Look for <code>add_image_size('post-image-name');</code> line in your functions.php, and check the name, if you want to use your theme&#8217;s thumbnails.</p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/mHv2UwESQts" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/wordpress/wordpress-include-your-featured-post-image-in-rss-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/wordpress/wordpress-include-your-featured-post-image-in-rss-feeds/</feedburner:origLink></item>
		<item>
		<title>Create sitemap.xml In WordPress Without Using Any Plugins</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/3nGoR3zs0vg/</link>
		<comments>http://emrahgunduz.com/categories/development/wordpress/create-sitemap-xml-in-wordpress-without-any-plugins/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 13:29:49 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom code]]></category>
		<category><![CDATA[no plugin]]></category>
		<category><![CDATA[sitemap.xml]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=137</guid>
		<description><![CDATA[Everybody likes plugins, and most of them are really great (in case of WordPress). But some people like me, tend to do the work by themselves. So, here is a [...]]]></description>
			<content:encoded><![CDATA[<p>Everybody likes plugins, and most of them are really great (in case of WordPress). But some people like me, tend to do the work by themselves.</p>
<p>So, here is a simple code that will re-create a sitemap.xml file, everytime you publish a post or page. Copy the code and paste it to your theme&#8217;s functions.php file (<em>wp-content/themes/your_theme_folder/functions.php</em>).</p>
<p>PS. I added <em><span style="color: #993300;">&lt;?php &#8230; ?&gt;</span></em> for clean code coloring, you will not need those lines.</p>
<pre>
<div class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;publish_post&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;eg_create_sitemap&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;publish_page&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;eg_create_sitemap&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>

<span style="color: #000000; font-weight: bold;">function</span> eg_create_sitemap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; <span style="color: #000088;">$postsForSitemap</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
&nbsp; &nbsp; <span style="color: #0000ff;">'numberposts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
&nbsp; &nbsp; <span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'modified'</span><span style="color: #339933;">,</span>
&nbsp; &nbsp; <span style="color: #0000ff;">'post_type'</span> &nbsp;<span style="color: #339933;">=&gt;</span> <a target="_blank" href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
&nbsp; &nbsp; <span style="color: #0000ff;">'order'</span> &nbsp; &nbsp;<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'DESC'</span>
&nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #000088;">$sitemap</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;'</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #000088;">$sitemap</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&gt;'</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postsForSitemap</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp; &nbsp; setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; <span style="color: #000088;">$postdate</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_modified</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; <span style="color: #000088;">$sitemap</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;url&gt;'</span><span style="color: #339933;">.</span>
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'&lt;loc&gt;'</span><span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/loc&gt;'</span><span style="color: #339933;">.</span>
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'&lt;lastmod&gt;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$postdate</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/lastmod&gt;'</span><span style="color: #339933;">.</span>
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'&lt;changefreq&gt;monthly&lt;/changefreq&gt;'</span><span style="color: #339933;">.</span>
&nbsp; &nbsp; <span style="color: #0000ff;">'&lt;/url&gt;'</span><span style="color: #339933;">;</span>
&nbsp; <span style="color: #009900;">&#125;</span>
&nbsp; 
&nbsp; <span style="color: #000088;">$sitemap</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/urlset&gt;'</span><span style="color: #339933;">;</span>
&nbsp; 
&nbsp; <span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <a target="_blank" href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;sitemap.xml&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <a target="_blank" href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sitemap</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp; <a target="_blank" href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></div>
</pre>
<p>If you&#8217;ve got custom post types, you&#8217;ll need to add the registered taxonomy to &#8216;post_type&#8217; array part of the code.</p>
<p>For a big blog with thousands of posts, creating a sitemap.xml file with every post publish action might not be a good solution, so keep that in mind.</p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/3nGoR3zs0vg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/wordpress/create-sitemap-xml-in-wordpress-without-any-plugins/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/wordpress/create-sitemap-xml-in-wordpress-without-any-plugins/</feedburner:origLink></item>
		<item>
		<title>Random Rotate Maxscript Version 1.1</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/Is_8pEobZfI/</link>
		<comments>http://emrahgunduz.com/categories/development/maxscript/random-rotate-maxscript-version-1-1/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 22:05:58 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Maxscript]]></category>
		<category><![CDATA[3dsmax]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[object based]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[rotate]]></category>
		<category><![CDATA[selection center]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=121</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/random_rotate11-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Random Rotate 1.1" title="Random Rotate 1.1" /></p>I’ve changed how random rotate works, and added a few new features. First of all, rotation now uses quaternion, which is better than euler rotation. I was converting euler angles [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/random_rotate11-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Random Rotate 1.1" title="Random Rotate 1.1" /></p><p>I’ve changed how random rotate works, and added a few new features. First of all, rotation now uses quaternion, which is better than euler rotation. I was converting euler angles to quats, this was getting rid of the gimbal lock, but it was not enough for adding new ways of rotation to the script.</p>
<p><a href="http://emrahgunduz.com/wp-content/uploads/zip/random_rotate_v1.1.zip">Download Random Rotate 1.1</a></p>
<p>So, with new version, you are now able to rotate an object randomly bu using objects’ local or world coordinates, or the screen coordinate itself. Also, it is now possible to use the selection center, or another object’s pivot.</p>
<p>I don’t know where you can use these new features, but it was fun building them in. Have fun <img src='http://emrahgunduz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here are some screenshots:<br />
<div class="eggallery">
					<p>Drag drop to start the script<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-rotate-11/random_rotate_11_dragdrop-3KW65180.jpg"
								title="Drag drop to start the script"
								alt="Drag drop to start the script"
								class="eggalleryimage" />
					</p>
					<p>Script popup appears<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-rotate-11/random_rotate_11_toolappears-5NUNY30O.jpg"
								title="Script popup appears"
								alt="Script popup appears"
								class="eggalleryimage" />
					</p>
					<p>World Z only random rotation<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-rotate-11/random_rotate_worldzonly-082M0H3R.jpg"
								title="World Z only random rotation"
								alt="World Z only random rotation"
								class="eggalleryimage" />
					</p>
					<p>Screen Z only random rotation<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-rotate-11/random_rotate_screenzonly-N6P9Q350.jpg"
								title="Screen Z only random rotation"
								alt="Screen Z only random rotation"
								class="eggalleryimage" />
					</p>
					<p>Selection center Z only random rotation<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-rotate-11/random_rotate_selectioncenterz-2UN4OXVV.jpg"
								title="Selection center Z only random rotation"
								alt="Selection center Z only random rotation"
								class="eggalleryimage" />
					</p>
					<p>Selected object Z only random rotation<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-rotate-11/random_rotate_selectedobjectz-ET0AD675.jpg"
								title="Selected object Z only random rotation"
								alt="Selected object Z only random rotation"
								class="eggalleryimage" />
					</p></div></p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/Is_8pEobZfI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/maxscript/random-rotate-maxscript-version-1-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/maxscript/random-rotate-maxscript-version-1-1/</feedburner:origLink></item>
		<item>
		<title>Random Material Assigner for Objects with Multiple MaterialIDs</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/qb-M78h8AvY/</link>
		<comments>http://emrahgunduz.com/categories/development/maxscript/random-material-assigner-for-objects-with-multiple-materialids/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 19:43:59 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Maxscript]]></category>
		<category><![CDATA[3dsmax]]></category>
		<category><![CDATA[material]]></category>
		<category><![CDATA[materialid]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[multisub]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=101</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/01/random_matid-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Random Material Assigner" title="Random Material Assigner" /></p>Works on one or multiple object selections. Script detects the materialID count and creates a multi-sub material(s) for the selected object(s), and changes the diffuse channel with a random color. [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/01/random_matid-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Random Material Assigner" title="Random Material Assigner" /></p><p>Works on one or multiple object selections. Script detects the materialID count and creates a multi-sub material(s) for the selected object(s), and changes the diffuse channel with a random color. If there is only one materialID on the object, script simply creates a standart material.</p>
<p><a href="http://emrahgunduz.com/wp-content/uploads/zip/materialid_randommats.zip">Download Random Material Assigner for Objects with MaterialID</a></p>
<p>As this is a macroscript, after running it, you need to add it to a quad menu, or an icon on a toolbar, or to a menu. Script’s category is “emrahgunduz.com”.</p>
<p>Keep these in mind</p>
<ul>
<li>Created materials are named after the object’ own name.</li>
<li>Materials in the multi-sub object will be “Standard”.</li>
<li>Changes diffuse channel color with a random one.</li>
<li>Works only with poly, mesh or patch object. There is no nurbs or basic object support.</li>
</ul>
<p>Here are some screenshots<br />
<div class="eggallery">
					<p>Drag drop script for installation<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-material-assigner/random_matid_dragdrop-1SU0A4H3.jpg"
								title="Drag drop script for installation"
								alt="Drag drop script for installation"
								class="eggalleryimage" />
					</p>
					<p>Add script to your quad menu or to a toolbar<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-material-assigner/random_matid_addtomenu-91K5T9G7.jpg"
								title="Add script to your quad menu or to a toolbar"
								alt="Add script to your quad menu or to a toolbar"
								class="eggalleryimage" />
					</p>
					<p>Select your object and run the script<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-material-assigner/random_matid_selectandrun-9U35GU87.jpg"
								title="Select your object and run the script"
								alt="Select your object and run the script"
								class="eggalleryimage" />
					</p>
					<p>Your object is randomly materialized<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-material-assigner/random_matid_objectmaterialized-LW7X85MV.jpg"
								title="Your object is randomly materialized"
								alt="Your object is randomly materialized"
								class="eggalleryimage" />
					</p></div></p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/qb-M78h8AvY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/maxscript/random-material-assigner-for-objects-with-multiple-materialids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/maxscript/random-material-assigner-for-objects-with-multiple-materialids/</feedburner:origLink></item>
		<item>
		<title>Random Scale Maxscript</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/ImwE9qIN-Tc/</link>
		<comments>http://emrahgunduz.com/categories/development/maxscript/random-scale-maxscript/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 20:52:06 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Maxscript]]></category>
		<category><![CDATA[3dsmax]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=115</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/random_scale-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Random Scale" title="Random Scale" /></p>This one, as you can guess, randomly changes the scale of the selected objects. You can scale in uniform, or any axis alone or together. Download Random Scale Maxscript Script [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/02/random_scale-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Random Scale" title="Random Scale" /></p><p>This one, as you can guess, randomly changes the scale of the selected objects. You can scale in uniform, or any axis alone or together.</p>
<p><a href="http://emrahgunduz.com/wp-content/uploads/zip/random_scale.zip">Download Random Scale Maxscript</a></p>
<p>Script allows you to scale any object. Plus you can randomly scale incrementally. This will cause objects get bigger and bigger (or smaller and smaller, depending on the random multiplier).</p>
<p>Here are some screenshots<br />
<div class="eggallery">
					<p>Drag drop to start the script<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-scale-maxscript/random_scale_installation-C0IV4959.jpg"
								title="Drag drop to start the script"
								alt="Drag drop to start the script"
								class="eggalleryimage" />
					</p>
					<p>The popup appears<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-scale-maxscript/random_scale_popsup-AG347C4M.jpg"
								title="The popup appears"
								alt="The popup appears"
								class="eggalleryimage" />
					</p>
					<p>Random scale your selected objects<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-scale-maxscript/random_scale_scale01-43315TQQ.jpg"
								title="Random scale your selected objects"
								alt="Random scale your selected objects"
								class="eggalleryimage" />
					</p>
					<p>Incremental random scale<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-scale-maxscript/random_scale_scale02-0E280QB9.jpg"
								title="Incremental random scale"
								alt="Incremental random scale"
								class="eggalleryimage" />
					</p></div></p>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/ImwE9qIN-Tc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/maxscript/random-scale-maxscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/maxscript/random-scale-maxscript/</feedburner:origLink></item>
		<item>
		<title>Randomly Delete Objects With Maxscript</title>
		<link>http://feedproxy.google.com/~r/emrahgunduz/feed/~3/rezXyWcFkeE/</link>
		<comments>http://emrahgunduz.com/categories/development/maxscript/randomly-delete-objects-with-maxscript/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 19:13:50 +0000</pubDate>
		<dc:creator>emrahgunduz</dc:creator>
				<category><![CDATA[Maxscript]]></category>
		<category><![CDATA[3dsmax]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://emrahgunduz.com/?p=95</guid>
		<description><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/01/rdo-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Randomly Delete Objects" title="Randomly Delete Objects" /></p>The script randomly deletes meshes from the selection. As the script depends on the random numbers created by 3dsmax, the percentage can be %0-1 off what you expected. Just select [...]]]></description>
			<content:encoded><![CDATA[<p><img width="730" height="220" src="http://emrahgunduz.com/wp-content/uploads/2011/01/rdo-730x220.jpg" class="attachment-thumb-post wp-post-image" alt="Randomly Delete Objects" title="Randomly Delete Objects" /></p><p>The script randomly deletes meshes from the selection. As the script depends on the random numbers created by 3dsmax, the percentage can be %0-1 off what you expected. Just select the meshes you want to randomly delete. Enter a percentage, click the Delete button.</p>
<p><a href="http://emrahgunduz.com/wp-content/uploads/zip/random_delete.zip">Download Random Delete</a></p>
<p>Here are some screenshots<br />
<div class="eggallery">
					<p>Just drag drop for startup<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-delete-maxscript_1/rdo_installation-85AQ5H98.jpg"
								title="Just drag drop for startup"
								alt="Just drag drop for startup"
								class="eggalleryimage" />
					</p>
					<p>Script comes to life<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-delete-maxscript_1/rdo_popup-C967CGI4.jpg"
								title="Script comes to life"
								alt="Script comes to life"
								class="eggalleryimage" />
					</p>
					<p>10 percent random deletion<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-delete-maxscript_1/rdo_10percent-977U9822.jpg"
								title="10 percent random deletion"
								alt="10 percent random deletion"
								class="eggalleryimage" />
					</p>
					<p>50 percent random deletion<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-delete-maxscript_1/rdo_50percent-23HQ78IT.jpg"
								title="50 percent random deletion"
								alt="50 percent random deletion"
								class="eggalleryimage" />
					</p>
					<p>90 percent random deletion<br/>
					<img src="http://emrahgunduz.com/wp-content/uploads/eggallery/random-delete-maxscript_1/rdo_90percent-T5QC1U6T.jpg"
								title="90 percent random deletion"
								alt="90 percent random deletion"
								class="eggalleryimage" />
					</p></div></p>
<p>And here is the code if you want to check it right away</p>
<pre>
<div class="maxscript" style="font-family:monospace;"><span style="color: #dc143c;">rollout</span> RDGUI <span style="color: #7f007f;">&quot;Random Delete v.1.0&quot;</span> width:<span style="color: #ff4500;">184</span> height:<span style="color: #ff4500;">144</span>
<span style="color: black;">&#40;</span>
&nbsp; spinner s_percentage <span style="color: #7f007f;">&quot;&quot;</span> pos:<span style="color: black;">&#91;</span><span style="color: #ff4500;">112</span>,<span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span> width:<span style="color: #ff4500;">48</span> height:<span style="color: #ff4500;">16</span> enabled:<span style="color: #007f00;">true</span> range:<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">100</span>,<span style="color: #ff4500;">50</span><span style="color: black;">&#93;</span> type:#integer
&nbsp; button b_delete <span style="color: #7f007f;">&quot;Delete&quot;</span> pos:<span style="color: black;">&#91;</span><span style="color: #ff4500;">56</span>,<span style="color: #ff4500;">40</span><span style="color: black;">&#93;</span> width:<span style="color: #ff4500;">72</span> height:<span style="color: #ff4500;">20</span>
&nbsp; label l_percent <span style="color: #7f007f;">&quot;%&quot;</span> pos:<span style="color: black;">&#91;</span><span style="color: #ff4500;">163</span>,<span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span> width:<span style="color: #ff4500;">12</span> height:<span style="color: #ff4500;">16</span>
&nbsp; label l_info <span style="color: #7f007f;">&quot;Deletion Percentage :&quot;</span> pos:<span style="color: black;">&#91;</span><span style="color: #ff4500;">8</span>,<span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span> width:<span style="color: #ff4500;">104</span> height:<span style="color: #ff4500;">17</span>
&nbsp; 
&nbsp; <span style="color: #007f00;">on</span> b_delete pressed <span style="color: blue;font-weight:bold;">do</span>
&nbsp; <span style="color: black;">&#40;</span>
&nbsp; &nbsp; per <span style="color: #66cc66;">=</span> s_percentage.<span style="color: #0000cd;">value</span> <span style="color: blue;font-weight:bold;">as</span> Float <span style="color: #66cc66;">/</span> <span style="color: #ff4500;">100</span>
&nbsp; &nbsp; sel <span style="color: #66cc66;">=</span> <span style="color: blue;font-weight:bold;">selection</span> <span style="color: blue;font-weight:bold;">as</span> array
&nbsp; &nbsp; count <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span>
&nbsp; &nbsp; 
&nbsp; &nbsp; <span style="color: blue;font-weight:bold;">if</span> sel.<span style="color: #3c83b1;">count</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">2</span> <span style="color: blue;font-weight:bold;">then</span>
&nbsp; &nbsp; <span style="color: black;">&#40;</span>
&nbsp; &nbsp; &nbsp; <span style="color: blue;font-weight:bold;">undo</span> <span style="color: #007f00;">on</span>
&nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;font-weight:bold;">while</span> count <span style="color: #66cc66;">&lt;</span> sel.<span style="color: #3c83b1;">count</span> <span style="color: blue;font-weight:bold;">do</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rand <span style="color: #66cc66;">=</span> random <span style="color: #ff4500;">0.0</span> <span style="color: #ff4500;">1.0</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;font-weight:bold;">if</span> rand <span style="color: #66cc66;">&lt;</span> per <span style="color: blue;font-weight:bold;">do</span> <span style="color: black;">&#40;</span>delete sel<span style="color: black;">&#91;</span>count<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #66cc66;">+=</span> <span style="color: #ff4500;">1</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span>
&nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span>
&nbsp; &nbsp; <span style="color: black;">&#41;</span>
&nbsp; &nbsp; <span style="color: blue;font-weight:bold;">else</span> <span style="color: #0000cd;">messageBox </span><span style="color: #7f007f;">&quot;You must select at least three or more objects&quot;</span> title:<span style="color: #7f007f;">&quot;Random Delete&quot;</span>
&nbsp; <span style="color: black;">&#41;</span>
<span style="color: black;">&#41;</span>

RDFloater <span style="color: #66cc66;">=</span> <span style="color: #0000cd;">newRolloutFloater </span><span style="color: #7f007f;">&quot;emrahgunduz.com&quot;</span> <span style="color: #ff4500;">195</span> <span style="color: #ff4500;">100</span>
addRollOut RDGUI RDFloater</div>
</pre>
<img src="http://feeds.feedburner.com/~r/emrahgunduz/feed/~4/rezXyWcFkeE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://emrahgunduz.com/categories/development/maxscript/randomly-delete-objects-with-maxscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://emrahgunduz.com/categories/development/maxscript/randomly-delete-objects-with-maxscript/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 18/96 queries in 0.098 seconds using memcached
Object Caching 1490/1680 objects using memcached

Served from: emrahgunduz.com @ 2012-05-14 06:06:11 -->

