<?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>ANDY STRATTON</title>
	<atom:link href="http://theandystratton.com/feed" rel="self" type="application/rss+xml" />
	<link>http://theandystratton.com</link>
	<description>WordPress and PHP Developer</description>
	<lastBuildDate>Wed, 18 Apr 2012 20:49:34 +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>Restrict WordPress Registration to Email&#160;Whitelist</title>
		<link>http://theandystratton.com/2011/restrict-wordpress-registration-to-email-whitelist</link>
		<comments>http://theandystratton.com/2011/restrict-wordpress-registration-to-email-whitelist#comments</comments>
		<pubDate>Tue, 11 Oct 2011 21:33:48 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=590</guid>
		<description><![CDATA[Today I ran into a request with a client that I wanted to document and share: restricting registration to a WordPress site to a whitelist of email address domains. Luckily, there&#8217;s a sweet hook, registration_errors you can get into. It accepts 3 parameters: $errors, which is the WP_Error object; $login, which is the user_login entered [...]]]></description>
			<content:encoded><![CDATA[<p>Today I ran into a request with a client that I wanted to document and share: restricting registration to a WordPress site to a whitelist of email address domains.</p>
<p>Luckily, there&#8217;s a sweet hook, <code>registration_errors</code> you can get into. It accepts 3 parameters: <code>$errors</code>, which is the WP_Error object; <code>$login</code>, which is the <code>user_login</code> entered during registration; and <code>$email</code>, which is the <code>user_email</code> entered during registration.</p>
<p>Here&#8217;s the code:</p>
<pre><code>add_action('registration_errors', 'sizeable_restrict_domains', 10, 3);
function sizeable_restrict_domains( $errors, $login, $email ) {
	$whitelist = array('sizeableinteractive.com', 'theandystratton.com');
	if ( is_email($email) ) {
		$parts = explode('@', $email);
		$domain = $parts[count($parts)-1];
		if ( !in_array(strtolower($domain), $whitelist) ) {
			$errors->add('email_domain', __('<strong>ERROR:</strong> You may only register with an approved email address.'));
		}
	}
	return $errors;
}</code></pre>
<p><strong>Remember</strong> to specify some kind of priority AND how many parameters your callback function will accept when adding actions. I always forget to specify them when coding quickly from scratch and wonder why I&#8217;m getting weird values in my callback functions parameters.</p>
<p>Happy WP&#8217;ing.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/restrict-wordpress-registration-to-email-whitelist/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recursively Delete Subversion (.svn)&#160;Directories</title>
		<link>http://theandystratton.com/2011/recursively-delete-subversion-svn-directories</link>
		<comments>http://theandystratton.com/2011/recursively-delete-subversion-svn-directories#comments</comments>
		<pubDate>Wed, 05 Oct 2011 18:20:14 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=588</guid>
		<description><![CDATA[I alway am hunting for this little command-line gem, so I figured I&#8217;d post it and share the quick shell script I added to my home directory to make it faster for me to do this. Often, I will find an old project (or inherit, or destroy) a project with subversion directories and files in [...]]]></description>
			<content:encoded><![CDATA[<p>I alway am hunting for this little command-line gem, so I figured I&#8217;d post it and share the quick shell script I added to my home directory to make it faster for me to do this.</p>
<p>Often, I will find an old project (or inherit, or destroy) a project with subversion directories and files in it. However I get there, every few months I find myself wanting to remove subversion folders recursively and am not well-versed in shell scripting to remember how to do it.</p>
<p>Here&#8217;s the single line magic removal of .svn directories:</p>
<pre><cod>rm -rf `find . -type d -name .svn`</code></pre>
<p>And here&#8217;s the script I wrote and placed in my home directory, <code>~/recursively-kill-svn.sh</code>:</p>
<pre><code>while true; do
	read -p "Do you want to recursively delete all .svn folders/files in the current directory (`pwd`)? (y/n)" yn
	case $yn in

		[Yy]* ) rm -rf `find . -type d -name .svn`; echo ".svn directories in `pwd` have been recursively killed!!1"; break;;

		[Nn]* ) echo "I've done absolutely nothing."; exit;;
		* ) exit;
	esac
done</code></pre>
<p>With this in my home directory, I just move to a project folder, type:</p>
<pre><code>~/recursively-kill-svn.sh</code></pre>
<p>&#8230;and hit enter. Enjoy.</p>
<p>P.S. If it&#8217;s not working for you (or auto-completing when you hit tab in Terminal) make sure it has permissions to execute:</p>
<pre><code>chmod +x ~/recursively-kill-svn.sh</code></pre>
<p>P.P.S. You can rename the file to whatever you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/recursively-delete-subversion-svn-directories/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sizeable Spaces &#8211; Baltimore&#160;Coworking</title>
		<link>http://theandystratton.com/2011/sizeable-spaces-baltimore-coworking</link>
		<comments>http://theandystratton.com/2011/sizeable-spaces-baltimore-coworking#comments</comments>
		<pubDate>Thu, 14 Jul 2011 23:58:09 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=574</guid>
		<description><![CDATA[We did it. As of July 4, 2011, our space for coworking in Baltimore has launched. I give you Sizeable Spaces, an 1800 square foot dedicated coworking facility in the Federal Hill district of Baltimore, MD. The space includes: 24/7 keyless entry Conference room with presentation capabilities 50/10Mbps business class Internet connection (wired and wifi) [...]]]></description>
			<content:encoded><![CDATA[<p>We did it. As of July 4, 2011, our space for <a href="http://www.sizeablespaces.org" rel="external">coworking in Baltimore</a> has launched.</p>
<p>I give you <a href="http://www.sizeablespaces.org" rel="external nofollow">Sizeable Spaces</a>, an 1800 square foot dedicated coworking facility in the Federal Hill district of Baltimore, MD. The space includes:</p>
<ul>
<li>24/7 keyless entry</li>
<li>Conference room with presentation capabilities</li>
<li>50/10Mbps business class Internet connection (wired and wifi)</li>
<li>Microwave, coffee machine, water cooler and refrigerator</li>
<li>11 dedicated desks for working and a vacant private office for additional space or private phone calls</li>
<li>Free residential parking</li>
<li>Color laser printer (networked)</li>
<li>Two outside decks&#8230;and as much more as we can add&#8230;</li>
</ul>
<p>Check us out when you have a chance, take a tour, or even come work a free day and see how you like it. We&#8217;re having an <a href="http://lightstreetopenhouse.eventbrite.com/" rel="external">open house</a> on Tuesday, July 26th if you&#8217;re interested in checking it out, having some food/drinks and meeting other people like us.</p>
<p>I&#8217;m extremely excited to see how the community in our space grows, it&#8217;s organically grown from 4-7 members in a week. The power of community and doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/sizeable-spaces-baltimore-coworking/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twitter&#8217;s Search Widget Showing Too Many&#160;Tweets</title>
		<link>http://theandystratton.com/2011/twitter-search-widget-showing-too-many-tweets</link>
		<comments>http://theandystratton.com/2011/twitter-search-widget-showing-too-many-tweets#comments</comments>
		<pubDate>Tue, 31 May 2011 22:26:59 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=570</guid>
		<description><![CDATA[So this is a quick post from an issue that has frustrated me. I am using and re-styling Twitter&#8217;s search widget on a client&#8217;s site. When I create it on Twitter&#8217;s widget builder, it looks great. When I paste it on the site, it&#8217;s not limiting the tweets to 5, it defaults back to 30 [...]]]></description>
			<content:encoded><![CDATA[<p>So this is a quick post from an issue that has frustrated me. I am using and re-styling <a href="http://twitter.com/about/resources/widgets/widget_search" rel="external">Twitter&#8217;s search widget</a> on a client&#8217;s site. When I create it on <a href="http://twitter.com/about/resources/widgets" rel="external">Twitter&#8217;s widget builder</a>, it looks great. When I paste it on the site, it&#8217;s not limiting the tweets to 5, it defaults back to 30 or some large number I don&#8217;t want.</p>
<p>It&#8217;s effectively missing a very simple, but critical JSON property in the root level object, named <code style="background:lightYellow;">rpp</code> (results per page, perhaps?).</p>
<h2>Example:</h2>
<pre><code>&lt;script src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt;
&lt;script&gt;
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: 'rainbow',
  interval: 6000,
  <strong style="background-color:lightYellow;">rpp: 5,</strong>
  title: 'It\'s a double rainbow',
  subject: 'Across the sky',
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#8ec1da',
      color: '#ffffff'
    },
    tweets: {
      background: '#ffffff',
      color: '#444444',
      links: '#1985b5'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
&lt;/script&gt;</code></pre>
<p>That&#8217;s it. Just add that <code>rpp</code> property and set it to the number you want to limit by and boom!</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/twitter-search-widget-showing-too-many-tweets/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Lost Widgets When Migrating WordPress Domains (dev to production&#160;server)</title>
		<link>http://theandystratton.com/2011/lost-widgets-when-migrating-domains-server</link>
		<comments>http://theandystratton.com/2011/lost-widgets-when-migrating-domains-server#comments</comments>
		<pubDate>Tue, 24 May 2011 03:57:41 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=550</guid>
		<description><![CDATA[This is something I ran into long into working on WordPress sites. Here&#8217;s how what happens: I work locally with a MAMP setup I create virtual hosts per project Each virtual host corresponds to a host name I add to my /etc/hosts file Sometimes I mirror this to a staging server/domain for the client to [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I ran into long into working on WordPress sites. Here&#8217;s how what happens:</p>
<ul>
<li>I work locally with a MAMP setup</li>
<li>I create virtual hosts per project</li>
<li>Each virtual host corresponds to a host name I add to my <code>/etc/hosts</code> file</li>
<li>Sometimes I mirror this to a staging server/domain for the client to prime content before launch</li>
<li>When launching, I take the staging database in a SQL export and import it into the production database and run a query to update the domains</li>
</ul>
<p>Many times, the last item is a query like this (assuming default database prefix):</p>
<pre><code>UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://dev.mycoolwebsite.com', 'http://www.mycoolwebsite.com');</code></pre>
<p>This typically did the trick. I rarely had issues, until one day, I migrated that had a <a rel="external" href="http://codex.wordpress.org/Widgetizing_Themes">widgetized sidebar</a> from my local machine, let&#8217;s say the hostname was <code>localhost</code> and the production domain was <code>www.mycoolsite.com</code>.</p>
<p>Everything worked as planned, but I lost all my widgets.</p>
<h2>¿Por Que, Widgets?</h2>
<p>Here&#8217;s what I figured: WordPress uses a serialized PHP array to store widget settings in the database. This array also contains the site&#8217;s domain, an abbreviated example would be:</p>
<pre><code>a:2:{s:3:"url";s:17:"http://localhost/";s:4:"meta";s:17:"some kind of meta";}</code></pre>
<p><code>a:2</code> represents an array with 2 elements; <code>s:3</code> says <q>this is a string that&#8217;s 3 characters long<!--1--> and so forth. When I run my replace SQL, it changes <code>http://localhost/</code> to <code>http://www.mycoolsite.com/</code> but never updates the string&#8217;s length from <code>s:17</code> to what it <em>should be</em>, which is <code>s:26</code>.</q></p>
<p>This simple inconsistency will invalidate that serialized array, returning <code>false</code> when it is unserialized &#8212; meaning no widgets or settings.</p>
<h2>Any Solution?</h2>
<p>Two solutions I use, short of some make-shiv helper script:</p>
<ol>
<li>Use a development/staging hostname that&#8217;s the same length so you can do a global replace (e.g. dev.mycoolsite.com, stg.mycoolsite.com, etc.)</li>
<li>Run a more target query</li>
</ol>
<p>Target Your Query, Hit the Widgets Page</p>
<p>Now, the following steps have worked for me and seem to be easier for me to be lazy with my organization up front. I recommend option 1 to be safe, but you can try this too:</p>
<pre><code>UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://localhost', 'http://www.mycoolwebsite.com')
<strong>WHERE option_value LIKE 'http://%';</strong></code></pre>
<p>This will restrict the query only to WordPress option records that &lt;strong&gt;start&lt;/strong&gt; with the http:// protocol, thus ignoring serialized arrays. Once this runs, hit your widgets settings page and re-save things, and if you&#8217;re as lucky as me, everything is kosher.</p>
<h2>Yet Another Option</h2>
<p>This may actually be simpler. Go into your dev/staging/etc. site&#8217;s options and change the domain. You&#8217;ll get logged out. Go make your database dump and use that. You&#8217;ll probably need to do the previous steps to fix your dev/staging database though.</p>
<p>Hope this helps a few of you if you&#8217;re in a frustrated panic.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/lost-widgets-when-migrating-domains-server/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>No Magic Bullets &#8211; WordCamp Raleigh&#160;2011</title>
		<link>http://theandystratton.com/2011/no-magic-bullets-wordcamp-raleigh-2011</link>
		<comments>http://theandystratton.com/2011/no-magic-bullets-wordcamp-raleigh-2011#comments</comments>
		<pubDate>Mon, 23 May 2011 18:13:11 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=541</guid>
		<description><![CDATA[I had a blast as WordCamp Raleigh. I re-connected with a ton of great people and met even more new people. My presentation got excellent reception from all attendees and I was quite pleased. I want to issue a huge thank you to Michael Torbert, Steve Mortiboy and the Semper Fi Web Design team for [...]]]></description>
			<content:encoded><![CDATA[<p>I had a blast as <a href="http://www.wordcampraleigh.com" rel="external">WordCamp Raleigh</a>. I re-connected with a ton of great people and met even more new people. My presentation got excellent reception from all attendees and I was quite pleased.</p>
<p>I want to issue a huge thank you to Michael Torbert, Steve Mortiboy and the <a href="http://semperfiwebdesign.com" rel="external">Semper Fi Web Design</a> team for making this happen, and making it happen well.</p>
<h2>The Slides</h2>
<div style="width:600px" id="__ss_8071017"><iframe src="http://www.slideshare.net/slideshow/embed_code/8071017" width="600" height="501" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><strong style="display:block;margin:12px 0 4px"><a href="http://slidesha.re/lLXIIs" rel="external" title="Diet Pills, SEO and Theme Frameworks: There are no magic bullets.">Diet Pills, SEO and Theme Frameworks: There are no magic bullets.</a></strong></div>
<p>You can <a href="/downloads/wcraleigh-preso-theandystratton.pdf">download the PDF</a> or <a href="http://slidesha.re/lLXIIs" rel="external">view the presentation on SlideShare</a>.</p>
<p>I think that the <a href="http://www.wordcampraleigh.com" rel="external">WordCamp Raleigh website</a> will also be posting slides and video(s).</p>
<p>Thanks to all who attended, see you at the next WordCamp!</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/no-magic-bullets-wordcamp-raleigh-2011/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Raw HTML Snippets WordPress&#160;Plugin</title>
		<link>http://theandystratton.com/2011/raw-html-snippets-wordpress-plugin</link>
		<comments>http://theandystratton.com/2011/raw-html-snippets-wordpress-plugin#comments</comments>
		<pubDate>Thu, 12 May 2011 15:16:52 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=531</guid>
		<description><![CDATA[Ever since my über vent over fake shortcodes that autoformat the output of real shortcodes, I realized that the intention was good but the execution was bad. So, I wrote a quick plugin that I thought was a more elegant (and that did not affect expected, core WordPress behaviors). Raw HTML Snippets This plugin allows [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since my über vent over <a href="http://theandystratton.com/2011/shortcode-autoformatting-html-with-paragraphs-and-line-breaks">fake shortcodes that autoformat the output of real shortcodes</a>, I realized that the intention was good but the execution was bad.</p>
<p>So, I wrote a quick plugin that I thought was a more elegant (and that did not affect expected, core WordPress behaviors).</p>
<h2>Raw HTML Snippets</h2>
<p>This plugin allows you to create a library of raw HTML snippets you need to embed within post/page content, then uses the native shortcode API to embed them without them being auto-formatted by <code>wpautop</code> or <code>wptexturize</code>.</p>
<p>It may not be as convenient as pasting directly into the HTML tab of the WYSIWYG editor, but it&#8217;s a solution that&#8217;s reusable, clean and does not interfere with the core functionality of WordPress or other possible plugins/shortcodes/content filters.</p>
<p><a herf="http://wordpress.org/extend/plugins/raw-html-snippets/" rel="external">Raw HTML Snippets</a> | <a href="http://downloads.wordpress.org/plugin/raw-html-snippets.zip" rel="external">Download</a></p>
<p>Give it a whirl, and let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/raw-html-snippets-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Shortcode Autoformatting HTML with Paragraphs and Line&#160;Breaks</title>
		<link>http://theandystratton.com/2011/shortcode-autoformatting-html-with-paragraphs-and-line-breaks</link>
		<comments>http://theandystratton.com/2011/shortcode-autoformatting-html-with-paragraphs-and-line-breaks#comments</comments>
		<pubDate>Tue, 10 May 2011 22:41:50 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=512</guid>
		<description><![CDATA[So, I have been working on a client&#8217;s WP plugin that is relatively linked to their ThemeForest WordPress theme authored by the good folks at ThemeFuse using their theme framework. Now, the easiest way to limit the reliance on the theme for the functionality I am building is to use shortcodes that output conditional content [...]]]></description>
			<content:encoded><![CDATA[<p>So, I have been working on a client&#8217;s WP plugin that is relatively linked to their <a href="http://www.themeforest.com" rel="nofollow external" title="Dear General Public: Stop customizing pre-built themes.">ThemeForest</a> WordPress theme authored by the good folks at <a href="http://www.themefuse.com" rel="external nofollow">ThemeFuse</a> using their <q>theme framework</q>.</p>
<p>Now, the easiest way to limit the reliance on the theme for the functionality I am building is to use shortcodes that output conditional content based on whether a user is logged in, based on user meta data, etc.</p>
<h2>Shortcode Autoformatting Has Helped Doubled My Time</h2>
<p>I have spent twice the amount of estimated time on this project, and at least 50% of that bloat has been this mysterious issue of my shortcode output being mysteriously auto-formatted with paragraph tags (<code>&lt;p&gt;</code>) and line-breaks (<code>&lt;br /&gt;</code>).</p>
<p>I&#8217;ve spent days ripping out the tiny hairs on my head trying to figure out why I&#8217;m such a moron when it comes to WP&#8217;s shortcode API and core content filters (things I&#8217;ve been working with for YEARS).</p>
<h2>I Do Something I Should Do More Often.</h2>
<p>My e-friend <a href="http://twitter.com/carlhancock" rel="external">Carl Hancock</a> of <a href="http://www.rocketgenius.com/" rel="external">Rocket Genius</a>, the company behind the awesomeness of functionality and user-experience that is <a href="http://www.gravityforms.com" rel="external" title="Worth Every Damn Penny + $100">GravityForms</a>, helped shed some light on this problem.</p>
<p>I figured he&#8217;d be the prefect person to reach out to, since the core of displaying a Gravity Form relies on WordPress&#8217; <a href="http://codex.wordpress.org/Shortcode_API" rel="external">Shortcode API</a>.</p>
<p>As we are direct messaging on Twitter, I remember his comments about fixing MANY ThemeForest theme issues for clients using Gravity Forms due to terrible coding standards and overriding core functionality that affect both Gravity Forms and other plugins.</p>
<p>I hunt through some of the 100+ files embedded in this pre-built theme <q>framework</q> and fine this, well, poor code:</p>
<pre><code>//Disable Automatic formatting in WordPress posts
function my_formatter($content) {
	$new_content = '';
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

	foreach ($pieces as $piece) {
		if (preg_match($pattern_contents, $piece, $matches)) {
			$new_content .= $matches[1];
		} else {
			$new_content .= wptexturize(wpautop($piece));
		}
	}
	return $new_content;
}

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');

add_filter('the_content', 'my_formatter', 99);
</code></pre>
<p>No sooner than I see this code, I get a DM from Carl with a link to a <a href="http://www.wprecipes.com/disable-wordpress-automatic-formatting-on-posts-using-a-shortcode" rel="external">WP Recipe article</a> with the exact same code.</p>
<p>I&#8217;m not sure WHO this code started with, but I know who used it.</p>
<h2>Why is this a problem?</h2>
<p>It&#8217;s globally removing two very important core content filters that WP has built-in for very good reasons. It is typically assumed by most themes and plugins that these filters are running. I don&#8217;t have a problem turning them off conditionally (i.e. specific post ID&#8217;s, specific page templates in a theme, etc.). Better yet, set this as a setting in a custom field, <em>per page/post</em>, and have it on by default. Give me the option to disable it and even know it exists if I&#8217;m walking into the theme from a distance. </p>
<div style="width:250px;float:right;margin:0 0 1em 1em;background:#f5f5f5;border:1px solid #ccc;padding:1em;font-size:11px;font-style:italic;">At least give it the same priority as the <code>wpautop</code> and <code>wptexturize</code> filters so it does NOT affect shortcode output and behaves as similarly as possible! I realize this is to allow users to have &#8220;raw HTML output,&#8221; but you can do the same thing using it as a content filter and token replacement before/after these core filters are called.</div>
<p>This makes this theme work perfectly and negatively affects ANY and ALL plugins that have shortcodes or possibly filter content after the assumed priority of <code>wpautop</code> and <code>wptexturize</code>.</p>
<p>This is not a solution. It&#8217;s more of a hack that may or may not have cause the earthquake in Haiti, the tsunami in Japan and the tornados in the southern U.S&#8230;</p>
<h2>How the hell do I fix this?</h2>
<p><strong>Don&#8217;t use a theme that poor code in it.</strong> That&#8217;s the optimal solution. Don&#8217;t expect a $36 purchase from a virtual Wal-mart to be stable, secure or provide you with a strong solution for communicating and interacting with your clients.</p>
<h2>Okay, so realistically how do I fix this?</h2>
<ol>
<li>You can comment these lines of code out, including the <code>remove_filter()</code> calls, so that WP behaves as expected.</li>
<li>You can remove this filter in your shortcodes, which is what I did since my client is going to continue to use this theme:
<pre><code>add_shortcode('andy_shortcode', 'andy_shortcode');
function andy_shortcode( $atts, $content = '' ) {
	remove_filter('the_content', 'my_formatter', 99);
	extract(shortcode_atts(array(), $atts));
	$output = '&lt;div class="my_formatter_violated_my_output"&gt;';
	$output .= 'Thanks for using the my theme framework.&lt;/div&gt;';
	return $output;
}</code></pre>
<p>Remeber you MUST <strong>enter their priority value of 99</strong> (or whatever it is set to in your theme, chances are you&#8217;re using a theme from the same authors, or authors of the same mentality).
</li>
<li>You can stop using shortcodes or pray that it doesn&#8217;t affect you.</li>
</ol>
<h2>Final Thoughts</h2>
<p>I understand what the intention of this functionality is. In fact, I think it&#8217;s a good idea, just a poor implementation.</p>
<p>Ultimately, I&#8217;d move away from these themes and check out some stronger theme directories with dedicate WP experts coding, not a hodge-podge marketplace. Being that I&#8217;m kind of against purchasing pre-built themes from both a designer and developer standpoint, I can&#8217;t recommend a good site, but I&#8217;m sure I can keep recommending sites NOT to use.</p>
<p>Good luck and God Speed.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/shortcode-autoformatting-html-with-paragraphs-and-line-breaks/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress 3.1 Admin Bar and I Can&#8217;t See Custom&#160;Fields!</title>
		<link>http://theandystratton.com/2011/wordpress-3-1-admin-bar-and-i-cant-see-custom-fields</link>
		<comments>http://theandystratton.com/2011/wordpress-3-1-admin-bar-and-i-cant-see-custom-fields#comments</comments>
		<pubDate>Thu, 24 Feb 2011 16:42:11 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=496</guid>
		<description><![CDATA[Alright WP junkies, I hope you&#8217;ve been upgrading. I won&#8217;t dive too deep into nerdiness of how the WP core team has answered my prayers and added a lot of things like better support in WP Query for taxonomy queries and Custom Fields/Meta queries, let&#8217;s focus on the Oh, Shit! moments a few of my [...]]]></description>
			<content:encoded><![CDATA[<p>Alright WP junkies, I hope you&#8217;ve been upgrading. I won&#8217;t dive too deep into nerdiness of how the WP core team has answered my prayers and added a lot of things like better support in WP Query for <a href="http://codex.wordpress.org/Function_Reference/query_posts#Taxonomy_Parameters" rel="external">taxonomy queries</a> and <a href="http://codex.wordpress.org/Function_Reference/query_posts#Custom_Field_Parameters" rel="external">Custom Fields/Meta queries</a>, let&#8217;s focus on the <q>Oh, Shit!</q> moments a few of my clients had today when I rolled some updates out.</p>
<h2>I Can&#8217;t See My Custom Fields</h2>
<p>I used custom fields a lot. Sometimes I create custom meta boxes for them, sometimes I have clients use the custom fields meta box directly. When we upgraded one of my client&#8217;s sites, my original administrator account still saw everything but the other accounts only saw the Publish, Page Attributes and title/editor panes in the Add/Edit Page screen.</p>
<p>Not cool. I was freaked. Then I realized (thanks to a <a href="http://wordpress.org/support/topic/wordpress-31-stable-cant-view-post-excerpts-or-custom-fields" rel="external">support post</a> at WordPress.org) that there are screen options there. They could&#8217;ve been there before and I just never paid attention, but now I know:</p>
<p><a target="_blank" href="http://theandystratton.com/wp-content/uploads/2011/02/Screen-shot-2011-02-24-at-11.32.40-AM.png"><img src="http://theandystratton.com/wp-content/uploads/2011/02/Screen-shot-2011-02-24-at-11.32.40-AM-300x79.png" alt="" title="Editor Screen Options" width="300" height="79" class="alignnone size-medium wp-image-500" /></a></p>
<p>Hopefully that helps you out.</p>
<h2>Killing the WordPress 3.1 Update Admin Bar</h2>
<p>Don&#8217;t get me wrong. I get it. I like it. But I have some installs where we are leveraging WP accounts but don&#8217;t want to advertise to the user that we&#8217;re on WP. I&#8217;ve used it for some very interesting applications and customized some installs heavily (not core, of course) and some clients just freaked about it.</p>
<p>My <a href="http://yoast.com/disable-wp-admin-bar/" rel="external">preferred method</a>, thanks to <a href="http://yoast.com" rel="external">Joost de Valk</a>, is to just to turn it off completely:</p>
<pre><code>add_filter('show_admin_bar', '__return_false');</code></pre>
<p>Remember, if you just want to hide it for yourself you can edit your user profile in the admin screens. <a href="http://yoast.com/disable-wp-admin-bar/" rel="external">Check out Joost&#8217;s article</a> for more options. Happy double-you-peeing.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2011/wordpress-3-1-admin-bar-and-i-cant-see-custom-fields/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>BuddyPress Avatars Not Displaying with WordPress&#160;3.0</title>
		<link>http://theandystratton.com/2010/buddypress-avatars-not-displaying-with-wordpress-3-0</link>
		<comments>http://theandystratton.com/2010/buddypress-avatars-not-displaying-with-wordpress-3-0#comments</comments>
		<pubDate>Thu, 09 Sep 2010 15:13:26 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theandystratton.com/?p=488</guid>
		<description><![CDATA[I don&#8217;t work with BuddyPress much if at all, but have been doing a lot more of it lately. Recently, we had an issue where avatars were not displaying on pages using the built-in template tags, like bp_member_avatar() and others. We thought this was a weird environment issue at first, but then I found this [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t work with BuddyPress much if at all, but have been doing a lot more of it lately. Recently, we had an issue where avatars were not displaying on pages using the built-in template tags, like <code>bp_member_avatar()</code> and others.</p>
<p>We thought this was a weird environment issue at first, but then I found <a href="http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/custom-avatars-not-showing-on-multisite-blogs/" rel="external">this post</a> that showed me it&#8217;s a common issue that&#8217;s been reported to their development team.</p>
<p>I continued searching for a solution and got some direction <a href="http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/custom-avatars-arent-shown-on-single-blogs-in-wpmu/" rel="external">from a solution</a> by <a href="http://buddypress.org/community/members/foralien/" rel="external">@foralien</a> on the BuddyPress forums. Her solution did not work for, but I created my own version and had success.</p>
<h2>What was happening?</h2>
<p>Our BuddyPress installation was trying to get avatars from <code>/blogs.dir/1/files/avatars/{$user_id}/{$filename}</code> – which did not eve exist, this was referencing a files directory for the root blog and it didn&#8217;t even exist.</p>
<p>As per <a href="http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/custom-avatars-arent-shown-on-single-blogs-in-wpmu/" rel="external">@foralien&#8217;s solution</a>, I created 2 filters (one for the avatar path, the other for the avatar public URL):</p>
<p><a href="/downloads/bp-avatar-filters.txt"><strong>Download the Code</strong></a></p>
<pre class="brush: php; title: ; notranslate">// Custom filters to clean up issues in WP 3.0 with avatar paths.
// Written by @theandystratton
function sizeable_bp_core_avatar_folder_dir( $path ) {
	$items = explode('/', $path);
	$path = ABSPATH . 'wp-content/uploads/avatars/' . end($items);
	return $path;
}
add_filter('bp_core_avatar_folder_dir', 'sizeable_bp_core_avatar_folder_dir');
function sizeable_bp_core_avatar_folder_url( $url ) {
	$items = explode('/', $url);
	$url = 'http://' . $items[2] . '/wp-content/uploads/avatars/' . end($items);
	return $url;
}
add_filter('bp_core_avatar_folder_url', 'sizeable_bp_core_avatar_folder_url');</pre>
<h2>What it&#8217;s doing</h2>
<p>We&#8217;re filtering the path and the url for avatars to ensure it&#8217;s using the WP 3.0 location, which is the upload_path for the root site followed by <code>/avatars/{$user_id}</code>. This is <em>not</em> a forever fix. I&#8217;d use it as duct tape until they release a BuddyPress update for WP 3.0 fixing the issue.</p>
<p>Hope this helps you guys and saves you some time and frustration.</p>
]]></content:encoded>
			<wfw:commentRss>http://theandystratton.com/2010/buddypress-avatars-not-displaying-with-wordpress-3-0/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

