Gocodebox_Banner_Notifier::notifications()
This code calls the server at $this->notifications_url to see if there are any notifications to display to the user.
Description Description
Runs on the wp_ajax_{$this->prefix}_notifications hook.
Note we exit instead of returning because this is loaded via AJAX.
Source Source
File: libraries/banner-notifications/src/notifications.php
function notifications() {
if ( ! current_user_can( 'manage_options' ) ) {
exit;
}
$notification = $this->get_next_notification();
if ( empty( $notification ) ) {
exit;
}
$paused = $this->notifications_pause();
if ( $paused && empty( $_REQUEST[ "{$this->prefix}_notification" ] ) && $notification->priority !== 1 ) {
exit;
}
?>
<div class="<?php echo esc_attr( $this->prefix ); ?>_notification <?php echo esc_attr( $this->prefix ); ?>_notification-<?php echo esc_attr( $notification->type ); ?>" id="<?php echo esc_attr( $notification->id ); ?>">
<?php if ( ( isset( $notification->dismissable ) && $notification->dismissable ) || ( isset( $notification->dismissible ) && $notification->dismissible ) ) { ?>
<button type="button" data-nonce="<?php echo esc_attr( wp_create_nonce( $this->prefix . '_notification_dismiss_' . $notification->id ) ); ?>" class="<?php echo esc_html( $this->prefix ); ?>-notice-button notice-dismiss" value="<?php echo esc_attr( $notification->id ); ?>"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'lifterlms' ); ?></span></button>
<?php } ?>
<div class="<?php echo esc_attr( $this->prefix ); ?>_notification-icon"><span class="dashicons dashicons-<?php echo esc_attr( $notification->dashicon ); ?>"></span></div>
<div class="<?php echo esc_attr( $this->prefix ); ?>_notification-content">
<h3><?php echo esc_html( $notification->title ); ?></h3>
<?php
$allowed_html = array(
'a' => array(
'class' => array(),
'href' => array(),
'target' => array(),
'title' => array(),
),
'p' => array(
'class' => array(),
),
'b' => array(
'class' => array(),
),
'em' => array(
'class' => array(),
),
'br' => array(),
'strike' => array(),
'strong' => array(),
);
echo wp_kses( $notification->content, $allowed_html );
?>
</div> <!-- end <?php echo esc_html( $this->prefix ); ?>_notification-content -->
</div> <!-- end <?php echo esc_html( $this->prefix ); ?>_notification -->
<?php
exit;
}
Expand full source code Collapse full source code View on GitHub