|
1 | 1 | /**
|
2 | 2 | * External dependencies
|
3 | 3 | */
|
4 |
| -import { merge, isPlainObject, get } from 'lodash'; |
| 4 | +import { merge, isPlainObject, get, has } from 'lodash'; |
5 | 5 |
|
6 | 6 | /**
|
7 | 7 | * Internal dependencies
|
@@ -208,26 +208,40 @@ const persistencePlugin = function( registry, pluginOptions ) {
|
208 | 208 | };
|
209 | 209 |
|
210 | 210 | /**
|
211 |
| - * Deprecated: Remove this function once WordPress 5.3 is released. |
| 211 | + * Deprecated: Remove this function and the code in WordPress Core that calls |
| 212 | + * it once WordPress 5.4 is released. |
212 | 213 | */
|
213 | 214 |
|
214 | 215 | persistencePlugin.__unstableMigrate = ( pluginOptions ) => {
|
215 | 216 | const persistence = createPersistenceInterface( pluginOptions );
|
216 | 217 |
|
217 |
| - // Preferences migration to introduce the block editor module |
218 |
| - const insertUsage = get( persistence.get(), [ |
219 |
| - 'core/editor', |
220 |
| - 'preferences', |
221 |
| - 'insertUsage', |
222 |
| - ] ); |
| 218 | + const state = persistence.get(); |
223 | 219 |
|
| 220 | + // Migrate 'insertUsage' from 'core/editor' to 'core/block-editor' |
| 221 | + const insertUsage = get( state, [ 'core/editor', 'preferences', 'insertUsage' ] ); |
224 | 222 | if ( insertUsage ) {
|
225 | 223 | persistence.set( 'core/block-editor', {
|
226 | 224 | preferences: {
|
227 | 225 | insertUsage,
|
228 | 226 | },
|
229 | 227 | } );
|
230 | 228 | }
|
| 229 | + |
| 230 | + // Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post' |
| 231 | + const areTipsEnabled = get( state, [ 'core/nux', 'preferences', 'areTipsEnabled' ] ); |
| 232 | + const hasWelcomeGuide = has( state, [ 'core/edit-post', 'preferences', 'features', 'welcomeGuide' ] ); |
| 233 | + if ( areTipsEnabled !== undefined && ! hasWelcomeGuide ) { |
| 234 | + persistence.set( |
| 235 | + 'core/edit-post', |
| 236 | + merge( state[ 'core/edit-post' ], { |
| 237 | + preferences: { |
| 238 | + features: { |
| 239 | + welcomeGuide: areTipsEnabled, |
| 240 | + }, |
| 241 | + }, |
| 242 | + } ) |
| 243 | + ); |
| 244 | + } |
231 | 245 | };
|
232 | 246 |
|
233 | 247 | export default persistencePlugin;
|
0 commit comments