Repository navigation
Playground/blueprint preview #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3737b88
ci: setup blueprint for wp playground demo
firestar300 de030d7
docs: add README.md
firestar300 63247c9
docs: fix playground url
firestar300 db6e2b8
fix(blueprint): ref typo
firestar300 b714450
fix(bluprint): config
firestar300 1db3bba
fix(bluprint): config
firestar300 d253880
fix(blueprint): ship built assets for Playground installs
firestar300 8f5fbaa
fix(blueprint): use self-closing core/icon markup
firestar300 9e4e35e
fix(blueprint): use real core icon names in demo
firestar300 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| [](https://beapi.fr) | ||
|
|
||
| [](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/BeAPI/blockparty-button-icon/refs/heads/playground/blueprint-preview/.wordpress-org/blueprints/blueprint.json) | ||
|
|
||
| # Blockparty Button Icon | ||
|
|
||
| Extend the WordPress **core Button** block (`core/button`) with optional icons, placement controls, and spacing between icon and label. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Core block extension**: No new block name — editors keep using the familiar Button block | ||
| - **Optional icon**: Insert an icon as an inner block (defaults to `core/icon` on WordPress 7.0+) | ||
| - **Icon position**: Display the icon to the left or right of the label | ||
| - **Block gap**: Control horizontal spacing between icon and text via block spacing settings | ||
| - **Valid markup**: Icons render inside links with a `span` wrapper on the front end (phrasing content) | ||
| - **Extensible**: Filter which icon block types may be inserted into a button | ||
|
|
||
| ## Requirements | ||
|
|
||
| - WordPress 7.0 or higher | ||
| - PHP 8.1 or higher | ||
| - Gutenberg block editor | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Manual installation | ||
|
|
||
| 1. Download the plugin files | ||
| 2. Upload the `blockparty-button-icon` folder to `/wp-content/plugins/` | ||
| 3. Activate the plugin through the **Plugins** screen in WordPress | ||
|
|
||
| ### Composer installation | ||
|
|
||
| ```bash | ||
| composer require beapi/blockparty-button-icon | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Enable an icon on a button | ||
|
|
||
| 1. Add or select a **Button** block in the editor | ||
| 2. Open the block **Styles** panel (sidebar) | ||
| 3. Turn on **Show icon** | ||
| 4. Choose **Left** or **Right** for icon position | ||
| 5. Use the block toolbar **Icon** control to pick or replace the icon | ||
| 6. Adjust **Block spacing → Block gap** (horizontal) to change the space between icon and label | ||
|
|
||
| ### Allowed icon blocks | ||
|
|
||
| By default, only `core/icon` is allowed inside the button link. | ||
|
|
||
| Customize the list with the `blockparty_button_icon_allowed_icon_blocks` filter: | ||
|
|
||
| ```php | ||
| add_filter( | ||
| 'blockparty_button_icon_allowed_icon_blocks', | ||
| static function (): array { | ||
| return array( 'core/icon', 'blockparty/icon' ); | ||
| } | ||
| ); | ||
| ``` | ||
|
|
||
| The first block type in the filtered list is used when the editor creates a new icon inner block. | ||
|
|
||
| ## Accessibility | ||
|
|
||
| - Button label text is wrapped in `<span class="wp-block-button__label">` when an icon is present, keeping a clear text node for assistive technologies | ||
| - On the front end, `core/icon` outer wrappers are output as `span` elements when rendered inside button links | ||
|
|
||
| ## Generated markup example | ||
|
|
||
| ```html | ||
| <div class="wp-block-button blockparty-button-icon blockparty-button-icon--left"> | ||
| <a class="wp-block-button__link wp-element-button" href="#" style="gap:var(--wp--preset--spacing--20)"> | ||
| <span class="wp-block-icon" aria-hidden="true">…</span> | ||
| <span class="wp-block-button__label">Get started</span> | ||
| </a> | ||
| </div> | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Node.js 24.18+ and npm 11.16+ (see `package.json` `engines`) | ||
| - Composer 2.x | ||
|
|
||
| ### Build | ||
|
|
||
| ```bash | ||
| composer install | ||
| npm install | ||
| npm run build | ||
| ``` | ||
|
|
||
| ### Watch mode | ||
|
|
||
| ```bash | ||
| npm start | ||
| ``` | ||
|
|
||
| ### Linting | ||
|
|
||
| ```bash | ||
| composer cs | ||
| npm run lint:js src | ||
| npm run lint:css -- "src/**/*.scss" | ||
| ``` | ||
|
|
||
| ### WordPress Playground blueprint | ||
|
|
||
| The [Playground blueprint](.wordpress-org/blueprints/blueprint.json) installs the plugin from the `playground/blueprint-preview` branch, which includes built assets and Composer `vendor/` for demos. Update that branch after releases when you change the public demo. | ||
|
|
||
| ### Internationalization | ||
|
|
||
| ```bash | ||
| npm run make-pot | ||
| npm run make-json | ||
| ``` | ||
|
|
||
| ## Support | ||
|
|
||
| For bug reports and feature requests, use the [GitHub issues](https://github.com/BeAPI/blockparty-button-icon/issues) page. | ||
|
|
||
| ## Changelog | ||
|
|
||
| See [readme.txt](readme.txt) and [CHANGELOG.md](CHANGELOG.md) for version history. | ||
|
|
||
| Developed with ❤️ by [Be API](https://beapi.fr) | ||
|
|
||
| ## License | ||
|
|
||
| GPL-2.0-or-later |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php return array( | ||
| 'dependencies' => array( | ||
| 'react-jsx-runtime', | ||
| 'wp-block-editor', | ||
| 'wp-blocks', | ||
| 'wp-components', | ||
| 'wp-data', | ||
| 'wp-element', | ||
| 'wp-hooks', | ||
| 'wp-i18n', | ||
| 'wp-keycodes', | ||
| 'wp-primitives', | ||
| 'wp-url' | ||
| ), | ||
| 'version' => 'ff595fb21b7020ff3bb6' | ||
| ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.