• Hello,

    I know my share of html and css but I’m a newbie to php (and quite confused).
    While reading the codex about registering sidebars I saw

    'name'          => __( 'Sidebar name', 'theme_text_domain' ),
    	'id'            => 'unique-sidebar-id',
    	'description'   => '',

    later I saw

    'name' => __( 'Main Sidebar', 'theme-slug' ),
            'id' => 'sidebar-1',
            'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),

    Note that in the second example there is __( in the description.
    I searched what the __() is about and found out it is for translation (?).
    Now my question is: Since I’m a total newbie and don’t need any translation, could I make my life just a bit easier and omit the __() from the name and description?
    And btw is always the __() used for translations? Could I omit it wherever I find it or will it break my code?
    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes, that is used for echoing with translations if available with the text domain, you could just drop wordpress as text domain if you don’t wish to build translation-ready theme or plugin, so, your code could go like this:

    'name' => __( 'Main Sidebar', 'wordpress' ),
    'id' => 'sidebar-1',
    'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'wordpress' ),
    //other array elements

    Hope someone else give you another thought on this ??

    From what I can tell it’s used for language translation. If it can’t find the phrase in its table then it outputs the text as is. You can probably not use them if your site is all English anyway.

    Thread Starter Kavouras

    (@kavouras)

    I see.

    'name'          => 'Sidebar name',
    'id'            => 'unique-sidebar-id',
    'description'   => 'Sidebar description',

    This seems a bit more comprehensible. Hope it is ok.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can the __() thing be omited?’ is closed to new replies.