From 2362cb37df53833c046e73e37a16e0ee12d78e43 Mon Sep 17 00:00:00 2001 From: abuoyoyo Date: Sun, 17 Jul 2022 18:18:45 +0300 Subject: [PATCH] FOUC - add body class .notices-above-title Do not display notices before they are moved to new position. --- css/admin_notices.css | 8 ++++++++ src/NoticeManager.php | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/css/admin_notices.css b/css/admin_notices.css index a1fc27d..fb0c429 100644 --- a/css/admin_notices.css +++ b/css/admin_notices.css @@ -33,4 +33,12 @@ .notice_container > div.notice, .notice_container > div.update-nag{ margin: 5px 12px 15px 12px !important; /* Override plugins custom css */ +} + +/* This should only be used if auto-collect/above-title is enabled */ +.notices-above-title .wrap > div.updated, +.notices-above-title .wrap > div.error, +.notices-above-title .wrap > div.notice, +.notices-above-title .wrap > div.update-nag{ + display: none; } \ No newline at end of file diff --git a/src/NoticeManager.php b/src/NoticeManager.php index 0dc97d9..52300d6 100644 --- a/src/NoticeManager.php +++ b/src/NoticeManager.php @@ -35,6 +35,10 @@ class NoticeManager{ // array_walk($this->options,function(&$item){$item=0;}); } + if ( ! empty( $this->options['above_title'] ) ){ + add_filter( 'admin_body_class', fn($classes) => $classes . ' notices-above-title' ); + } + } function admin_enqueues(){