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
New Embed Variations Break allowed_block_types() Functionality. #27913
Comments
|
Hey @timnolte - you could unregister any block variation you don't want to use ( |
|
@ntsekouras the problem is that I want an explicit allow list. When developing client sites we are not always styling 100% of all Core blocks. Additionally, what you list is a totally different code base, JavaScript, so now I must maintain block controls 8n 2 different code bases. This is way more to maintain and now causes problems for where to go to maintain a single allowed block list. I should also point out that this breaks sites that have already been using the |
|
I agree with @timnolte. We have a similar setup for our Clients, a single explicit allowed list in PHP. Updating to WP 5.6 prevented our Clients from adding any embeds since we only allowed certain ones in the |
|
I share the same reasons as @timnolte states above for using an explicit allow list. Targeting unrequired block variations by unregistering them would also mean having to manually update this deny list every time future releases introduce new variations. |
|
Okay, I get what you mean. Block variations API is a powerful one, but is expanding right now.. There are some other similar issues about the |
|
@chthonic-ds I had the same problem, that wen new variants will be added, they would be available. So as workaround i used import domeReady from '@wordpress/dom-ready';
import { getBlockVariations, unregisterBlockVariation } from '@wordpress/blocks';
domeReady(() => {
const allowedEmbedVariants = ['youtube'];
getBlockVariations('core/embed').forEach(variant => {
if(!allowedEmbedVariants.includes(variant.name)) {
unregisterBlockVariation('core/embed', variant.name);
}
});
});This will hide all variants but not youtube and the main implementation of embed. The problem is that you sill can use the main implementation of embed to embed everything you want. @ntsekouras is there a way to to change this? |
This is really interesting! I'll look into it more :) What do you think the behaviour should be on pasting such a link? Example unregister |
When unregistering |
|
@ntsekouras I think the expected behavior would be that the link is just visible as text inside a paragraph, rather than being embedded. |
@chrisvanpatten yes something like that. Also a info "This is not a valid embed URL. The URL will only displayed as Text." for the user how insert a not allowed embed URL would be nice too. |
|
I understand these can be disabled/enabled through JS but when enabling/disabling based on user->role the hook is much more beneficially. Does anyone know how to accomplish a user->role based approach in JS? |
|
What exactly is the point of having PHP and a filter of "allowed_block_types_all" In the time this bug has been live the filter itself was deprecated and replaced, and left broken! If the "answer " is to unhook each unwanted block in JS, then why did the PHP hook even change in WP5.8 ? Why aren't core devs honest that they consider PHP sites as "dull" of no concern. Be honest, its all about the latest shiny nonsense. Get ready to see that deprecated in February too. And again in April. But whats important is cool shiny, right? Not dull corporate commercial "functionality" |
|
Any movement here? |
Further HackeryTo disable all but YouTube and Vimeo variations in the menu use @gherrink 's solution. Then to disable transformation-by-paste use the following hackery.
Note that this is fragile but as robust as I could make it. If the |
Describe the bug
Since WordPress changed the Embed blocks to all variations of the
core/embedblock they are now no longer being allowed individually by using theallowed_block_types()hook in previous versions of WP.To reproduce
Steps to reproduce the behavior:
Expected behavior
Embed variations are all distinct things that should be allowed to be whitelisted for use.
Editor version (please complete the following information):
The text was updated successfully, but these errors were encountered: