add_notice( $text, $type, $class, $dismissible ); } /** * Add admin notices to the $notices array. * * @since 1.5 * @param string $text The notice text. * @param string $type The notice type. * @param string $class The notice class. * @return void */ public function add_notice( $text = '', $type = '', $class = '', $dismissible = true ) { // Add type to class. $class .= $type ? ' notice-' . $type : ''; // notice-info, notice-success, notice-warning, notice-error $this->notices[] = [ 'text' => $text, 'type' => $type, 'class' => $class, 'dismissible' => $dismissible, ]; } /** * Return the $notices. * * @since 1.5 * @return array $notices The notice. */ public function get_notices() { if ( empty( $this->notices ) ) { return false; // bail early if no notices. } return $this->notices; } /** * Render admin notices in the WP admin. * * @since 1.5 * @return void */ public function alm_admin_notices() { $notices = $this->get_notices(); if ( ! $notices ) { return; // bail early if no notices. } // Loop notices. foreach ( $notices as $notice ) { $open = '
'; $close = '
' ?>