misc - cleanup + notes + typos + lint + modernize code
This commit is contained in:
parent
1d813a48c9
commit
f01cdbf2b0
@ -40,10 +40,11 @@ var NoticeManager = (function ($, document) {
|
||||
});
|
||||
|
||||
// scroll page to top when closing notice panel
|
||||
// cannot convert to arrow function - uses this
|
||||
// could use event.target instead
|
||||
button.on("click", function () {
|
||||
if ($(this).hasClass("screen-meta-active")) {
|
||||
// function used to work with $(this)
|
||||
// using e.target instead
|
||||
// not sure if this should perhaps be e.currentTarget
|
||||
button.on("click", (e) => {
|
||||
if ($(e.target).hasClass("screen-meta-active")) {
|
||||
if (haveClosed) {
|
||||
NoticeManager.addCounter();
|
||||
}
|
||||
@ -68,7 +69,7 @@ var NoticeManager = (function ($, document) {
|
||||
console.log(options);
|
||||
|
||||
// bootstrap notices
|
||||
// get all notices that are not explicily marked as `.inline` or `.below-h2`
|
||||
// get all notices that are not explicitly marked as `.inline` or `.below-h2`
|
||||
// we add .update-nag.inline for WordPress Update notice
|
||||
notices = $("div.updated, div.error, div.notice")
|
||||
.not(".inline, .below-h2")
|
||||
@ -148,7 +149,7 @@ var NoticeManager = (function ($, document) {
|
||||
notices.appendTo(".notice_container").eq(0);
|
||||
$(".notice_container").removeClass("empty"); // .empty removes padding
|
||||
|
||||
haveClosed = true; // initial collection has occured.
|
||||
haveClosed = true; // initial collection has occurred.
|
||||
|
||||
/**
|
||||
* When dismissible notices are dismissed, check if any notices are left on page.
|
||||
|
||||
@ -13,7 +13,7 @@ defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
use WPHelper\PluginCore;
|
||||
|
||||
/**
|
||||
* Print setting page
|
||||
* Bootstrap plugin and admin page (Tools > Notice Manager)
|
||||
*/
|
||||
new PluginCore(
|
||||
__FILE__,
|
||||
@ -28,7 +28,6 @@ new PluginCore(
|
||||
'sections' => [
|
||||
[
|
||||
'id' => 'notice_manager',
|
||||
// 'title' => 'N',
|
||||
'description' => 'Setup How notice manager functions.',
|
||||
'fields' => [
|
||||
[
|
||||
@ -66,6 +65,4 @@ new PluginCore(
|
||||
require_once 'src/NoticeManager.php';
|
||||
|
||||
|
||||
add_action('plugins_loaded', function(){
|
||||
new NoticeManager();
|
||||
});
|
||||
add_action( 'plugins_loaded', fn() => new NoticeManager() );
|
||||
@ -22,7 +22,7 @@ class NoticeManager{
|
||||
|
||||
function __construct(){
|
||||
// exit early if not admin page
|
||||
if ( !is_admin() )
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
$this->options = get_option( 'notice_manager' );
|
||||
@ -35,8 +35,6 @@ class NoticeManager{
|
||||
if ( ! empty( $this->options['auto_collect'] ) ){
|
||||
add_filter( 'admin_body_class', fn($classes) => $classes . ' notices-auto-collect' );
|
||||
}
|
||||
}else{
|
||||
// array_walk($this->options,function(&$item){$item=0;});
|
||||
}
|
||||
|
||||
if ( ! empty( $this->options['above_title'] ) ){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user