承接 arraypress/wp-anonymize-utils 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

arraypress/wp-anonymize-utils

Composer 安装命令:

composer require arraypress/wp-anonymize-utils

包简介

A simple WordPress utility for anonymizing personal data (names, phones, addresses)

README 文档

README

A simple WordPress utility for anonymizing personal data including names, phone numbers, addresses, and generic text masking. Perfect for GDPR compliance and e-commerce privacy requirements.

Features

  • 🎯 Focused API - Just 6 essential methods for personal data anonymization
  • 🔒 Privacy Compliance - Built for GDPR and privacy regulations
  • 📦 E-commerce Ready - Perfect for WooCommerce and custom shop plugins
  • 🪶 Lightweight - Single class, ~150 lines of code
  • 🔧 Global Functions - Optional helper functions for convenience

Requirements

  • PHP 7.4 or later
  • WordPress 5.0 or later

Installation

composer require arraypress/wp-utils-anonymize

Usage

Using the Class

use ArrayPress\AnonymizeUtils\Anonymize;

// Anonymize names - preserves first and last letter
$name = Anonymize::name( 'John Smith' );
// Returns: "J**n S***h"

// Anonymize phone numbers - keeps last 4 digits
$phone = Anonymize::phone( '555-123-4567' );
// Returns: "*******4567"

// Anonymize addresses - preserves structure
$address = Anonymize::address( '123 Main Street' );
// Returns: "*** **** ******"

// Anonymize zip codes - keeps last 2 characters
$zip = Anonymize::zipcode( '90210' );
// Returns: "***10"

// Generic text masking
$text = Anonymize::text( 'sensitive', 2, 1 );
// Returns: "se******e"

// Bulk anonymize fields
$data = Anonymize::fields( [
    'billing_name' => 'John Doe',
    'billing_phone' => '555-1234',
    'billing_address' => '123 Main St'
] );
// Returns anonymized array with auto-detection

Using Global Functions

// Simple global functions for common operations
echo anonymize_name( 'Jane Doe' );        // "J**e D*e"
echo anonymize_phone( '555-1234' );       // "****1234"  
echo anonymize_address( '456 Oak Ave' );  // "*** *** ***"

E-commerce Example

use ArrayPress\Utils\Anonymize;

// GDPR compliance - anonymize customer data
class Order_Privacy {
    
    public function anonymize_order( $order_id ) {
        $order = wc_get_order( $order_id );
        
        // Anonymize billing information
        $order->set_billing_first_name( Anonymize::name( $order->get_billing_first_name() ) );
        $order->set_billing_last_name( Anonymize::name( $order->get_billing_last_name() ) );
        $order->set_billing_phone( Anonymize::phone( $order->get_billing_phone() ) );
        $order->set_billing_address_1( Anonymize::address( $order->get_billing_address_1() ) );
        $order->set_billing_postcode( Anonymize::zipcode( $order->get_billing_postcode() ) );
        
        $order->save();
    }
}

Check if Data is Anonymized

$name = 'J**n S***h';
if ( Anonymize::is_anonymized( $name ) ) {
    // Data has already been anonymized
}

Methods

name( string $name ): string

Anonymizes names while preserving the first and last letter of each word.

phone( string $phone, int $keep_last = 4 ): string

Anonymizes phone numbers, keeping only the specified number of last digits.

address( string $address ): string

Anonymizes addresses while preserving structure (spaces, punctuation, line breaks).

zipcode( string $zip, int $keep_last = 2 ): string

Anonymizes postal codes, keeping only the specified number of last characters.

text( string $text, int $show_first = 1, int $show_last = 1 ): string

Generic text masking that shows only specified characters at start and end.

fields( array $data ): array

Bulk anonymize multiple fields with automatic type detection based on field names.

is_anonymized( string $text ): bool

Check if text appears to be already anonymized (contains 3+ asterisks).

Why This Library?

  • Focused - Just personal data anonymization, nothing else
  • E-commerce Ready - Built with WooCommerce/SugarCart needs in mind
  • GDPR Compliant - Helps meet "right to be forgotten" requirements
  • Simple API - Easy to remember methods that do one thing well
  • No Dependencies - Just PHP and WordPress

Note on Email and IP Anonymization

This library focuses on personal data (names, phones, addresses). For email and IP anonymization, use the dedicated utilities:

License

GPL-2.0-or-later

Support

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-09-02