<?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>Co-op Media</title>
	<atom:link href="http://co-opmedia.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://co-opmedia.org</link>
	<description>Minneapolis Interactive Design and Development</description>
	<lastBuildDate>Tue, 13 Jul 2010 15:18:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WordPress Database Error: Duplicate entry `0` for key 1</title>
		<link>http://co-opmedia.org/2010/07/wordpress-database-error-duplicate-entry-0-for-key-1/</link>
		<comments>http://co-opmedia.org/2010/07/wordpress-database-error-duplicate-entry-0-for-key-1/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 15:17:34 +0000</pubDate>
		<dc:creator>Paul Wenzel</dc:creator>
				<category><![CDATA[Developer Notes]]></category>

		<guid isPermaLink="false">http://co-opmedia.org/?p=114</guid>
		<description><![CDATA[Losing auto-increment attributes will lead to unintended consequences in your Wordpress installation. ]]></description>
			<content:encoded><![CDATA[<p>After migrating a large WordPress Mu database to a new host, I encountered errors when attempting to create new blogs. This awesome developer  <a href="http://myonecent.wordpress.com/2007/12/12/database-error-duplicate-entry-0-for-key-1/">posted a solution</a>  a few years back, noting auto-increment attributes sometimes get lost when doing MySQL dumps.</p>
<p>To prevent this issue from happening, be sure to use  <code>--complete-insert</code> when running mysqldump. The addition of  <code>--create-options</code> couldn't hurt.</p>
<p>Here's a quick example:</p>
<pre class="prettyprint lang-bash"><code>mysqldump --quote-names --complete-insert --create-options
--user=username --password=password database &gt; dumpfile.sql</code></pre>
<p>This is one of those errors that doesn't make any sense at all, until it sinks in. After awhile, it makes total sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://co-opmedia.org/2010/07/wordpress-database-error-duplicate-entry-0-for-key-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix for MAMP when MySQL is not starting</title>
		<link>http://co-opmedia.org/2010/05/fix-for-mamp-when-mysql-fail/</link>
		<comments>http://co-opmedia.org/2010/05/fix-for-mamp-when-mysql-fail/#comments</comments>
		<pubDate>Sun, 30 May 2010 10:00:21 +0000</pubDate>
		<dc:creator>Paul Wenzel</dc:creator>
				<category><![CDATA[Developer Notes]]></category>

		<guid isPermaLink="false">http://co-opmedia.org/?p=97</guid>
		<description><![CDATA[Fixing MySQL when MAMP leaves a dookie.]]></description>
			<content:encoded><![CDATA[<p>Occasionally <a href="http://mamp.info/">MAMP for OSX</a> will fail to start MySQL server. If this happens, here’s a quick fix:</p>
<p>1. Quit MAMP<br />
2. Open the terminal and type: <code>killall -9 mysqld</code><br />
3. Restart MAMP</p>
]]></content:encoded>
			<wfw:commentRss>http://co-opmedia.org/2010/05/fix-for-mamp-when-mysql-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Textwrangler Speed on Large Files</title>
		<link>http://co-opmedia.org/2010/05/textwrangler-speed-on-large-files/</link>
		<comments>http://co-opmedia.org/2010/05/textwrangler-speed-on-large-files/#comments</comments>
		<pubDate>Fri, 28 May 2010 01:06:06 +0000</pubDate>
		<dc:creator>Paul Wenzel</dc:creator>
				<category><![CDATA[Developer Notes]]></category>

		<guid isPermaLink="false">http://co-opmedia.org/?p=94</guid>
		<description><![CDATA[Textwrangler is snappy with really huge text files.]]></description>
			<content:encoded><![CDATA[<p>While attempting to open a 230MB SQL file, I discovered that <a href="http://www.barebones.com/products/TextWrangler/">Textwrangler</a> opens giant text files rather quickly, while  <a href="http://www.barebones.com/products/bbedit/">BBEdit</a> and <a href="http://macromates.com/">Textmate</a> tend to choke on them, if they even open at all.</p>
<p>Try it for yourself.  It'll blow your mind.</p>
]]></content:encoded>
			<wfw:commentRss>http://co-opmedia.org/2010/05/textwrangler-speed-on-large-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the template_redirect hook for custom WordPress URIs</title>
		<link>http://co-opmedia.org/2010/05/template-redirect/</link>
		<comments>http://co-opmedia.org/2010/05/template-redirect/#comments</comments>
		<pubDate>Fri, 14 May 2010 15:54:48 +0000</pubDate>
		<dc:creator>Paul Wenzel</dc:creator>
				<category><![CDATA[Developer Notes]]></category>

		<guid isPermaLink="false">http://new.co-opmedia.org/?p=24</guid>
		<description><![CDATA[Add "fake" pages to your site with these quick additions to your Wordpress or Wordpress Mu theme code, taking advantage of the 'template_redirect' plugin hook.]]></description>
			<content:encoded><![CDATA[<p>In developing a large-scale WordPress Mu site, I hit a point where I needed to create custom pages and associated templates on each blog.  Rather than iterating through each blog, I simply added a "fake" page to my WordPress theme code, applying it as a new feature to each site in my WPMU-based network.</p>
<p>In this example, I'll show you how to add a links page to your site, without actually creating a page in the WordPress admin interface. </p>
<p>First, be sure you have a file called <code>links.php</code> in your theme's template directory. </p>
<pre class="prettyprint"><code>&lt;?php
/*
Template Name: Links
*/
?&gt;

&lt;?php get_header(); ?&gt;

		&lt;h2&gt;My example links page&lt;/h2&gt;
		&lt;p&gt;This is an example list of folks that I know.&lt;/p&gt;

		&lt;?php
		$bm = get_bookmarks( array(
		            'orderby'        =&gt; 'rand',
		            'order'          =&gt; 'ASC',
		            'limit'          =&gt; -1,
		            'hide_invisible' =&gt; 1,
		            'show_updated'   =&gt; 0,
		            'include'        =&gt; null,
		            'exclude'        =&gt; null,
		            'search'         =&gt; '.'));
		?&gt;
		&lt;?php foreach ($bm as $bookmark): ?&gt;
		&lt;p&gt;<strong>&lt;?php echo $bookmark-&gt;link_name ?&gt;</strong> - &lt;?php echo $bookmark-&gt;link_url?&gt;&lt;/p&gt;
	&lt;?php endforeach; ?&gt;

&lt;?php get_footer(); ?&gt;</code></pre>
<p>Next, include this get_uri() function in your functions.php file:</p>
<pre class="prettyprint"><code>function get_uri() {
	$request_uri = $_SERVER['REQUEST_URI'];
	// for consistency, check to see if trailing slash exists in URI request
	if (substr($request_uri, -1)!="/") {
		$request_uri = $request_uri."/";
	}
	preg_match_all('#[^/]+/#', $request_uri, $matches);
	// could've used explode() above, but this is more consistent across varied WP installs
	$uri = $matches[0];
	return $uri;
}</code></pre>
<p>Add this set of functions and wordpress actions in your functions.php file:</p>
<pre class="prettyprint"><code>	function links_template_title() {
		return "My Example Link Page";
	}

	function links_template() {
		$uri = get_uri();
		if ($uri[0]=='links/') {
			add_filter('wp_title', 'links_template_title', 20);
			// optional hook for the_title
			// add_filter('the_title', 'links_template_title', 20);
			include(TEMPLATEPATH . '/links.php');
			exit;
		}
	}</code></pre>
<p>Now go to <strong>www.myexample.com/wordpress/links</strong> and enjoy your custom links page!</p>
<p>To take it a bit further, we could add another custom page with a few modifications, such as a local weather page. Just create another custom page template, <code>page-weather.php</code> and put it in your theme directory.</p>
<pre class="prettyprint"><code>&lt;?php
/*
Template Name: Weather Template
*/
?&gt;

&lt;?php get_header(); ?&gt;

		&lt;h2&gt;My example weather page&lt;/h2&gt;
		&lt;p&gt;This page could pull some information from the national weather service.&lt;/p&gt;
		&lt;p&gt;Forecast: The rain in Spain falls mainly on the plain.&lt;/p&gt;

&lt;?php get_footer(); ?&gt;</code></pre>
<p>Add this to your <code>functions.php</code> file:</p>
<pre class="prettyprint"><code>function weather_template_title() {
	return "Weather";
}

function weather_template() {
	$uri = get_uri();
	if ($uri[0]=='weather/') {
		add_filter('wp_title', 'weather_template_title', 20);
		// add_filter('the_title', 'weather_template_title', 20);
		include(TEMPLATEPATH . '/page-weather.php');
		exit;
	}
}</code></pre>
<p>Now go to <strong>www.myexample.com/wordpress/weather</strong> and enjoy your custom weather page.</p>
]]></content:encoded>
			<wfw:commentRss>http://co-opmedia.org/2010/05/template-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPMU Roles and Capabilities Hacks</title>
		<link>http://co-opmedia.org/2010/04/wpmu-roles-and-capabilities-hacks/</link>
		<comments>http://co-opmedia.org/2010/04/wpmu-roles-and-capabilities-hacks/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 04:41:41 +0000</pubDate>
		<dc:creator>Paul Wenzel</dc:creator>
				<category><![CDATA[Developer Notes]]></category>

		<guid isPermaLink="false">http://new.co-opmedia.org/?p=12</guid>
		<description><![CDATA[Modifications you can use to create site-wide roles and capabilities in your Worpress Mu blog network.]]></description>
			<content:encoded><![CDATA[<p>The following are some quick hacks you can apply to the WordPress <a href="http://wordpress.org/extend/plugins/capsman/">Capabilities Manager</a> plugin to set up custom roles on your entire network. </p>
<p>As of this writing, the plugin could only create custom roles on a blog level. There has been  <a href="http://wordpress.org/support/topic/362577">lots</a> <a href="http://wordpress.org/support/topic/275585">of</a> <a href="http://premium.wpmudev.org/forums/topic/role-editor-for-wpmu">discussion</a> on the matter. The root of the problem is that each blog in a WPMU installation has its own capabilities stored separately. </p>
<p>I initially tried to create my own database table with custom roles and capabilities, but I soon realized that WordPress would require a great deal more customization to make this work.  So, I decided to give in and store all the data the "native" way (which I consider somewhat dirty).</p>
<p>The following are modifications made to the <code>includes/manager.php</code> included with the <code>capsman</code> plugin. In short, I replaced all the CRUD functions with some quick loops that iterate through each blog in the network, making use of WPMU's <code>get_blog_list()</code> function.</p>
<p><strong>Caveats:</strong></p>
<p>1. This has only been tested on a simple level using WPMU 2.9.2.<br />
2. Due to the nature of WPMU, it creates a lot of duplicate data in your database.<br />
3. Performance could be better, but it crunched through 1200 blogs in about 10 seconds. </p>
<p>Let's take a look at <code>includes/manager.php</code>.</p>
<p>On <strong>Line 292</strong>, replace <code>saveRoleCapabilities</code> with the following <code>foreach</code> loop. I commented out the original code that was there, leaving it for reference.</p>
<pre class="prettyprint"><code>// *********** begin paul wenzel's modifications...
// updates/saves capabilties for this role, for all blogs
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
	switch_to_blog($blog['blog_id']);
	$this-&gt;saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
}
// $this-&gt;saveRoleCapabilities($post['current'], $post['caps'], $post['level']); // Original Code
// ********* end paul wenzel's modifications</code></pre>
<p>Around <strong>line 311</strong>, modify the call to <code>createRole</code>.</p>
<pre class="prettyprint"><code>// *********** begin paul wenzel's modifications... create roles for all blogs
// TODO: Add WPMU/multisite check using function_exists(get_bloglist()).
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
	switch_to_blog($blog['blog_id']);
	$newrole = $this-&gt;createRole($post['create-name']);
}

// **** Original Code
// if ( $newrole = $this-&gt;createRole($post['create-name']) ) {
// 	ak_admin_notify(__('New role created.', $this-&gt;ID));
// 	$this-&gt;current = $newrole;
// } else {
// 	ak_admin_error(__('Error: Failed creating the new role.', $this-&gt;ID));
// }

// ********* end paul wenzel's modifications</code></pre>
<p>On <strong>Line 335</strong>, modify the createRole call, copying the current role to a new one.</p>
<pre class="prettyprint"><code>// *********** begin paul wenzel's modifications... updates roles for all blogs
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
	switch_to_blog($blog['blog_id']);
	$newrole = $this-&gt;createRole($post['copy-name'], $current-&gt;capabilities);
}

// *** Original Plugin Code
// if ( $newrole = $this-&gt;createRole($post['copy-name'], $current-&gt;capabilities) ) {
// 	ak_admin_notify(__('New role created.', $this-&gt;ID));
// 	$this-&gt;current = $newrole;
// } else {
// 	ak_admin_error(__('Error: Failed creating the new role.', $this-&gt;ID));
// }
// ********* end paul wenzel's modifications</code></pre>
<p>On <strong>Line 362</strong>, add_cap method, adding a new capability to all blogs.</p>
<pre class="prettyprint"><code>// *********** begin paul wenzel's modifications... adds a new capability
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
	switch_to_blog($blog['blog_id']);
	$role-&gt;add_cap($newname['name']);
}
// restore_current_blog();
// $role-&gt;add_cap($newname['name']); // Original Code
// ********* end paul wenzel's modifications</code></pre>
<p>Finally, at <strong>Line 446</strong>, repeat the remove_role call, which deletes roles for all blogs. </p>
<pre class="prettyprint"><code>// *********** begin paul wenzel's modifications... deletes roles for all blogs
$blog_list = get_blog_list( 0, 'all' );
foreach ($blog_list AS $blog) {
	switch_to_blog($blog['blog_id']);
	remove_role($this-&gt;current);
}

