diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b051fd..489ffd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,14 +42,14 @@ jobs: name: "Build project PHP" uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.1 - run: composer install --prefer-dist --no-dev -o --ignore-platform-reqs - id: setup-node name: "Setup Node.js" uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: 'package.json' cache: 'npm' - id: build-js diff --git a/.plugin-data b/.plugin-data index 783dffd..5f90b2a 100644 --- a/.plugin-data +++ b/.plugin-data @@ -1,4 +1,4 @@ { - "version": "1.0.2", + "version": "1.0.3", "slug": "blockparty-modal" } diff --git a/README.md b/README.md index 49a012f..0b52457 100644 --- a/README.md +++ b/README.md @@ -249,10 +249,13 @@ This plugin is distributed under the GPL-2.0-or-later license. See the [LICENSE] See [readme.txt](readme.txt) for the full version history. Recent highlights: +- **1.0.3** + - Fix: prevent adding linkedModalId attribute to non allowed blocks. + - Set min required PHP version to 8.1 + - **1.0.2** - Filter `blockparty_modal_trigger_allowed_blocks` to control which blocks can be modal triggers; dialog margin and InnerBlocks fixes. - Crawl Modal blocks from patterns - - Set min required PHP version to 8.0 - Style issues - **1.0.1** diff --git a/blockparty-modal.php b/blockparty-modal.php index b028c3b..f7bd456 100644 --- a/blockparty-modal.php +++ b/blockparty-modal.php @@ -2,9 +2,9 @@ /** * Plugin Name: Blockparty Modal * Description: Modal block for WordPress editor. - * Version: 1.0.2 + * Version: 1.0.3 * Requires at least: 6.8 - * Requires PHP: 8.0 + * Requires PHP: 8.1 * Author: Be API Technical Team * License: GPL-2.0-or-later * License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -19,7 +19,7 @@ exit; // Exit if accessed directly. } -define( 'BLOCKPARTY_MODAL_VERSION', '1.0.2' ); +define( 'BLOCKPARTY_MODAL_VERSION', '1.0.3' ); define( 'BLOCKPARTY_MODAL_URL', plugin_dir_url( __FILE__ ) ); define( 'BLOCKPARTY_MODAL_DIR', plugin_dir_path( __FILE__ ) ); diff --git a/composer.json b/composer.json index 33b1092..f9f9d24 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "phpro/grumphp-shim": true }, "platform": { - "php": "8.3.28" + "php": "8.1.31" } }, "require": { diff --git a/composer.lock b/composer.lock index 697401e..0acda2f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9a712678399b3657193b1525263cfd5d", + "content-hash": "92b88d47f2f14b96832bda5db8a372b4", "packages": [ { "name": "composer/installers", @@ -2973,12 +2973,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "1476a499c47192447981cb2a9b63f87eca5abc83" + "reference": "9746179cca33c473a76c87aba60ed34fb3b633a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1476a499c47192447981cb2a9b63f87eca5abc83", - "reference": "1476a499c47192447981cb2a9b63f87eca5abc83", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9746179cca33c473a76c87aba60ed34fb3b633a7", + "reference": "9746179cca33c473a76c87aba60ed34fb3b633a7", "shasum": "" }, "conflict": { @@ -3410,7 +3410,7 @@ "leantime/leantime": "<3.3", "lexik/jwt-authentication-bundle": "<2.10.7|>=2.11,<2.11.3", "libreform/libreform": ">=2,<=2.0.8", - "librenms/librenms": "<25.12", + "librenms/librenms": "<26.2", "liftkit/database": "<2.13.2", "lightsaml/lightsaml": "<1.3.5", "limesurvey/limesurvey": "<6.5.12", @@ -3990,7 +3990,7 @@ "type": "tidelift" } ], - "time": "2026-02-18T01:37:03+00:00" + "time": "2026-02-18T22:11:51+00:00" }, { "name": "roots/wordpress-no-content", @@ -4065,29 +4065,29 @@ }, { "name": "sebastian/diff", - "version": "7.0.0", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7ab1ea946c012266ca32390913653d844ecd085f" + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7ab1ea946c012266ca32390913653d844ecd085f", - "reference": "7ab1ea946c012266ca32390913653d844ecd085f", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", "shasum": "" }, "require": { - "php": ">=8.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^12.0", - "symfony/process": "^7.2" + "phpunit/phpunit": "^10.0", + "symfony/process": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "7.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -4120,7 +4120,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/7.0.0" + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" }, "funding": [ { @@ -4128,7 +4128,7 @@ "type": "github" } ], - "time": "2025-02-07T04:55:46+00:00" + "time": "2024-03-02T07:15:17+00:00" }, { "name": "spatie/array-to-xml", @@ -4279,47 +4279,47 @@ }, { "name": "symfony/console", - "version": "v7.4.4", + "version": "v6.4.32", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "41e38717ac1dd7a46b6bda7d6a82af2d98a78894" + "reference": "0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/41e38717ac1dd7a46b6bda7d6a82af2d98a78894", - "reference": "41e38717ac1dd7a46b6bda7d6a82af2d98a78894", + "url": "https://api.github.com/repos/symfony/console/zipball/0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3", + "reference": "0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3", "shasum": "" }, "require": { - "php": ">=8.2", + "php": ">=8.1", "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^7.2|^8.0" + "symfony/string": "^5.4|^6.0|^7.0" }, "conflict": { - "symfony/dependency-injection": "<6.4", - "symfony/dotenv": "<6.4", - "symfony/event-dispatcher": "<6.4", - "symfony/lock": "<6.4", - "symfony/process": "<6.4" + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" }, "provide": { "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^6.4|^7.0|^8.0", - "symfony/dependency-injection": "^6.4|^7.0|^8.0", - "symfony/event-dispatcher": "^6.4|^7.0|^8.0", - "symfony/http-foundation": "^6.4|^7.0|^8.0", - "symfony/http-kernel": "^6.4|^7.0|^8.0", - "symfony/lock": "^6.4|^7.0|^8.0", - "symfony/messenger": "^6.4|^7.0|^8.0", - "symfony/process": "^6.4|^7.0|^8.0", - "symfony/stopwatch": "^6.4|^7.0|^8.0", - "symfony/var-dumper": "^6.4|^7.0|^8.0" + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -4353,7 +4353,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.4.4" + "source": "https://github.com/symfony/console/tree/v6.4.32" }, "funding": [ { @@ -4373,7 +4373,7 @@ "type": "tidelift" } ], - "time": "2026-01-13T11:36:38+00:00" + "time": "2026-01-13T08:45:59+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4444,25 +4444,25 @@ }, { "name": "symfony/filesystem", - "version": "v7.4.0", + "version": "v6.4.30", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "d551b38811096d0be9c4691d406991b47c0c630a" + "reference": "441c6b69f7222aadae7cbf5df588496d5ee37789" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a", - "reference": "d551b38811096d0be9c4691d406991b47c0c630a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/441c6b69f7222aadae7cbf5df588496d5ee37789", + "reference": "441c6b69f7222aadae7cbf5df588496d5ee37789", "shasum": "" }, "require": { - "php": ">=8.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.8" }, "require-dev": { - "symfony/process": "^6.4|^7.0|^8.0" + "symfony/process": "^5.4|^6.4|^7.0" }, "type": "library", "autoload": { @@ -4490,7 +4490,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.4.0" + "source": "https://github.com/symfony/filesystem/tree/v6.4.30" }, "funding": [ { @@ -4510,27 +4510,27 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2025-11-26T14:43:45+00:00" }, { "name": "symfony/finder", - "version": "v7.4.5", + "version": "v6.4.33", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ad4daa7c38668dcb031e63bc99ea9bd42196a2cb" + "reference": "24965ca011dac87431729640feef8bcf7b5523e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ad4daa7c38668dcb031e63bc99ea9bd42196a2cb", - "reference": "ad4daa7c38668dcb031e63bc99ea9bd42196a2cb", + "url": "https://api.github.com/repos/symfony/finder/zipball/24965ca011dac87431729640feef8bcf7b5523e0", + "reference": "24965ca011dac87431729640feef8bcf7b5523e0", "shasum": "" }, "require": { - "php": ">=8.2" + "php": ">=8.1" }, "require-dev": { - "symfony/filesystem": "^6.4|^7.0|^8.0" + "symfony/filesystem": "^6.0|^7.0" }, "type": "library", "autoload": { @@ -4558,7 +4558,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.4.5" + "source": "https://github.com/symfony/finder/tree/v6.4.33" }, "funding": [ { @@ -4578,7 +4578,7 @@ "type": "tidelift" } ], - "time": "2026-01-26T15:07:59+00:00" + "time": "2026-01-26T13:03:48+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5084,23 +5084,22 @@ }, { "name": "symfony/string", - "version": "v7.4.4", + "version": "v6.4.30", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "1c4b10461bf2ec27537b5f36105337262f5f5d6f" + "reference": "50590a057841fa6bf69d12eceffce3465b9e32cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/1c4b10461bf2ec27537b5f36105337262f5f5d6f", - "reference": "1c4b10461bf2ec27537b5f36105337262f5f5d6f", + "url": "https://api.github.com/repos/symfony/string/zipball/50590a057841fa6bf69d12eceffce3465b9e32cb", + "reference": "50590a057841fa6bf69d12eceffce3465b9e32cb", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3.0", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.33", + "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", "symfony/polyfill-mbstring": "~1.0" }, @@ -5108,11 +5107,10 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/emoji": "^7.1|^8.0", - "symfony/http-client": "^6.4|^7.0|^8.0", - "symfony/intl": "^6.4|^7.0|^8.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^6.4|^7.0|^8.0" + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5151,7 +5149,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.4.4" + "source": "https://github.com/symfony/string/tree/v6.4.30" }, "funding": [ { @@ -5171,7 +5169,7 @@ "type": "tidelift" } ], - "time": "2026-01-12T10:54:30+00:00" + "time": "2025-11-21T18:03:05+00:00" }, { "name": "vimeo/psalm", @@ -5293,23 +5291,23 @@ }, { "name": "webmozart/assert", - "version": "2.1.4", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "b39f1870fc7c3e9e4a26106df5053354b9260a33" + "reference": "9be6926d8b485f55b9229203f962b51ed377ba68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/b39f1870fc7c3e9e4a26106df5053354b9260a33", - "reference": "b39f1870fc7c3e9e4a26106df5053354b9260a33", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68", + "reference": "9be6926d8b485f55b9229203f962b51ed377ba68", "shasum": "" }, "require": { "ext-ctype": "*", "ext-date": "*", "ext-filter": "*", - "php": "^8.2" + "php": "^7.2 || ^8.0" }, "suggest": { "ext-intl": "", @@ -5319,7 +5317,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-feature/2-0": "2.0-dev" + "dev-master": "1.10-dev" } }, "autoload": { @@ -5335,10 +5333,6 @@ { "name": "Bernhard Schussek", "email": "bschussek@gmail.com" - }, - { - "name": "Woody Gilk", - "email": "woody.gilk@gmail.com" } ], "description": "Assertions to validate method input/output with nice error messages.", @@ -5349,9 +5343,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/2.1.4" + "source": "https://github.com/webmozarts/assert/tree/1.12.1" }, - "time": "2026-02-17T12:17:51+00:00" + "time": "2025-10-29T15:56:20+00:00" }, { "name": "wp-cli/mustache", @@ -5750,7 +5744,7 @@ }, "platform-dev": {}, "platform-overrides": { - "php": "8.3.28" + "php": "8.1.31" }, "plugin-api-version": "2.6.0" } diff --git a/package.json b/package.json index 0da2287..e306a11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockparty-modal", - "version": "1.0.2", + "version": "1.0.3", "description": "Add a modal block to the WordPress editor.", "author": "Be API", "license": "GPL-2.0-or-later", @@ -34,5 +34,8 @@ "devDependencies": { "@wordpress/env": "latest", "@wordpress/scripts": "^31.4.0" + }, + "volta": { + "node": "22.22.0" } } diff --git a/readme.txt b/readme.txt index 1a7766d..c885cca 100644 --- a/readme.txt +++ b/readme.txt @@ -45,10 +45,13 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove == Changelog == += 1.0.3 = +* Fix: prevent adding linkedModalId attribute to non allowed blocks. +* Set min required PHP version to 8.1 + = 1.0.2 = * Filter `blockparty_modal_trigger_allowed_blocks` to control which blocks can be modal triggers; dialog margin and InnerBlocks fixes. * Crawl Modal blocks from patterns -* Set min required PHP version to 8.0 * Style issues = 1.0.1 = diff --git a/src/blockparty-modal/block.json b/src/blockparty-modal/block.json index 9ce4cad..42e0aaa 100644 --- a/src/blockparty-modal/block.json +++ b/src/blockparty-modal/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "blockparty/modal", - "version": "1.0.2", + "version": "1.0.3", "title": "Modal", "category": "widgets", "description": "Insert a modal dialog that opens on trigger. Configure content and behaviour in the editor; the modal is displayed on the frontend when activated.", diff --git a/src/blockparty-modal/index.js b/src/blockparty-modal/index.js index f0040b3..d17d1a6 100644 --- a/src/blockparty-modal/index.js +++ b/src/blockparty-modal/index.js @@ -1,11 +1,11 @@ /** - * Registers the modal block and adds "Open modal on click" to all blocks. + * Registers the modal block and adds "Open modal on click" to blocks allowed as triggers. * * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/ */ import { registerBlockType, getBlockTypes } from '@wordpress/blocks'; import { addFilter } from '@wordpress/hooks'; -import { useSelect } from '@wordpress/data'; +import { useSelect, select } from '@wordpress/data'; import { InspectorControls } from '@wordpress/block-editor'; import { PanelBody, ComboboxControl } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; @@ -33,18 +33,44 @@ registerBlockType( metadata.name, { save, } ); -// Add linkedModalId attribute to all block types (so any block can be a trigger). +/** + * Returns the list of block names allowed as modal triggers (same as filter blockparty_modal_trigger_allowed_blocks). + * Used so we only add linkedModalId to those blocks. + * + * @return {string[]} Allowed block names. + */ +function getModalTriggerAllowedBlocks() { + try { + const settings = select( 'core/block-editor' ).getSettings(); + const list = settings?.blockpartyModalTriggerAllowedBlocks; + return Array.isArray( list ) ? list : [ 'core/button' ]; + } catch { + return [ 'core/button' ]; + } +} + +// Add linkedModalId attribute only to blocks allowed as modal triggers. addFilter( 'blocks.registerBlockType', 'blockparty-modal/add-linked-modal-attribute', - addLinkedModalAttribute + ( settings, blockName ) => { + const allowedBlocks = getModalTriggerAllowedBlocks(); + if ( ! allowedBlocks.includes( blockName ) ) { + return settings; + } + return addLinkedModalAttribute( settings ); + } ); // Blocks registered before our script loaded (e.g. core blocks) didn't get the -// filter — re-register them so linkedModalId is persisted on save. +// filter — re-register only allowed blocks so linkedModalId is persisted on save. +const allowedBlocks = getModalTriggerAllowedBlocks(); const blockTypes = getBlockTypes(); blockTypes.forEach( ( blockType ) => { - if ( ! blockType.attributes?.[ LINKED_MODAL_ATTR ] ) { + if ( + allowedBlocks.includes( blockType.name ) && + ! blockType.attributes?.[ LINKED_MODAL_ATTR ] + ) { registerBlockType( blockType.name, addLinkedModalAttribute( blockType ) @@ -63,18 +89,18 @@ addFilter( return ; } - const allowedBlocks = useSelect( ( select ) => { - const settings = select( 'core/block-editor' ).getSettings(); + const triggerAllowedBlocks = useSelect( ( storeSelect ) => { + const settings = storeSelect( 'core/block-editor' ).getSettings(); const list = settings?.blockpartyModalTriggerAllowedBlocks; return Array.isArray( list ) ? list : [ 'core/button' ]; }, [] ); - if ( ! allowedBlocks.includes( name ) ) { + if ( ! triggerAllowedBlocks.includes( name ) ) { return ; } - const modalOptions = useSelect( ( select ) => { - return getModalOptionsFromEditor( select ); + const modalOptions = useSelect( ( storeSelect ) => { + return getModalOptionsFromEditor( storeSelect ); }, [] ); const options = [