Title: $this-&gt;WP_Widget() syntax
Last modified: August 19, 2016

---

# $this->WP_Widget() syntax

 *  [Ryan](https://wordpress.org/support/users/rfrankel/)
 * (@rfrankel)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/this-wp_widget-syntax/)
 * This may be a dumb question but I have been unable to find a reasonable description
   in the Codex or online…
 * In the Widget example there is in the constructor function the following line…
 * `$this->WP_Widget( 'example-widget', __('Example Widget', 'example'), $widget_ops,
   $control_ops );`
 * I am wondering what the ‘example-widget’ and __(‘Example Widget’, ‘example’) 
   are for. The $widget_ops and $control_ops I have been able to decipher from online
   material but the first two I am not sure about. It seems that sometimes these
   are included and other times they are not.
 * If anyone could provide information, a link to the the codex where this is covered
   or anything at all please let me know.
 * All the best.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Ryan](https://wordpress.org/support/users/rfrankel/)
 * (@rfrankel)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/this-wp_widget-syntax/#post-1721379)
 * UPDATE: I found some information in trunk/wp-includes/widgets.php but I am not
   sure I am interpreting it correctly.
 * the ‘example-widget’ part is a Base-ID?
 * the __(‘Example Widget’, ‘example’) is the Name of the widget?
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/this-wp_widget-syntax/#post-1721380)
 * `example-widget`
    – the slug for the widget
 * `__('Example Widget', 'example')` – the value in this case is the widget display
   name (slugs are for reference, all lowercase and hyphens in place of spaces)
   –
   a translatable string – first part is the string/text – second part is the text
   domain name
 * If my theme registered a text domain(what you register to make a theme or plugin
   translation ready) with the name `bob` (for example), i’d wrap all pieces of 
   text like this..
 *     ```
       <?php _e( 'some text i\'m echoing and making translatable', 'bob' ); ?>
       ```
   
 * or
 *     ```
       <?php
       $var = __( 'some text being stored in a var for translation', 'bob' );
       ?>
       ```
   
 * If you have no need for translation, just drop the translation wrapper/function-
   call..
 *     ```
       __('Example Widget', 'example')
       ```
   
 * Can be..
 *     ```
       'Example Widget'
       ```
   
 * More on translation here (if it’s of interest).
    [http://codex.wordpress.org/I18n_for_WordPress_Developers](http://codex.wordpress.org/I18n_for_WordPress_Developers)
 *  Thread Starter [Ryan](https://wordpress.org/support/users/rfrankel/)
 * (@rfrankel)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/this-wp_widget-syntax/#post-1721381)
 * Got it Mark. That was fast!! Many thanks for the info.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/this-wp_widget-syntax/#post-1721382)
 * You’re welcome.. 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘$this->WP_Widget() syntax’ is closed to new replies.

## Tags

 * [wp_widget](https://wordpress.org/support/topic-tag/wp_widget/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 2 participants
 * Last reply from: [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/this-wp_widget-syntax/#post-1721382)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
