-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
How do plugins change the block editor icon? #38555
Comments
Although I didn't want to do this by setting a site icon through the customiser, I tried it anyway for the time being, and I am finding that I can't even change the block editor icon this way. Nothing I try will change the default icon. Using core version 5.9 with all plugins deactivated. |
How about using the rest_index hook? Like this: function register_site_icon_url( $response ) {
$data = $response->data;
$data['site_icon_url'] = get_theme_file_uri( 'icon.png' );
$response->set_data( $data );
return $response;
}
add_filter( 'rest_index', 'register_site_icon_url' ); |
Thanks for the code, it solves what I want to do. I did come across that hook in my research but couldn't spot how to use it. Still not sure why the customiser didn't work? |
I haven't analyzed it in depth, so I don't know if the lack of functioning of the customizer is a specification or a bug. I will look into it again if I have time. |
Confirmed to work with the gutenberg plugin active, but not when inactive. |
I notice that some code handling the site icon that passes through this filter was only added in core version 5.9, which suggests that the regression might have happened in that version. On the other hand, I can't find anything in version 5.8.3 to handle the site icon. Does anyone know whether the icon replacement was ever possible in core, or only with the plugin active? |
It looks like this was fixed by WordPress/wordpress-develop#3157 |
Description
I want to bundle an image in my (private) plugin, and use it as the icon that shows in the top-left corner of the block editor screen.
There is an official filter for changing the site icon, but it is not used when resolving the block editor icon. Apparently, the only way to change the default icon is through an attachment post ID, which seems unnecessarily stringent.
Either the existing filter should be used here, or there should be a second filter specifically for the block editor icon.
I would appreciate this to be considered a high priority and considered a bug, not an enhancement. It should always be easy for plugins to disable the default branding.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: