Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
hooks.currentFilter();
// $ExpectType boolean
import * as hooks from '@wordpress/hooks';
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
// We only need to run `grunt watch` on WordPress folder updates.
if ( folderPref && 'wordpress-folder' !== folderPref ) {
return;
}
setStatus( 'grunt', 'building' );
debug( 'Preparing to run `grunt watch`' );
if ( watchProcess ) {
debug( 'Ending previous `grunt watch` process' );
watchProcess.kill();
watchProcess = null;
}
if ( ! didAction( 'npm_install_finished' ) ) {
debug( "Bailing, `npm install` isn't finished" );
return;
}
if ( ! cwd ) {
debug( "Bailing, WordPress folder isn't set" );
return;
}
const grunt = cwd + '/node_modules/grunt/bin/grunt';
debug( 'Starting `grunt watch`' );
watchProcess = spawn( NODE_BIN, [
grunt,
'watch',
'--dev',
// $ExpectType string | null
hooks.currentAction();
// $ExpectType string | null
hooks.currentFilter();
// $ExpectType boolean
hooks.doingAction();
// $ExpectType boolean
hooks.doingAction('my-action');
// $ExpectType boolean
hooks.doingFilter();
// $ExpectType boolean
hooks.doingFilter('my-action');
// $ExpectType number
hooks.didAction('my-action');
// $ExpectType number
hooks.didFilter('my-filter');
// $ExpectType HookMap
hooks.actions;
// $ExpectType HookMap
hooks.filters;
(() => {
const {
// $ExpectType HookMap
actions,
// $ExpectType HookMap
filters,
} = hooks.createHooks();
import * as hooks from '@wordpress/hooks';
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']);
import * as hooks from '@wordpress/hooks';
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');
import * as hooks from '@wordpress/hooks';
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.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
// $ExpectType boolean
hooks.doingAction();
// $ExpectType boolean
hooks.doingAction('my-action');
// $ExpectType boolean
hooks.doingFilter();
// $ExpectType boolean
hooks.doingFilter('my-action');
// $ExpectType number
hooks.didAction('my-action');
// $ExpectType number
hooks.didFilter('my-filter');
// $ExpectType HookMap
hooks.actions;
// $ExpectType HookMap
hooks.filters;
(() => {
const {
// $ExpectType HookMap
actions,
// $ExpectType HookMap
filters,
} = hooks.createHooks();
// $ExpectType ActionCallback[]
actions.__current;
// $ExpectType FilterCallback[]
filters.__current;
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
hooks.currentFilter();
// $ExpectType boolean
hooks.doingAction();
// $ExpectType boolean
hooks.doingAction('my-action');
// $ExpectType boolean
hooks.doingFilter();
// $ExpectType boolean
hooks.doingFilter('my-action');
// $ExpectType number
hooks.didAction('my-action');
// $ExpectType number
hooks.didFilter('my-filter');