PluginProbe ʕ •ᴥ•ʔ
FrontBlocks for Gutenberg/GeneratePress / 1.5.2
FrontBlocks for Gutenberg/GeneratePress v1.5.2
1.5.2 1.5.1 1.4.0 1.5.0 trunk 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 ci-artifacts
frontblocks / assets / admin / redundant-plugins-notice.js
frontblocks / assets / admin Last commit date
icons 1 week ago custom-post-types.js 8 months ago redundant-plugins-notice.js 4 days ago review-notice.js 6 days ago settings-src.css 4 days ago settings.css 4 days ago
redundant-plugins-notice.js
65 lines
1 /**
2 * FrontBlocks Redundant Plugins Notice
3 *
4 * Handles dismissal of the redundant-plugin admin notices. Unlike the review
5 * notice, dismissal here is scoped to a state hash (which plugins/versions
6 * were detected): the notice reappears if that state changes later.
7 */
8
9 (function () {
10 'use strict';
11
12 document.addEventListener('DOMContentLoaded', function () {
13 var notices = document.querySelectorAll('.frbl-redundant-plugin-notice');
14
15 if (!notices.length) {
16 return;
17 }
18
19 function sendDismiss(entryId, stateHash) {
20 var data = new FormData();
21 data.append('action', 'frbl_dismiss_redundant_plugin_notice');
22 data.append('nonce', frblRedundantPluginsNotice.nonce);
23 data.append('entry_id', entryId);
24 data.append('state_hash', stateHash);
25
26 return fetch(frblRedundantPluginsNotice.ajaxurl, {
27 method: 'POST',
28 body: data
29 });
30 }
31
32 notices.forEach(function (notice) {
33 var entryId = notice.getAttribute('data-entry-id');
34 var stateHash = notice.getAttribute('data-state-hash');
35 var dismissLink = notice.querySelector('.frbl-dismiss-redundant-plugin');
36
37 function dismiss(e) {
38 if (e) {
39 e.preventDefault();
40 }
41
42 // Only hide once the dismissal is actually saved, so the notice
43 // doesn't silently vanish while a dropped request leaves the
44 // server-side state undismissed.
45 sendDismiss(entryId, stateHash).then(function (response) {
46 if (response.ok) {
47 notice.style.display = 'none';
48 }
49 });
50 }
51
52 if (dismissLink) {
53 dismissLink.addEventListener('click', dismiss);
54 }
55
56 // WordPress built-in dismiss button (.notice-dismiss), if present.
57 notice.addEventListener('click', function (e) {
58 if (e.target && e.target.classList.contains('notice-dismiss')) {
59 dismiss();
60 }
61 });
62 });
63 });
64 }());
65