Disable Comments: blocks registered only in JavaScript can't be inserted while the module is on
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, php, wordpress
Research direction
Read the allowed_block_types_all callback in obfx_modules/disable-comments/init.php (lines 159–194), then reproduce with the Playground link and the qa/js-only block registration from the issue. Check how the callback handles an incoming true value and PHP-registered blocks. Done when JavaScript-only blocks remain insertable with Disable Comments on while comment blocks stay unavailable.
Written by the indexing model from the issue text.
Description
Disable Comments: blocks registered only in JavaScript can't be inserted while the module is on
With Disable Comments on, the block editor no longer lets you insert any block that a plugin registers only in JavaScript (no PHP register_block_type()). Core blocks and PHP-registered blocks are unaffected. The comment blocks are removed as intended.
Seen on Orbit Fox 3.0.12 with WordPress 7.1.3 and 7.1.4.
Try it in Playground: WordPress latest (7.1.4), Neve, Orbit Fox with Disable Comments on; it opens a new post in the editor.
Checked through that link, with a test block registered from the console: canInsertBlockType('qa/js-only') is false, core/paragraph is true, core/comments is false (as intended). With the module off, the same test block is insertable.
Steps to reproduce
- Orbit Fox → General Settings: turn on Disable Comments.
- Open a new post in the block editor and open the browser console.
- Run:
(Or, without the console: use any plugin whose blocks are registered only in JavaScript, and search the inserter for one of them.)wp.blocks.registerBlockType('qa/js-only',{apiVersion:3,title:'QA JS only',category:'text',edit:()=>null,save:()=>null}); wp.data.select('core/block-editor').canInsertBlockType('qa/js-only') - Turn Disable Comments off, reload the editor and run the same lines.
Expected: true in both cases, and the block is in the inserter.
Actual: false while Disable Comments is on; true once it's off.
Cause
obfx_modules/disable-comments/init.php, the allowed_block_types_all callback (lines 159–194): when the incoming value is true ("all blocks allowed"), it replaces it with the list of blocks registered in PHP (WP_Block_Type_Registry::get_instance()->get_all_registered(), lines 179–182) minus the comment blocks. Blocks registered only in JavaScript aren't in that registry, so they drop out of the allowed list.
Possible fix
Leave true alone and remove the comment blocks on the client instead (for example wp.blocks.unregisterBlockType() for each disallowed block in an editor script, or wp.hooks' blocks.registerBlockType filter). Only filter when the incoming value is already an array. Not tried; a suggestion from the code.
Found while building Orbit Fox's compatibility checks (Codeinwp/qa-compatibility#100), where it is recorded as a known difference: the same on every WordPress version tested.
- Dominant language
- PHP
- Stars
- 13
- Forks
- 18
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 10
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Codeinwp/themeisle-companion
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Codeinwp/themeisle-companion#1014 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Codeinwp/themeisle-companion#1013 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Codeinwp/themeisle-companion#1009 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Codeinwp/themeisle-companion#1008 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 77/100
Codeinwp/themeisle-companion#1015 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Codeinwp/themeisle-companion
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
neos/flow-development-collection#3655 ·
Maintainers usually reply within 2 days
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
craftcms/cms#20596 · 1 comment ·
Maintainers usually reply within 1 day
-
Перевод устарел
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
Maintainers usually reply within 1 day