How to use @wordpress/deprecated - 10 common examples

To help you get started, we’ve selected a few @wordpress/deprecated 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 WordPress / gutenberg / editor / components / rich-text / index.js View on Github external
RichTextContainer.Content = ( { value, format, tagName: Tag, ...props } ) => {
	let content;
	switch ( format ) {
		case 'string':
			content = { value };
			break;

		case 'element':
			// NOTE: In removing this, ensure to remove also every related
			// function from `format.js`, including the `dom-react` dependency.
			deprecated( 'RichText `element` format', {
				version: '3.5',
				plugin: 'Gutenberg',
				alternative: 'the compatible `children` format',
			} );

			content = value;
			break;

		case 'children':
			content = { children.toHTML( value ) };
			break;
	}

	if ( Tag ) {
		return { content };
	}
github Automattic / wp-calypso / client / gutenberg / editor / edit-post / index.js View on Github external
export function initializeEditor( id, postType, postId, settings, overridePost ) {
	const target = document.getElementById( id );
	const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, overridePost );

	// Global deprecations which cannot otherwise be injected into known usage.
	deprecated( 'paragraphs block class set is-small-text, ..., is-large-text', {
		version: '3.6',
		alternative: 'has-small-font-size, ..., has-large-font-size class set',
		plugin: 'Gutenberg',
		hint: 'If paragraphs using this classes are opened in the editor new classes are automatically applied the post just needs to be saved. This is a global warning, shown regardless of whether the classes are used in the current post.',
	} );

	dispatch( 'core/nux' ).triggerGuide( [
		'core/editor.inserter',
		'core/editor.settings',
		'core/editor.preview',
		'core/editor.publish',
	] );

	render(
		,
		target
github WordPress / gutenberg / packages / data / src / plugins / async-generator / middleware.js View on Github external
export function toAsyncIterable( object ) {
	if ( isAsyncIterable( object ) ) {
		deprecated( 'Writing Resolvers as async generators', {
			alternative: 'resolvers as generators with controls',
			plugin: 'Gutenberg',
			version: 4.2,
		} );
		return object;
	}

	return ( async function* () {
		// Normalize as iterable...
		if ( ! isIterable( object ) ) {
			object = [ object ];
		}

		for ( const maybeAction of object ) {
			yield maybeAction;
		}
github WordPress / gutenberg / editor / hooks / align.js View on Github external
export function getBlockValidAlignments( blockName ) {
	// Explicitly defined array set of valid alignments
	const blockAlign = getBlockSupport( blockName, 'align' );
	if ( Array.isArray( blockAlign ) ) {
		return blockAlign;
	}

	const validAlignments = [];
	if ( true === blockAlign ) {
		// `true` includes all alignments...
		validAlignments.push( 'left', 'center', 'right' );

		// ...including wide alignments unless explicitly `false`.
		if ( getBlockSupport( blockName, 'wideAlign' ) === false ) {
			deprecated( 'supports.wideAlign in Block API', {
				version: '3.6',
				alternative: 'supports.alignWide',
				plugin: 'Gutenberg',
			} );
		} else if ( hasBlockSupport( blockName, 'alignWide', true ) ) {
			validAlignments.push( 'wide', 'full' );
		}
	}

	return validAlignments;
}
github WordPress / gutenberg / packages / editor / src / components / panel-color / index.js View on Github external
function PanelColor( { colors, title, colorValue, initialOpen, ...props } ) {
	deprecated( 'wp.editor.PanelColor', {
		version: '4.3',
		alternative: 'wp.editor.PanelColorSettings',
		plugin: 'Gutenberg',
	} );

	const colorObject = getColorObjectByColorValue( colors, colorValue );
	const colorName = colorObject && colorObject.name;
	return (
		
			
		
	);
}
github WordPress / gutenberg / packages / block-editor / src / components / rich-text / index.js View on Github external
function getAllowedFormats( { allowedFormats, formattingControls } ) {
	if ( ! allowedFormats && ! formattingControls ) {
		return;
	}

	if ( allowedFormats ) {
		return allowedFormats;
	}

	deprecated( 'wp.blockEditor.RichText formattingControls prop', {
		alternative: 'allowedFormats',
	} );

	return formattingControls.map( ( name ) => `core/${ name }` );
}
github WordPress / gutenberg / packages / nux / src / index.js View on Github external
/**
 * WordPress dependencies
 */
import deprecated from '@wordpress/deprecated';

/**
 * Internal dependencies
 */
import './store';

export { default as DotTip } from './components/dot-tip';

deprecated( 'wp.nux', {
	hint: 'wp.components.Guide can be used to show a user guide.',
} );
github WordPress / gutenberg / packages / core-data / src / resolvers.js View on Github external
export function* hasUploadPermissions() {
	deprecated( "select( 'core' ).hasUploadPermissions()", {
		alternative: "select( 'core' ).canUser( 'create', 'media' )",
	} );
	yield* canUser( 'create', 'media' );
}
github WordPress / gutenberg / utils / deprecated.js View on Github external
export function buildTermsTree( flatTerms ) {
	deprecated( 'wp.utils.buildTermsTree', {
		version: '3.5',
		plugin: 'Gutenberg',
	} );
	const termsByParent = groupBy( flatTerms, 'parent' );
	const fillWithChildren = ( terms ) => {
		return terms.map( ( term ) => {
			const children = termsByParent[ term.id ];
			return {
				...term,
				children: children && children.length ?
					fillWithChildren( children ) :
					[],
			};
		} );
	};
github WordPress / gutenberg / core-blocks / text-columns / index.js View on Github external
edit: ( ( { attributes, setAttributes, className } ) => {
		const { width, content, columns } = attributes;

		deprecated( 'The Text Columns block', {
			alternative: 'the Columns block',
			plugin: 'Gutenberg',
		} );

		return (
			
				
					 setAttributes( { width: nextWidth } ) }
						controls={ [ 'center', 'wide', 'full' ] }
					/>

@wordpress/deprecated

Deprecation utility for WordPress.

GPL-2.0-or-later
Latest version published 11 days ago

Package Health Score

98 / 100
Full package analysis

Popular @wordpress/deprecated functions