How to use the @wordpress/hooks.removeAllFilters function in @wordpress/hooks

To help you get started, we’ve selected a few @wordpress/hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / wordpress__hooks / wordpress__hooks-tests.ts View on Github external
hooks.addAction('my-action', 'my/namespace', () => {});
hooks.addAction('my-action', 'my/namespace', () => {}, 20);

hooks.addFilter('my-filter', 'my/namespace', (foo: string, bar: number) => `${foo}${bar}`);
hooks.addFilter('my-filter', 'my/namespace', (foo: number, bar: number) => bar, 23);

hooks.removeAction('my-action', 'my/namespace');
hooks.removeFilter('my-filter', 'my/namespace');

// $ExpectType boolean
hooks.hasAction('my-action');
// $ExpectType boolean
hooks.hasFilter('my-filter');

hooks.removeAllActions('my-action', 'my/namespace');
hooks.removeAllFilters('my-filter', 'my/namespace');

// $ExpectType unknown
hooks.doAction('my-action');
// $ExpectType string
hooks.doAction('my-action', 'foo');

// $ExpectType unknown
hooks.applyFilters('my-filter');
// $ExpectType number
hooks.applyFilters('my-action', 123);
// $ExpectType (string | number)[]
hooks.applyFilters('my-action', [123, '456']);

// $ExpectType string | null
hooks.currentAction();
// $ExpectType string | null
github google / site-kit-wp / stories / wp-dashboard.stories.js View on Github external
.add( 'WordPress Dashboard', () => {
		window.googlesitekit = wpDashboardData;
		window.googlesitekit.admin.assetsRoot = '/assets/';
		const addWPSearchConsoleDashboardWidget = createAddToFilter( <WPSearchConsoleDashboardWidget /> );
		const addWPAnalyticsDashboardWidgetOverview = createAddToFilter( <WPAnalyticsDashboardWidgetOverview /> );
		const addWPAnalyticsDashboardWidgetTopPagesTable = createAddToFilter( <WPAnalyticsDashboardWidgetTopPagesTable /> );

		removeAllFilters( 'googlesitekit.WPDashboardHeader' );
		addFilter( 'googlesitekit.WPDashboardHeader',
			'googlesitekit.SearchConsole',
			addWPSearchConsoleDashboardWidget, 11 );

		addFilter( 'googlesitekit.WPDashboardHeader',
			'googlesitekit.Analytics',
			addWPAnalyticsDashboardWidgetOverview );
		addFilter( 'googlesitekit.WPDashboardModule',
			'googlesitekit.Analytics',
			addWPAnalyticsDashboardWidgetTopPagesTable );

		setTimeout( () => {
			doAction(
				'googlesitekit.moduleLoaded',
				'WPDashboard'
			);