[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
(no description)
File Size: | 898 lines (30 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
debounceAsync(func, delayMS) X-Ref |
Performs a leading edge debounce of async functions. If three functions are throttled at the same time: - The first happens immediately. - The second is never called. - The third happens `delayMS` milliseconds after the first has resolved. This is distinct from `{ debounce } from @wordpress/compose` in that it waits for promise resolution. param: {Function} func A function that returns a promise. param: {number} delayMS A delay in milliseconds. return: {Function} A function that debounce whatever function is passed |
create({preloadedData,localStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',requestDebounceMS = 2500} = {}) X-Ref |
Creates a persistence layer that stores data in WordPress user meta via the REST API. param: {Object} options param: {?Object} options.preloadedData Any persisted preferences data that should be preloaded. param: {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used param: {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at return: {Object} A persistence layer for WordPress user meta. |
set(newData) X-Ref |
No description |
moveFeaturePreferences(state, sourceStoreName) X-Ref |
Move the 'features' object in local storage from the sourceStoreName to the preferences store data structure. Previously, editors used a data structure like this for feature preferences: ```js { 'core/edit-post': { preferences: { features; { topToolbar: true, // ... other boolean 'feature' preferences }, }, }, } ``` And for a while these feature preferences lived in the interface package: ```js { 'core/interface': { preferences: { features: { 'core/edit-post': { topToolbar: true } } } } } ``` In the preferences store, 'features' aren't considered special, they're merged to the root level of the scope along with other preferences: ```js { 'core/preferences': { preferences: { 'core/edit-post': { topToolbar: true, // ... any other preferences. } } } } ``` This function handles moving from either the source store or the interface store to the preferences data structure. param: {Object} state The state before migration. param: {string} sourceStoreName The name of the store that has persisted return: {Object} The migrated state |
moveThirdPartyFeaturePreferencesToPreferences(state) X-Ref |
The interface package previously had a public API that could be used by plugins to set persisted boolean 'feature' preferences. While usage was likely non-existent or very small, this function ensures those are migrated to the preferences data structure. The interface package's APIs have now been deprecated and use the preferences store. This will convert data that looks like this: ```js { 'core/interface': { preferences: { features: { 'my-plugin': { myPluginFeature: true } } } } } ``` To this: ```js * { 'core/preferences': { preferences: { 'my-plugin': { myPluginFeature: true } } } } ``` param: {Object} state The local storage state return: {Object} The state with third party preferences moved to the |
moveIndividualPreferenceToPreferences(state, {from: sourceStoreName,to: scope}, key, convert = identity) X-Ref |
Migrates an individual item inside the `preferences` object for a package's store. Previously, some packages had individual 'preferences' of any data type, and many used complex nested data structures. For example: ```js { 'core/edit-post': { preferences: { panels: { publish: { opened: true, enabled: true, } }, // ...other preferences. }, }, } This function supports moving an individual preference like 'panels' above into the preferences package data structure. It supports moving a preference to a particular scope in the preferences store and optionally converting the data using a `convert` function. ``` param: {Object} state The original state. param: {Object} migrate An options object that contains details of the migration. param: {string} migrate.from The name of the store to migrate from. param: {string} migrate.to The scope in the preferences store to migrate to. param: {string} key The key in the preferences object to migrate. param: {?Function} convert A function that converts preferences from one format to another. |
moveInterfaceEnableItems(state) X-Ref |
Migrates interface 'enableItems' data to the preferences store. The interface package stores this data in this format: ```js { enableItems: { singleEnableItems: { complementaryArea: { 'core/edit-post': 'edit-post/document', 'core/edit-site': 'edit-site/global-styles', } }, multipleEnableItems: { pinnedItems: { 'core/edit-post': { 'plugin-1': true, }, 'core/edit-site': { 'plugin-2': true, }, }, } } } ``` and it should be converted it to: ```js { 'core/edit-post': { complementaryArea: 'edit-post/document', pinnedItems: { 'plugin-1': true, }, }, 'core/edit-site': { complementaryArea: 'edit-site/global-styles', pinnedItems: { 'plugin-2': true, }, }, } ``` param: {Object} state The local storage state. |
convertEditPostPanels(preferences) X-Ref |
Convert the post editor's panels state from: ``` { panels: { tags: { enabled: true, opened: true, }, permalinks: { enabled: false, opened: false, }, }, } ``` to a new, more concise data structure: { inactivePanels: [ 'permalinks', ], openPanels: [ 'tags', ], } param: {Object} preferences A preferences object. return: {Object} The converted data. |
getLegacyData(userId) X-Ref |
Gets the legacy local storage data for a given user. param: {string | number} userId The user id. return: {Object | null} The local storage data. |
convertLegacyData(data) X-Ref |
Converts data from the old `@wordpress/data` package format. param: {Object | null | undefined} data The legacy data in its original format. return: {Object | undefined} The converted data or `undefined` if there was |
convertLegacyLocalStorageData(userId) X-Ref |
Gets the legacy local storage data for the given user and returns the data converted to the new format. param: {string | number} userId The user id. return: {Object | undefined} The converted data or undefined if no local |
convertComplementaryAreas(state) X-Ref |
No description |
convertEditorSettings(data) X-Ref |
Internal dependencies |
convertPreferencesPackageData(data) X-Ref |
Internal dependencies |
__unstableCreatePersistenceLayer(serverData, userId) X-Ref |
Creates the persistence layer with preloaded data. It prioritizes any data from the server, but falls back first to localStorage restore data, and then to any legacy data. This function is used internally by WordPress in an inline script, so prefixed with `__unstable`. param: {Object} serverData Preferences data preloaded from the server. param: {string} userId The user id. return: {Object} The persistence layer initialized with the preloaded data. |
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |