<?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: Adding settings to admin pages</title>
	<atom:link href="http://wp-fun.co.uk/2008/11/28/adding-settings-to-admin-pages/feed/" rel="self" type="application/rss+xml" />
	<link>http://wp-fun.co.uk/2008/11/28/adding-settings-to-admin-pages/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 16 Mar 2010 13:31:15 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: ala_747</title>
		<link>http://wp-fun.co.uk/2008/11/28/adding-settings-to-admin-pages/comment-page-1/#comment-1094</link>
		<dc:creator>ala_747</dc:creator>
		<pubDate>Fri, 27 Feb 2009 16:51:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.wp-fun.co.uk/?p=793#comment-1094</guid>
		<description>Thank you very much for your answer :)&lt;br&gt;&lt;br&gt;I&#039;ve tried to do this but $this-&gt;adb value is always returning &#039;d&#039; (the last item of my $as array).&lt;br&gt;&lt;br&gt;I think I&#039;ll need to do it the old way (a new admin page) :(&lt;br&gt;&lt;br&gt;Again, thanks for your time!</description>
		<content:encoded><![CDATA[<p>Thank you very much for your answer :)</p>
<p>I&#39;ve tried to do this but $this-&gt;adb value is always returning &#39;d&#39; (the last item of my $as array).</p>
<p>I think I&#39;ll need to do it the old way (a new admin page) :(</p>
<p>Again, thanks for your time!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Rickmann</title>
		<link>http://wp-fun.co.uk/2008/11/28/adding-settings-to-admin-pages/comment-page-1/#comment-1093</link>
		<dc:creator>Andrew Rickmann</dc:creator>
		<pubDate>Fri, 27 Feb 2009 15:44:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.wp-fun.co.uk/?p=793#comment-1093</guid>
		<description>What I usually do is to make sure the plugin and all its functions are contained within a class and then assigned the values to the class so the callback function can access them by using $this-&gt;myVar i.e.&lt;br&gt;&lt;br&gt;class myPlugin&lt;br&gt;{&lt;br&gt;&lt;br&gt;private $myVar = 10;&lt;br&gt;&lt;br&gt;function myCallBack(){&lt;br&gt;&lt;br&gt;$newVar = $this-&gt;myVar;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;br&gt;}</description>
		<content:encoded><![CDATA[<p>What I usually do is to make sure the plugin and all its functions are contained within a class and then assigned the values to the class so the callback function can access them by using $this-&gt;myVar i.e.</p>
<p>class myPlugin<br />{</p>
<p>private $myVar = 10;</p>
<p>function myCallBack(){</p>
<p>$newVar = $this-&gt;myVar;</p>
<p>}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ala_747</title>
		<link>http://wp-fun.co.uk/2008/11/28/adding-settings-to-admin-pages/comment-page-1/#comment-1092</link>
		<dc:creator>ala_747</dc:creator>
		<pubDate>Fri, 27 Feb 2009 13:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.wp-fun.co.uk/?p=793#comment-1092</guid>
		<description>That&#039;s awesome! Thank you for sharing!!&lt;br&gt;&lt;br&gt;But I&#039;m trying to figure out how to pass an argument to the callback function. Actually, I don&#039;t know if it could be done :(&lt;br&gt;&lt;br&gt;Eg.&lt;br&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;$as = array(&#039;A&#039;, &#039;B&#039;, &#039;C&#039;, &#039;D&#039;);&lt;br&gt;$adb = null;&lt;br&gt;&lt;br&gt;function my_new_settings(){&lt;br&gt;	global $as;&lt;br&gt;	foreach($as as $a):&lt;br&gt;&lt;br&gt;		$adb = sanitize_title($a);		&lt;br&gt; &lt;br&gt;		register_setting(&#039;media&#039;,&quot;{$adb}_1&quot;);&lt;br&gt;		register_setting(&#039;media&#039;,&quot;{$adb}_2&quot;);&lt;br&gt;&lt;br&gt;		add_settings_field(&quot;{$adb}&quot; , &quot;{$a} setting:&quot; ,&lt;br&gt;			&#039;my_new_callback&#039; , &#039;media&#039; , &#039;default&#039;);&lt;br&gt;&lt;br&gt;	endforeach;&lt;br&gt;}&lt;br&gt;&lt;br&gt;function my_new_callback(){&lt;br&gt;	global $adb;&lt;br&gt;&lt;br&gt;	echo &quot;&lt;label for=&quot;{$adb}_1&quot;&gt;Setting 1&lt;/label&gt;&lt;br&gt;		&lt;input name=&quot;{$adb}_1&quot; id=&quot;{$adb}_1&quot; value=&quot;&quot;.attribute_escape(get_option(&quot;{$adb}_1&quot;)).&quot;&quot; class=&quot;small-text&quot; type=&quot;text&quot;&gt;&lt;br&gt;		&lt;label for=&quot;{$adb}_2&quot;&gt;Setting 2&lt;/label&gt;&lt;br&gt;		&lt;input name=&quot;{$adb}_2&quot; id=&quot;{$adb}_2&quot; value=&quot;&quot;.attribute_escape(get_option(&quot;{$adb}_2&quot;)).&quot;&quot; class=&quot;small-text&quot; type=&quot;text&quot;&gt;&lt;br&gt;	&quot;;&lt;br&gt;}&lt;br&gt;&lt;br&gt;add_action(&#039;admin_init&#039;, &#039;my_new_settings&#039;);&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;Maybe I&#039;m missing something? Thanks in advance!</description>
		<content:encoded><![CDATA[<p>That&#39;s awesome! Thank you for sharing!!</p>
<p>But I&#39;m trying to figure out how to pass an argument to the callback function. Actually, I don&#39;t know if it could be done :(</p>
<p>Eg.</p>
<p><code><br />$as = array(&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;);<br />$adb = null;</p>
<p>function my_new_settings(){<br />	global $as;<br />	foreach($as as $a):</p>
<p>		$adb = sanitize_title($a);		</p>
<p>		register_setting(&#39;media&#39;,"{$adb}_1");<br />		register_setting(&#39;media&#39;,"{$adb}_2");</p>
<p>		add_settings_field("{$adb}" , "{$a} setting:" ,<br />			&#39;my_new_callback&#39; , &#39;media&#39; , &#39;default&#39;);</p>
<p>	endforeach;<br />}</p>
<p>function my_new_callback(){<br />	global $adb;</p>
<p>	echo "&lt;label for="{$adb}_1"&gt;Setting 1&lt;/label&gt;<br />		&lt;input name="{$adb}_1" id="{$adb}_1" value="".attribute_escape(get_option("{$adb}_1"))."" class="small-text" type="text"&gt;<br />		&lt;label for="{$adb}_2"&gt;Setting 2&lt;/label&gt;<br />		&lt;input name="{$adb}_2" id="{$adb}_2" value="".attribute_escape(get_option("{$adb}_2"))."" class="small-text" type="text"&gt;<br />	";<br />}</p>
<p>add_action(&#39;admin_init&#39;, &#39;my_new_settings&#39;);<br /></code></p>
<p>Maybe I&#39;m missing something? Thanks in advance!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
