dqpd4268 2015-01-16 00:37
浏览 48
已采纳

Wordpress小部件构造函数

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!

  • 写回答

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码