Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Jojo Ind
Jojo Ind
2,260 Points

What is this PHP/Wordpress Array means ?

Hi, I'm currently learning to integrate Redux framework to my wp theme.

In Redux sample-config file, there's a line like this :

Redux::setSection( $opt_name, array(
        'title' => __( 'Basic Fields', 'redux-framework-demo' ),
        'subtitle'  => __( 'Subtitle', 'redux-framework-demo' ),
        'desc'      => __( 'Field Description', 'redux-framework-demo' ),
        'id'    => 'basic',
        'icon'  => 'el el-home'
    ) );

On the title, subtitle, and desc, What are those 2 parameters means ? why the second one is always 'redux-framework-demo' ?

and what are their role ?

What will happen if I change the 'redux-framework-demo' to something else ?

I've been digging to Redux doc but I couldn't find any information about this.

Thank you Jojo

1 Answer

Chris Shaw
Chris Shaw
26,650 Points

Hi Jojo Ind,

If you look carefully you will see the two strings are encapsulated within a function that is called __, it looks like a very long underscore but it's two separate characters. This function is part of the l10n translation base that allows text in your code to be easily translated for many different languages.

See the following link for more information: _2

Hope that helps.

Jojo Ind
Jojo Ind
2,260 Points

Hi Chris Upjohn,

Thanks for your answer. It really helps. After reading the link you provided (wp codex), I still don't understand the roles of the 2nd parameter ($domain). <?php $translated_text = __( $text, $domain ); ?>

Based on the wp codex, $text (string) (required) is the Text to translate and the $domain (string) (optional) is the Domain to retrieve the translated text.

Does it mean, when I open this wp theme in other language, the $text will be translated to $domain ?