wp-digital / wp-start-up
WPStartUp 插件在 WordPress 安装后进行初始设置。在 Bugsnag 和 Pingdom 中创建项目。
Requires
- php: >=7.4
- ext-json: *
Requires (Dev)
- innocode-digital/php-cs: ^1.0
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-11 10:28:01 UTC
README
描述
WPStartUp 是一款强大的工具,可简化 WordPress 安装后的初始设置过程。它允许您轻松地在 Bugsnag 和 Pingdom 中创建项目,增强网站的性能和监控能力。
安装
安装 WPStartUp 有两种便捷的方式
-
使用 Composer: 建议使用 Composer。只需运行以下命令
composer require wp-digital/wp-start-up
WPStartUp 将默认安装为 必须使用的插件。如果您想自定义安装路径,可以在您的
composer.json
中使用extra.installer-paths
控制。 -
使用 Git Clone: 或者,您可以直接将存储库克隆到
wp-content/mu-plugins/
或wp-content/plugins/
目录。按照以下步骤操作cd wp-content/plugins/ git clone git@github.com:wp-digital/wp-start-up.git cd wp-start-up/ composer install
如果您将插件作为常规插件安装,请从 WordPress 控制面板的“插件”页面激活 WPStartUp,或使用 WP-CLI: wp plugin activate wp-start-up
。
配置
要配置 WPStartUp,请在您的 wp-config.php
文件中添加以下常量
define( 'BUGSNAG_TOKEN', '' ); define( 'BUGSNAG_PROJECT', '' ); define( 'PINGDOM_TOKEN', '' ); define( 'PINGDOM_PROJECT', '' );
请注意,定义 BUGSNAG_API_KEY
常量表示 Bugsnag 项目已创建,并且插件不会创建新的项目。
使用
WPStartUp 会自动在 Bugsnag 和 Pingdom 中创建项目,增强网站的性能监控能力。如果您想通过新的集成扩展其功能,请使用 wp_start_up_integrations
钩子
add_filter( 'wp_start_up_integrations', function( array $integrations ): array { $integrations[] = new YourCustomIntegration(); return $integrations; } );
请确保您的集成实现了 WPD\WPStartUp\Interfaces\IntegrationInterface
接口。
默认情况下,WPStartUp 将插件设置存储在 WordPress 选项表中。如果您更喜欢自定义存储解决方案,请使用 wp_start_up_default_storage
过滤器
add_filter( 'wp_start_up_default_storage', function(): \WPD\WPStartUp\Interfaces\StorageInterface { return new YourCustomStorage(); } );
同样,确保您的自定义存储实现了 \WPD\WPStartUp\Interfaces\StorageInterface
接口。
此外,WPStartUp 使用原生的 wp_remote_request
函数发送 API 请求。如果您想使用不同的方法,您可以修改此行为使用 wp_start_up_default_sender
过滤器
add_filter( 'wp_start_up_default_sender', function(): \WPD\WPStartUp\Interfaces\SenderInterface { return new YourCustomSender(); } );
同样,您的自定义发送者应实现 \WPD\WPStartUp\Interfaces\SenderInterface
接口。
有了 WPStartUp,您可以自由地定制 WordPress 设置,并将其与其他服务无缝集成,确保网站管理体验流畅高效。