NoticeManager.moveAboveTitle + above_title option

This commit is contained in:
abuoyoyo 2022-07-16 20:10:00 +03:00
parent 57c54c756a
commit a2c3e60f87
3 changed files with 19 additions and 9 deletions

View File

@ -77,14 +77,9 @@ var NoticeManager = (function ($, document) {
if (options.screen_panel && options.auto_collect) { if (options.screen_panel && options.auto_collect) {
NoticeManager.collectNotices(); NoticeManager.collectNotices();
} else { } else {
/** if (options.above_title) {
* Move ALL notices above page title. NoticeManager.moveAboveTitle();
* Default no-panel action - override WordPress moving notices BELOW title. }
* I HATE it when WordPress moves notices below title.
*
* comment this line out to completely restore WordPress functionality when auto_collect is off
*/
notices.insertBefore(".wrap:first");
} }
/** /**
@ -169,5 +164,14 @@ var NoticeManager = (function ($, document) {
$("#screen-meta-links").detach(); $("#screen-meta-links").detach();
} }
}, },
/**
* Move ALL notices above page title.
* Default no-panel action - override WordPress moving notices BELOW title.
* I HATE it when WordPress moves notices below title.
*/
moveAboveTitle: () => {
notices.insertBefore(".wrap:first");
},
}; };
}(jQuery,document) ) }(jQuery,document) )

View File

@ -30,6 +30,12 @@ new PluginCore(
// 'title' => 'N', // 'title' => 'N',
'description' => 'Setup How notice manager functions.', 'description' => 'Setup How notice manager functions.',
'fields' => [ 'fields' => [
[
'id' => 'above_title',
'title' => 'Above Title',
'type' => 'checkbox',
'description' => 'Move all notices above title. (WordPress core moves notices below title using script.)',
],
[ [
'id' => 'screen_panel', 'id' => 'screen_panel',
'title' => 'Notices Panel', 'title' => 'Notices Panel',

View File

@ -32,7 +32,7 @@ class NoticeManager{
if ( ! empty( $this->options['screen_panel'] ) ){ if ( ! empty( $this->options['screen_panel'] ) ){
add_action( 'admin_init' , [ $this , 'register_notice_manager_panel' ] ); add_action( 'admin_init' , [ $this , 'register_notice_manager_panel' ] );
}else{ }else{
array_walk($this->options,function(&$item){$item=0;}); // array_walk($this->options,function(&$item){$item=0;});
} }
} }