<?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>Apartment One Six</title>
	
	<link>http://apartmentonesix.com</link>
	<description />
	<lastBuildDate>Sat, 21 Aug 2010 21:06:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ApartmentOneSix" /><feedburner:info uri="apartmentonesix" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Help!  All the posts have disappeared from my WordPress site!</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/0ucWrQXzx00/</link>
		<comments>http://apartmentonesix.com/2010/08/help-all-the-posts-have-disappeared-from-my-wordpress-site/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 19:20:50 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=223</guid>
		<description><![CDATA[I do all of the development work for an SEO/MMO program over at thekeywordacademy.com.  As part of the program, we&#8217;ve put together a system that facilitates guest posting on other members&#8217; sites easily.  That&#8217;s all well and good &#8211; but one problem we run into fairly often is this:  For whatever reason, [...]]]></description>
			<content:encoded><![CDATA[<p>I do all of the development work for an SEO/MMO program over at thekeywordacademy.com.  As part of the program, we&#8217;ve put together a system that facilitates guest posting on other members&#8217; sites easily.  That&#8217;s all well and good &#8211; but one problem we run into fairly often is this:  For whatever reason, the posts table on a site goes down, and the owner&#8217;s posts are all suddenly gone &#8211; without a trace.  Naturally, they get pretty worried, and an email shows up in my inbox (or in our forum).</p>
<p>The good news is: it&#8217;s almost always just a simple myIsam crash &#8211; easy to fix, and no data loss.  After going through this a number of times with various members, I decided I really ought to put together a quick tutorial on how to fix it.</p>
<h2>Symptoms</h2>
<p>First &#8211; how do you know this is the issue you&#8217;re seeing?  The most obvious symptom is this:  Your posts have just disappeared.  The homepage of your blog is giving a 404 (but a pretty one, with your theme), or just telling you it can&#8217;t find any posts.  You log into your dashboard, and much to your dismay, the edit posts screen is showing not ONE single post.  It&#8217;s terrifying, because it&#8217;s at exactly this moment that you realize you never installed that backup plugin (or more likely, you started to, but never finished, because it got tricky).  Much cursing later, you&#8217;ve resigned to the fact that all is lost.</p>
<h2>Diagnosis</h2>
<p>Of course, it&#8217;s likely that all is not lost &#8211; lets look at how to make sure.<br />
<img class="alignright size-full wp-image-226" title="phpmyadmin-logo" src="http://apartmentonesix.com/wp-content/uploads/2010/08/phpmyadmin-logo.jpeg" alt="" width="150" height="87" /></p>
<p>To get this done, you&#8217;re going to need to get direct access to your database somehow.  There are a number of ways you can do this, ranging from the super nerdy (command line/ssh access), to the moderately nerdy (MySQL gui client like <a href="http://www.sequelpro.com/" target="_blank">Sequel Pro</a>), to the entirely accessible &#8211; the web based interface of phpMyAdmin.  I havent run across a host in recent times that doesnt give you access to phpMyAdmin in some form, so that&#8217;s what we&#8217;ll use here.</p>
<p>First, you&#8217;ll need to get into phpMyAdmin.  I can&#8217;t give you much help there, because it&#8217;s a different process with every host.  If you&#8217;re having trouble, get to your control panel, and just start searching for things &#8211; start with &#8220;phpMyAdmin&#8221;, but if you can&#8217;t find that, move on to &#8220;MySQL&#8221;, &#8220;Database&#8221; &#8211; things of that nature.  You&#8217;re bound to get on the right track soon enough.<br />
Once you&#8217;ve got phpMyAdmin opened up, you&#8217;ll end up at a screen that looks vaguely like this:<img src="http://apartmentonesix.com/wp-content/uploads/2010/08/Screen-shot-2010-08-17-at-10.23.25-AM-600x471.png" alt="" title="Screen shot 2010-08-17 at 10.23.25 AM" width="600" height="471" class="aligncenter size-large wp-image-227" /></p>
<h2>Find your database</h2>
<p>On this main page, you&#8217;ve got a list of databases off to the left, and lots of information and settings you don&#8217;t need to worry about in the center.   You need to choose the database that is running the WordPress install in question off on that left column, and click to open it up. (If you&#8217;ve got a number of WordPress installs on one server, this could be a bit tricky.  Check out the settings in your wp-config.php file if random guessing doesn&#8217;t do the trick).</p>
<p>Now that you&#8217;ve chosen your database, you&#8217;ll see the list on the left has changed &#8211; now you&#8217;re looking at tables inside the chosen database instead of databases.  Click on the wp_posts table to open it (note &#8211; it&#8217;s possible that this is something other than wp_posts, especially if you&#8217;ve got multiple installs in one database.  The table you want will definitely end in &#8220;posts&#8221;, and whatever comes before that can be found in your wp-config.php file  &#8211; look for &#8220;$table_prefix = &#8220;).  Clicking on the posts table will either pull up a page describing the contents of the table, or an error message, that looks something like this:<br />
<img src="http://apartmentonesix.com/wp-content/uploads/2010/08/crashed-600x121.png" alt="" title="crashed" width="600" height="121" class="aligncenter size-large wp-image-230" /></p>
<p>Surprisingly, this is good news.  Your precious posts are just one command away.  </p>
<h3>Repairing the table</h3>
<p>Finally, the juicy bits.  To repair the table, we&#8217;re going to need to run an SQL command on the database &#8211; and to do that, we&#8217;ll click the &#8220;SQL&#8221; tab near the top of the page.  Doing so should bring up a page with a box that looks something like this:<img src="http://apartmentonesix.com/wp-content/uploads/2010/08/repair-600x135.png" alt="" title="repair" width="600" height="135" class="aligncenter size-large wp-image-232" /><br />
As shown in the screenshot, you need to enter this:</p>
<pre class="brush: sql">
repair table wp_posts;
</pre>
<p>In case you hadn&#8217;t guessed &#8211; if your table didnt start with wp_, you need to adjust that command accordingly.  </p>
<p>Double check that you&#8217;ve typed the command in properly, and hit &#8220;Go&#8221; (bottom right of the input box).  If all went well, a moment of loading later, you should be presented with this screen:<br />
<img src="http://apartmentonesix.com/wp-content/uploads/2010/08/success-600x171.png" alt="" title="success" width="600" height="171" class="aligncenter size-large wp-image-233" /></p>
<p>And with that, you&#8217;re back in business.  Check your site, and your posts should be back.  In some cases, the wp_posts table isnt the only one that goes down, so as long as you&#8217;re in phpMyAdmin, you might double check to see if any of your other tables need some TLC from your newfound database administration skills.</p>
<p>On the off chance that none of this worked, the table wasn&#8217;t crashed, or repairing it didn&#8217;t fix the problem, there&#8217;s a fair chance you&#8217;re in serious trouble.  For problems with that, or any questions along the way, get in touch here, or <a href="mailto:peter@apartmentonesix.com">drop me an email</a>.</p>
<p>Good luck!</p>
<p><strong>Update</strong> &#8211; All this post disappearing have you hankering for some backup help?  Have a look at this post about <a href="http://codesessions.net/2010/08/backing-up-your-wordpress-install-the-basics/">How to back up your WordPress blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2010/08/help-all-the-posts-have-disappeared-from-my-wordpress-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2010/08/help-all-the-posts-have-disappeared-from-my-wordpress-site/</feedburner:origLink></item>
		<item>
		<title>Get Post Tags in Wordpress</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/--Bw_aobmXw/</link>
		<comments>http://apartmentonesix.com/2009/12/get-post-tags-in-wordpress/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:59:47 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=205</guid>
		<description><![CDATA[Here&#8217;s a little tidbit I can NEVER find when I need it:  If you need to get all the tags  that belong to a current post, here&#8217;s the function:
$tags = get_the_tags($post_id);
This will return an associative array of tags, with all their relevant info.
BONUS
If you need the same thing with categories, here&#8217;s your function:

 [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little tidbit I can NEVER find when I need it:  If you need to get all the tags  that belong to a current post, here&#8217;s the function:</p>
<p>$tags = get_the_tags($post_id);</p>
<p>This will return an associative array of tags, with all their relevant info.</p>
<p><strong>BONUS</strong><br />
If you need the same thing with categories, here&#8217;s your function:</p>
<pre class="brush: php">
    $args[&#039;fields&#039;] = &#039;all&#039;;
    $categories = wp_get_post_categories($post_id, $args);
</pre>
<p>Including the args bit allows you to retrieve all the category info.  If you leave that out (and use only the $post_id argument), you&#8217;ll get an array of relevant category ids, but no other info.</p>
<p>Big thanks to Clay Lua at <a href="http://hugred.com">hungred.com</a> and his post <a href="http://hungred.com/how-to/tag-post-id-wordpress/">Get Tag with Post ID in Wordpress</a> for pointing me in the right direction.</p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/12/get-post-tags-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/12/get-post-tags-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>Fixing Slow jQuery Animations in Internet Explorer</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/HMK0FOFYAls/</link>
		<comments>http://apartmentonesix.com/2009/09/fixing-slow-jquery-animations-in-internet-explorer/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 16:05:46 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[slideDown]]></category>
		<category><![CDATA[slideUp]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=193</guid>
		<description><![CDATA[I&#8217;m not going to lie:  I&#8217;m a javascript hack.  I dont know what I&#8217;m doing half the time, because I don&#8217;t have to use it all that often.  jQuery is seriously my saving grace when it comes to appearing to know what I&#8217;m doing with javascript.
That said, I&#8217;m currently working on a project that requires [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not going to lie:  I&#8217;m a javascript hack.  I dont know what I&#8217;m doing half the time, because I don&#8217;t have to use it all that often.  jQuery is seriously my saving grace when it comes to appearing to know what I&#8217;m doing with javascript.</p>
<p>That said, I&#8217;m currently working on a project that requires quite a bit of javascript work &#8211; specifically involving some animations &#8211; slideUp and slideDown stuff mostly.  I put it all together, and it worked beautifully in Firefox and Safari on my mac &#8211; smooth animations, perfect transitions.  As though I knew what I was doing.  I fire it up in IE7 just to be sure, and it&#8217;s a nightmare.  You can&#8217;t really call it &#8220;animation&#8221;.  Slow, choppy, and unpredictable &#8211; legitimately unusable.</p>
<p>A bit of googling around revealed that apparently no one else in the world has this problem, and I am an idiot.  Then I happened upon a gem at stackoverflow.com which mentioned, in passing, that Internet Explorer does an awful job of caching and displaying background images (specifically repeated background images) during animation &#8211; basically, he implied that for each frame of animation, I.E. loads, places, and renders each instance of a repeating background image, just one example of how a browser could have issues with animations. The specific elements I&#8217;m working with are 1000 px wide rows, and with each animation, about 10 of them have to move 300 pixels or so.  The kicker?  Each one is using a 1px wide repeating background.  1000 background images * 10 rows, and it becomes apparent why the animation was so bad.  I bit the bullet and tried a single 1000px wide background image, and the difference was night and day.</p>
<p>The moral of the story is this: the css techniques you use on elements that will be animated can have a serious affect on animation performance.  If you&#8217;re having problems, give some real thought to what the browser will have to do to animate the elements &#8211; calculating heights, margins, widths, background images, etc etc.  Experiment with different values, with an eye toward explicitly defining any value that the javascript might have to calculate (i.e. define heights instead of just letting the browser do it), and you can probably make a big difference in your javascript animation quality.<!--wsa:Test--></p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/09/fixing-slow-jquery-animations-in-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/09/fixing-slow-jquery-animations-in-internet-explorer/</feedburner:origLink></item>
		<item>
		<title>How to Display Properly Formatted Content From a $post Object in WordPress</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/l27Gm8HulDQ/</link>
		<comments>http://apartmentonesix.com/2009/05/how-to-display-properly-formatted-content-from-a-post-object-in-wordpress/#comments</comments>
		<pubDate>Fri, 22 May 2009 02:49:05 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Writing Plugins]]></category>
		<category><![CDATA[$post]]></category>
		<category><![CDATA[the_content]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=185</guid>
		<description><![CDATA[Occasionally, I&#8217;ll run into a situation where I need to call a post specifically using the get_post() function.  get_post() returns a Post object, with a number of member variables &#8211; the one that stores the actual content of the post being post_content.
However, if you try just echoing $post-&#62;post_content, you&#8217;ll get completely unformatted text &#8211; which [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally, I&#8217;ll run into a situation where I need to call a post specifically using the <a title="Wordpress get_post() codex page" href="http://codex.wordpress.org/Function_Reference/get_post" target="_blank">get_post()</a> function.  get_post() returns a Post object, with a number of member variables &#8211; the one that stores the actual content of the post being post_content.</p>
<p>However, if you try just echoing $post-&gt;post_content, you&#8217;ll get completely unformatted text &#8211; which is frustrating, because WordPress uses a great visual text editor on the backend &#8211; it&#8217;s a shame to not take advantage of it.  Fortunately, WordPress provides a filter to display the text just as it would be displayed in the the_content() function inside the loop.  Here&#8217;s how it works:</p>
<p>To get the content formatted properly, we need to apply a filter (which is different from adding a filter &#8211; here, we&#8217;re registering it so that other filter functions can modify it before it&#8217;s displayed).</p>
<pre class="brush: php">

apply_filters(&#039;the_content&#039;, $post-&gt;post_content);
</pre>
<p>So, we&#8217;re just applying the the_content filter to the $post-&gt;post_content variable.  Doing so means that any plugin which adds a filter function to the_content like this:</p>
<pre class="brush: php">

add_filter(&#039;the_content&#039;, &#039;my_content_manipulator&#039;);

function my_content_manipulator($content){

//do stuff here

return $content;

}
</pre>
<p>will be applied to your variable.  Fortunately, it also means that the WordPress core functions which format the post content correctly can also work on it.</p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/05/how-to-display-properly-formatted-content-from-a-post-object-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/05/how-to-display-properly-formatted-content-from-a-post-object-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>Get the Current Admin Page Title in a Plugin</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/PE_WsP6Gbow/</link>
		<comments>http://apartmentonesix.com/2009/05/get-the-current-admin-page-title-in-a-plugin/#comments</comments>
		<pubDate>Sat, 16 May 2009 20:41:03 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Writing Plugins]]></category>
		<category><![CDATA[get_admin_page_title]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=177</guid>
		<description><![CDATA[Here&#8217;s something that comes up for me pretty often:  depending on what I&#8217;m trying to do, I sometimes need plugin functions to run (or not run) simply based on which admin page the user is visiting.   Here&#8217;s the WordPress function that will give you the title of the currently loaded admin page:


get_admin_page_title()

So, if you only [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s something that comes up for me pretty often:  depending on what I&#8217;m trying to do, I sometimes need plugin functions to run (or not run) simply based on which admin page the user is visiting.   Here&#8217;s the WordPress function that will give you the title of the currently loaded admin page:</p>
<pre class="brush: php">

get_admin_page_title()
</pre>
<p>So, if you only want to run a bit of code on the &#8220;Edit Posts&#8221; page, you&#8217;d put together a conditional statement like this:</p>
<pre class="brush: php">

if(get_admin_page_title() == &#039;Edit Posts&#039;){
//do something fancy
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/05/get-the-current-admin-page-title-in-a-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/05/get-the-current-admin-page-title-in-a-plugin/</feedburner:origLink></item>
		<item>
		<title>How to Hide Certain Custom Fields From the Edit Post Page</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/6oi_lVK6_34/</link>
		<comments>http://apartmentonesix.com/2009/05/how-to-hide-certain-custom-fields-from-the-edit-post-page/#comments</comments>
		<pubDate>Sat, 16 May 2009 04:22:32 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Writing Plugins]]></category>
		<category><![CDATA[Custom Fields]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Post Meta]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=167</guid>
		<description><![CDATA[Post meta is easily one of the most useful features in WordPress from a developer&#8217;s perspective.  Adding custom content to a post provides the ability to accomplish countless goals quickly and easily.
Sometimes, it makes sense to give the user access to a post meta field &#8211; for example, if they need to add a thumbnail [...]]]></description>
			<content:encoded><![CDATA[<p>Post meta is easily one of the most useful features in WordPress from a developer&#8217;s perspective.  Adding custom content to a post provides the ability to accomplish countless goals quickly and easily.</p>
<p>Sometimes, it makes sense to give the user access to a post meta field &#8211; for example, if they need to add a thumbnail url to a post, they&#8217;re probably going to need to access to those post meta fields.  Other times, having the post meta field visible is only likely to confuse the visitor.  One (extremely popular) place that I&#8217;ve seen this is the All in One SEO Plugin.  All in One SEO is wildly popular, and does what it claims well.  It provides a few extra fields, and a nice, easy to use interface to get at them.  Here&#8217;s what it looks like when you get started:</p>
<p><a href="http://apartmentonesix.com/wp-content/uploads/2009/05/picture-31.png"><img class="aligncenter size-large wp-image-172" title="picture-31" src="http://apartmentonesix.com/wp-content/uploads/2009/05/picture-31-500x166.png" alt="picture-31" width="500" height="166" /></a>Fantastic.  It&#8217;s attractive, easy to use, and works well.  So we save our post, and then later on, we go back to edit the meta description.  Here&#8217;s what we get:</p>
<p><a href="http://apartmentonesix.com/wp-content/uploads/2009/05/picture-4.png"><img class="aligncenter size-large wp-image-173" title="picture-4" src="http://apartmentonesix.com/wp-content/uploads/2009/05/picture-4-500x494.png" alt="picture-4" width="500" height="494" /></a>At this point, its pretty clear what&#8217;s going on if you understand the inner workings of WordPress &#8211; AIOSEO has saved our values to custom fields, so now they&#8217;re showing up there.  However, most users dont understand, or even care about how AIOSEO works, or what custom fields are.  All they know is that strange stuff is showing up, and they&#8217;re not sure where to edit their meta keywords, because they&#8217;re showing up in 2 places.  Most people have the gumption to just change one and see what happens &#8211; but there will always be users who get scared and decide they want to email you about the issue, or worse, just uninstall the plugin and move on.</p>
<h3>Underscores to the Rescue</h3>
<p>The WordPress developers, fortunately, thought of this.  In fact, they store all kinds of stuff that they don&#8217;t want the user to see in custom fields &#8211; things like the last time the post was edited, who is currently editing it, and a few others.  A quick look at the database, reveals this:<a href="http://apartmentonesix.com/wp-content/uploads/2009/05/picture-5.png"><img class="aligncenter size-full wp-image-174" title="picture-5" src="http://apartmentonesix.com/wp-content/uploads/2009/05/picture-5.png" alt="picture-5" width="406" height="43" /></a>Notice a trend?  The mysterious custom field key values are prepended with an underscore.  Give it a try &#8211; enter a new custom field from the edit-post page, and enter a name that starts with an underscore &#8211; like _thumbnail, or _meta_keywords.  Hit &#8220;Add Custom Field&#8221;, and it disappears &#8211; but if you check the database, its right where it should be.</p>
<p>Now get out there and start hiding things from your users!</p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/05/how-to-hide-certain-custom-fields-from-the-edit-post-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/05/how-to-hide-certain-custom-fields-from-the-edit-post-page/</feedburner:origLink></item>
		<item>
		<title>Using a Custom User Table Share Users Between Two WordPress Installs</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/jnelQdbb4dk/</link>
		<comments>http://apartmentonesix.com/2009/04/using-a-custom-user-table-share-users-between-two-wordpress-installs/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 02:11:26 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom_user_meta_table]]></category>
		<category><![CDATA[custom_user_table]]></category>
		<category><![CDATA[usermeta]]></category>
		<category><![CDATA[wp_usermeta]]></category>
		<category><![CDATA[wp_users]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=162</guid>
		<description><![CDATA[In one of many, many strokes of genius, the WordPress core developers threw in a bit of code to allow users (ok, other developers) to define a custom user table, and a custom usermeta table for a WordPress install.
In it&#8217;s simplest form, you can point your Wordpress user table at that of another blog on [...]]]></description>
			<content:encoded><![CDATA[<p>In one of many, many strokes of genius, the WordPress core developers threw in a bit of code to allow users (ok, other developers) to define a custom user table, and a custom usermeta table for a WordPress install.</p>
<p>In it&#8217;s simplest form, you can point your Wordpress user table at that of another blog on your server.  Doing so means both blogs (and why stop at 2?) share user information:  passwords, usernames, author bios, etc etc.  If you&#8217;ve got a site that requires numerous different, separate WordPress installs (think something along the lines of <a href="http://www.wired.com/blogs/">wired.com</a>), but the same authors often write on many or all of them, this is a great, and easy solution.</p>
<h3>Enough Already, Give Me the Code</h3>
<p>Yes Sir.  Just slap this code in your wp-config file:</p>
<pre class="brush: php">

define(&#039;CUSTOM_USER_TABLE&#039;,&#039;new_user_table&#039;);
define(&#039;CUSTOM_USER_META_TABLE&#039;, &#039;new_usermeta_table&#039;);
</pre>
<p>It&#8217;s pretty self explanatory from there &#8211; just define a custom user table, and a custom usermeta table, and you&#8217;re good to go.  Want your users to share login info across different blogs, but be able to have a different bio for each one?  Define a custom user table, but leave the default user_meta table.  Everything stored in the users table (ID, login, password, nicename, email, url, and display name, among other things) will stay the same across all blogs.  Everything else (nickname, user level, First Name, Last Name, and many other things), will be blog specific.</p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/04/using-a-custom-user-table-share-users-between-two-wordpress-installs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/04/using-a-custom-user-table-share-users-between-two-wordpress-installs/</feedburner:origLink></item>
		<item>
		<title>How To:  Get an Overview of all Action and Filter Hooks</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/d_PqfElsAjg/</link>
		<comments>http://apartmentonesix.com/2009/04/how-to-get-an-overview-of-all-action-and-filter-hooks/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 03:17:46 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Writing Plugins]]></category>
		<category><![CDATA[$wp_filter]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=150</guid>
		<description><![CDATA[Here&#8217;s a very cool little tidbit I found today (strangely enough, I found it in the bbpress codebase, while working on a bbpress plugin..)  Wordpress keeps track of which function/filter combinations are registered, along with which action hooks have been called at any point.  If you&#8217;re having trouble trying to figure out which action hook [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a very cool little tidbit I found today (strangely enough, I found it in the bbpress codebase, while working on a bbpress plugin..)  Wordpress keeps track of which function/filter combinations are registered, along with which action hooks have been called at any point.  If you&#8217;re having trouble trying to figure out which action hook you should use to run some code for your plugin or theme, give this a try (on a test install, of course).</p>
<h3>$wp_filter()</h3>
<p>As far as I can tell, this holds every currently registered function/filter combination, and all the relevant information.  I can&#8217;t quite figure out exactly what determines which filters this grabs &#8211; I&#8217;ve tried calling it from a few places, and the results are slightly different, but I can&#8217;t seem to find a pattern.  I initially assumed that you wouldnt be able to see about admin side hooks from the front end, but this isn&#8217;t the case.  At any rate, you get lots of information from anywhere. Not getting the info you want?  Call it from somewhere else!  This is a great debugging tool if you&#8217;re having trouble with plugin incompatibility &#8211; it gives you a list of the filters and actions being called,the matching functions that are working on them, the priority specified for each hook call, the accepted args, and even the order in which same-priority-level hooks are called.  An example:</p>
<pre class="brush: php">
    [the_title] =&gt; Array
        (
            [10] =&gt; Array
                (
                    [wptexturize] =&gt; Array
                        (
                            [function] =&gt; wptexturize
                            [accepted_args] =&gt; 1
                        )

                    [convert_chars] =&gt; Array
                        (
                            [function] =&gt; convert_chars
                            [accepted_args] =&gt; 1
                        )

                    [trim] =&gt; Array
                        (
                            [function] =&gt; trim
                            [accepted_args] =&gt; 1
                        )

                )

        )
</pre>
<p>This is a small snippet I pulled after displaying the contents of this variable in the footer of a theme.  As you can see, the referenced hook is a filter, specifically &#8220;the_title&#8221;.  It has 3 functions attached to it: wptexturize, convert_chars, and trim.  Each one is at priority level 10 (which is the default), but they are called in the order listed.   Each accepts 1 argument.</p>
<h3>Try it Out</h3>
<p>If you want to have a look yourself, display the contents of wp_filter with this code snippet:</p>
<pre class="brush: php">
&lt;?php
global $wp_filter;
print_r($wp_filter);
?&gt;
</pre>
<p>This is going to dump the contents right to the screen, so you don&#8217;t want to do it on a live blog.  As with any use of the print_r() function, the results will be formatted nicely in the source code &#8211; but not in the rendered html.</p>
<p>Roundup:<br />
<a href="http://www.shankrila.com/tech-stuff/top-wordpress-plugins/" title="Top &#038; Best 65+ WordPress Plugins | ShanKri-la" target="_blank">Top wordpress plugins</a><br />
<a href="http://www.pingable.org/20-of-the-best-free-magazine-wordpress-themes/" title="wordpress magazine theme" target="_blank">wordpress magazine theme</a></p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/04/how-to-get-an-overview-of-all-action-and-filter-hooks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/04/how-to-get-an-overview-of-all-action-and-filter-hooks/</feedburner:origLink></item>
		<item>
		<title>New Wordpress Plugin:  Default Post Content</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/HokC7TnOGcw/</link>
		<comments>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 16:28:06 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Plugin Releases]]></category>
		<category><![CDATA[default post]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[post content]]></category>
		<category><![CDATA[Post Meta]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=144</guid>
		<description><![CDATA[Justin over at justintadlock.com made a post a few days ago about how to preset text in the WordPress post editor.  It&#8217;s a great post, with an interesting filter detailed.  In the comments, somebody mentioned that they&#8217;d like to be able to preset custom fields as well &#8211; something that seems like it shouldn&#8217;t work [...]]]></description>
			<content:encoded><![CDATA[<p>Justin over at <a title="Justin Tadlock" href="http://justintadlock.com" target="_blank">justintadlock.com</a> made a post a few days ago about how to <a href="http://justintadlock.com/archives/2009/04/05/how-to-preset-text-in-the-wordpress-post-editor" target="_blank">preset text in the WordPress post editor</a>.  It&#8217;s a great post, with an interesting filter detailed.  In the comments, somebody mentioned that they&#8217;d like to be able to preset custom fields as well &#8211; something that seems like it shouldn&#8217;t work (Custom fields need a post id to work on, and new posts dont have a post id).  Yesterday, the workaround hit me like a slap in the face while I was in the shower &#8211; so I decided to package up this, along with the original code that Justin published in a plugin.</p>
<p>It&#8217;s not the most elegant piece of code in the world, but it works on all the installs I&#8217;ve tried it on.  I&#8217;ll try to put up a post detailing how it works soon, but in the meantime, feel free to download the plugin and give it a try.</p>
<p><a title="Default Post Content Plugin" href="http://apartmentonesix.com/plugins/default-post-content/">Default Post Content Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/</feedburner:origLink></item>
		<item>
		<title>Saving Wordpress Plugin Options – Admin Panels Done Right</title>
		<link>http://feedproxy.google.com/~r/ApartmentOneSix/~3/fXtS_M8PFTE/</link>
		<comments>http://apartmentonesix.com/2009/04/saving-wordpress-plugin-options-admin-panels-done-right/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 02:54:53 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Writing Plugins]]></category>

		<guid isPermaLink="false">http://apartmentonesix.com/?p=120</guid>
		<description><![CDATA[This isn&#8217;t a terribly difficult task &#8211; it&#8217;s incredibly common, and it&#8217;s covered multiple places in the codex.  So why am I writing about it?  A few months ago, I was tasked with customizing a plugin &#8211; one that someone else wrote.  I need to add some options to it, and their [...]]]></description>
			<content:encoded><![CDATA[<p>This isn&#8217;t a terribly difficult task &#8211; it&#8217;s incredibly common, and it&#8217;s covered multiple places in the codex.  So why am I writing about it?  A few months ago, I was tasked with customizing a plugin &#8211; one that someone else wrote.  I need to add some options to it, and their code was baffling to me.  I could see that they were using custom options, but I couldnt understand how they were being set &#8211; it was like the author just made some form fields and hoped for the best.</p>
<h3>More Wordpress Magic</h3>
<p>What was happening is referenced here (Right in the codex &#8211; apparently the last place I thought to look).   My first instinct has always been to post forms on an admin page to itself, then handle checking for the $_POST values, and creating/updating the appropriate options.  As is often the case, WordPress makes it even easier than that:</p>
<h3>Set Up Your Form Properly</h3>
<p>I wont get into the boring details &#8211; you can look at the codex page for that &#8211; but pay special attention to the hidden fields you set up:</p>
<pre class="brush: html">

&lt;input name=&quot;action&quot; type=&quot;hidden&quot; value=&quot;update&quot; /&gt;
&lt;input name=&quot;page_options&quot; type=&quot;hidden&quot; value=&quot;new_option_name,some_other_option,option_etc&quot; /&gt;
</pre>
<p>Not too tough to understand &#8211; the first line tells the system that we&#8217;re going to be updating, and the second line lets WordPress know which fields we want to create/update.  These, of course, need to match the &#8220;name&#8221; attribute of the input elements up above.</p>
<h3>But What About Arrays?</h3>
<p>I posted a few days ago about the <a title="Maybe Serialize and the Magic of WordPress" href="http://apartmentonesix.com/2009/03/maybe_serialize-and-the-magic-of-wordpress/">very cool functionality of maybe_serialize()</a>, and its relation to WordPress options.  I often store arrays in options, because they help keep the database free of unnecessary clutter, and they make your plugin even easier to use (from a developers view).  I was a little worried that this &#8220;page options&#8221; trick would prevent me from saving arrays &#8211; but alas, WordPress saved the day again:</p>
<pre class="brush: php">

&lt;input type=&quot;text&quot; name=&quot;fruit_colors[&#039;apple&#039;]&quot; value=&quot;red&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;fruit_colors[&#039;carrot&#039;]&quot; value=&quot;orange&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;fruit_colors[&#039;banana&#039;]&quot; value=&quot;yellow&quot;&gt;
</pre>
<p>Just make a form field an array, like you would with a set of checkboxes (by adding [] after it).  Pass in the proper values to the page_option hidden field, like so:</p>
<pre class="brush: html">

&lt;input name=&quot;page_options&quot; type=&quot;hidden&quot; value=&quot;fruit_colors&quot; /&gt;
</pre>
<p>This can get pretty interesting &#8211; a few days ago I used to to loop through categories and associate a string with each one &#8211; you can do the same for posts, days of the week, whatever suits your plugin.</p>
<p>So there you go.  You&#8217;ve got yourself an option without any tinkering with $_POST variables, or checking if you need to update or create an option.  Wordpress even takes care of serializing it for you.  What a world&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://apartmentonesix.com/2009/04/saving-wordpress-plugin-options-admin-panels-done-right/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://apartmentonesix.com/2009/04/saving-wordpress-plugin-options-admin-panels-done-right/</feedburner:origLink></item>
	</channel>
</rss>
