[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 /** 2 * Front-end Sitewide notices block class. 3 * 4 * @since 9.0.0 5 */ 6 class bpSitewideNoticeBlock { 7 constructor( settings ) { 8 const { path, dismissPath, root, nonce } = settings; 9 this.path = path; 10 this.dismissPath = dismissPath; 11 this.root = root; 12 this.nonce = nonce; 13 } 14 15 start() { 16 // Listen to each Block's dismiss button clicks 17 document.querySelectorAll( '.bp-sitewide-notice-block a.dismiss-notice' ).forEach( ( dismissButton ) => { 18 dismissButton.addEventListener( 'click', ( event ) => { 19 event.preventDefault(); 20 21 fetch( this.root + this.dismissPath, { 22 method: 'POST', 23 headers: { 24 'X-WP-Nonce' : this.nonce, 25 } 26 } ).then( 27 ( response ) => response.json() 28 ).then( 29 ( data ) => { 30 if ( 'undefined' !== typeof data && 'undefined' !== typeof data.dismissed && data.dismissed ) { 31 document.querySelectorAll( '.bp-sitewide-notice-block' ).forEach( ( elem ) => { 32 elem.remove(); 33 } ); 34 } 35 } 36 ); 37 } ); 38 } ); 39 } 40 } 41 42 // widget_bp_core_sitewide_messages buddypress widget wp-block-bp-sitewide-notices > bp-sitewide-notice > a.dismiss-notice 43 const settings = window.bpSitewideNoticeBlockSettings || {}; 44 const bpSitewideNotice = new bpSitewideNoticeBlock( settings ); 45 46 if ( 'loading' === document.readyState ) { 47 document.addEventListener( 'DOMContentLoaded', bpSitewideNotice.start() ); 48 } else { 49 bpSitewideNotice.start(); 50 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri May 5 01:01:24 2023 | Cross-referenced by PHPXref 0.7.1 |