Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Assuming i've got a bunch of setting sections. I add these sections to my plugin page in the following way.

$sections = array('notifcations', 'updates');

foreach ($sections as $section)
{
    add_settings_section(
        $section .'_section',
        $section,
        array( $this, 'disable_callback_warnings' ),
        'sgnc'
    );
}

Everything works as expected but i wonder how to localise the section headline? As far as i know i can't pass any variables to the locale functions _e() and __(). So this won't work:

$sections = array('notifcations', 'updates');

foreach ($sections as $section)
{
    add_settings_section(
        $section .'_section',
        __($section),
        array( $this, 'disable_callback_warnings' ),
        'sgnc'
    );
}

http://codex.wordpress.org/Function_Reference/add_settings_section

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Localize the headings in your initial array:

$sections = array(
    'notifcations' => __( 'Notifications', 'your_text_domain' ), 
    'updates' => __( 'Updates', 'your_text_domain' )
);

foreach ($sections as $section => $header )
{
    add_settings_section(
        $section .'_section',
        $header,
        array( $this, 'disable_callback_warnings' ),
        'sgnc'
    );
}
share|improve this answer
    
Somehow obvious... Thanks Thomas! –  gearsdigital Oct 17 '12 at 17:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.