Вопрос

I have a function like this:

add_settings_field( 'contact_phone', 'Contact Phone', 'settings_callback', 'general');

That works. It calls settings_callback. Cool. The problem I have with this is: I don't want to have to define a callback function for every setting I add, if all I'm doing is echoing out a little bit of stuff.

function settings_callback()
{
    echo '<input id="contact_phone" type="text" class="regular-text" name="contact_phone" />';
}

Why on earth should I have to do that? The id, class, and name should all be params.

Is there no way to pass params to the settings_callback function? I started looking at the core, got here: http://core.trac.wordpress.org/browser/tags/3.1.3/wp-admin/includes/template.php

..and ran into this $wp_settings_fields global. Where is this defined?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с wordpress.stackexchange
scroll top