I'm trying to create a widget from scratch, and I've got everything running fine, but some portions via copy and paste only. I'm trying to understand what the second parameter is in the $name portion of the "parent::__construct() array. That would be 'akf_widget_domain' in the following example. Is it just a value placeholder for a key=>value pair? I would imagine if the widget domain is listed as part of the value, as it is in the example I got this from, then perhaps this is important for localization? The code looks like this-
function __construct() {
parent::__construct(
// Base ID
'akf_intro',
// Widget name ( $name in the WP_Widget core)
__('AKF Intro Widget', 'akf_widget_domain'),
// Widget description
array( 'description' => __( 'A Widget for the AKF site', 'akf_widget_domain' ), )
);
}//construct end
Thanks for any help!
The __()
function in WordPress is an alias for the translate()
function. The first argument is the string you wish to translate and the second value, akf_widget_domain
in your example, is the text domain. The domain is a unique string used in all translate function calls inside your theme/plugin.
Further reading: http://codex.wordpress.org/Function_Reference/_2