Miguel Fonseca
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: 6.9 breaks block image backgrounds with single quoteHey, @lunaman. Although in this case the issue is visible only when the plugin is active, it could still hint at a problem in WP 6.9. And indeed I believe it could be this recently reported bug at play. If so, it has been fixed in trunk and is expected in the 6.9.1 release soon (but no dates available yet).
Forum: Fixing WordPress
In reply to: Deleting images from media libraryIf you have access to WP-CLI in an interactive shell (terminal), you can batch-delete attachments as follows:
- List all attachments. Since we are dealing with a lot of images, you may want to set a higher “posts per page” parameter, but be careful not to overwhelm the server with too high a number. In the example below, I’ll use
1000. - Filter the list to keep only those whose date matches
2025-09-. - Gather the IDs and delete the attachments in batches of 100.
First, before deleting, make sure that the matches are sound:
wp post list --post_type=attachment --posts_per_page=500 --fields=ID,post_date,post_title --format=csv | awk -F, '$2 ~ /2025-09-/'Then, if you are confident, proceed with the deletion. This is irreversible, so be careful!
# CAREFUL! DANGER ZONE
wp post list --post_type=attachment --posts_per_page=500 --fields=ID,post_date --format=csv | awk -F, '$2 ~ /2025-09-/ {print $1}' | xargs -rn100 wp post delete --force
# CAREFUL! DANGER ZONEHope this helps.
Forum: Fixing WordPress
In reply to: 6.9 breaks block image backgrounds with single quoteHello,
The
data-backattribute is not standard in the Group block. Could you provide detailed instructions so that I can try to reproduce the problem?Forum: Fixing WordPress
In reply to: After automatic updating to 6.9 Deprecated: Function WP_DependenciesHi there,
The most important thing to do is to set up WordPress so that it won’t show these notices on the site. Usually this is done by editing your
wp-config.phpfile according to this document, or by following this unofficial tutorial; whichever feels easier.The notice itself is not a true error, but a warning for developers and administrators. In this case, it pertains to the deprecation of legacy code that was meant to help authors support Internet Explorer. I recommend contacting the authors of the Kalidasa theme so thay they can update it to remove any Internet-Explorer-specific workarounds that they may have kept.
Forum: Developing with WordPress
In reply to: Javascript method/action to trigger block editor refreshCan you point me in the right direction for the documentation for this Data API? I can only find information on the REST API.
The Data API is organised in “stores”, with each store exposing its own set of “selectors” (methods with which you retrieve state) and “actions” (which you can dispatch to trigger changes in the store).
You can access the entire reference here. Within it, you will find two stores that are helpful for your task: the editor store and the block-editor store. The editor store contains data specific to the post editor, such as active taxonomies. The block-editor store contains, among other things, settings dictating how the block editor should behave, such as which block types are allowed.
I’ve implemented the code but when I change the category I just see the same taxonomy term ID returned:
If I understood you correctly, I think the issue is that you would like the code to run without having to even save the draft. In that case, you’ll need a slightly different state selector called
getEditedPostAttribute. I have updated my demo accordingly, and this works on my test site:function makeListener() { let prevCategories = []; return function updateAllowedBlockTypes() { // We usewp.data.select()to access a specific data store -- in this // case, the 'core/editor' store, which is tied to the post currently // being edited. // // This call exposes all state selectors, among which we find: // // - getEditedPostAttribute // - getCurrentPostAttribute // // SelectorgetEditedPostAttributereflects changes to the post as // they are being made by the user, whilegetCurrentPostAttribute// only reflects changes after the post is saved. const categories = wp.data .select( 'core/editor' ) .getEditedPostAttribute( 'categories' ); // Bail if the data isn't ready yet. if ( ! categories ) { return; } // Bail if there has been no meaningful state change. if ( categories === prevCategories ) { return; } prevCategories = categories; const MY_CATEGORY = 1; const MY_CATEGORY_ALLOWED_TYPES = [ 'core/paragraph', 'core/image' ]; // Notice how we connect to the 'core/block-editor' store instead of // 'core/editor' for state related to block editor settings, such as // allowed block types. const currentTypes = wp.data .select( 'core/block-editor' ) .getSettings()?.allowedBlockTypes; const nextTypes = categories.includes( MY_CATEGORY ) ? MY_CATEGORY_ALLOWED_TYPES : true; if ( nextTypes !== currentTypes ) { console.log( 'setting allowed block types to', nextTypes ); wp.data.dispatch( 'core/block-editor' ).updateSettings( { allowedBlockTypes: nextTypes, } ); } }; } const unsubscribe = wp.data.subscribe( makeListener() );I hope this helps!
Forum: Developing with WordPress
In reply to: Javascript method/action to trigger block editor refreshHi there,
I think you’ll have a better experience if, instead of having to refresh, you leverage the Data API to react to changes in the post’s terms. As a proof of concept, you can try the following directly in your browser console when editing a post:
function makeListener() { let prevCategories; return function updateAllowedBlockTypes() { const categories = wp.data.select('core/editor').getCurrentPost().categories; if (categories === prevCategories) { return; } prevCategories = categories; const MY_CATEGORY = 1; const MY_CATEGORY_ALLOWED_TYPES = ['core/paragraph', 'core/image']; const currentTypes = wp.data.select('core/block-editor').getSettings().allowedBlockTypes; const nextTypes = categories.includes(MY_CATEGORY) ? MY_CATEGORY_ALLOWED_TYPES : true; if (nextTypes !== currentTypes) { console.log('setting allowed block types to', nextTypes); wp.data.dispatch('core/block-editor').updateSettings({ allowedBlockTypes: nextTypes, }); } }; }; const unsubscribe = wp.data.subscribe(makeListener());Replace the constant
MY_CATEGORY = 1;with whatever works for you. You’ll notice that, as soon as you save your draft after toggling that category, the console will log that it either set the allowed block types to['core/paragraph', 'core/image']or that it reset it totrue.I’ll leave the details up to you, but I hope this illustrates how to work with the Data API. 🙂
Oh, also note that the
allowed_block_typesfilter was deprecated in 5.8 in favour ofallowed_block_types_all.Forum: Fixing WordPress
In reply to: To prevent deleting reusable blocksHello,
Internally, Reusable Blocks are a Custom Post Type (CPT), so you could prevent editors from deleting them by filtering the capabilities on said CPT.
I suggest starting at the support article for Roles & Capabilities, from which you could either manually perform the necessary changes in code, or find a plugin that might do that for you.
Hope this helps.
Forum: Plugins
In reply to: [Gutenberg] Request for official Gutenberg create-react-appHello,
We do have an official tool. Check out @wordpress/create-block.
Forum: Fixing WordPress
In reply to: TinyMCE conflict, white text on editorThis seems like a plugin compatibility issue coming from Unyson. To quote the notice on the plugin’s homepage: This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
I recommend asking at Unyson’s support page so the plugin’s developers and support community can help you with this.
Forum: Plugins
In reply to: [Gutenberg] I can’t see photosHello,
I can see many galleries on that page — presumably all of them — with no issues. Perhaps you experienced a temporary caching issue, or throttling from the server serving the images?
In any case, I’ll mark this as resolved.
Hi @nick6352683, thanks for the extra feedback.
Two quick notes on the following:
Another issue that came back is the issue of ACF blocks not “registering” default field values until you make any change to a field. So let’s say you have a Heading block made with ACF Pro, and if you just insert the block and make no changes to it, and save the post/page, nothing shows up on the front end, even though on the backend, the default value is correctly shown. If you make a change to any of the block fields, then all is fine… This was happening a year ago, got fixed by springtime 2019, and Gutenberg managed to reintroduce this annoyance with Gutenberg 6.4, which persists until now…
- This would be better handled in a separate ticket, so that this ticket can be kept focused and tickets can be easier to search in general.
- It’s important to note that these systems for change detection in the block editor are, as of WordPress 5.3, part of core and not just the Gutenberg plugin. Without having more means to debug, this really sounds like an issue to bring up with maintainers of either ACF Blocks or ACF.
If I create a new page, add some blocks, close it, re-open it, changing nothing, then this message is there.
Hi, James. Some logic around autosaving was fixed recently (e.g. #18051). Are you still experiencing this issue in the latest version of Gutenberg?
If so, then the following would definitely be something to look at:
I am using custom ACF Blocks, and some custom changes to Gutenberg Blocks. It seems to happen more when using ACF Blocks, but I need to look in to some more.
(emphasis mine)
Forum: Fixing WordPress
In reply to: Login PRoblem: Can’t Type In PasswordThis is odd.
Are you then completely unable to access your site’s admin dashboard?
Is it possible that any plugin could be interfering with the login page?
If indeed you are locked out of your dashboard, you could try deactivating all plugins using phpMyAdmin by following the steps indicated here:
Forum: Fixing WordPress
In reply to: Updated to WordPress 5.3 – Post page shows isSavingPost null errorUpdated to wordpress 5.3 and was getting ‘isSavingPost’ of null in my console error. […] Not sure if this is related to Yoast or any other plugin
I’ve tracked the error down to a plugin called Link Whisper. One of the scripts in the plugin (wp-content/plugins/link-whisper/js/wpil_admin.js) listens to data-related events in the editor and, whenever anything changes, it tries to call a WordPress API but fails in the process.
In this case, it seems that the Yoast plugin, as part of its normal operation, initiates an action which Link Whisper then reacts to. I’d try disabling Link Whisper rather than Yoast and see if that helps. If so, I would then suggest bringing up this issue with the maintainers of Link Whisper.
Forum: Fixing WordPress
In reply to: Login PRoblem: Can’t Type In PasswordHello! Could you provide some details? Namely:
– Which browser you are using, and which version of it
– Which operating system you are using
– Whether there are any specificities in how you are navigating the page, e.g. using a mouse to click on fields, or the keyboard to tab, or some other method.Thanks!
- List all attachments. Since we are dealing with a lot of images, you may want to set a higher “posts per page” parameter, but be careful not to overwhelm the server with too high a number. In the example below, I’ll use