Skip to content

Commit

Permalink
Framework: Drop deprecations slated for 3.1 removal (#7419)
Browse files Browse the repository at this point in the history
* Framework: Drop deprecations slated for 3.1 removal

* Framework: Remove code required for polyfilling moved components in blocks module

* Framework: Remove deprecated utils

* Docs: Update deprecation message for wp.utils.isExtraSmall to make it correct
  • Loading branch information
aduth authored and gziolo committed Jun 21, 2018
1 parent 859f016 commit 5389ada
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 258 deletions.
9 changes: 0 additions & 9 deletions blocks/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@ export function registerBlockType( name, settings ) {
return;
}

if ( 'isPrivate' in settings ) {
deprecated( 'isPrivate', {
version: '3.1',
alternative: 'supports.inserter',
plugin: 'Gutenberg',
} );
set( settings, [ 'supports', 'inserter' ], ! settings.isPrivate );
}

if ( 'useOnce' in settings ) {
deprecated( 'useOnce', {
version: '3.3',
Expand Down
15 changes: 1 addition & 14 deletions docs/data/core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,6 @@ Gets the document title to be used.

Document title.

### getEditedPostExcerpt

Returns the raw excerpt of the post being edited, preferring the unsaved
value if different than the saved post.

*Parameters*

* state: Global application state.

*Returns*

Raw post excerpt.

### getEditedPostPreviewLink

Returns a URL to preview the post being edited.
Expand Down Expand Up @@ -1392,4 +1379,4 @@ Returns an action object used in signalling that the editor settings have been u

*Parameters*

* settings: Updated settings
* settings: Updated settings
3 changes: 2 additions & 1 deletion docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo
- `wp.blocks.withEditorSettings` is removed. Please use the data module to access the editor settings `wp.data.select( "core/editor" ).getEditorSettings()`.
- All DOM utils in `wp.utils.*` are removed. Please use `wp.dom.*` instead.
- `isPrivate: true` has been removed from the Block API. Please use `supports.inserter: false` instead.
- `wp.utils.isExtraSmall` function removed. Please use `wp.viewport.isExtraSmall` instead.
- `wp.utils.isExtraSmall` function removed. Please use `wp.viewport` module instead.
- `getEditedPostExcerpt` selector removed (`core/editor`). Use `getEditedPostAttribute( 'excerpt' )` instead.

## 3.0.0

Expand Down
9 changes: 0 additions & 9 deletions edit-post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ export function reinitializeEditor( postType, postId, target, settings, override
* @return {Object} Editor interface.
*/
export function initializeEditor( id, postType, postId, settings, overridePost ) {
if ( 'production' !== process.env.NODE_ENV ) {
// Remove with 3.0 release.
window.console.info(
'`isSelected` usage is no longer mandatory with `BlockControls`, `InspectorControls` and `RichText`. ' +
'It is now handled by the editor internally to ensure that controls are visible only when block is selected. ' +
'See updated docs: https://github.com/WordPress/gutenberg/blob/master/blocks/README.md#components.'
);
}

const target = document.getElementById( id );
const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, overridePost );

Expand Down
2 changes: 1 addition & 1 deletion editor/components/post-excerpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function PostExcerpt( { excerpt, onUpdateExcerpt } ) {
export default compose( [
withSelect( ( select ) => {
return {
excerpt: select( 'core/editor' ).getEditedPostExcerpt(),
excerpt: select( 'core/editor' ).getEditedPostAttribute( 'excerpt' ),
};
} ),
withDispatch( ( dispatch ) => ( {
Expand Down
115 changes: 0 additions & 115 deletions editor/deprecated.js

This file was deleted.

1 change: 0 additions & 1 deletion editor/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './deprecated';
import './store';
import './hooks';

Expand Down
18 changes: 0 additions & 18 deletions editor/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,24 +444,6 @@ export function getDocumentTitle( state ) {
return title;
}

/**
* Returns the raw excerpt of the post being edited, preferring the unsaved
* value if different than the saved post.
*
* @param {Object} state Global application state.
*
* @return {string} Raw post excerpt.
*/
export function getEditedPostExcerpt( state ) {
deprecated( 'getEditedPostExcerpt', {
version: '3.1',
alternative: 'getEditedPostAttribute( state, \'excerpt\' )',
plugin: 'Gutenberg',
} );

return getEditedPostAttribute( state, 'excerpt' );
}

/**
* Returns a URL to preview the post being edited.
*
Expand Down
35 changes: 0 additions & 35 deletions editor/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const {
getCurrentPostType,
getPostEdits,
getDocumentTitle,
getEditedPostExcerpt,
getEditedPostVisibility,
isCurrentPostPending,
isCurrentPostPublished,
Expand Down Expand Up @@ -665,40 +664,6 @@ describe( 'selectors', () => {
} );
} );

describe( 'getEditedPostExcerpt', () => {
it( 'should return the post saved excerpt if the excerpt is not edited', () => {
const state = {
currentPost: {
excerpt: 'sassel',
},
editor: {
present: {
edits: { status: 'private' },
},
},
};

expect( getEditedPostExcerpt( state ) ).toBe( 'sassel' );
expect( console ).toHaveWarned();
} );

it( 'should return the edited excerpt', () => {
const state = {
currentPost: {
excerpt: 'sassel',
},
editor: {
present: {
edits: { excerpt: 'youcha' },
},
},
};

expect( getEditedPostExcerpt( state ) ).toBe( 'youcha' );
expect( console ).toHaveWarned();
} );
} );

describe( 'getEditedPostVisibility', () => {
it( 'should return public by default', () => {
const state = {
Expand Down
18 changes: 1 addition & 17 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-utils',
gutenberg_url( 'build/utils/index.js' ),
array( 'lodash', 'wp-blob', 'wp-deprecated', 'wp-dom', 'wp-api-request', 'wp-i18n' ),
array( 'lodash', 'wp-blob', 'wp-deprecated', 'wp-api-request', 'wp-i18n' ),
filemtime( gutenberg_dir_path() . 'build/utils/index.js' ),
true
);
Expand Down Expand Up @@ -1189,19 +1189,3 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
*/
do_action( 'enqueue_block_editor_assets' );
}

/**
* Ensure the editor module is loaded before third party plugins.
*
* Remove this in Gutenberg 3.1
*/
function polyfill_blocks_module_in_scripts() {
if ( ! is_gutenberg_page() ) {
return;
}

wp_enqueue_script( 'wp-editor' );
}

add_action( 'enqueue_block_editor_assets', 'polyfill_blocks_module_in_scripts', 9 );
add_action( 'enqueue_block_assets', 'polyfill_blocks_module_in_scripts', 9 );
38 changes: 0 additions & 38 deletions utils/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* WordPress dependencies
*/
import * as blob from '@wordpress/blob';
import * as dom from '@wordpress/dom';
import originalDeprecated from '@wordpress/deprecated';

const wrapFunction = ( source, sourceName, version ) =>
Expand All @@ -21,32 +20,6 @@ export const createBlobURL = wrapBlobFunction( 'createBlobURL' );
export const getBlobByURL = wrapBlobFunction( 'getBlobByURL' );
export const revokeBlobURL = wrapBlobFunction( 'revokeBlobURL' );

// dom
const wrapDomFunction = wrapFunction( dom, 'dom', '3.1' );
export const computeCaretRect = wrapDomFunction( 'computeCaretRect' );
export const documentHasSelection = wrapDomFunction( 'documentHasSelection' );
export const focus = {
focusable: {
find: wrapFunction( dom.focus.focusable, 'dom.focus.focusable', '3.1' )( 'find' ),
},
tabbable: {
find: wrapFunction( dom.focus.tabbable, 'dom.focus.tabbable', '3.1' )( 'find' ),
isTabbableIndex: wrapFunction( dom.focus.tabbable, 'dom.focus.tabbable', '3.1' )( 'isTabbableIndex' ),
},
};
export const getRectangleFromRange = wrapDomFunction( 'getRectangleFromRange' );
export const getScrollContainer = wrapDomFunction( 'getScrollContainer' );
export const insertAfter = wrapDomFunction( 'insertAfter' );
export const isHorizontalEdge = wrapDomFunction( 'isHorizontalEdge' );
export const isTextField = wrapDomFunction( 'isTextField' );
export const isVerticalEdge = wrapDomFunction( 'isVerticalEdge' );
export const placeCaretAtHorizontalEdge = wrapDomFunction( 'placeCaretAtHorizontalEdge' );
export const placeCaretAtVerticalEdge = wrapDomFunction( 'placeCaretAtVerticalEdge' );
export const remove = wrapDomFunction( 'remove' );
export const replace = wrapDomFunction( 'replace' );
export const replaceTag = wrapDomFunction( 'replaceTag' );
export const unwrap = wrapDomFunction( 'unwrap' );

// deprecated
export function deprecated( ...params ) {
originalDeprecated( 'wp.utils.deprecated', {
Expand All @@ -57,14 +30,3 @@ export function deprecated( ...params ) {

return originalDeprecated( ...params );
}

// viewport
export function isExtraSmall() {
originalDeprecated( 'wp.utils.isExtraSmall', {
version: '3.1',
alternative: 'wp.viewport.isExtraSmall',
plugin: 'Gutenberg',
} );

return window && window.innerWidth < 782;
}

0 comments on commit 5389ada

Please sign in to comment.