定制 recoded-dev/wordpress-block-parser 二次开发

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

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

recoded-dev/wordpress-block-parser

最新稳定版本:v0.1.0

Composer 安装命令:

composer require recoded-dev/wordpress-block-parser

包简介

Parse WordPress edit context content to PHP objects

README 文档

README

Parse WordPress edit-context content to PHP objects easily.

Installation

composer require recoded-dev/wordpress-block-parser

Examples

Parsing and replacing

<?php

use Recoded\WordPressBlockParser\BlockParser;
use Recoded\WordPressBlockParser\Blocks\Block;
use Recoded\WordPressBlockParser\BlockReplacer;

$content = <<<HTML
<!-- wp:paragraph -->
Test
<!-- /wp:paragraph -->
HTML;

$parser = BlockParser::create($content);
$replacer = BlockReplacer::create($content);

foreach ($parser as $block) {
    // $block->namespace
    // $block->name
    // $block->attributes

    if ($block instanceof Block) {
        // $block->content
    }

    $replacer->replace($block, 'Your replaced content');
}

echo (string) $replacer; // Your replaced content

Contributing

Everyone is welcome to contribute. Feel free to PR your work once you think it's ready. Or open a draft-PR if you want to get some opinions or further help.

I would like to keep this package relatively small and want to avoid bloat. The package should remain extensible and unopinionated.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-11