: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
<?php if ( ! empty( $alert['message'] ) ) : ?>
<p><?php echo wp_kses_post( $alert['message'] ); ?></p>
<?php if ( ! empty( $alert['html'] ) ) : ?>
function_exists( 'wp_encode_emoji' ) ? wp_encode_emoji( $alert['html'] ) : $alert['html'],
<?php if ( ! empty( $alert['actions'] ) && is_array( $alert['actions'] ) ) : ?>
foreach ( $alert['actions'] as $action ) {
$link_text = ! empty( $action['primary'] ) && true === $action['primary'] ? '<strong>' . esc_html( $action['text'] ) . '</strong>' : esc_html( $action['text'] );
if ( 'link' === $action['type'] ) {
$attributes = 'target="_blank" rel="noreferrer noopener"';
'code' => $alert['code'],
'pum_dismiss_alert' => $action['action'],
$attributes = 'class="pum-dismiss"';
<li><a data-action="<?php echo esc_attr( $action['action'] ); ?>" href="<?php echo esc_url( $url ); ?>" <?php echo $attributes; ?> ><?php echo $link_text; ?></a></li>
<?php if ( $alert['dismissible'] ) : ?>
<a href="<?php echo esc_url( $dismiss_url ); ?>" data-action="dismiss" class="button dismiss pum-dismiss">
<span class="screen-reader-text"><?php _e( 'Dismiss this item.', 'popup-maker' ); ?></span> <span class="dashicons dashicons-no-alt"></span>
remove_filter( 'safe_style_css', [ __CLASS__, 'allow_inline_styles' ] );
public static function get_global_alerts() {
$alerts = self::get_alerts();
foreach ( $alerts as $alert ) {
if ( $alert['global'] ) {
$global_alerts[] = $alert;
public static function get_alerts() {
if ( ! isset( $alert_list ) ) {
$alert_list = apply_filters( 'pum_alert_list', [] );
foreach ( $alert_list as $alert ) {
// Ignore dismissed alerts.
if ( self::has_dismissed_alert( $alert['code'] ) ) {
$alerts[] = wp_parse_args(
// Sort alerts by priority, highest to lowest.
$alerts = PUM_Utils_Array::sort( $alerts, 'priority', true );
* Handles if alert was dismissed AJAX
public static function ajax_handler() {
'pum_dismiss_alert' => '',
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'pum_alerts_action' ) ) {
$results = self::action_handler( $args['code'], $args['pum_dismiss_alert'], $args['expires'] );
if ( true === $results ) {
* Handles if alert was dismissed by page reload instead of AJAX
public static function php_handler() {
if ( ! isset( $_REQUEST['pum_dismiss_alert'] ) ) {
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'pum_alerts_action' ) ) {
'pum_dismiss_alert' => '',
self::action_handler( $args['code'], $args['pum_dismiss_alert'], $args['expires'] );
* Handles the action taken on the alert.
* @param string $code The specific alert.
* @param string $action Which action was taken
* @param string $expires When the dismissal expires, if any.
* @uses PUM_Utils_Logging::instance
* @uses PUM_Utils_Logging::log
public static function action_handler( $code, $action, $expires ) {
if ( empty( $action ) || 'dismiss' === $action ) {
$dismissed_alerts = self::dismissed_alerts();
$dismissed_alerts[ $code ] = ! empty( $expires ) ? strtotime( '+' . $expires ) : true;
$user_id = get_current_user_id();
update_user_meta( $user_id, '_pum_dismissed_alerts', $dismissed_alerts );
} catch ( Exception $e ) {
pum_log_message( 'Error dismissing alert. Exception: ' . $e->getMessage() );
do_action( 'pum_alert_dismissed', $code, $action );
public static function has_dismissed_alert( $code = '' ) {
$dimissed_alerts = self::dismissed_alerts();
$alert_dismissed = array_key_exists( $code, $dimissed_alerts );
// If the alert was dismissed and has a non true type value, it is an expiry time.
if ( $alert_dismissed && true !== $dimissed_alerts[ $code ] ) {
return strtotime( 'now' ) < $dimissed_alerts[ $code ];
* Returns an array of dismissed alert groups.
public static function dismissed_alerts() {
$user_id = get_current_user_id();
$dismissed_alerts = get_user_meta( $user_id, '_pum_dismissed_alerts', true );
if ( ! is_array( $dismissed_alerts ) ) {
update_user_meta( $user_id, '_pum_dismissed_alerts', $dismissed_alerts );
return $dismissed_alerts;