doze79040 2012-10-07 13:08
浏览 39
已采纳

WordPress字符串常量是否有标准或编码标准?

I have a set of options I want to store in a WordPress plugin and these names are likely never to change. However, I want to account for the eventuality that they do.

If myplugin is the name of the plugin I'm developing, I have an 'option names' named in the following style:

  • myplugin_preference_name
  • myplugin_preference_address

That sort of thing.

Anyway, there doesn't appear to be any sort of authority on whether using a PHP define() call is ok in this case or not (in the context of a WordPress plugin).

I have already had a look through the wordpress coding standards:

http://codex.wordpress.org/WordPress_Coding_Standards

  • 写回答

1条回答 默认 最新

  • dongshang1768 2012-10-07 13:10
    关注

    Constants in Wordpress are normally written UPPERCASE.

    You do not find that in the coding standards, because wordpress coding standards are historically weakly documented and enforced, I would not rely too much to that document.

    Also you should consider to not introduce constants too much. Not everyhing you can use a constant for, needs to be one, normally variables already do a good job.

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

报告相同问题?