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

<channel>
	<title>Codepolice&#187; wordpress</title>
	<atom:link href="http://codepolice.net/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepolice.net</link>
	<description>Random posts from Ola in English. Mainly about programming and the web.</description>
	<lastBuildDate>Tue, 24 Jan 2012 07:19:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a empty/blank text widget for WordPress without additional markup and divs</title>
		<link>http://codepolice.net/creating-a-emptyblank-text-widget-for-wordpress-without-additional-markup-and-divs/</link>
		<comments>http://codepolice.net/creating-a-emptyblank-text-widget-for-wordpress-without-additional-markup-and-divs/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 11:06:52 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://403-autosave</guid>
		<description><![CDATA[WordPress provide a simple text widget that you can use on your blog to add some random HTML, Ads, images and so on. But i has one problem and that is that it&#8217;s always adding some extra HTML like this. &#60;div class=&#34;widget&#34;&#62; &#60;div class=&#34;textwidget&#34;&#62; &#60;/div&#62; &#60;/div&#62; Sometimes you really do not want this code if [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress provide a simple text widget that you can use on your blog to add some random HTML, Ads, images and so on. But i has one problem and that is that it&#8217;s always adding some extra HTML like this.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;widget&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;textwidget&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Sometimes you really do not want this code if you for example want to add a widget to a ul and want the outer tag to be a li. I tried to Google for this but surprisingly i didn&#8217;t find a single &#8220;Super Empty Text Widget&#8221; so i created one myself.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * SuperEmptyWidget Class
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> SuperEmptyWidget <span style="color: #000000; font-weight: bold;">extends</span> WP_Widget <span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/** constructor */</span>
    <span style="color: #000000; font-weight: bold;">function</span> SuperEmptyWidget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">WP_Widget</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'SuperEmptyWidget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/** @see WP_Widget::widget */</span>
    <span style="color: #000000; font-weight: bold;">function</span> widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/** @see WP_Widget::update */</span>
    <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_instance</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$instance</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/** @see WP_Widget::form */</span>
    <span style="color: #000000; font-weight: bold;">function</span> form<span style="color: #009900;">&#40;</span><span style="color: #000088;">$instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> esc_attr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
         <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>p<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
          <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span>?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_field_id<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span>?php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;/</span>label<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
		          <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span>p<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
          <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>textarea <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span>widefat<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> cols<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">20</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> rows<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">16</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> id<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span>?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_field_id<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;</span> name<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span>?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_field_name<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span>?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span> ?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;/</span>textarea<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// class SuperEmptyWidget</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// register SuperEmptyWidget widget</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widgets_init'</span><span style="color: #339933;">,</span> <span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return register_widget(&amp;quot;SuperEmptyWidget&amp;quot;);'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Just add that to your functions.php and you should have a widget that do not add any crap either before or after the content.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/creating-a-emptyblank-text-widget-for-wordpress-without-additional-markup-and-divs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Only show the sub menu when the parent is selected with the new wp_nav_menu in WordPress 3.0</title>
		<link>http://codepolice.net/only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0/</link>
		<comments>http://codepolice.net/only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 14:06:07 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0</guid>
		<description><![CDATA[I just spent two hours trying to hide the submenu for a menu item that is not selected in the new menu system in WordPress 3.0. First i found this post in the WordPress forums where someone had built a &#8220;Custom Walker&#8221; but it was for a slightly different scenario and it was also a [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent two hours trying to hide the submenu for a menu item that is not selected in the new menu system in WordPress 3.0. First i found <a href="http://wordpress.org/support/topic/413314">this post in the WordPress forums</a> where someone had built a &#8220;Custom Walker&#8221; but it was for a slightly different scenario and it was also a really complicated solution. Then i realized that i can do this super simple with jQuery. All you need is two lines of codes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.sub-menu&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.current_page_item .sub-menu, .current_page_parent .sub-menu&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.sub-menu li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;li class='sub-menu-seperator'&gt;|&lt;/li&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will hide all sub-menus, and then if a parent happens to have the class .current_page_item we show the sub-menu. My god i love jQuery.</p>
<p><strong>Update:</strong></p>
<p>As sushicodeur suggest you could of course do this only with CSS, it&#8217;s basically the same thing.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.sub-menu</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.current_page_item</span> <span style="color: #6666ff;">.sub-menu</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.current_page_parent</span> <span style="color: #6666ff;">.sub-menu</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.codepolice.net @ 2012-02-05 01:00:44 -->
