Home / Admin / Hide All Admin Notices in Sidebar
Duplicate Snippet

Embed Snippet on Your Site

Hide All Admin Notices in Sidebar

Hides all admin notices in a collapsible sidebar.

AI generated code. Use with caution.

Code Preview
php
<?php
// Hide all admin notices in a collapsible sidebar
function hide_all_admin_notices_in_sidebar() {
    ?>
    <style>
        .wp-core-ui .notice {
            display: none;
        }
        .wp-core-ui .notice.is-dismissible {
            display: block;
        }
        .wp-core-ui .notice.is-dismissible .notice-dismiss {
            display: none;
        }
        .wp-core-ui .notice.is-dismissible .notice-content {
            cursor: pointer;
        }
        .wp-core-ui .notice.is-dismissible .notice-content:after {
            content: "\f142";
            font-family: "dashicons";
            font-size: 16px;
            margin-left: 5px;
        }
        .wp-core-ui .notice.is-dismissible .notice-content.collapsed:after {
            content: "\f140";
        }
    </style>
    <script>
        jQuery(document).ready(function($) {
            $('.wp-core-ui .notice.is-dismissible .notice-content').on('click', function() {
                $(this).toggleClass('collapsed');
                $(this).parent().find('.notice-text').slideToggle();
            });
        });
    </script>
    <?php
}
add_action('admin_head', 'hide_all_admin_notices_in_sidebar');

Comments

Add a Comment