options(); // load notices from "queue". $notices = isset( $options['notices'] ) ? $options['notices'] : array(); // check if notice_key was already saved, this prevents the same notice from showing up in different forms. if ( ! isset( $notices[ $notice_key ] ) ) { $notices[ $notice_key ] = array(); } else { // add `closed` marker, if given. if ( ! empty( $atts['closed'] ) ) { $notices[ $notice_key ]['closed'] = absint( $atts['closed'] ); } } // update db. $options['notices'] = $notices; // update db if changed. if ( $options_before !== $options ) { $this->update_options( $options ); } } /** * Return notices option from DB * * @return array $options */ public function options() { if ( ! isset( $this->options ) ) { $this->options = get_option( ADVADS_SLUG . '-frontend-notices', array() ); } if ( ! is_array( $this->options ) ) { $this->options = array(); } return $this->options; } /** * Update notice options * * @param array $options new options. */ public function update_options( array $options ) { // do not allow to clear options. if ( array() === $options ) { return; } $this->options = $options; update_option( ADVADS_SLUG . '-frontend-notices', $options ); } }