Get notices.

@since 160524 WP notices.

@return array All notices.
962443
protected function get(): array
    {
        $notices        = $this->s::sysOption('notices', null, false);
        return $notices = is_array($notices) ? $notices : [];
    }
490968
public function getValidStatusCodes()
    {
        return array(
            self::STATUS_OK,
            self::STATUS_ACCEPTED,
            self::STATUS_NON_AUTHORITATIVE_INFORMATION,
            self::STATUS_NO_CONTENT,
            self::STATUS_RESET_CONTENT,
            self::STATUS_PARTIAL_CONTENT,
            self::STATUS_CREATED
        );
    }
209405
private function admin_page_notices() {
		$display = ( isset( $_GET['updated'] ) && is_multisite() )
				|| isset( $_GET['reset'] )
				|| isset( $_GET['refresh_transients'] );

		if ( $display ) {
			echo '<div class="updated"><p>';
		}
		if ( ( isset( $_GET['updated'] ) && '1' === $_GET['updated'] ) && is_multisite() ) {
			esc_html_e( 'Settings saved.', 'github-updater' );
		} elseif ( isset( $_GET['reset'] ) && '1' === $_GET['reset'] ) {
			esc_html_e( 'RESTful key reset.', 'github-updater' );
		} elseif ( isset( $_GET['refresh_transients'] ) && '1' === $_GET['refresh_transients'] ) {
			esc_html_e( 'Cache refreshed.', 'github-updater' );
		}
		if ( $display ) {
			echo '</p></div>';
		}
	}
48546
public function deleteAll()
    {
        $responses = array();
        $notifications = self::paginatedList();
        if ($notifications['success']) {
            foreach ($notifications['response']['data'] as $notification) {
                $responses[] = self::delete($notification->uuid);
            }
        } else {
            return array($notifications);
        }
        return $responses;
    }
1269065
public function getMessages()
    {
        $messages = array();

        foreach ($this->getDescendants() as $widget) {
            $messages = array_merge($messages, $widget->getMessages());
        }

        return $messages;
    }
186900
public function getNotificationTemplateData()
    {
        $fields = $this->Context->getValues();
        if (!is_array($fields)) {
            $fields = [];
        }
        $fields['Content'] = $this->Content;
        return $fields;
    }
83811
private function getMessages()
    {
        $messages = [];
        $content = '';
        fseek($this->fh, 0);
        while (!feof($this->fh)) {
            $content .= fgets($this->fh);
        }
        if ($content) {
            $messages = json_decode($content, true);
        }
        return $messages;
    }
65219
public function postbackMessages()
    {
        $result = [];
        foreach ($this->entries as $entry) {
            foreach ($entry->messages as $entryMessage) {
                if ($entryMessage->isPostback) {
                    $result[] = $entryMessage;
                }
            }
        }
        return collect($result);
    }
1104074
private function show_plugin_update_notices() {
		add_action( 'in_plugin_update_message-' . $this->app->define->plugin_base_name, function ( $data, $r ) {
			$new_version = $r->new_version;
			$url         = $this->app->utility->array_get( $data, 'PluginURI' );
			$notices     = $this->get_upgrade_notices( $new_version, $url );
			if ( ! empty( $notices ) ) {
				$this->get_view( 'admin/include/upgrade', [
					'notices' => $notices,
				], true );
			}
		}, 10, 2 );
	}
124881
public function getAllMessage()
    {
        $messages = [];
        foreach (array_keys($this->errors) as $key) {
            $messages[$key] = $this->getMessage($key);
        }
        return $messages;
    }
