定制 arraypress/edd-register-email-tags 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

arraypress/edd-register-email-tags

Composer 安装命令:

composer require arraypress/edd-register-email-tags

包简介

A streamlined library for managing and registering custom email tags in Easy Digital Downloads (EDD), making email template customization more intuitive and maintainable.

README 文档

README

A PHP library for easy registration and management of Easy Digital Downloads (EDD) email tags, providing a fluent builder interface and robust tag handling. Features type safety, error handling, and context-aware tag processing.

Features

  • 📧 Email Tag Management: Easily register and manage EDD email tags
  • 🏗️ Fluent Builder Interface: Intuitive tag configuration with method chaining
  • WordPress Integration: Seamless integration with EDD's email system
  • 🛡️ Type Safety: Full type hinting and strict types enforcement
  • 🔄 Context Awareness: Support for context-specific tag processing
  • 🎯 Recipient Filtering: Control tag visibility based on recipient types
  • 🚦 Error Handling: Robust error handling with debug logging
  • 🏭 Factory Pattern: Efficient tag creation and registration
  • 🔌 Plugin Support: Easy integration with existing plugins
  • Clean API: Simple and intuitive API design

Requirements

  • PHP 7.4 or later
  • WordPress 5.0 or later
  • Easy Digital Downloads plugin
  • Composer (for installation)

Installation

Install via Composer:

composer require arraypress/edd-email-tags

Basic Usage

use ArrayPress\EDD\Register\EmailTags;

// Initialize the factory with your plugin file
$tags = EmailTags::register( __FILE__ );

// Register a simple email tag
$tags->tag( 'customer_name' )
     ->description( 'The customer\'s full name' )
     ->callback( function( $payment_id ) {
         $payment = edd_get_payment( $payment_id );
         return $payment ? $payment->get_name() : '';
     } )
     ->register();

Extended Examples

Creating Tags with Custom Context

$tags->tag( 'subscription_status' )
     ->description( 'The status of the subscription' )
     ->label( 'Subscription Status' )
     ->contexts( ['subscription', 'renewal'] )
     ->callback( function( $email_object_id, $email_object = null, $email = null ) {
         return $email_object->get_status_label();
     } )
     ->register();

Adding Context-Aware Tags

$tags->tag( 'order_currency' )
     ->description( 'The currency used for the order' )
     ->contexts( ['order'] )
     ->callback( function( $email_object_id, $email_object = null, $email = null ) {
         return $email_object->currency;
     } )
     ->register();

Working with Multiple Tags

// Register multiple tags at once
$tags->tag( 'customer_name' )
     ->description( 'The customer\'s full name' )
     ->callback( function( $email_object_id, $email_object = null, $email = null ) {
         return $email_object->get_name();
     } )
     ->register()
     
     ->tag( 'payment_status' )
     ->description( 'The payment status' )
     ->callback( function( $email_object_id, $email_object = null, $email = null ) {
         return $email_object->status_nicename;
     } )
     ->register();

API Methods

EmailTags Factory Methods

  • register( string $file ): Create/get factory instance for a plugin
  • get_by( string $file ): Get all registered tags for a plugin
  • tag( string $tag ): Create a new tag builder
  • add_tag( EmailTag $tag ): Add a tag to the factory
  • register_tags(): Register all tags with EDD

TagBuilder Methods

  • description( string $description ): Set tag description
  • label( string $label ): Set tag label
  • callback( callable $callback ): Set tag callback
  • contexts( array $contexts ): Set allowed contexts
  • recipients( array $recipients ): Set allowed recipients
  • register(): Build and register the tag

EmailTag Methods

  • get_tag(): Get tag identifier
  • get_description(): Get tag description
  • get_label(): Get tag label
  • get_contexts(): Get allowed contexts
  • get_recipients(): Get allowed recipients
  • get_callback(): Get wrapped callback function
  • get_raw_callback(): Get original unwrapped callback

Use Cases

  • Order Information: Display order-specific details in emails
  • Customer Data: Include customer information in notifications
  • Subscription Details: Show subscription status and information
  • Custom Notifications: Create specialized email content
  • Admin Communications: Include admin-specific information
  • Dynamic Content: Generate context-aware email content
  • Conditional Display: Show content based on recipient type
  • Payment Information: Include payment-specific details
  • Product Details: Display purchased item information
  • System Integration: Connect with other plugin systems

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the GPL-2.0-or-later License.

Support

arraypress/edd-register-email-tags 适用场景与选型建议

arraypress/edd-register-email-tags 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 arraypress/edd-register-email-tags 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-12-22