PageSourceSearch

https://www.dailybulletin.com/wp-content/plugins/mng-cache-control…/mng-cache-control-adminbar.js?ver=0.2.1

js dailybulletin.com collected 2026-10-02 03:13:08 UTC 3,530 bytes, 110 lines download raw bytes

1function MNG_Cache_Control_AdminBar( { rootUrl, rootAction, nonce, isSectionFront, isHomepage, termId, taxonomy, slug } ) {
2  const LOGGER_PREFIX = '[MNG Cache Control AdminBar]';
3
4  const initialize = () => {
5    console.log( LOGGER_PREFIX, 'Initializing...' );
6
7    const adminBar          = document.querySelector( '#wp-toolbar' );
8    const cacheControlPanel = adminBar.querySelector( 'ul #wp-admin-bar-mng-cache-control-admin-bar-menu' );
9    const invalidationTools = cacheControlPanel.querySelector( 'ul#wp-admin-bar-mng-cache-control__invalidation-tools' );
10    const invalidationLinks = invalidationTools.querySelectorAll( 'li a' );
11
12    invalidationLinks.forEach( ( link ) => {
13      link.addEventListener( 'click', onInvalidationLinkClick );
14    } );
15
16    console.log( LOGGER_PREFIX, 'Successfully initialized' );
17  };
18
19  const handleHomepageQueryFlushClick = async () => {
20    console.log( LOGGER_PREFIX, 'User wishes to flush the homepage query cache.' );
21
22    doRequest( {
23         cacheaction: 'flush_homepage_query_cache'
24       } )
25      .then( ( response ) => {
26        if ( ! response.ok ) {
27          throw new Error( `[MNG Cache Control] Failed to flush the homepage's query cache using the debug bar! ${response.statusText}` );
28        }
29
30        alert( 'Successfully flushed the homepage query cache. Please reload the page.' );
31      } )
32      .catch( ( error ) => {
33        throw new Error( LOGGER_PREFIX + ` Failed to flush Section Query cache! ${error.message}` );
34      } );
35  };
36
37  const handleSectionQueryFlushClick = () => {
38    console.log( LOGGER_PREFIX, 'User wishes to flush this section front\'s query cache.' );
39
40    doRequest( {
41         cacheaction: 'flush_section_query_cache',
42         term_id:     termId,
43         taxonomy:    taxonomy,
44         slug:        slug
45       } )
46      .then( ( response ) => {
47        if ( ! response.ok ) {
48          throw new Error( `[MNG Cache Control] Failed to flush this section\'s query cache using the debug bar! ${response.statusText}` );
49        }
50
51        alert( `Successfully flushed the section front cache for ${slug}! Please reload the page.` );
52      } )
53      .catch( ( error ) => {
54        throw new Error( LOGGER_PREFIX + ` Failed to flush Section Query cache! ${error.message}` );
55      } );
56  };
57
58  const onInvalidationLinkClick = ( event ) => {
59    event.preventDefault();
60
61    const target      = event.target;
62    const targetTitle = event.target?.title;
63
64    if ( targetTitle ) {
65      switch( true ) {
66        case targetTitle.includes( 'Homepage' ):
67          handleHomepageQueryFlushClick();
68          break;
69
70        default:
71          handleSectionQueryFlushClick();
72          break;
73      }
74    }
75
76    return false;
77  };
78
79  const doRequest = async ( requestParams ) => {
80    const defaults = {
81      action:      rootAction,
82      _ajax_nonce: nonce,
83    };
84
85    requestParams = {
86      ...requestParams,
87      ...defaults
88    };
89
90    let formData = new FormData();
91    Object.entries( requestParams ).forEach( ( [ key, value ] ) => {
92      formData.append( key, value ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.append
93    } );
94
95    return fetch( rootUrl, {
96      method: 'POST',
97      body:   new URLSearchParams( formData )
98    } );
99  };
100
101  initialize();
102}
103
104document.addEventListener( 'DOMContentLoaded', () => {
105  if ( 'interactive' === document.readyState ) {
106    if ( window.cache_control_adminbar_support ) {
107      MNG_Cache_Control_AdminBar( window.cache_control_adminbar_support );
108    }
109  }
110} );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.