notifications ) ) { $this->init(); } if( !key_exists( $handle, $this->notifications ) ) { $this->notifications[$handle] = $options; } else trigger_error( "The handle $handle has already been registered. Please choose a different handle for your notification." ); } public function render_notifications() { foreach($this->notifications as $handle => $notification) { $this->render_notification( $handle, $notification ); } } public function render_network_notifications() { foreach( $this->notifications as $handle => $notification ) { if( $notification['network'] ) $this->render_notification( $handle, $notification ); } } public function dismiss_notification() { $id = filter_input( INPUT_POST, 'id' ); if( !in_array( $id, $this->dismissed_notices ) ) { $this->dismissed_notices[] = $id; update_option( 'wp_dismissed_notices', $this->dismissed_notices); } die(); } public function render_script() { ?> dismissed_notices = get_option('wp_dismissed_notices'); if( false === $this->dismissed_notices ) $this->dismissed_notices = array(); var_dump($this->dismissed_notices); } private function render_notification( $id, $n ) { if( in_array( $id, $this->dismissed_notices ) ) return; printf( '

%s

', $id, $n['type'], $n['dismissible']?'is-dismissible ':'', $n['class'], $n['html'] ); } } }