primetime/wp-plugin-activation-manifest

WordPress插件基于文件激活控制,简单易用

v1.1.1 2021-07-06 21:01 UTC

This package is auto-updated.

Last update: 2024-09-07 03:43:47 UTC


README

轻松锁定单个插件的激活状态,基于环境。

用法

创建一个YAML文件,定义你想要强制执行的插件激活状态。你可以根据需要命名,并放在任何地方(理想情况下放在webroot之外)。将此文件添加到你的项目仓库中。

示例清单文件

# top level keys are the environment
some_environment:
  enable:
    - someplugin/someplugin.php
  disable:
    - someotherplugin/someotherplugin.php
  # supports multisite
  network-enable:
    - someplugin/someplugin.php
  network-disable:
    - someplugin/someplugin.php

# 'global' is a special key that you can use to apply to all environments
global:
  enable:
    - woocommerce/woocommerce.php
    - wpmandrill/wpmandrill.php
    
development:
  disable:
    - wpmandrill/wpmandrill.php
    

安装 composer require primetime/wp-plugin-activation-manifest

执行命令

require('vendor/autoload.php');
// ...
// after WordPress is loaded - eg: within an mu-plugin
// ..
\PrimeTime\WordPress\PluginManifest\Activation::set('path/to/plugin-manifest.yml', getenv('WP_ENV'));

在上面的例子中,WP_ENV是一个环境变量,用于定义环境的名称(例如:开发、测试、生产)。这个环境名称应该与yaml文件中的顶级键匹配。

环境配置在global配置之后应用,并将优先于它。

就这样!