ironbound / wp-notifications
WordPress 中发送通知的框架。
v1.0.1
2015-10-05 05:58 UTC
Requires
- php: >=5.3.0
Suggests
- mandrill/mandrill: Allows for sending notifications via Mandrill
This package is auto-updated.
Last update: 2024-09-08 04:46:51 UTC
README
WP Notifications 是一个用于在 WordPress 中发送通知的简单、直接的框架。它支持多种发送策略和通过队列的批量处理。
基本用法
WP Notifications 使用简单,直观。
发送单个通知
$recipient = wp_get_current_user(); $manager = Factory::make( 'your-notification' ); $message = "Hey {first_name}, how's it going?"; $subject = "Hey!" $notification = new Notification( $recipient, $manager, $message, $subject ); $notification->set_strategy( new WP_Mail() )->send();
发送多个通知
$queue = new WP_Cron( new Options_Storage( 'your-project-name' ) ); $queue->process( $notifications, new WP_Mail() );
设置模板标签监听器
add_action( 'ibd_wp_notifications_template_manager_your-notification', function( Manager $manager ) { // a template tag of {first_name} will be automatically replaced // with the recipient's first name when sending. $manager->add_listener( new Listener( 'first_name', function( WP_User $recipient ) { return $recipient->first_name; } ) ); } );
支持
策略
- WP_Mail
- iThemes Exchange
- Easy Digital Downloads
- Mandrill
队列
- WP_Cron
- Mandrill
安装
首先,使用 Composer 将 WP Notifications 添加为依赖项
composer require ironbound/wp-notifications
然后,确保您的引导文件正在加载 composer 自动加载器
require_once 'vendor/autoload.php';
许可证
MIT