sultann/wp-addtextdomain 问题修复 & 功能扩展

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

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

sultann/wp-addtextdomain

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sultann/wp-addtextdomain

包简介

A Composer package to automatically replace text domains in WordPress gettext functions

README 文档

README

A Composer package that automatically replaces text domains in WordPress gettext functions. It can be used as a Composer plugin that runs automatically after package installation/update, or as a standalone CLI tool.

Features

  • Automatically replaces text domains in WordPress gettext functions
  • Runs as a Composer plugin or standalone CLI tool
  • Configurable through composer.json or command-line arguments
  • Supports all WordPress gettext functions
  • Excludes vendor and node_modules directories by default

Installation

Via Composer (recommended)

composer require sultann/wp-addtextdomain

Manual Installation

  1. Clone the repository:
git clone https://github.com/sultann/wp-addtextdomain.git
  1. Install dependencies:
composer install

Usage

As a Composer Plugin

Add the configuration to your project's composer.json:

{
    "require": {
        "sultann/wp-addtextdomain": "^1.0"
    },
    "extra": {
        "addtextdomain": {
            "textdomain": "my-new-domain",
            "updateDomains": ["old-domain", "another-old-domain"],
            "files": ["src/", "templates/"]
        }
    }
}

As a CLI Tool

# Replace single text domain
vendor/bin/addtextdomain new-domain old-domain

# Replace multiple text domains
vendor/bin/addtextdomain new-domain old-domain1 old-domain2

# Process specific directory
vendor/bin/addtextdomain new-domain old-domain --dir=src/

Configuration

Add the configuration to your project's composer.json under the extra section:

{
    "extra": {
        "addtextdomain": {
            "textdomain": "my-new-domain",        // Required: New text domain to use
            "updateDomains": ["old-one", "old2"], // Required: List of old domains to replace
            "files": [                            // Optional: Files or directories to scan
                "includes/",
                "functions.php"
            ]
        }
    }
}

Configuration Options

  • textdomain: (Required) The new text domain to use for replacement
  • updateDomains: (Required) Array of old text domains to be replaced
  • files: (Optional) Array of files or directories to scan. If not provided, all PHP files in the root and subdirectories will be scanned

Automatic Exclusions

The following directories are automatically excluded from scanning:

  • vendor/
  • node_modules/

Supported WordPress Functions

The package processes the following WordPress gettext functions:

  • __()
  • _e()
  • _x()
  • _n()
  • _nx()
  • _ex()
  • _n_noop()
  • _nx_noop()
  • translate()
  • esc_html__()
  • esc_html_e()
  • esc_html_x()
  • esc_attr__()
  • esc_attr_e()
  • esc_attr_x()

License

GPL-2.0-or-later

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固