tormjens/wp-queue-mail 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tormjens/wp-queue-mail

Composer 安装命令:

composer require tormjens/wp-queue-mail

包简介

Candidate profiles for OSM Aviation.

关键字:

README 文档

README

A plugin to queue WordPress emails. When sending out emails in bulk the action of sending each of them is both time and resource consuming. That's where queues come in. When you add an e-mail to a queue instead of sending it, it is a matter of adding a row to the database, instead of connecting to the server, sending the contents and so on.

Simply enable the plugin and it will automatically hook in to the wp_mail function and start queueing emails.

The queue part was taken from the (Mailchimp for WooCommerce plugin)[https://github.com/mailchimp/mc-woocommerce], but was originally written by (A5hleyRich)[https://github.com/A5hleyRich/wp-background-processing]

Getting started

The tables needed for the queue to work can be set up using the following WP CLI command in the root of your project.

$ wp queue create-tables

The queue

The queue can be processed in two ways.

Via a WP CLI queue listener

This is my favorite as it runs on the CLI and thus is not affected by the memory and timeout limit of PHP.

Start the queue listener by navigation to the root of your project and type:

$ wp queue listen

To make sure the queue listener is always running you could use something like (Supervisor)[http://supervisord.org/].

Via WP Cron

This works for most websites running WordPress. The queue is simply added to the WP Cron schedule and executed according to it.

Using it for other things than mails

The queue is not specifically bound to sending emails. You can create your own jobs and dispatch them via the features of this plugin.

The job

A job must extend the WP_Job class and contain a handle method. You can use a constructor to give the job the data you need processed.

<?php
class Publish_Podcast extends WP_Job {

	protected $name;

	protected $location;
	
	public function __construct( $name, $location ) {
		$this->name = $name;
		$this->location = $location;
	}

	public function handle() {
		// process the podcast here
	}

}

The handle method is what will be fired by the queue.

When you are ready to dispatch a job, you can use the convenient wp_queue helper function.

<?php 
wp_queue(new Publish_Podcast('Scooby Doo And His Friends', 'iTunes'));

The next time the queue is processed the job will be a part of it. Neat!

tormjens/wp-queue-mail 适用场景与选型建议

tormjens/wp-queue-mail 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56 次下载、GitHub Stars 达 8, 最近一次更新时间为 2017 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wordpress」 「wp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tormjens/wp-queue-mail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tormjens/wp-queue-mail 我们能提供哪些服务?
定制开发 / 二次开发

基于 tormjens/wp-queue-mail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 56
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-13