• Resolved tomo55555

    (@tomo55555)


    Is it possible to hide or disable the generate blocks menu item in the posts admin area next to the publish and options menu buttons please (top right) ?

    Not sure why it’s there.

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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;
    }'
    );
    Thread Starter tomo55555

    (@tomo55555)

    Thank you for your help.

    Plugin Support ying

    (@yingscarlett)

    You are welcome ? ??

    Thread Starter tomo55555

    (@tomo55555)

    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.

    Thread Starter tomo55555

    (@tomo55555)

    Thanks again.

    Plugin Support Alvind

    (@alvindcaesar)

    No problem

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.