PHPackages                             offset/blocks - 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. offset/blocks

ActivePackage[Utility &amp; Helpers](/categories/utility)

offset/blocks
=============

Create Gutenberg blocks more easily

1.0.1(4y ago)09MITPHPPHP &gt;=7.0

Since Dec 30Pushed 4y agoCompare

[ Source](https://github.com/offsetwp/blocks)[ Packagist](https://packagist.org/packages/offset/blocks)[ Docs](https://github.com/offsetwp/blocks)[ RSS](/packages/offset-blocks/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Blocks - Create Gutenberg blocks more easily
============================================

[](#blocks---create-gutenberg-blocks-more-easily)

Installation
------------

[](#installation)

```
composer require offset/blocks
```

Use
---

[](#use)

```
use Offset\Block;

// Create an empty block
$block = new Block();

// Pass the "block.json" file of your Gutenberg block
$block->setSettingsFromJSONPath(__DIR__ . '/block.json');

// Add the file that will be used for the dynamic rendering of your block. You have access to `$attributes` and `$content`.
$block->setRender(__DIR__ . '/template/view.php');

// Save your block in Gutenberg and load the styles and scripts
$block->init();
```

You can also render the content with a function

```
// Add the file that will be used for the dynamic rendering of your block. You have access to `$attributes` and `$content`.
$block->setRender(function($attributes, $content) {
    return 'My block';
});
```

### Filters and overrides

[](#filters-and-overrides)

Filters are automatically added to your blocks to give you greater flexibility in development and customization.

#### `offset_block_attributes`

[](#offset_block_attributes)

Filter all attributes of all Gutenberg blocks.

##### Parameters

[](#parameters)

- `$attributes` - `array` - Block attributes. Default empty array

##### Example

[](#example)

```
function attributes_filter($attributes) {
    $attributes['myValue'] = 'Changed';
    return $attributes;
}

add_filter('offset_block_attributes', 'attributes_filter', 10, 1);
```

#### `offset_block_attributes_{block_name}`

[](#offset_block_attributes_block_name)

Filter the attributes of Gutenberg blocks that have the same name.

The `block_name` corresponds to the `name` parameter in the `block.json` file, replacing special characters with `_` (example: `offset-pack/block-one` -&gt; `offset_pack_block_one`).

##### Parameters

[](#parameters-1)

- `$attributes` - `array` - Block attributes. Default empty array

##### Example

[](#example-1)

```
function attributes_filter($attributes) {
    $attributes['myValue'] = 'Changed';
    return $attributes;
}

add_filter('offset_block_attributes_offset_pack_block_one', 'attributes_filter', 10, 1);
```

#### `offset_block_content`

[](#offset_block_content)

Filters all contents of all Gutenberg blocks.

##### Parameters

[](#parameters-2)

- `$content` - `string` - Block content. Default empty string.

##### Example

[](#example-2)

```
function content_filter($content) {
    $content .= 'Add new line';
    return $content;
}

add_filter('offset_block_content', 'content_filter', 10, 1);
```

#### `offset_block_content_{block_name}`

[](#offset_block_content_block_name)

Filter the content of Gutenberg blocks that have the same name.

The `block_name` corresponds to the `name` parameter in the `block.json` file, replacing special characters with `_` (example: `offset-pack/block-one` -&gt; `offset_pack_block_one`).

##### Parameters

[](#parameters-3)

- `$content` - `string` - Block content. Default empty string.

##### Example

[](#example-3)

```
function content_filter($content) {
    $content .= 'Add new line';
    return $content;
}

add_filter('offset_block_content_offset_pack_block_one', 'content_filter', 10, 1);
```

#### `offset_block_render_{block_name}`

[](#offset_block_render_block_name)

Filter the html of Gutenberg blocks that have the same name.

The `block_name` corresponds to the `name` parameter in the `block.json` file, replacing special characters with `_` (example: `offset-pack/block-one` -&gt; `offset_pack_block_one`).

##### Parameters

[](#parameters-4)

- `$html` - `string` - Block html. Default empty string
- `$attributes` - `array` - Block attributes. Default empty array
- `$content` - `string` - Block content. Default empty string.

##### Example

[](#example-4)

```
function render_filter($html, $attributes, $content) {
    $html .= 'Add new block';
    return $html;
}

add_filter('offset_block_render_offset_pack_block_one', 'render_filter', 10, 3);
```

#### `offset_block_is_style_enqueue`

[](#offset_block_is_style_enqueue)

Remove styles from all Gutenberg blocks.

#### Example

[](#example-5)

```
add_filter('offset_block_is_style_enqueue', '__return_false');
```

#### `offset_block_is_style_enqueue_{block_name}`

[](#offset_block_is_style_enqueue_block_name)

Remove styles from Gutenberg blocks with the same name.

The `block_name` corresponds to the `name` parameter in the `block.json` file, replacing special characters with `_` (example: `offset-pack/block-one` -&gt; `offset_pack_block_one`).

#### Example

[](#example-6)

```
add_filter('offset_block_is_style_enqueue_offset_pack_block_one', '__return_false');
```

#### `offset_block_is_script_enqueue`

[](#offset_block_is_script_enqueue)

Remove scripts from all Gutenberg blocks.

#### Example

[](#example-7)

```
add_filter('offset_block_is_script_enqueue', '__return_false');
```

#### `offset_block_is_script_enqueue_{block_name}`

[](#offset_block_is_script_enqueue_block_name)

Remove scripts from Gutenberg blocks with the same name.

The `block_name` corresponds to the `name` parameter in the `block.json` file, replacing special characters with `_` (example: `offset-pack/block-one` -&gt; `offset_pack_block_one`).

#### Example

[](#example-8)

```
add_filter('offset_block_is_script_enqueue_offset_pack_block_one', '__return_false');
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

1600d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f92310287db168bd8da8a7b15d26e9e0849a6c7ab9a30d7fc32497d7e5f4bab8?d=identicon)[w-jerome](/maintainers/w-jerome)

---

Top Contributors

[![w-jerome](https://avatars.githubusercontent.com/u/1685550?v=4)](https://github.com/w-jerome "w-jerome (1 commits)")

---

Tags

wordpressblockgutenbergoffset

### Embed Badge

![Health badge](/badges/offset-blocks/health.svg)

```
[![Health](https://phpackages.com/badges/offset-blocks/health.svg)](https://phpackages.com/packages/offset-blocks)
```

###  Alternatives

[log1x/poet

Configuration-based post type, taxonomy, editor color palette, block category, and block registration for Sage 10.

218280.1k1](/packages/log1x-poet)[log1x/acf-editor-palette

A replica Gutenberg color picker field for Advanced Custom Fields.

100284.1k](/packages/log1x-acf-editor-palette)[infinum/eightshift-libs

WordPress libs developed by Eightshift team to use in modern WordPress.

63118.9k3](/packages/infinum-eightshift-libs)[generoi/wp-gutenberg-button-popup

A boilerplate WordPress Gutenberg block

181.5k](/packages/generoi-wp-gutenberg-button-popup)[tiny-pixel/acorn-block-templates

Block templates for Sage 10

191.2k](/packages/tiny-pixel-acorn-block-templates)

PHPackages © 2026

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