// remove_role($this-&gt;current); // original code
// ********* end paul wenzel's modifications</code></pre>
<p>With the above iterative loops in place, you should be able to enjoy custom roles and capabilities throughout your blog network.</p>
]]></content:encoded>
			<wfw:commentRss>http://co-opmedia.org/2010/04/wpmu-roles-and-capabilities-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whitespace on Facebook</title>
		<link>http://co-opmedia.org/2010/02/facebook-whitespace/</link>
		<comments>http://co-opmedia.org/2010/02/facebook-whitespace/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 13:10:28 +0000</pubDate>
		<dc:creator>Paul Wenzel</dc:creator>
				<category><![CDATA[Developer Notes]]></category>

		<guid isPermaLink="false">http://co-opmedia.org/?p=99</guid>
		<description><![CDATA[Blissful whitespace amidst the clutter.]]></description>
			<content:encoded><![CDATA[<p>Create a file called Usercontent.css and save it anywhere on your computer (home directory). In it, paste the following contents and save.</p>
<pre class="prettyprint lang-css"><code>/* Usercontent.css
Blissfull Whitespace */

#ssponsor, .footer_ad, .banner_ad,
.social_ad, .ad_capsule, .sidebar_ads,
.adcolumn, .admarket_ad, .sidebar_item.sponsor,
.emu_sponsor, .home_sponsor {
	display: none !important;
}</code></pre>
<p>Open <strong>Safari</strong> > <strong>Preferences</strong> > <strong>Advanced</strong> > <strong>Style Sheet</strong>, and browse for your newly created Usercontent.css file. </p>
<p>Enjoy your newfound whitespace. This is confirmed to work with Safari on OSX as of this post's date. I imagine it would work in other browsers, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://co-opmedia.org/2010/02/facebook-whitespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached (feed is rejected)
Page Caching using memcached
Database Caching 2/9 queries in 0.002 seconds using memcached

Served from: co-opmedia.org @ 2010-07-30 06:55:29 -->