Must Use Plugins ----必须使用的插件

Must Use Plugins (必须使用的插件)

Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folder and which are automatically enabled on all sites in the installation. Must-use plugins do not show in the default list of plugins on the Plugins page of wp-admin – although they do appear in a special Must-Use section – and cannot be disabled except by removing the plugin file from the must-use directory, which is found in wp-content/mu-plugins by default.

Must-use plugins (a.k.a. mu-plugins) 是插件,安装在内容文件夹中的一个特殊目录中。并且在安装的所有站点上自动启用。Must-use plugins不显示在wp-admin的插件页面的默认插件列表中。--尽管他们出现在一个特殊的必须使用部分 --并且不能被禁用,除非从必需的目录中删除插件文件。默认情况下在wp-content/mu-plugins中找到。

 

Features (特性)

  • Always-on, no need to enable via admin and users cannot disable by accident.
  • Can be enabled simply by uploading file to the mu-plugins directory, without having to log-in.
  • Loaded by PHP, in alphabetical order, before normal plugins, meaning API hooks added in an mu-plugin apply to all other plugins even if they run hooked-functions in the global namespace.
  • 始终在,无需通过管理员启用,用户不能意外禁用。
  • 只需将文件上传到MU插件目录就可以启用,而无需登录。
  • PHP按字母顺序加载,在正常的插件之前,在mu-plugin中添加的API钩子适用于所有其他插件,即使它们在全局命名空间中运行钩子函数。

Caveats(注意事项)

Despite its suitability for many special cases, the mu-plugins system is not always ideal and has several downsides that make it innapropriate in certain circumstances. Below are several important caveats to keep in mind:

尽管许多特殊情况下的适用性,mu-plugins系统并不总是理想的,有几个缺点,使它在某些情况下不合适。以下是几个重要的注意事项:

 

  • Plugins in the must-use directory will not appear in the update notifications nor show their update status on the plugins page, so you are responsible for learning about and performing updates on your own.
  • Activation hooks are not executed in plugins added to the must-use plugins folder. These hooks are used by many plugins to run installation code that sets up the plugin initially and/or uninstall code that cleans up when the plugin is deleted. Plugins depending on these hooks may not function in the mu-plugins folder, and as such all plugins should be carefully tested specifically in the mu-plugins directory before being deployed to a live site.
  • WordPress only looks for PHP files right inside the mu-plugins directory, and (unlike for normal plugins) not for files in subdirectories. You may want to create a proxy PHP loader file inside the mu-plugins directory:
  • must-use目录中的插件不会出现在更新通知中,也不会显示在插件页面上的更新状态,因此您负责自己学习和执行更新。
  • Activation hooks不在添加到必须使用的插件文件夹中的插件中执行。许多插件使用这些钩子来运行安装代码,最初安装插件和/或卸载在删除插件时清理的代码。依赖于这些钩子的插件可能在MU插件文件夹中不起作用,因此,在部署到现场之前,所有插件都应该在MU插件目录中进行仔细测试。
  • WordPress只有找PHP文件里面的MU插件目录,和(不链接正常的插件)不是子目录中的文件。您可能希望在MU插件目录中创建代理PHP加载程序文件:
1 <?php // mu-plugins/load.php
2 require WPMU_PLUGIN_DIR.'/my-plugin/my-plugin.php';

 

History and Naming(历史和命名)

The 'mu-plugins' directory was originally implemented by WPMU (Multi-User) to offer site admins an easy way to activate plugins by default on all blogs in the farm. There was a need for this feature because at the time the multi-user-specific code did not offer ways of achieving this effect using the site admin section (today the renamed "Multisite WordPress" has features to manage plugins from inside the admin).

 'mu-plugins' 目录最初是由WPMU(多用户)提供网站管理员通过对农场所有的博客默认激活插件的简单方法。有此功能的需要,同时多用户特定的代码并没有提供实现这一效果,使用网站后台管理部分的方式(现在改名为“多点WordPress”具有的特点,从内部admin管理插件)。

 

The code handling /mu-plugins/ was merged into the main WordPress code on 03/07/09 with this changeset a full 10 months before the wpmu codebase was initially merged, and all WP sites could take advantage of autoloaded plugins, whether they had MU/Multisite enabled or not. The feature is useful for all types of WP installations depending on circumstances, so this makes sense.

代码处理 /mu-plugins/合并到主WordPress代码,是在03/07/09。 满10个月之前的WPMU代码最初是合并,和所有的WP网站可以利用自动载入插件,不管他们是否有MU/Multisite启用或禁用。这个特性对于所有类型的WP安装都是有用的,这取决于环境,所以这是有意义的。

In this process the name "mu plugins" became a misnomer because it did not apply exclusively to multisite installs and because "MU" was not even being used anymore to refer to WP installations with multiple blogs. Despite this, the name was kept and re-interpreted to mean "Must-use plugins", i.e. These are plugins that must always be used, thus they are autoloaded on all sites regardless of the settings in the Plugins pane of wp-admin.

在这一过程中“mu-plugins”成为一个误称,因为它不适用于多点安装,因为“MU”甚至被再使用是指多个博客WP设备。尽管如此,这个名字被重新解释为“Must-use plugins”,即这些插件,必须经常使用,因此他们自动加载在所有站点。不理会wp-admin插件面板的设置。

Thus "Must-Use" is effectively a Backronym, like PHP (which originally meant "Personal Home Page" but was later re-interpreted as meaning "PHP Hypertext Preprocessor", which is also a Recursive Acronym).

 因此,“Must-Use”是有效的——像PHP(原意为“Personal Home Page”,但后来被重新解释为“PHP Hypertext Preprocessor”,这也是一个递归的缩写)。

 

Source Code

This page is  marked as incomplete. You can  help Codex by  expanding it.

 

转载于:https://www.cnblogs.com/kais7mg/p/7717406.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值