HEX
Server:
System: Linux aac286ea486c 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 08:51:45 EDT 2026 x86_64
User: root (0)
PHP: 8.2.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,disk_free_space,diskfreespace
Upload Files
File: /dom877180/wp-content/plugins/mailchimp-for-wp/includes/admin/class-admin-messages.php
<?php

defined('ABSPATH') or exit;


/**
 * Class MC4WP_Admin_Messages
 *
 * @ignore
 * @since 3.0
 */
class MC4WP_Admin_Messages
{
    /**
     * @var array
     */
    protected $bag;

    /**
     * @var bool
     */
    protected $dirty = false;

    /**
     * Add hooks
     */
    public function add_hooks()
    {
        add_action('admin_notices', [ $this, 'show' ]);
        register_shutdown_function([ $this, 'save' ]);
    }

    private function load()
    {
        if (is_null($this->bag)) {
            $this->bag = get_option('mc4wp_flash_messages', []);
        }
    }

    // empty flash bag
    private function reset()
    {
        $this->bag   = [];
        $this->dirty = true;
    }

    /**
     * Flash a message (shows on next pageload)
     *
     * @param string $message
     * @param string $type
     */
    public function flash($message, $type = 'success')
    {
        $this->load();
        $this->bag[] = [
            'text' => $message,
            'type' => $type,
        ];
        $this->dirty = true;
    }



    /**
     * Show queued flash messages
     */
    public function show()
    {
        $this->load();

        $allowed_html = [
            'a' => [ 'href' => [] ],
            'br' => [],
            'strong' => [],
        ];

        foreach ($this->bag as $message) {
            printf('<div class="notice notice-%s is-dismissible"><p>%s</p></div>', esc_attr($message['type']), wp_kses($message['text'], $allowed_html));
        }

        $this->reset();
    }

    /**
     * Save queued messages
     *
     * @hooked `shutdown`
     */
    public function save()
    {
        if ($this->dirty) {
            update_option('mc4wp_flash_messages', $this->bag, false);
        }
    }
}