PAnD::is_admin_notice_active PHP Method

is_admin_notice_active() public static method

Is admin notice active?
public static is_admin_notice_active ( string $arg ) : boolean
$arg string data-dismissible content of notice.
return boolean
        public static function is_admin_notice_active($arg)
        {
            $array = explode('-', $arg);
            $length = array_pop($array);
            $option_name = implode('-', $array);
            $db_record = get_site_transient($option_name);
            if ('forever' == $db_record) {
                return false;
            } elseif (absint($db_record) >= time()) {
                return false;
            } else {
                return true;
            }
        }

Usage Example

        /**
         * Display admin notices / action links.
         *
         * @return bool/string false or Admin notice.
         */
        public function admin_notices()
        {
            if (!current_user_can('update_plugins')) {
                return false;
            }
            $message = null;
            foreach ($this->notices as $notice) {
                $status = empty($notice['status']) ? 'updated' : $notice['status'];
                if (!empty($notice['action'])) {
                    $action = esc_attr($notice['action']);
                    $message = esc_html($notice['text']);
                    $message .= ' <a href="javascript:;" class="wpdi-button" data-action="' . $action . '" data-slug="' . $notice['slug'] . '">' . ucfirst($action) . ' Now &raquo;</a>';
                }
                if (!empty($notice['status'])) {
                    $message = esc_html($notice['message']);
                }
                $dismissible = 'dependency-installer-' . dirname($notice['slug']) . '-7';
                if (class_exists('\\PAnd') && !\PAnD::is_admin_notice_active($dismissible)) {
                    continue;
                }
                ?>
				<div data-dismissible="<?php 
                echo $dismissible;
                ?>
" class="<?php 
                echo $status;
                ?>
 notice is-dismissible dependency-installer">
					<p><?php 
                echo '<strong>[' . __('Dependency') . ']</strong> ' . $message;
                ?>
</p>
				</div>
				<?php 
            }
        }
All Usage Examples Of PAnD::is_admin_notice_active