WordPress:Hacking WordPress

来自站长百科
Seadragon530讨论 | 贡献2008年5月5日 (一) 15:57的版本
跳转至: 导航、​ 搜索

In very early versions of WordPress, the only way to modify the behavior of WordPress was through a "hack", i.e. by modifying the core files of WordPress. However, since version 1.5, WordPress has offered both plugin and theme capabilities as mechanisms to modify nearly everything that WordPress does, from looks to functionality, so hacks are seldom necessary any more, and certainly not recommended.

Hacks are not officially supported by WordPress. Use at your own risk.

在很早的WordPress版本中,唯一修改WordPress行为的方法就是通过"hack",如,通过修改WordPress核心文件。尽管如此,1.5版之后,WordPress提供了 插件主题这两个方法修改几乎所有WordPress能做的东西,从功能上来看,hack几乎已经不需要了,自然的也就不推荐使用了。

Hack并不被 WordPress正式的支持。使用有一定风险。

Using WordPress Hacks

Although hacks are not recommended, and since version 1.5 of WordPress, seldom necessary, for completeness, this article still documents the my-hacks.php file, which you can enable and use for "hacks". Basically, you can put PHP functions and variable definitions into this file (which goes into your root WordPress installation directory), and if you activate it, it will be loaded just before plugins when WordPress starts up.

使用WordPress Hacks

尽管不推荐使用hack,而且从WordPress1.5版后WordPress很少需要,但是为了完整性,本文提到了my-hacks.php文件,你可以激活并且使用"hack"。 基本上,你可以吧PHP函数和变量定义放到这个文件中去 (这个文件在你的WordPress安装目录根目录下),如果你激活它,它将在WordPress启动时在插件之前被载入。

To activate my-hacks.php:

  • In the Administration Panel, choose Options > Miscellaneous.
  • At the bottom of the page, click the check box for Use legacy my-hacks.php file support to put a check in it.
  • Click Update to save the changed option.

要激活 my-hacks.php

  • 在管理面板中选择操作 > Miscellaneous.
  • 在页面底部,点击Use legacy my-hacks.php file support复选框,选中它。
  • 点击更新保存更改。