Skip to content

Commit

Permalink
Framework: Remove deprecations slated for 3.7 removal (#9163)
Browse files Browse the repository at this point in the history
* Framework: Remove deprecations slated for 3.7 removal

* Update the packages changelogs

* Remove wp from the allowed globals

* Remove module constants comment

* Replace usage of deprecated selectors (getCategories)

* Addding missing deprecation to the docs

* Fix typos

* Fix isResolving selector call

* Update all changelogs to follow the guidelines

* Update the package lock

* Fix package-lock.json
  • Loading branch information
youknowriad authored Aug 29, 2018
1 parent 7462c63 commit 80ac625
Show file tree
Hide file tree
Showing 49 changed files with 215 additions and 1,489 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ module.exports = {
env: {
'jest/globals': true,
},
globals: {
wpApiSettings: true,
},
plugins: [
'jest',
],
Expand Down
18 changes: 16 additions & 2 deletions components/code-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import CodeEditor from './editor';
import Placeholder from '../../packages/components/src/placeholder';
import Spinner from '../../packages/components/src/spinner';

/**
* @var {string?} siteURL WordPRess Site URL
*/
let siteURL;

/**
* Configure the site's URL to lazy load scripts and styles.
*
* @param {string} url Site url.
*/
export function unstable__setSiteURL( url ) { // eslint-disable-line camelcase
siteURL = url;
}

function loadScript() {
return new Promise( ( resolve, reject ) => {
const handles = [ 'wp-codemirror', 'code-editor', 'htmlhint', 'csslint', 'jshint' ];
Expand All @@ -21,7 +35,7 @@ function loadScript() {
}

const script = document.createElement( 'script' );
script.src = `${ wpApiSettings.schema.url }/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`;
script.src = `${ siteURL }/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`;
script.onload = resolve;
script.onerror = reject;

Expand All @@ -35,7 +49,7 @@ function loadStyle() {

const style = document.createElement( 'link' );
style.rel = 'stylesheet';
style.href = `${ wpApiSettings.schema.url }/wp-admin/load-styles.php?load=${ handles.join( ',' ) }`;
style.href = `${ siteURL }/wp-admin/load-styles.php?load=${ handles.join( ',' ) }`;
style.onload = resolve;
style.onerror = reject;

Expand Down
2 changes: 1 addition & 1 deletion components/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Components
export { default as CodeEditor } from './code-editor';
export { default as CodeEditor, unstable__setSiteURL } from './code-editor'; // eslint-disable-line camelcase
export * from '../packages/components/src';

import '../packages/components/src/style.scss';
62 changes: 0 additions & 62 deletions docs/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,6 @@

## Selectors

### getTerms

Returns all the available terms for the given taxonomy.

*Parameters*

* state: Data state.
* taxonomy: Taxonomy name.

### getCategories

Returns all the available categories.

*Parameters*

* state: Data state.

*Returns*

Categories list.

### isRequestingTerms

Returns true if a request is in progress for terms data of a given taxonomy,
or false otherwise.

*Parameters*

* state: Data state.
* taxonomy: Taxonomy name.

*Returns*

Whether a request is in progress for taxonomy's terms.

### isRequestingCategories

Returns true if a request is in progress for categories data, or false
otherwise.

*Parameters*

* state: Data state.

*Returns*

Whether a request is in progress for categories.

### isRequestingEmbedPreview

Returns true if a request is in progress for embed preview data, or false
Expand All @@ -60,10 +12,6 @@ otherwise.
* state: Data state.
* url: URL the preview would be for.

*Returns*

Whether a request is in progress for an embed preview.

### getAuthors

Returns all available authors.
Expand Down Expand Up @@ -177,16 +125,6 @@ Is the preview for the URL an oEmbed link fallback.

## Actions

### receiveTerms

Returns an action object used in signalling that terms have been received
for a given taxonomy.

*Parameters*

* taxonomy: Taxonomy name.
* terms: Terms received.

### receiveUserQuery

Returns an action object used in signalling that authors have been received.
Expand Down
6 changes: 4 additions & 2 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo

- `wp.components.withAPIData` has been removed. Please use the Core Data module or `wp.apiFetch` directly instead.
- `wp.data.dispatch("core").receiveTerms` has been deprecated. Please use `wp.data.dispatch("core").receiveEntityRecords` instead.
- `getCategories` resolvers has been deprecated. Please use `getEntityRecords` resolver instead.
- `getCategories` resolver has been deprecated. Please use `getEntityRecords` resolver instead.
- `wp.data.select("core").getTerms` has been deprecated. Please use `wp.data.select("core").getEntityRecords` instead.
- `wp.data.select("core").getCategories` has been deprecated. Please use `wp.data.select("core").getEntityRecords` instead.
- `wp.data.select("core").isRequestingTerms` has been deprecated. Please use `wp.data.select("core").getEntitiesByKind` instead.
- `wp.data.select("core").isRequestingCategories` has been deprecated. Please use `wp.data.select("core/data").isResolving` instead.
- `wp.data.select("core").isRequestingTerms` has been deprecated. Please use `wp.data.select("core").isResolving` instead.
- `wp.data.restrictPersistence`, `wp.data.setPersistenceStorage` and `wp.data.setupPersistence` has been removed. Please use the data persistence plugin instead.

## 3.6.0

Expand Down
1 change: 0 additions & 1 deletion eslint/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module.exports = {
},
},
globals: {
wp: true,
window: true,
document: true,
},
Expand Down
62 changes: 6 additions & 56 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ function gutenberg_register_scripts_and_styles() {
'wp-data',
gutenberg_url( 'build/data/index.js' ),
array(
'wp-deprecated',
'wp-element',
'wp-compose',
'wp-is-shallow-equal',
Expand All @@ -252,15 +251,9 @@ function gutenberg_register_scripts_and_styles() {
implode(
"\n",
array(
// TODO: Transferring old storage should be removed at v3.7.
'( function() {',
' var userId = window.userSettings.uid;',
' var oldStorageKey = "WP_EDIT_POST_DATA_" + userId;',
' var storageKey = "WP_DATA_USER_" + userId;',
' if ( localStorage[ oldStorageKey ] ) {',
' localStorage[ storageKey ] = localStorage[ oldStorageKey ];',
' delete localStorage[ oldStorageKey ];',
' }',
' wp.data',
' .use( wp.data.plugins.persistence, { storageKey: storageKey } )',
' .use( wp.data.plugins.controls );',
Expand Down Expand Up @@ -368,7 +361,6 @@ function gutenberg_register_scripts_and_styles() {
'lodash',
'moment',
'wp-a11y',
'wp-api',
'wp-api-fetch',
'wp-compose',
'wp-deprecated',
Expand All @@ -384,6 +376,10 @@ function gutenberg_register_scripts_and_styles() {
filemtime( gutenberg_dir_path() . 'build/components/index.js' ),
true
);
wp_add_inline_script(
'wp-components',
sprintf( 'wp.components.unstable__setSiteURL(%s);', json_encode( site_url() ) )
);
wp_register_script(
'wp-blocks',
gutenberg_url( 'build/blocks/index.js' ),
Expand Down Expand Up @@ -612,7 +608,6 @@ function gutenberg_register_scripts_and_styles() {
'media-models',
'media-views',
'wp-a11y',
'wp-api',
'wp-api-fetch',
'wp-components',
'wp-compose',
Expand Down Expand Up @@ -965,47 +960,6 @@ function gutenberg_register_vendor_script( $handle, $src, $deps = array() ) {
);
}

/**
* Provide the components script with the required config to make withAPIData work.
*/
function gutenberg_prepare_wp_components_script() {
$schema_response = rest_do_request( new WP_REST_Request( 'GET', '/' ) );
if ( ! $schema_response->is_error() ) {
wp_add_inline_script(
'wp-components',
sprintf(
'wpApiSettings.cacheSchema = true; wpApiSettings.schema = %s;',
wp_json_encode( $schema_response->get_data() )
),
'before'
);
}

// Post Types Mapping.
$post_type_rest_base_mapping = array();
foreach ( get_post_types( array(), 'objects' ) as $post_type_object ) {
$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
$post_type_rest_base_mapping[ $post_type_object->name ] = $rest_base;
}

// Taxonomies Mapping.
$taxonomy_rest_base_mapping = array();
foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy_object ) {
$rest_base = ! empty( $taxonomy_object->rest_base ) ? $taxonomy_object->rest_base : $taxonomy_object->name;
$taxonomy_rest_base_mapping[ $taxonomy_object->name ] = $rest_base;
}

wp_add_inline_script(
'wp-components',
sprintf(
'wp.components.unstable__setApiSettings( wpApiSettings.schema, %s, %s )',
wp_json_encode( $post_type_rest_base_mapping ),
wp_json_encode( $taxonomy_rest_base_mapping )
),
'after'
);
}

/**
* Prepares server-registered blocks for JavaScript, returning an associative
* array of registered block data keyed by block name. Data includes properties
Expand Down Expand Up @@ -1218,8 +1172,6 @@ function get_block_categories( $post ) {
function gutenberg_editor_scripts_and_styles( $hook ) {
$is_demo = isset( $_GET['gutenberg-demo'] );

gutenberg_prepare_wp_components_script();

global $wp_scripts;

// Add "wp-hooks" as dependency of "heartbeat".
Expand Down Expand Up @@ -1446,10 +1398,8 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
( function() {
var editorSettings = %s;
window._wpLoadGutenbergEditor = new Promise( function( resolve ) {
wp.api.init().then( function() {
wp.domReady( function() {
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, editorSettings, window._wpGutenbergDefaultPost ) );
} );
wp.domReady( function() {
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, editorSettings, window._wpGutenbergDefaultPost ) );
} );
} );
} )();
Expand Down
19 changes: 5 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/a11y/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 1.1.0 (2018-07-12)

### New feature

- Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))

### Polish

- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805))
7 changes: 7 additions & 0 deletions packages/autop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
## 1.1.0 (2018-07-12)

### New Feature

- Updated build to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))

### Internal

- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805))

## 1.0.6 (2018-05-08)

### Polish

- Documentation: Fix API method typo for `removep`. ([#120](https://github.com/WordPress/packages/pull/120))
9 changes: 8 additions & 1 deletion packages/babel-plugin-makepot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
## 2.0.0 (2018-07-12)

- Breaking: Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))
### Breaking Change

- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))

### Internal

- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805))

## 1.0.1 (2018-05-18)

### Polish

- Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119))
Loading

0 comments on commit 80ac625

Please sign in to comment.