-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Framework: Remove deprecations slated for 3.7 removal #9163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
871e66b
f998f2f
bc12383
06813fb
7e99890
e5a5024
9f1afaa
dd6253b
96ff92f
9b12f66
4571e6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought: I wish there was an easy way to package the unstable pieces in one place, ala python's Publishing a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What would be the proposed advantage of this pattern?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To centralize the unstable APIs in a way that's clearly communicated and maintained. At the moment, we are using different name patterns (
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget 😆
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has already happened! 😅 |
||
| siteURL = url; | ||
| } | ||
|
|
||
| function loadScript() { | ||
| return new Promise( ( resolve, reject ) => { | ||
| const handles = [ 'wp-codemirror', 'code-editor', 'htmlhint', 'csslint', 'jshint' ]; | ||
|
|
@@ -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; | ||
|
|
||
|
|
@@ -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; | ||
|
|
||
|
|
||
| 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'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ module.exports = { | |
| }, | ||
| }, | ||
| globals: { | ||
| wp: true, | ||
| window: true, | ||
| document: true, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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', | ||
|
|
@@ -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 );', | ||
|
|
@@ -368,7 +361,6 @@ function gutenberg_register_scripts_and_styles() { | |
| 'lodash', | ||
| 'moment', | ||
| 'wp-a11y', | ||
| 'wp-api', | ||
| 'wp-api-fetch', | ||
| 'wp-compose', | ||
| 'wp-deprecated', | ||
|
|
@@ -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' ), | ||
|
|
@@ -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', | ||
|
|
@@ -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 | ||
|
|
@@ -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". | ||
|
|
@@ -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() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty happy about this one :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Next to eliminate |
||
| 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 ) ); | ||
| } ); | ||
| } ); | ||
| } )(); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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)) |
| 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)) |
| 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside: I was excited for a moment that we'd removed our last global. Then I saw we still have
wpineslint/config.js. Looking at remaining usage, I'm inclined to think we should just update those remaining few to at least point towindow.wpso we can remove / discourage any other use of the global.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it looks like there's no direct
wpglobal usage anymore.Edit: There is but it's not being caught by eslint when I removed the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see some
wp.oldEditorandwp.codeEditor?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, not sure why eslint is not catching them when I remove the global from
eslint/config.jsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that I removed the global from the config and the test is still passing. Any idea why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's
eslint-config-wordpress:https://github.com/WordPress-Coding-Standards/eslint-config-wordpress/blob/73a8d0a67ef714159b2df2aa16ce4d9180162761/index.js#L13
The
falsevalue is a bit misleading. It means that the variable is considered a global, but it's not allowed to be replaced:https://eslint.org/docs/user-guide/configuring#specifying-globals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of
falseis a bit frustrating as well because it makes it unclear how a project like ours could override the default config to disallow the global. Maybe worth discussing in tomorrow's JS chat?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already said we'd provide a new eslint package in Gutenberg with the updated guidelines discussed in previous meetings. We can remove these globals entirely from this new package.
We can discuss removing the globals altogether (as part of our new JS coding standards for ESnext)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still an open question as to whether
wpwould be a global we want to include in the default configuration, assuming a plugin might expect to use those globals rather than import from npm packages.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, maybe we should keep it and just override it in Gutenberg (if possible).