2015-01-16 00:37
浏览 48


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() {
// Base ID
// 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!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douchun6221 2015-01-16 00:58

    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

    打赏 评论

相关推荐 更多相似问题