承接 creode/wordpress-blocks-rector 相关项目开发

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

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

creode/wordpress-blocks-rector

最新稳定版本:1.3.1

Composer 安装命令:

composer require creode/wordpress-blocks-rector

包简介

Rector rules for Upgrades to the WordPress blocks package

README 文档

README

Rector rules for performing upgrades to the WordPress blocks package.

Installation

composer require --dev creode/wordpress-blocks-rector

Usage

Upgrade from 0.x to 1.x

To upgrade from 0.x to 1.x, run the following command, replacing {theme-name} with the name of your WordPress theme:

vendor/bin/rector process wp-content/themes/{theme-name} --config=vendor/creode/wordpress-blocks-rector/config/blocks-1-0.php

Block Plugin Documentation

Documentation for the block plugins can be found here.

Development

Using the DocBlockAttributeExtractor Trait

The DocBlockAttributeExtractor trait provides a convenient way to extract specific attributes from PHP docblock comments. This can be particularly useful when you need to parse metadata from comments in your code.

How to Use

  1. Include the Trait in Your Class:

    To use the DocBlockAttributeExtractor trait, include it in your class definition:

    use Creode\WordpressBlocksRector\Traits\DocBlockAttributeExtractor;
    
    class MyClass
    {
        use DocBlockAttributeExtractor;
    
        // Your class methods and properties
    }
  2. Extracting Attributes:

    Once the trait is included, you can use the extractDocBlockAttribute method to extract attributes from a docblock comment. This method requires two parameters:

    • $docComment: An instance of PhpParser\Comment\Doc representing the docblock comment.
    • $attributeKey: The key of the attribute you want to extract.

    Example usage:

     // Extract @wordpress-blocks-version from docblock if present
     $docComment = $node->getDocComment();
     $blocksVersion = $this->extractDocBlockAttribute($docComment, 'wordpress-blocks-version');
     if (!$blocksVersion) {
         return null;
     }
    
     // Run a version check to see if the block is compatible with the current version of the plugin.
     if (version_compare($blocksVersion, '1.3.0', '<')) {
         return null;
     }

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-17