|
1 | 1 | /* global ajaxurl, CBOXOLDashboardPanel */ |
2 | 2 |
|
3 | 3 | // Create 'Screen options' checkbox for OpenLab News panel. |
4 | | -const { backgroundColor, panelIsVisible, textColor } = CBOXOLDashboardPanel; |
| 4 | +const { allowDismissal, backgroundColor, panelIsVisible, textColor } = CBOXOLDashboardPanel; |
5 | 5 | const checkboxEl = document.createElement( 'input' ); |
6 | 6 | checkboxEl.setAttribute( 'type', 'checkbox' ); |
7 | 7 | checkboxEl.setAttribute( 'id', 'openlab_news_panel-hide' ); |
@@ -33,15 +33,17 @@ const dashboardWidgetsWrap = document.querySelector( '#dashboard-widgets-wrap' ) |
33 | 33 | dashboardWidgetsWrap.before( openlabNewsPanel ); |
34 | 34 |
|
35 | 35 | // Add a Dismiss link to the panel. |
36 | | -const openlabNewsPanelDismiss = document.createElement( 'a' ); |
37 | | -openlabNewsPanelDismiss.setAttribute( 'href', '#' ); |
38 | | -openlabNewsPanelDismiss.setAttribute( 'class', 'panel-dismiss' ); |
39 | | -openlabNewsPanelDismiss.textContent = 'Dismiss'; // @todo i18n |
40 | | -openlabNewsPanel.prepend( openlabNewsPanelDismiss ); |
41 | | -openlabNewsPanelDismiss.addEventListener( 'click', ( e ) => { |
42 | | - e.preventDefault(); |
43 | | - openlabNewsPanelDismissHandler( false ); |
44 | | -} ); |
| 36 | +if ( allowDismissal ) { |
| 37 | + const openlabNewsPanelDismiss = document.createElement( 'a' ); |
| 38 | + openlabNewsPanelDismiss.setAttribute( 'href', '#' ); |
| 39 | + openlabNewsPanelDismiss.setAttribute( 'class', 'panel-dismiss' ); |
| 40 | + openlabNewsPanelDismiss.textContent = 'Dismiss'; // @todo i18n |
| 41 | + openlabNewsPanel.prepend( openlabNewsPanelDismiss ); |
| 42 | + openlabNewsPanelDismiss.addEventListener( 'click', ( e ) => { |
| 43 | + e.preventDefault(); |
| 44 | + openlabNewsPanelDismissHandler( false ); |
| 45 | + } ); |
| 46 | +} |
45 | 47 |
|
46 | 48 | // Hide OpenLab News panel if checkbox is checked. |
47 | 49 | const openlabNewsPanelShow = document.querySelector( '#openlab_news_panel-hide' ); |
|
0 commit comments