WPML ICL_REGISTER_STRING()抛出致命错误,但工作正常

时间:2013-02-15 作者:Jeremiah Prummer

我正在帮助某人使用自定义插件,他们需要它与WPML兼容。使用WPML中的方法,我能够在WPML中注册一个字符串并在另一端输出它。然而,当插件最初被激活时,我得到了一个Call to undefined function icl_register_string() 错误它工作正常,但出现了致命错误。知道为什么会这样吗?资料来源:http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/

这是我的代码:

//Register Settings with WPML
icl_register_string( \'Match Previous Order\' , \'match_order\', \'Do you want these items to match a previous order from Direct Linen? If yes, use "Additional Notes" to explain.\' );

1 个回复
最合适的回答,由SO网友:s1lv3r 整理而成

您应该始终按照以下方式使用wpml函数:(您链接的HowTo实际上表明:-)

if( function_exists(\'icl_register_string\') ) { icl_register_string( \'Match Previous Order\' , \'match_order\', \'Do you want these items to match a previous order from Direct Linen? If yes, use "Additional Notes" to explain.\' ); }
这将确保在Wordpress安装中不存在WPML,或者在代码运行之前WPML未完全加载(插件激活时)时,不会出现任何错误。

结束

相关推荐

Custom metabox translation

我已经创建了一个自定义的帖子类型,并添加了一些自定义的元数据库,现在我想知道我在我的网站上使用了什么样的翻译插件?我对它们都没有经验,所以我不知道谁会支持我的自定义元数据库,谁不会。