first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/**
* External dependencies
*/
import { dispatch, select } from '@wordpress/data';
import type { Notice } from '@wordpress/notices';
export const hasNoticesOfType = (
context = '',
type: 'default' | 'snackbar'
): boolean => {
const notices: Notice[] = select( 'core/notices' ).getNotices( context );
return notices.some( ( notice: Notice ) => notice.type === type );
};
export const removeNoticesByStatus = ( status: string, context = '' ): void => {
const notices = select( 'core/notices' ).getNotices();
const { removeNotice } = dispatch( 'core/notices' );
const noticesOfType = notices.filter(
( notice ) => notice.status === status
);
noticesOfType.forEach( ( notice ) => removeNotice( notice.id, context ) );
};