186509
public function onAllAdminNotices()
    {
        if (!($notices = $this->get())) {
            return; // Nothing to do.
        }
        $time = time(); // The current time.

        foreach ($notices as $_key => &$_notice) {
            # Catch invalid/corrupted notices.

            if (!is_string($_key) || !is_array($_notice)) {
                unset($notices[$_key]);
                continue; // Ignore.
            }
            # Normalize the notice.

            $_notice = $this->normalize($_notice);

            # Initialize a few variables.

            $_markup           = '';
            $_current_user_can = false;
            $_is_applicable    = false;

            $_class = $this->App::CORE_CONTAINER_SLUG.'-menu-page-area';
            $_class .= ' -notice';
            $_class .= ' notice';

            $_style   = $_notice['style'];
            $_dismiss = ''; // Default; n/a.

            # Check for empty markup.

            if (!($_markup = $_notice['markup'])) {
                unset($notices[$_key]);
                continue; // Ignore.
            }
            # If transient, wipe after a single pass.

            if ($_notice['is_transient']) {
                unset($notices[$_key]);
            }
            # Has notice become too old; i.e., lingering?

            if ($_notice['_insertion_time'] < $this->outdated_notice_time
                && /* Not intentially delayed. */ $_notice['delay_until_time'] < $time) {
                unset($notices[$_key]); // Ancient history after this pass.
            }
            # Check conditions; i.e., is notice applicable?

            if (!$this->currentUserCan($_notice)) {
                continue; // Do not display.
            } elseif (!$this->isApplicableContext($_notice)) {
                continue; // Do not display.
            } elseif (!$this->isApplicablePage($_notice)) {
                continue; // Do not display.
            } elseif ($_notice['delay_until_time'] > $time) {
                continue; // Do not display.
            } elseif ($_notice['recurs_every'] && $_notice['_last_recur_dismiss_time']
                && $_notice['_last_recur_dismiss_time'] + $_notice['recurs_every'] > $time) {
                continue; // Do not display; not time to recur yet, based on last time.
            }
            # If `is_applicable` is a closure, check it's return value also.

            if ($this->c::isSerialized($_notice['is_applicable'])) {
                try { // Maybe catch exceptions here.
                    $_is_applicable = $this->c::unserializeClosure($_notice['is_applicable']);
                    $_is_applicable = $_is_applicable($this->App); // Should return (bool) or `null`.
                    $_is_applicable = $_is_applicable === null ? $_is_applicable : (bool) $_is_applicable;

                    // NOTE: A special return value of `null` indicates the notice
                    // is no longer applicable (at all) and should be dequeued entirely.

                    if ($_is_applicable === null) {
                        unset($notices[$_key]);
                        continue; // Ignore.
                    } elseif (!$_is_applicable) {
                        continue; // Do not display.
                    }
                } catch (\Throwable $Throwable) {
                    unset($notices[$_key]); // Avoid repeats.

                    if ($this->App->Config->©debug['©enable']) {
                        throw $Throwable;
                    }
                    continue; // Ignore.
                }
            }
            # If `markup` is a closure, call upon the closure now.

            if ($this->c::isSerialized($_notice['markup'])) {
                try { // Maybe catch exceptions here.
                    $_markup = $this->c::unserializeClosure($_notice['markup']);
                    $_markup = (string) $_markup($this->App); // Should return a string.

                    // NOTE: A special return value (empty) indicates the notice
                    // is no longer applicable (at all) and should be dequeued entirely.

                    if (!$_markup) {
                        unset($notices[$_key]);
                        continue; // Ignore.
                    }
                } catch (\Throwable $Throwable) {
                    unset($notices[$_key]); // Avoid repeats.

                    if ($this->App->Config->©debug['©enable']) {
                        throw $Throwable;
                    }
                    continue; // Ignore.
                }
            }
            # Setup notice classes for CSS in WP core.

            switch ($_notice['type']) {
                case 'info':
                    $_class .= ' notice-info';
                    break; // Blue coloration.

                case 'success':
                    $_class .= ' notice-success';
                    break; // Green coloration.

                case 'warning':
                    $_class .= ' notice-warning';
                    break; // Orange/yellow coloration.

                case 'error':
                    $_class .= ' notice-error';
                    break; // Red coloration.

                default: // Default (info).
                    $_class .= ' notice-info';
            }
            // Create dismiss icon if applicable.

            if ($_notice['is_persistent'] && $_notice['is_dismissable']) {
                // $_class .= ' is-dismissible';
                // We use a different approach for dismissals.

                $_style .= ' padding-right:38px; position:relative;';
                $_dismiss = '<a class="notice-dismiss" style="text-decoration:none;" href="'.esc_attr($this->dismissUrl($_key)).'">'.
                                '<span class="screen-reader-text">'.__('Dismiss this notice.', 'wp-sharks-core').'</span>'.
                            '</a>';
            }
            # Make sure markup is wrapped in a block-level tag so margins will exist.

            $_markup = $this->c::mbTrim($_markup); // Before checking.
            if (!preg_match('/^\<(?:p|div|form|h[1-6]|ul|ol)[\s>]/ui', $_markup)) {
                $_markup = '<p>'.$_markup.'</p>'; // Add `<p>` tag.
            }
            # Display notice `<div>` with the markup and a possible dismiss icon.

            echo '<div class="'.esc_attr($_class).'" style="'.esc_attr($_style).'">'.
                    $_markup.$_dismiss.// Possible dismiss icon.
                 '</div>';

            # Notice seen. Handle queue state logic now.

            if ($_notice['is_persistent']) {
                continue; // Persistent; do nothing.
                // See {@link dismiss()} for recurring + persistent notice handling.
                // A recurring + persistent notice is counted/updated when it's dismissed.
                // If it's not dismissable, then it simply remains until dequeued manually.
            } elseif ($_notice['recurs_every']) {
                ++$_notice['_recurrences']; // Update counter.

                if ($_notice['_recurrences'] < $_notice['recurs_times']) {
                    $_notice['_last_recur_dismiss_time'] = $time;
                } else {
                    unset($notices[$_key]); // Dequeue.
                }
            } else {
                unset($notices[$_key]); // Dequeue.
            }
        } // unset($_key, $_notice, $_markup, $_current_user_can, $_is_applicable, $_class, $_style, $_dismiss);

        $this->update($notices);
    }
