-
Website
http://www.wp-fun.co.uk -
Original page
http://www.wp-fun.co.uk/2008/11/28/adding-settings-to-admin-pages/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
donnacha | WordSkill
1 comment · 11 points
-
Improving The Web
5 comments · 1 points
-
michaeltwofish
4 comments · 12 points
-
Busby SEO Test
2 comments · 1 points
-
ringmaster
7 comments · 1 points
-
-
Popular Threads
But I'm trying to figure out how to pass an argument to the callback function. Actually, I don't know if it could be done :(
Eg.
$as = array('A', 'B', 'C', 'D');
$adb = null;
function my_new_settings(){
global $as;
foreach($as as $a):
$adb = sanitize_title($a);
register_setting('media',"{$adb}_1");
register_setting('media',"{$adb}_2");
add_settings_field("{$adb}" , "{$a} setting:" ,
'my_new_callback' , 'media' , 'default');
endforeach;
}
function my_new_callback(){
global $adb;
echo "<label for=\"{$adb}_1\">Setting 1</label>
<input name=\"{$adb}_1\" id=\"{$adb}_1\" value=\"".attribute_escape(get_option("{$adb}_1"))."\" class=\"small-text\" type=\"text\">
<label for=\"{$adb}_2\">Setting 2</label>
<input name=\"{$adb}_2\" id=\"{$adb}_2\" value=\"".attribute_escape(get_option("{$adb}_2"))."\" class=\"small-text\" type=\"text\">
";
}
add_action('admin_init', 'my_new_settings');
Maybe I'm missing something? Thanks in advance!
class myPlugin
{
private $myVar = 10;
function myCallBack(){
$newVar = $this->myVar;
}
}
I've tried to do this but $this->adb value is always returning 'd' (the last item of my $as array).
I think I'll need to do it the old way (a new admin page) :(
Again, thanks for your time!