<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: New Wordpress Plugin:  Default Post Content</title>
	<atom:link href="http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/feed/" rel="self" type="application/rss+xml" />
	<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/</link>
	<description></description>
	<lastBuildDate>Mon, 12 Jul 2010 12:35:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John Stringfellow</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-2301</link>
		<dc:creator>John Stringfellow</dc:creator>
		<pubDate>Sun, 06 Dec 2009 22:32:22 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-2301</guid>
		<description>Peter,

Thank you for this plugin. It will help me cut out about 7 steps out of my user created content system. I have got it working but I keep getting this error message:

Warning: Invalid argument supplied for foreach() in /home/*****/public_html/wp-content/plugins/default-post-content/default_post_content.php on line 53

Warning: Cannot modify header information - headers already sent by (output started at /home/*****/public_html/wp-content/plugins/default-post-content/default_post_content.php:53) in /home/*****/public_html/wp-includes/pluggable.php on line 865

I am not sure what it asking me to do here. Do you have any ideas?

John</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>Thank you for this plugin. It will help me cut out about 7 steps out of my user created content system. I have got it working but I keep getting this error message:</p>
<p>Warning: Invalid argument supplied for foreach() in /home/*****/public_html/wp-content/plugins/default-post-content/default_post_content.php on line 53</p>
<p>Warning: Cannot modify header information &#8211; headers already sent by (output started at /home/*****/public_html/wp-content/plugins/default-post-content/default_post_content.php:53) in /home/*****/public_html/wp-includes/pluggable.php on line 865</p>
<p>I am not sure what it asking me to do here. Do you have any ideas?</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-135</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 21 Apr 2009 04:49:49 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-135</guid>
		<description>Glad I could help, and I&#039;m glad to hear your project is going well.  I definitely want to see it when it&#039;s ready, so drop me a line here or send me an email at peter[at]apartmentonesix[dot]com.

