level-level/ll-plugin-autoloader
Composer 安装命令:
composer require level-level/ll-plugin-autoloader
包简介
Simplifies loading the composer autoloader and mu-plugins in WordPress.
README 文档
README
When 0-loader.php is inserted into the mu-plugins directory it will load all subdirectory plugin as it would normal plugins.
Configuration options
You have multiple options to manipulate where the Plugin Loader will look for a vendor folder. Define one of the following values in wp-config:
1. Default == wp-content directory
If you define nothing it will load the same as 2. wp-content directory.
2. wp-content directory
Load from the parent directory above mu-plugins (should be the wp-content dir). This is only used when no LL_AUTOLOAD_DIR is set.
define('LL_AUTOLOAD_CONTENT_DIR', true);
3. Child theme
Use the current Child theme via get_stylesheet_directory as the theme folder containing the vendor folder. This is only used when no LL_AUTOLOAD_DIR is set.
define('LL_AUTOLOAD_USE_CHILD', true);
4. Parent/default theme
Use the current parent theme via get_template_directory as the theme folder containing the vendor folder. This is only used when no LL_AUTOLOAD_DIR is set.
define('LL_AUTOLOAD_USE_PARENT', true);
5. Custom path
Use a specific directory. The script will still append /vendor/autoload.php to this path.
define('LL_AUTOLOAD_DIR', '/path/to/wordpress/theme/');
Overview
| Setting | Result |
|---|---|
| Nothing | wp-content directory |
define( 'LL_AUTOLOAD_DIR', '/tmp/' ); |
/tmp/ |
define( 'LL_AUTOLOAD_CONTENT_DIR', true ); |
wp-content directory |
define( 'LL_AUTOLOAD_USE_CHILD', true ); |
Stylesheet directory (child theme) |
define( 'LL_AUTOLOAD_USE_PARENT', true ); |
Template directory (parent theme) |
Pre and Post autoload
Pre autoload
Right before the vendor autoload file is loaded, the pre-autoload.php file in the directory specified as the autoload directory is required if it exists.
This file can be used to set environment variables required in composer loaded dependencies.
Post autoload
Right after the vendor autoload file is loaded, but before the mu-plugins are loaded, the post-autoload.php file in the directory specified as the autoload directory is required if it exists.
This file can be used to bootstrap/configure mu-plugin loaded dependencies, or trigger actions that need to happen as early as possible, but autoloading to be set up.
Adding logging is an example of this. You probably require the Monolog composer dependency, but want it to be bootstrapped before we load the mu-plugins.
Force load normal plugins
In some cases, loading a plugin as must-use plugin can cause issues with the plugin. Instead, you have the option to force load plugins like normal plugins.
In the path where also your vendor folder is, create a file called ll-forced-plugins.json.
Inside, paste the following content.
{
"forced_plugins": [
{
"slug": "first-plugin/first-plugin.php",
"network": false
},
{
"slug": "second-plugin/second-plugin.php",
"network": true
}
]
}
The slug references the plugin file to load. Network determines if a plugin should be network activated if it's a multisite installation.
Please note these force activated plugins will only be activated when visiting the WP-admin. This is needed because some plugins want to perform actions like redirects directly after activation.
Upgrading from v2.x to v3.x
In v3, the wp-content directory loads by default, instead of the template directory in v2. To restore behaviour, set define( 'LL_AUTOLOAD_USE_PARENT', true ); in wp-config.php.
level-level/ll-plugin-autoloader 适用场景与选型建议
level-level/ll-plugin-autoloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 194.04k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 level-level/ll-plugin-autoloader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 level-level/ll-plugin-autoloader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 194.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-21