最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filters - Is it better to use a constant or apply_filter?

programmeradmin2浏览0评论

I'm using WPML, which has several ways to access the current language.

ICL_LANGUAGE_CODE

if( ICL_LANGUAGE_CODE === 'en' ){
  // Do stuff
}

apply_filter( 'wpml_current_language', null )' docs

$lang = apply_filter( 'wpml_current_language', null );
if( $lang === 'en' ){
  // Do stuff
}

I can't find any documentation on the ICL_LANGUAGE_CODE.

The apply_filter has a documentation page, but in my opinion, the readability drops with this.

Are there any obvious drawbacks using one or the other?


Update

I know that I mentioned WPML, but that was to give the question context. This is WordPress-specific and not 3rd party specific. The dynamic could be anywhere in WordPress, in any plugin and/or theme.

发布评论

评论列表(0)

  1. 暂无评论