Good Luck!</description>
		<content:encoded><![CDATA[<p>Glad I could help, and I&#8217;m glad to hear your project is going well.  I definitely want to see it when it&#8217;s ready, so drop me a line here or send me an email at peter[at]apartmentonesix[dot]com.</p>
<p>Good Luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: I.N.K.</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-133</link>
		<dc:creator>I.N.K.</dc:creator>
		<pubDate>Mon, 20 Apr 2009 20:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-133</guid>
		<description>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You did it man! This single trick will finally make my whole project come true. I&#039;ve been searching for this solution for like, ages. Coupled with more fields plugin, It totally makes for a much friendly cms environment. From here,  it won&#039;t take much for us to go live. I&#039;ll show you when it&#039;s done, so you&#039;ll see what you helped doing. WP community rules.

On another note: why on earth would somebody wear such thing as a a pale screen t-shirt?
http://img145.imageshack.us/img145/8614/palescreentshirt.jpg
that&#039;s beyond me, really.</description>
		<content:encoded><![CDATA[<p>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br />
You did it man! This single trick will finally make my whole project come true. I&#8217;ve been searching for this solution for like, ages. Coupled with more fields plugin, It totally makes for a much friendly cms environment. From here,  it won&#8217;t take much for us to go live. I&#8217;ll show you when it&#8217;s done, so you&#8217;ll see what you helped doing. WP community rules.</p>
<p>On another note: why on earth would somebody wear such thing as a a pale screen t-shirt?<br />
<a href="http://img145.imageshack.us/img145/8614/palescreentshirt.jpg" rel="nofollow">http://img145.imageshack.us/img145/8614/palescreentshirt.jpg</a><br />
that&#8217;s beyond me, really.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-132</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Mon, 20 Apr 2009 18:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-132</guid>
		<description>Hah... the pale screen strikes again.  You might look into changing your error_reporting settings for your php install to display errors- the pale screen would become much friendlier :)

Anyway, you&#039;re missing a lowly close-paren.  Here&#039;s the fixed code:

&lt;a href=&quot;http://wordpress.pastebin.com/m2636d1be&quot; rel=&quot;nofollow&quot;&gt;http://wordpress.pastebin.com/m2636d1be&lt;/a&gt;

Also, &#039;dpc_parent_id&#039; had curly quotes around it, which was causing php to not read it&#039;s contents properly.  My fault for not using pastebin or something similar.  Let me know how that turns out!</description>
		<content:encoded><![CDATA[<p>Hah&#8230; the pale screen strikes again.  You might look into changing your error_reporting settings for your php install to display errors- the pale screen would become much friendlier <img src='http://apartmentonesix.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, you&#8217;re missing a lowly close-paren.  Here&#8217;s the fixed code:</p>
<p><a href="http://wordpress.pastebin.com/m2636d1be" rel="nofollow">http://wordpress.pastebin.com/m2636d1be</a></p>
<p>Also, &#8216;dpc_parent_id&#8217; had curly quotes around it, which was causing php to not read it&#8217;s contents properly.  My fault for not using pastebin or something similar.  Let me know how that turns out!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: I.N.K.</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-131</link>
		<dc:creator>I.N.K.</dc:creator>
		<pubDate>Mon, 20 Apr 2009 18:43:34 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-131</guid>
		<description>Hi Peter, thanks so much for your help + taking the challenge.
Upon test: the first function works, the second one gives me the pale screen of sadness.
http://wordpress.pastebin.com/m13e8b081
I hate the pale screen with a passion.</description>
		<content:encoded><![CDATA[<p>Hi Peter, thanks so much for your help + taking the challenge.<br />
Upon test: the first function works, the second one gives me the pale screen of sadness.<br />
<a href="http://wordpress.pastebin.com/m13e8b081" rel="nofollow">http://wordpress.pastebin.com/m13e8b081</a><br />
I hate the pale screen with a passion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-125</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sun, 19 Apr 2009 18:00:48 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-125</guid>
		<description>Hah - what a mess!  I thought this was going to be a pretty simple solution, but it quickly fell apart.  Fortunately, I hate backing down from a challenge.  Here&#039;s how I suggest you handle it:

First, some things you need to know:
The default post content uses values from the database.  Because of this, they are available wherever you need them.  Unfortunately, when using a $_GET variable,  you&#039;ve only got it once - on the write new post page.  The values can&#039;t (easily) be sent through with the first autosave (as I do with the flag in DPC), because it isnt available at $_GET since autosave uses an ajax request to do its magic.

To get around all this, I decided the easiest thing would be to take the variables from $_GET and put them into hidden fields on the page, so when the post is saved or published, they&#039;ll go through with the rest of the post information.  At that point, we can pick them up and use them in new post meta.

The only problem with this route is that it would be possible for someone, while editing a post, to reset these values, because we can&#039;t really differentiate between that first post save and any other post save (if there is a way to tell the difference, anybody, I&#039;d love to hear it).  To do so, however, they&#039;d need to put the variables in the url string.  And now that I think of it, we could probably check to make sure we&#039;re on new-post.php, and only show the hidden form fields there - problem solved. 

Anyway, on to some code to get you started:

First, you need to insert the hidden fields on the new post page.  The &#039;submitpost_box&#039; hook seems as good as any, its inside the opening and closing form tags on post-new.php, which is all we really need.
&lt;code&gt;
add_action(&#039;submitpost_box&#039;, &#039;hidden_fields&#039;);

function hidden_fields(){
  global $post;
  if($post-&gt;ID == 0){
    echo &#039;&lt;input type=&quot;hidden&quot; name=&quot;dpc_parent_id&quot; value=&quot;&#039;.$_GET[&#039;parent_id&#039;].&#039;&quot; /&gt;&#039;;
    echo &#039;&lt;input type=&quot;hidden&quot; name=&quot;dpc_page_type&quot; value=&quot;&#039;.$_GET[&#039;page_type&#039;].&#039;&quot; /&gt;&#039;;
  }
}
&lt;/code&gt;
So, as you can see, on the submitpost_box hook, we&#039;re just echoing out some input fields, with names we can remember (I prefixed them to prevent naming collisions, and because I was testing this inside the DPC plugin code), and give them values from the $_GET.  I tested to see if $post-&gt;ID == 0 because if it does, we know its a new post.  We dont want to do this stuff on posts we&#039;re just editing, because it will overwrite the old values.

After that, all we need to do is pick up the values when the post is being saved.
&lt;code&gt;
add_action(&#039;transition_post_status&#039;, &#039;dpc_set_postmeta_flag&#039;, 10, 3);
function dpc_set_postmeta_flag($new_status, $old_status, $post){
  if(isset($_POST[&#039;dpc_parent_id&#039;]){
    update_post_meta($post-&gt;ID, &#039;dpc_parent_id&#039;, $_POST[&#039;dpc_parent_id&#039;]);
    update_post_meta($post-&gt;ID, &#039;dpc_page_type&#039;, $_POST[&#039;dpc_page_type&#039;]);
  }
}
&lt;/code&gt;

Now, I used the transition_post_status hook, because its what I was using in the DPC plugin - but another one might be more fitting - edit_post comes to mind.  Anyway, as you can see, all I did was call update_post_meta to get the post meta entered.  I checked if $_POST[&#039;dpc_parent_id&#039;] was set first because if that isn&#039;t set, then these values weren&#039;t passed in, and we&#039;d probably overwrite the old values with blanks, since it was a post revision.

I think that should do it - give it a try, and let me know how it turns out for you!

A little more info, in case you&#039;re not familiar with hooks:
&lt;a href=&quot;http://codex.wordpress.org/Plugin_API&quot; rel=&quot;nofollow&quot;&gt;Wordpress Plugin API&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hah &#8211; what a mess!  I thought this was going to be a pretty simple solution, but it quickly fell apart.  Fortunately, I hate backing down from a challenge.  Here&#8217;s how I suggest you handle it:</p>
<p>First, some things you need to know:<br />
The default post content uses values from the database.  Because of this, they are available wherever you need them.  Unfortunately, when using a $_GET variable,  you&#8217;ve only got it once &#8211; on the write new post page.  The values can&#8217;t (easily) be sent through with the first autosave (as I do with the flag in DPC), because it isnt available at $_GET since autosave uses an ajax request to do its magic.</p>
<p>To get around all this, I decided the easiest thing would be to take the variables from $_GET and put them into hidden fields on the page, so when the post is saved or published, they&#8217;ll go through with the rest of the post information.  At that point, we can pick them up and use them in new post meta.</p>
<p>The only problem with this route is that it would be possible for someone, while editing a post, to reset these values, because we can&#8217;t really differentiate between that first post save and any other post save (if there is a way to tell the difference, anybody, I&#8217;d love to hear it).  To do so, however, they&#8217;d need to put the variables in the url string.  And now that I think of it, we could probably check to make sure we&#8217;re on new-post.php, and only show the hidden form fields there &#8211; problem solved. </p>
<p>Anyway, on to some code to get you started:</p>
<p>First, you need to insert the hidden fields on the new post page.  The &#8217;submitpost_box&#8217; hook seems as good as any, its inside the opening and closing form tags on post-new.php, which is all we really need.<br />
<code><br />
add_action('submitpost_box', 'hidden_fields');</p>
<p>function hidden_fields(){<br />
  global $post;<br />
  if($post->ID == 0){<br />
    echo '<br />
<input type="hidden" name="dpc_parent_id" value="'.$_GET['parent_id'].'" />';<br />
    echo '<br />
<input type="hidden" name="dpc_page_type" value="'.$_GET['page_type'].'" />';<br />
  }<br />
}<br />
</code><br />
So, as you can see, on the submitpost_box hook, we&#8217;re just echoing out some input fields, with names we can remember (I prefixed them to prevent naming collisions, and because I was testing this inside the DPC plugin code), and give them values from the $_GET.  I tested to see if $post->ID == 0 because if it does, we know its a new post.  We dont want to do this stuff on posts we&#8217;re just editing, because it will overwrite the old values.</p>
<p>After that, all we need to do is pick up the values when the post is being saved.<br />
<code><br />
add_action('transition_post_status', 'dpc_set_postmeta_flag', 10, 3);<br />
function dpc_set_postmeta_flag($new_status, $old_status, $post){<br />
  if(isset($_POST['dpc_parent_id']){<br />
    update_post_meta($post->ID, 'dpc_parent_id', $_POST['dpc_parent_id']);<br />
    update_post_meta($post->ID, 'dpc_page_type', $_POST['dpc_page_type']);<br />
  }<br />
}<br />
</code></p>
<p>Now, I used the transition_post_status hook, because its what I was using in the DPC plugin &#8211; but another one might be more fitting &#8211; edit_post comes to mind.  Anyway, as you can see, all I did was call update_post_meta to get the post meta entered.  I checked if $_POST['dpc_parent_id'] was set first because if that isn&#8217;t set, then these values weren&#8217;t passed in, and we&#8217;d probably overwrite the old values with blanks, since it was a post revision.</p>
<p>I think that should do it &#8211; give it a try, and let me know how it turns out for you!</p>
<p>A little more info, in case you&#8217;re not familiar with hooks:<br />
<a href="http://codex.wordpress.org/Plugin_API" rel="nofollow">Wordpress Plugin API</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: I.N.K.</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-124</link>
		<dc:creator>I.N.K.</dc:creator>
		<pubDate>Sun, 19 Apr 2009 16:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-124</guid>
		<description>Code got stripped so, to make sense, I&#039;m adding it here without the php tags
The post-new url has the &quot;parentId&quot; already in it (is_child_of=xy), so I could grab it from there with something like php echo $_GET[&quot;is_child_of&quot;]; 
I just need to put together a basic stripped down version of your code, a simple function that sets meta_key &quot;is_child_of&quot; to the value of &quot;php echo $_GET[&quot;is_child_of&quot;];</description>
		<content:encoded><![CDATA[<p>Code got stripped so, to make sense, I&#8217;m adding it here without the php tags<br />
The post-new url has the &#8220;parentId&#8221; already in it (is_child_of=xy), so I could grab it from there with something like php echo $_GET["is_child_of"];<br />
I just need to put together a basic stripped down version of your code, a simple function that sets meta_key &#8220;is_child_of&#8221; to the value of &#8220;php echo $_GET["is_child_of"];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: I.N.K.</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-123</link>
		<dc:creator>I.N.K.</dc:creator>
		<pubDate>Sun, 19 Apr 2009 16:39:15 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-123</guid>
		<description>Hi Peter.
Luckily I can safely answer &quot;no&quot; to both questions. The user doesn&#039;t even need to know about all this &quot;is_child_of&quot; stuff.  I&#039;ve been looking at your plugin code, and the solution is right there.
Obviously some stuff is there just to have different  fields and values  submitted by the admin.
I later found out about some very basic/childish/foundation concept: the $_GET.
The post-new url has the &quot;parentId&quot; already in it (is_child_of=xy), so I could grab it from there with something like ;
I just need to put together a basic stripped down version of your code, a simple function that sets meta_key &quot;is_child_of&quot; to the value of &quot; 
And where to put it.  
I know I&#039;m learning something here, but it&#039;s taking me ages, so if you can help, that&#039;d be awesome.
BTW, mail is valid, so..we can go on with this here, or one on one. whatever you like best.</description>
		<content:encoded><![CDATA[<p>Hi Peter.<br />
Luckily I can safely answer &#8220;no&#8221; to both questions. The user doesn&#8217;t even need to know about all this &#8220;is_child_of&#8221; stuff.  I&#8217;ve been looking at your plugin code, and the solution is right there.<br />
Obviously some stuff is there just to have different  fields and values  submitted by the admin.<br />
I later found out about some very basic/childish/foundation concept: the $_GET.<br />
The post-new url has the &#8220;parentId&#8221; already in it (is_child_of=xy), so I could grab it from there with something like ;<br />
I just need to put together a basic stripped down version of your code, a simple function that sets meta_key &#8220;is_child_of&#8221; to the value of &#8221;<br />
And where to put it.<br />
I know I&#8217;m learning something here, but it&#8217;s taking me ages, so if you can help, that&#8217;d be awesome.<br />
BTW, mail is valid, so..we can go on with this here, or one on one. whatever you like best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-120</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sun, 19 Apr 2009 02:32:46 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-120</guid>
		<description>Hi I.N.K. - 

It sounds like the technique I used could probably be applied here.  A couple of questions:
Do you need the user to be able to edit the parent post id value?  Does the user need to be able to edit the post type?

If the user shouldn&#039;t be able to edit those fields, your job is much easier - you just need to hook in when the post is saved (this is when you first get a post id, so its the first point you&#039;re able to save post meta).  

If you need them to be able to edit the values, its a little more complicated.  If that&#039;s the case, let me know, I bet we can figure out a solution.

Good Luck!</description>
		<content:encoded><![CDATA[<p>Hi I.N.K. &#8211; </p>
<p>It sounds like the technique I used could probably be applied here.  A couple of questions:<br />
Do you need the user to be able to edit the parent post id value?  Does the user need to be able to edit the post type?</p>
<p>If the user shouldn&#8217;t be able to edit those fields, your job is much easier &#8211; you just need to hook in when the post is saved (this is when you first get a post id, so its the first point you&#8217;re able to save post meta).  </p>
<p>If you need them to be able to edit the values, its a little more complicated.  If that&#8217;s the case, let me know, I bet we can figure out a solution.</p>
<p>Good Luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: I.N.K.</title>
		<link>http://apartmentonesix.com/2009/04/new-wordpress-plugin-default-post-content/comment-page-1/#comment-119</link>
		<dc:creator>I.N.K.</dc:creator>
		<pubDate>Sat, 18 Apr 2009 23:24:33 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=144#comment-119</guid>
		<description>ps2: don&#039;t be (furtherly) confused by &quot;xy being the pageID&quot; and &quot;mypagetype&quot;. Those are mistakes. 
I really meant &quot;xy being the postID&quot; and &quot;myposttype&quot;.</description>
		<content:encoded><![CDATA[<p>ps2: don&#8217;t be (furtherly) confused by &#8220;xy being the pageID&#8221; and &#8220;mypagetype&#8221;. Those are mistakes.<br />
I really meant &#8220;xy being the postID&#8221; and &#8220;myposttype&#8221;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
