Plugin Support
ying
(@yingscarlett)
Hi there,
Try adding the PHP code blow to hide the button:
wp_add_inline_style( 'wp-block-library',
'button.components-button[aria-label="GenerateBlocks"] {
display: none;
}'
);
I just wanted to let you know that your code created an error which I’m told is due to the function wp_add_inline_style
. According to the query monitor this function is being called too early, before the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks are fired which is not the correct procedure.
My eventual solution was this code but maybe not ideal:
function my_custom_admin_styles() {
echo '<style>
button.components-button[aria-label="GenerateBlocks"] {
display: none;
}
</style>';
}
add_action('admin_head', 'my_custom_admin_styles');
Plugin Support
Alvind
(@alvindcaesar)
Alternatively you can use this
add_action( 'admin_footer', function() {
?>
<script>
document.addEventListener('DOMContentLoaded', function () {
if (typeof wp !== 'undefined' && typeof wp.plugins !== 'undefined') {
var unregisterPlugin = wp.plugins.unregisterPlugin;
unregisterPlugin('gblocks-editor-sidebar');
}
});
</script>
<?php
} );
This code will remove the button from the DOM instead of just hiding it.