1069674
public function getMessages()
    {
        $messages = parent::getMessages();

        if ($this->model !== null) {
            foreach ($this->model as $row) {
                foreach ($this->columns as $column) {
                    $messages = array_merge(
                        $messages,
                        $column->getMessages($row)
                    );
                }

                foreach ($this->spanning_columns as $column) {
                    $messages = array_merge(
                        $messages,
                        $column->getMessages($row)
                    );
                }
            }

            foreach ($this->extra_rows as $row) {
                if ($row instanceof SwatTableViewWidgetRow) {
                    $messages = array_merge($messages, $row->getMessages());
                }
            }
        }

        return $messages;
    }
263864
public function getLastNotice()
    {
        $notice = pg_last_notice( $this->resource->get() );
        // this generic text doesn't actually tell us anything and clutters up the notice.
        // remove
        $notice = str_replace( 'LOCATION:  exec_stmt_raise, pl_exec.c:2840', '', $notice );
        return trim( $notice );
    }
259526
public function getNotifications()
    {
        $repository = $this->getService('repos:notifications.notification');

        return $repository->getQuery()
                ->status(ComNotificationsDomainEntityNotification::STATUS_SENT)
                ->id($this->notificationIds->toArray())
                ->toEntityset();
    }
951931
public function getAll() {
		if ($this->hasAny()) {
			$messages = $_SESSION[self::SESSION_KEY_FLASH];

			$_SESSION[self::SESSION_KEY_FLASH] = [];

			return $messages;
		}
		else {
			return [];
		}
	}
457803
protected function normalize(array $notice): array
    {
        $notice = array_merge($this->defaults, $notice);
        $notice = array_intersect_key($notice, $this->defaults);

        $notice['_insertion_time'] = (int) $notice['_insertion_time'];

        $notice['id']    = (string) $notice['id'];
        $notice['type']  = (string) $notice['type'];
        $notice['style'] = (string) $notice['style'];

        $notice['for_context']     = (string) $notice['for_context'];
        $notice['not_for_context'] = (string) $notice['not_for_context'];

        $notice['for_page']     = (string) $notice['for_page'];
        $notice['not_for_page'] = (string) $notice['not_for_page'];

        $notice['recurs_every']             = max(0, (int) $notice['recurs_every']);
        $notice['recurs_times']             = max(0, (int) $notice['recurs_times']);
        $notice['_recurrences']             = max(0, (int) $notice['_recurrences']);
        $notice['_last_recur_dismiss_time'] = max(0, (int) $notice['_last_recur_dismiss_time']);

        $notice['delay_until_time'] = max(0, (int) $notice['delay_until_time']);

        $notice['requires_cap'] = (string) $notice['requires_cap'];
        $notice['for_user_id']  = max(0, (int) $notice['for_user_id']);

        if ($notice['is_applicable'] instanceof \Closure) {
            $notice['is_applicable'] = $this->c::serializeClosure($notice['is_applicable']);
        } else {
            $notice['is_applicable'] = (string) $notice['is_applicable'];
        }
        $notice['is_persistent']  = (bool) $notice['is_persistent'];
        $notice['is_dismissable'] = (bool) $notice['is_dismissable'];

        $notice['is_transient'] = (bool) $notice['is_transient'];
        $notice['push_to_top']  = (bool) $notice['push_to_top'];

        if (!$notice['id']) { // An ID is required for recurrences.
            $notice['recurs_every'] = 0; // Not possible.
        }
        if ($notice['recurs_every'] || $notice['delay_until_time']) {
            $notice['is_transient'] = false; // Implies NOT transient.
        }
        if (!in_array($notice['type'], ['info', 'success', 'warning', 'error'], true)) {
            $notice['type'] = 'info'; // Use default type.
        }
        if ($notice['markup'] instanceof \Closure) {
            $notice['markup'] = $this->c::serializeClosure($notice['markup']);
        } else {
            $notice['markup'] = (string) $notice['markup'];
        }
        ksort($notice); // Sort by key for hashing.

        return $notice;
    }
41422
public function getAll() : array
    {
        $convertedClaims = [];
        $timeFields = ['exp', 'nbf', 'iat'];

        // Convert date times to timestamps
        foreach ($this->claims as $name => $value) {
            if ($value !== null && in_array($name, $timeFields)) {
                /** @var DateTimeImmutable $value */
                $value = $value->getTimestamp();
            }

            $convertedClaims[$name] = $value;
        }

        if (!isset($this->claims['jti'])) {
            $convertedClaims['jti'] = $this->getId();
        }

        return $convertedClaims;
    }