awpswp-mailhog-mu-plugin

WordPress Mailhog MU 插件。设计用于与 docker-compose 一起使用

安装: 82

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:wordpress-muplugin

0.2.0 2021-03-09 15:08 UTC

This package is not auto-updated.

Last update: 2024-09-19 06:00:25 UTC


README

WordPress Mailhog MU 插件。设计用于与 docker-compose 一起使用。

将其作为开发依赖项安装

composer require awps/wp-mailhog-mu-plugin --dev

添加插件位置的说明

注意:.srv/wordpress/ 替换为您的 WP 安装路径。

"extra": {
    "installer-paths": {
      ".srv/wordpress/wp-content/mu-plugins/{$name}/": [ "type:wordpress-muplugin"]
    }
},

docker-compose.yml 中添加 Mailhog 配置

version: '3'
services:
    # ... other services
    mailhog:
        image: mailhog/mailhog
        ports:
            - 1025:1025 # smtp server
            - 8025:8025 # web ui

最后,将加载器添加到 mu-plugins 中。

默认情况下,MU 插件不能从文件夹中加载,它们必须是一个单独的文件。希望我们可以通过加载所有遵循简单模式的插件来欺骗系统。有关详细信息,请参阅此 gist:https://gist.github.com/awps/9d9d97ef743d78f32f10ca78d2ba1746

将此代码保存到文件中,并将其放置在 mu-plugins 目录中。

<?php
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS;
$iterator = new \FilesystemIterator(__DIR__, $flags);

foreach ($iterator as $path => $item) {
    if ($item->isDir()) {
        $muPath = trailingslashit($path);
        $fileName = basename($item->getFileName());
        $filePath = "{$muPath}/{$fileName}.php";

        if (file_exists($filePath)) {
            require_once $filePath;
        }
    }
}