load_notices(); } public function _action_render_notices() { foreach ( $this->notices as $notice ) { echo Brizy_Admin_View::render( 'notice', $notice ); } $this->notices = array(); } public function _action_store_notices() { if ( ! empty( $this->notices ) ) { set_transient( self::BRIZY_NOTICE_TRANSIENT_KEY, $this->notices, 120 ); } } protected function load_notices() { $notices = get_transient( self::BRIZY_NOTICE_TRANSIENT_KEY ); if ( $notices ) { $this->notices = $notices; delete_transient( self::BRIZY_NOTICE_TRANSIENT_KEY ); } } public function add( $message, $type ) { $this->notices[ md5( $message ) ] = array( 'message' => $message, 'type' => $type, ); } public function add_info( $message ) { $this->add( $message, self::INFO ); } public function add_warning( $message ) { $this->add( $message, self::WARNING ); } public function add_success( $message ) { $this->add( $message, self::SUCCESS ); } public function add_error( $message ) { $this->add( $message, self::ERROR ); } public function count() { return count( $this->notices ); } public function has( $hash ) { return isset( $this->notices[ $hash ] ); } public function has_notice_type( $type ) { $array_filter = array_filter( $this->notices, function ( $var ) use ( $type ) { return $var['type'] == $type; } ); return count( $array_filter ) > 0; } public function get( $hash ) { if ( $this->has( $hash ) ) { return $this->notices[ $hash ]; } return null; } }