PHPackages                             ergosarapu/wp-htmlblocks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ergosarapu/wp-htmlblocks

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

ergosarapu/wp-htmlblocks
========================

WP HtmlBlocks plugin

v1.0.4(9mo ago)01.2kGPL-2.0-onlyPHPPHP &gt;=7.4CI passing

Since Feb 9Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/ergosarapu/wp-htmlblocks)[ Packagist](https://packagist.org/packages/ergosarapu/wp-htmlblocks)[ RSS](/packages/ergosarapu-wp-htmlblocks/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (12)Versions (6)Used By (0)

[![Actions Status](https://github.com/ergosarapu/wp-htmlblocks/workflows/build/badge.svg)](https://github.com/ergosarapu/wp-htmlblocks/actions)[![License: GPL v2](https://camo.githubusercontent.com/77e900ae34f8da9ccccc42662fce61a94ab07ddbfe3f7d066178e824f3673dbd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c25323076322d626c75652e737667)](LICENSE)

WP HtmlBlocks plugin
====================

[](#wp-htmlblocks-plugin)

Capture sections of HTML document into Wordpress Blocks so that HTML template can be filled with Wordpress content. Well-suited for composing HTML template based newsletters quickly and regularly.

Install using Composer
======================

[](#install-using-composer)

The plugin uses [Carbon Fields](https://github.com/htmlburger/carbon-fields) composer dependency. Carbon Fields library contains JS/CSS assets, which are requested by wp-admin but not found due to the default vendor directory not being a web directory.

A workaround is to install Carbon Fields library to web directory by changing installer-paths for "htmlburger/carbon-fields", change your composer.json accordingly:

```
"extra": {
    "installer-paths": {
        "YOUR_DESIRED_LOCATION/vendor/{$vendor}/{$name}/": ["htmlburger/carbon-fields"]
    }
}
```

Then require WP HtmlBlocks plugin using Composer:

```
composer require "ergosarapu/wp-htmlblocks"
```

Configuration
=============

[](#configuration)

Configuration is currently loaded when environment variable `HTMLBLOCKS_CONFIG` is set to a valid YAML configuration file. For multiple configurations separate paths using [PATH\_SEPARATOR](https://www.php.net/manual/en/dir.constants.php), e.g.

- `/path/to/config1.yml;/path/to/config2.yml` on Windows;
- `/path/to/config1.yml:/path/to/config2.yml` otherwise;

Configuration errors are logged to `error_log`, in case blocks do not appear in WP post editor, seek culprit from logs.

Example
=======

[](#example)

HTML:

```

    Greeting

            Post on left
            Post on right

```

YAML configuration:

```
block: # Define block
  html: example.html # Path to html template file
  name: Newsletter # Block name
  description: Newsletter block # Block description
  xpath: //html # Select whole HTML to render this Block
  icon: email # Block icon as WP Dashicon
  category: # Set category this Block appears under
    slug: newsletter
    title: Newsletter
    icon: email
  fields: # Create Fields for Block
    - field:
        type: text # Field type 'text' (can be any of Carbon Fields supported field types)
        name: greeting
        label: Enter Your greeting here
        replaces: # Define how Field values replaces sections in HTML
          - replace:
              xpath: //h1/text() # XPath of section to replace in HTML
              value_path: greeting # Path to field value using dot notation
  blocks: # Define unlimited nested blocks
    - block:
        name: Two Posts
        description: Two Posts block
        xpath: //tr
        icon: block-default
        category:
          slug: newsletter
          title: Newsletter
          icon: email
        fields:
          - field:
              type: association
              name: posts
              label: Select Post or Page
              functions: # Configure Field using config methods supported by Carbon Fields
                - name: set_types
                  args:
                    - - type: post
                        post_type: post
                      - type: post
                        post_type: page
                - name: set_min
                  args:
                    - 2
                - name: set_max
                  args:
                    - 2
              replaces:
                - replace:
                    xpath: //td[@id="post_left"]/text()
                    function:
                      name: get_the_title
                      args:
                        - arg:
                            value_path: posts.0.id
                - replace:
                    xpath: //td[@id="post_right"]/text()
                    function: # Call arbitrary functions to render desired replacement result
                      name: strtoupper
                      args:
                        - arg:
                            function: # Pass another arbitrary function as an argument
                              name: get_the_title
                              args:
                                - arg:
                                    value_path: posts.1.id
```

Result blocks in WP admin:

[![WP Admin](examples/example-admin.png)](examples/example-admin.png)

Rendered HTML result:

```

    Hello World!

            Privacy Policy
            SAMPLE PAGE

```

**Note!** The final end-result depends on the template used to render the post. You may want to render output within plain template, for that you can use a specific plugin to set blank template for the post or modify your theme to support blank template.

Tasks
=====

[](#tasks)

- `composer build` - build by running tests and code checks
- `composer test` - run tests
- `composer phpcs` - run PHP CodeSniffer
- `composer phpmd` - run PHP Mess Detector

License
=======

[](#license)

Licensed under GPLv2

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance55

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~419 days

Total

5

Last Release

296d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1115717?v=4)[ergosarapu](/maintainers/ergosarapu)[@ergosarapu](https://github.com/ergosarapu)

---

Top Contributors

[![ergosarapu](https://avatars.githubusercontent.com/u/1115717?v=4)](https://github.com/ergosarapu "ergosarapu (19 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ergosarapu-wp-htmlblocks/health.svg)

```
[![Health](https://phpackages.com/badges/ergosarapu-wp-htmlblocks/health.svg)](https://phpackages.com/packages/ergosarapu-wp-htmlblocks)
```

###  Alternatives

[roots/bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

6.5k463.8k2](/packages/roots-bedrock)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[october/rain

October Rain Library

1601.7M83](/packages/october-rain)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318123.0k1](/packages/cognesy-instructor-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
