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

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

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100