Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,676 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 ?