[ 'class' => [], ], 'p' => [ 'class' => [], ], 'h2' => [ 'class' => [], ], 'ul' => [ 'class' => [], ], 'li' => [ 'class' => [], ], 'span' => [ 'class' => [], ], 'a' => [ 'class' => [], 'href' => [], 'rel' => [], 'target' => [], ], 'em' => [ 'class' => [], ], 'strong' => [ 'class' => [], ], 'img' => [ 'class' => [], 'alt' => [], 'src' => [], 'width' => [], 'height' => [], ], 'br' => [], 'style' => [], ]; private static $notices = []; public static function init($options) { $notices = []; if (isset($options['notices']) && is_array($options['notices'])) { foreach ($options['notices'] as $notice) { if (!isset($notice['unique_id']) || !isset($notice['content'])) { continue; } $notices[] = $notice; } } $stylesheet = get_stylesheet(); $addons_notice = $stylesheet . '_addons_notification'; $addons_notice_def = $stylesheet . '_addons_notification_def'; $theme_notice = $stylesheet . '_theme_notification'; $notices[] = array( 'unique_id' => $addons_notice, 'content' => "addons-notice.php", 'remove_if_active' => 'superb-blocks/plugin.php' ); $notices[] = array( 'unique_id' => $addons_notice_def, 'content' => "addons-notice-def.php", 'requires_dismiss' => $addons_notice, 'remove_if_active' => 'superb-blocks/plugin.php', 'delay' => '+3 days' ); if (isset($options['theme_url'])) { $notices[] = array( 'unique_id' => $theme_notice, 'content' => "theme-notice.php", 'data' => [ 'theme_url' => $options['theme_url'] ], 'delay' => '+2 days' ); } self::$notices = $notices; add_action('admin_notices', array(__CLASS__, 'AdminNotices')); add_action('wp_ajax_spbtic_dismiss_notice', array(__CLASS__, 'MaybeDismissNotice')); } public static function AdminNotices() { foreach (self::$notices as $notice) { $notice_path = trailingslashit(get_template_directory()) . 'inc/superbthemes-info-content/admin-notice/notices/' . $notice['content']; if (!file_exists($notice_path)) { continue; } // Remove notice if the required plugin is active if (isset($notice['remove_if_active'])) { if (is_plugin_active($notice['remove_if_active'])) { continue; } } // Check if the notice requires another notice to be dismissed. if (isset($notice['requires_dismiss'])) { if (!get_user_meta(get_current_user_id(), self::PREFIX . $notice['requires_dismiss'], true)) { continue; } } // Check if the notice has been dismissed. if (get_user_meta(get_current_user_id(), self::PREFIX . $notice['unique_id'], true)) { continue; } // Check if the notice is delayed if (isset($notice['delay'])) { $delay_init = get_user_meta(get_current_user_id(), self::PREFIX_DELAY . $notice['unique_id'], true); if (!$delay_init) { update_user_meta(get_current_user_id(), self::PREFIX_DELAY . $notice['unique_id'], time()); continue; } $delay = strtotime($notice['delay'], $delay_init); if ($delay > time()) { continue; } } ob_start(); include_once $notice_path; $content = ob_get_clean(); echo wp_kses($content, self::ALLOWED_HTML); } self::PrintScripts(); } public static function PrintScripts() { ?>