Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .plugin-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.0.8",
"version": "1.1.0",
"slug": "blockparty-icons"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This plugin **doesn't run any sanitization on SVGs** before using them. Only use

## Changelog

### 1.1.0 - 2026-08-14

- Add WP-CLI command to convert `beapi/icon-block` / `beapi/icon-item` old contents to `blockparty/icon`

### 1.0.8 - 2026-06-26

- Fix icon padding values missing CSS units in the editor
Expand Down
126 changes: 126 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Migrating from `beapi/icon-block` to `blockparty-icons`

This document describes how to move from the abandoned [`beapi/icon-block`](https://github.com/BeAPI/beapi-icon-block) package to `beapi/blockparty-icons`.

## Package swap

```bash
composer remove beapi/icon-block
composer require beapi/blockparty-icons
```

Activate `blockparty-icons` and deactivate `icon-block`.

## Theme API changes

| `beapi/icon-block` | `blockparty-icons` |
|---|---|
| Namespace `Beapi\IconBlock\` | Namespace `Blockparty\Icons\` |
| Constant `BEAPI_ICON_DIR` | Constant `BLOCKPARTY_ICONS_DIR` |
| Action `icon_block_init` | Action `blockparty_icons_init` |
| `register_icon_collection()` | Same helper name under the new namespace |

Example:

```php
use Blockparty\Icons\Icon\Collection;
use function Blockparty\Icons\register_icon_collection;

add_action(
'blockparty_icons_init',
static function () {
register_icon_collection(
'my_collection',
[
'label' => 'My custom icons collection',
'type' => 'sprite',
'source' => get_stylesheet_directory() . '/dist/icons/sprite.svg',
]
);
}
);
```

You can also pass a `Collection` instance built with `Collection::from_sprite()` / `Collection::from_folder()`.

## Block model changes

| Old | New |
|---|---|
| Parent `beapi/icon-block` + child `beapi/icon-item` | Single dynamic block `blockparty/icon` |
| Saved markup `ul` / `li` (v3) or `div.icon-container` (legacy) | Server-rendered `div.wp-block-blockparty-icon` |
| Allowlist / block styles on `beapi/icon-block` | Register against `blockparty/icon` |
| CSS `.wp-block-beapi-icon-block` | CSS `.wp-block-blockparty-icon` |

### Attribute mapping

| Old (`icon-item` / legacy parent) | New (`blockparty/icon`) |
|---|---|
| `icon` (`name`, `type`, `label`, optional `collection`) | `icon` (requires `collection` + `name`) |
| Parent `collection.name` (legacy object) | `icon.collection` |
| `iconColorValue` / legacy `iconColor.color` | `iconColor` (value kept as-is, including `inherit`) |
| `size` (int) | `size` (int) |
| `borderRadius` (int) | `borderRadius` (string, e.g. `0px`) |
| `url`, `label`, `className` | same |
| Custom attrs (e.g. `sharedBlockId`) | preserved |

Empty parent shells (no icon selected) become an empty `blockparty/icon` with preserved `className` / custom attrs.

Multiple `beapi/icon-item` children become sibling `blockparty/icon` blocks.

## Content migration (WP-CLI)

After activating `blockparty-icons` and updating theme collections:

```bash
# Preview (current site)
wp blockparty-icons migrate-from-icon-block --dry-run

# Apply on the current site
wp blockparty-icons migrate-from-icon-block

# Limit post types
wp blockparty-icons migrate-from-icon-block --post-type=post,page
```

The command always targets **one site only**. On multisite, repeat it yourself with `--url=` for each site:

```bash
wp blockparty-icons migrate-from-icon-block --url=https://example.com/
wp blockparty-icons migrate-from-icon-block --url=https://example.com/site-2/
```

The command:

1. Scans `post_content` for `beapi/icon-block` / `beapi/icon-item`
2. Parses blocks, converts markup recursively, serializes back (attrs only — no asset resolution that aborts conversion)
3. Updates the post with `wp_slash()` on content (required so `\u002d` escapes for `--` in block comments are not stripped by `wp_update_post()`)
4. Logs migrated / skipped counts
5. Lists missing icon assets (`collection/name`) so you can add them manually to theme assets / collections

When `collection` is missing on the icon object (and not on the parent attrs), the block is skipped — there is no default collection. Missing files among converted icons are reported, not skipped.

### Revisions

Only the scanned post types are migrated (public REST post types + `wp_block` by default). **Revisions are not included**, so parent posts are updated while historical revisions can still contain the old `beapi/icon-block` / `beapi/icon-item` markup. That is expected. To migrate revisions as well, pass them explicitly, for example:

```bash
wp blockparty-icons migrate-from-icon-block --post-type=revision
```

### Duplicate Post (Yoast)

If [Yoast Duplicate Post](https://wordpress.org/plugins/duplicate-post/) is active, updating a Rewrite & Republish **copy** via `wp_update_post()` (especially without `--user=`) can call `wp_die( 'You are not allowed to republish this post.' )` and abort the whole WP-CLI run.

Preferred workaround: skip that plugin for the migration only (global WP-CLI flag):

```bash
wp --skip-plugins=duplicate-post blockparty-icons migrate-from-icon-block --url=https://example.com/
```

## Front-end checklist

- Re-register custom block styles (e.g. `is-style-inline`) on `blockparty/icon`
- Update theme SCSS selectors from `.wp-block-beapi-icon-block` to `.wp-block-blockparty-icon`
- Update block patterns / allowlists
- Smoke-test sprite vs raw icons, colors, sizes, and shared blocks
9 changes: 7 additions & 2 deletions blockparty-icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Provides blocks in WordPress editor to add custom SVG icons.
* Requires at least: 6.2
* Requires PHP: 8.1
* Version: 1.0.8
* Version: 1.1.0
* Author: Be API Technical Team
* Author URI: https://beapi.fr
* License: GPL-2.0-or-later
Expand All @@ -15,6 +15,7 @@

namespace Blockparty\Icons;

use Blockparty\Icons\Cli\MigrateFromIconBlockCommand;
use Blockparty\Icons\Icon\Collection;
use Blockparty\Icons\Icon\CollectionCreationException;
use Blockparty\Icons\Icon\CollectionItemsFactory;
Expand All @@ -29,7 +30,7 @@
include_once __DIR__ . '/vendor/autoload.php';
}

define( 'BLOCKPARTY_ICONS_VERSION', '1.0.8' );
define( 'BLOCKPARTY_ICONS_VERSION', '1.1.0' );
define( 'BLOCKPARTY_ICONS_URL', plugin_dir_url( __FILE__ ) );
define( 'BLOCKPARTY_ICONS_DIR', plugin_dir_path( __FILE__ ) );
define( 'BLOCKPARTY_ICONS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
Expand Down Expand Up @@ -333,3 +334,7 @@ function allow_css_attributes( $attr ) {
}

add_filter( 'safe_style_css', __NAMESPACE__ . '\\allow_css_attributes' );

if ( defined( 'WP_CLI' ) && WP_CLI ) {
\WP_CLI::add_command( 'blockparty-icons migrate-from-icon-block', MigrateFromIconBlockCommand::class );
}
Loading
Loading