How to use the @wordpress/hooks.doAction 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.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
github google / site-kit-wp / assets / js / googlesitekit-wp-dashboard.js View on Github external
domReady( function() {
	const wpDashboard = document.getElementById( 'js-googlesitekit-wp-dashboard' );
	if ( null !== wpDashboard ) {
		// Render the Dashboard App.
		render( <GoogleSitekitWPDashboard />, wpDashboard );

		/**
		 * Action triggered when the WP Dashboard App is loaded.
	 	*/
		doAction( 'googlesitekit.moduleLoaded', 'WPDashboard' );
	}
} );
github google / site-kit-wp / assets / js / googlesitekit-dashboard-details.js View on Github external
domReady( function() {
	const dashboardDetails = document.getElementById( 'js-googlesitekit-dashboard-details' );
	if ( null !== dashboardDetails ) {
		// Render the Dashboard App.
		render( <GoogleSitekitDashboardDetails />, dashboardDetails );

		/**
		 * Action triggered when the dashboard details App is loaded.
		 */
		doAction( 'googlesitekit.moduleLoaded', 'Dashboard' );
	}
} );
github google / site-kit-wp / assets / js / googlesitekit-dashboard-splash.js View on Github external
domReady( function() {
	if ( googlesitekit.admin.resetSession ) {
		clearAppLocalStorage();
	}

	const dashboardSplash = document.getElementById( 'js-googlesitekit-dashboard-splash' );
	if ( null !== dashboardSplash ) {
		// Render the Dashboard Splash App.
		render( <GoogleSitekitDashboardSplash />, dashboardSplash );

		/**
		 * Action triggered when the Dashboard Splash App is loaded.
		 */
		doAction( 'googlesitekit.moduleLoaded', 'Splash' );
	}
} );
github pento / testpress / src / services / node-downloader / index.js View on Github external
function triggerNextService() {
	doAction( 'updated_node_and_npm' );
}
github WordPress / gutenberg / packages / plugins / src / api / index.js View on Github external
settings = applyFilters( 'plugins.registerPlugin', settings, name );

	if ( ! isFunction( settings.render ) ) {
		console.error(
			'The "render" property must be specified and must be a valid function.'
		);
		return null;
	}

	plugins[ name ] = {
		name,
		icon: 'admin-plugins',
		...settings,
	};

	doAction( 'plugins.pluginRegistered', settings, name );

	return settings;
}
github gambitph / Stackable / src / components / responsive-toggle / index.js View on Github external
onChangeScreen( value ) {
		const firstScreenOption = this.props.screens[ 0 ]
		if ( ! this.state.isScreenPickerOpen && this.state.screen === firstScreenOption && value === firstScreenOption ) {
			this.setState( { isScreenPickerOpen: true } )
			if ( typeof instanceIdOwner === 'undefined' ) {
				setIsScreenPickerOpen( true )
				doAction( 'stackable.responsive-toggle.screen.open' )
			}
		} else if ( this.state.isScreenPickerOpen && value === firstScreenOption ) {
			this.setState( { isScreenPickerOpen: false } )
			if ( typeof instanceIdOwner === 'undefined' ) {
				setIsScreenPickerOpen( false )
				doAction( 'stackable.responsive-toggle.screen.close' )
			}
		}

		this.props.onChangeScreen( value )
		this.setState( { screen: value } )
		setSelectedScreen( value )
		doAction( 'stackable.responsive-toggle.screen.change', value )
	}
github gambitph / Stackable / src / modules / advanced-block-spacing / index.js View on Github external
enableMarginBottom: true,
		enableMarginLeft: true,
		enablePaddingTop: true,
		enablePaddingRight: true,
		enablePaddingBottom: true,
		enablePaddingLeft: true,
		...options,
	}

	addFilter( `stackable.${ blockName }.edit.inspector.advanced.before`, `stackable/${ blockName }/advanced-block-spacing`, inspectorControls( blockName, optionsToPass ), 5 )
	if ( optionsToPass.modifyStyles ) {
		addFilter( `stackable.${ blockName }.styles`, `stackable/${ blockName }/advanced-block-spacing`, addToStyleObject( blockName, optionsToPass ) )
	}
	addFilter( `stackable.${ blockName }.attributes`, `stackable/${ blockName }/advanced-block-spacing`, addAttributes )
	addFilter( `stackable.${ blockName }.main-block.classes`, `stackable/${ blockName }/advanced-block-spacing`, addCustomWidthClassName )
	doAction( `stackable.module.advanced-block-spacing`, blockName )
}
github gambitph / Stackable / src / modules / content-align / index.js View on Github external
const contentAlign = blockName => {
	addFilter( `stackable.${ blockName }.edit.inspector.before`, `stackable/${ blockName }/content-align`, addAlignToolbar, 11 )
	addFilter( `stackable.${ blockName }.attributes`, `stackable/${ blockName }/content-align`, addAttributes )
	addFilter( `stackable.${ blockName }.styles`, `stackable/${ blockName }/content-align`, addStyles, 9 )
	doAction( `stackable.module.content-align`, blockName )
}
github google / site-kit-wp / stories / data-table.stories.js View on Github external
setTimeout( () => {
			doAction(
				'googlesitekit.moduleLoaded',
				'Dashboard'
			);
		}, 250 );
		return (