widget_notifications.php
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong>Notifications</strong><span class="wf-dashboard-badge wf-notification-count-container wf-notification-count-value<?php echo (count($d->notifications) == 0 ? ' wf-hidden' : ''); ?>"><?php echo number_format_i18n(count($d->notifications)); ?></span>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<ul class="wf-dashboard-item-list">
<?php foreach ($d->notifications as $n): ?>
<li class="wf-notification" data-notification="<?php echo esc_html($n->id); ?>">
<div class="wf-dashboard-item-list-title"><?php echo $n->html; ?></div>
<?php foreach ($n->links as $l): ?>
<div class="wf-dashboard-item-list-action"><a href="<?php echo esc_html($l['link']); ?>"<?php if (preg_match('/^https?:\/\//i', $l['link'])) { echo ' target="_blank"'; } ?>><?php echo esc_html($l['label']); ?></a></div>
<?php endforeach; ?>
<div class="wf-dashboard-item-list-dismiss"><a href="#" class="wf-dismiss-notification"><i class="fa fa-times-circle" aria-hidden="true"></i></a></div>
</li>
<?php endforeach; ?>
<?php if (count($d->notifications) == 0): ?>
<li class="wf-notifications-empty">No notifications received</li>
<?php endif; ?>
</ul>
</div>
</div>
</div>
</div>
<script type="application/javascript">
(function($) {
$('.wf-dismiss-notification').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var n = $(this).closest('.wf-notification');
var id = n.data('notification');
n.fadeOut(400, function() {
n.remove();
var count = $('.wf-dismiss-notification').length;
WFDash.updateNotificationCount(count);
});
WFAD.ajax('wordfence_dismissNotification', {
id: id
}, function(res) {
//Do nothing
});
});
})(jQuery);
</script>