0

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

1 Answer 1

1

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'
    );
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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