定制 fwestdev/wp-stubs 二次开发

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

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

fwestdev/wp-stubs

Composer 安装命令:

composer require fwestdev/wp-stubs

包简介

README 文档

README

A Composer package that provides PHP stubs for WordPress, WooCommerce, and Advanced Custom Fields (ACF) along with comprehensive PHP CodeSniffer rules for linting WordPress projects.

What's Included

This package includes:

  • WordPress Core Stubs (php-stubs/wordpress-stubs) - PHP stubs for WordPress 6.4+
  • WooCommerce Stubs (php-stubs/woocommerce-stubs) - PHP stubs for WooCommerce 8.9+
  • ACF Pro Stubs (php-stubs/acf-pro-stubs) - PHP stubs for Advanced Custom Fields 6.0+
  • WordPress Coding Standards (wp-coding-standards/wpcs) - Official WordPress coding standards
  • PHP Compatibility (phpcompatibility/php-compatibility) - PHP version compatibility checking
  • PHP CodeSniffer (squizlabs/php_codesniffer) - The underlying code analysis tool

Installation

Install this package as a development dependency in your WordPress project:

composer require --dev fwestdev/wp-stubs:dev-main

Usage

Running PHP CodeSniffer

After installation, you can run the linting tools using the provided Composer scripts:

# Check code for violations
composer run phpcs

# Automatically fix code violations (where possible)
composer run phpcbf

Manual PHPCS Commands

You can also run PHPCS directly with custom options:

# Check specific files or directories
vendor/bin/phpcs path/to/your/files

# Check with specific standards
vendor/bin/phpcs --standard=WordPress path/to/your/files

# Generate a detailed report
vendor/bin/phpcs --report=full path/to/your/files

IDE Integration

The stubs will automatically be available to your IDE's intellisense and static analysis tools. Popular IDEs like PhpStorm, VS Code (with PHP extensions), and others will recognize WordPress, WooCommerce, and ACF functions without requiring the actual plugins to be installed.

Configuration

Default Configuration

The package includes a pre-configured phpcs.xml.dist file that:

  • Uses WordPress, WordPress-Extra, and WordPress-Docs coding standards
  • Sets minimum PHP version to 8.0+
  • Sets minimum WordPress version to 6.0+
  • Includes custom rules for WooCommerce and ACF functions
  • Excludes common directories (vendor, node_modules, tests, build, dist)
  • Allows modern PHP syntax (short arrays, short ternary operators)

Customizing for Your Project

To customize the configuration for your specific project:

  1. Copy phpcs.xml.dist to phpcs.xml
  2. Modify the rules as needed for your project
  3. Update the prefixes in the WordPress.NamingConventions.PrefixAllGlobals rule
  4. Adjust the text domain in the WordPress.WP.I18n rule

Example customization:

<!-- Update prefixes for your project -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
    <properties>
        <property name="prefixes" type="array">
            <element value="your_prefix"/>
            <element value="YourPrefix"/>
        </property>
    </properties>
</rule>

<!-- Update text domain -->
<rule ref="WordPress.WP.I18n">
    <properties>
        <property name="text_domain" type="array">
            <element value="your-text-domain"/>
        </property>
    </properties>
</rule>

Benefits

For Development

  • Improved IDE Support: Get full autocomplete and documentation for WordPress, WooCommerce, and ACF functions
  • Static Analysis: Catch errors before runtime without requiring WordPress installation
  • Code Quality: Enforce WordPress coding standards automatically
  • PHP Compatibility: Ensure your code works across different PHP versions

For CI/CD

Perfect for continuous integration pipelines:

# Example GitHub Actions workflow
- name: Install dependencies
  run: composer install --no-dev --optimize-autoloader

- name: Run PHPCS
  run: composer run phpcs

Supported Versions

  • PHP: 8.0+
  • WordPress: 6.0+
  • WooCommerce: 8.9+
  • ACF Pro: 6.0+

Contributing

If you find issues with the configuration or have suggestions for improvements, please open an issue or submit a pull request.

License

This package configuration is open source. Please refer to the individual stub packages for their respective licenses:

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-09-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固