Astra_Notices::show_notices()
Display the notices in the WordPress admin.
Description
Return
(void)
Source
File: inc/lib/astra-notices/class-astra-notices.php
public function show_notices() { $defaults = array( 'id' => '', // Optional, Notice ID. If empty it set `astra-notices-id-<$array-index>`. 'type' => 'info', // Optional, Notice type. Default `info`. Expected [info, warning, notice, error]. 'message' => '', // Optional, Message. 'show_if' => true, // Optional, Show notice on custom condition. E.g. 'show_if' => if( is_admin() ) ? true, false, . 'repeat-notice-after' => '', // Optional, Dismiss-able notice time. It'll auto show after given time. 'display-notice-after' => false, // Optional, Dismiss-able notice time. It'll auto show after given time. 'class' => '', // Optional, Additional notice wrapper class. 'priority' => 10, // Priority of the notice. 'display-with-other-notices' => true, // Should the notice be displayed if other notices are being displayed from Astra_Notices. 'is_dismissible' => true, 'capability' => 'manage_options', // User capability - This capability is required for the current user to see this notice. ); // Count for the notices that are rendered. $notices_displayed = 0; $notices = $this->get_notices(); foreach ( $notices as $key => $notice ) { $notice = wp_parse_args( $notice, $defaults ); // Show notices only for users with `manage_options` cap. if ( ! current_user_can( $notice['capability'] ) ) { continue; } $notice['id'] = self::get_notice_id( $notice, $key ); $notice['classes'] = self::get_wrap_classes( $notice ); // Notices visible after transient expire. if ( isset( $notice['show_if'] ) && true === $notice['show_if'] ) { // don't display the notice if it is not supposed to be displayed with other notices. if ( 0 !== $notices_displayed && false === $notice['display-with-other-notices'] ) { continue; } if ( self::is_expired( $notice ) ) { self::markup( $notice ); ++$notices_displayed; } } } }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |