: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const allSourcePreferences = state?.[sourceStoreName]?.preferences;
// Pass an object with the key and value as this allows the convert
// function to convert to a data structure that has different keys.
const convertedPreferences = convert({
[preferencesStoreName]: {
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js
* Migrates interface 'enableItems' data to the preferences store.
* The interface package stores this data in this format:
* 'core/edit-post': 'edit-post/document',
* 'core/edit-site': 'edit-site/global-styles',
* and it should be converted it to:
* complementaryArea: 'edit-post/document',
* complementaryArea: 'edit-site/global-styles',
* @param {Object} state The local storage state.
function moveInterfaceEnableItems(state) {
var _state$preferencesSto, _sourceEnableItems$si, _sourceEnableItems$mu;
const interfaceStoreName = 'core/interface';
const preferencesStoreName = 'core/preferences';
const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
// There's nothing to migrate, exit early.
if (!sourceEnableItems) {
const allPreferences = (_state$preferencesSto = state?.[preferencesStoreName]?.preferences) !== null && _state$preferencesSto !== void 0 ? _state$preferencesSto : {};
// First convert complementaryAreas into the right format.
// Use the existing preferences as the accumulator so that the data is
const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems?.singleEnableItems?.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {};
const preferencesWithConvertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
const data = sourceComplementaryAreas[scope];
// Don't overwrite any existing data in the preferences store.
if (accumulator?.[scope]?.complementaryArea) {
// Next feed the converted complementary areas back into a reducer that
// converts the pinned items, resulting in the fully migrated data.
const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems?.multipleEnableItems?.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {};
const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
const data = sourcePinnedItems[scope];
// Don't overwrite any existing data in the preferences store.
if (accumulator?.[scope]?.pinnedItems) {
}, preferencesWithConvertedComplementaryAreas);
const otherInterfaceItems = state[interfaceStoreName];
[preferencesStoreName]: {
preferences: allConvertedData
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.js
* Convert the post editor's panels state from:
* to a new, more concise data structure:
* @param {Object} preferences A preferences object.
* @return {Object} The converted data.
function convertEditPostPanels(preferences) {
const panels = (_preferences$panels = preferences?.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {};
return Object.keys(panels).reduce((convertedData, panelName) => {
const panel = panels[panelName];
if (panel?.enabled === false) {
convertedData.inactivePanels.push(panelName);
if (panel?.opened === true) {
convertedData.openPanels.push(panelName);
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/index.js
* Gets the legacy local storage data for a given user.
* @param {string | number} userId The user id.
* @return {Object | null} The local storage data.
function getLegacyData(userId) {
const key = `WP_DATA_USER_${userId}`;
const unparsedData = window.localStorage.getItem(key);
return JSON.parse(unparsedData);
* 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
function convertLegacyData(data) {
// Move boolean feature preferences from each editor into the
// preferences store data structure.
data = moveFeaturePreferences(data, 'core/edit-widgets');
data = moveFeaturePreferences(data, 'core/customize-widgets');
data = moveFeaturePreferences(data, 'core/edit-post');
data = moveFeaturePreferences(data, 'core/edit-site');
// Move third party boolean feature preferences from the interface package
// to the preferences store data structure.
data = moveThirdPartyFeaturePreferencesToPreferences(data);
// Move and convert the interface store's `enableItems` data into the
// preferences data structure.
data = moveInterfaceEnableItems(data);
// Move individual ad-hoc preferences from various packages into the
// preferences store data structure.
data = moveIndividualPreferenceToPreferences(data, {
data = moveIndividualPreferenceToPreferences(data, {
data = moveIndividualPreferenceToPreferences(data, {
}, 'panels', convertEditPostPanels);
data = moveIndividualPreferenceToPreferences(data, {
}, 'isPublishSidebarEnabled');
data = moveIndividualPreferenceToPreferences(data, {
}, 'isPublishSidebarEnabled');
data = moveIndividualPreferenceToPreferences(data, {
// The new system is only concerned with persisting
// 'core/preferences' preferences reducer, so only return that.
return data?.['core/preferences']?.preferences;
* 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
* storage data could be found.
function convertLegacyLocalStorageData(userId) {
const data = getLegacyData(userId);
return convertLegacyData(data);
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/convert-complementary-areas.js
function convertComplementaryAreas(state) {
return Object.keys(state).reduce((stateAccumulator, scope) => {
const scopeData = state[scope];
// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.
if (scopeData?.complementaryArea) {
const updatedScopeData = {
delete updatedScopeData.complementaryArea;
updatedScopeData.isComplementaryAreaVisible = true;
stateAccumulator[scope] = updatedScopeData;
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/convert-editor-settings.js
function convertEditorSettings(data) {
var _newData$coreEditPo, _newData$coreEditSi;
const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
settingsToMoveToCore.forEach(setting => {
if (data?.['core/edit-post']?.[setting] !== undefined) {
[setting]: data['core/edit-post'][setting]
delete newData['core/edit-post'][setting];
if (data?.['core/edit-site']?.[setting] !== undefined) {
delete newData['core/edit-site'][setting];
if (Object.keys((_newData$coreEditPo = newData?.['core/edit-post']) !== null && _newData$coreEditPo !== void 0 ? _newData$coreEditPo : {})?.length === 0) {
delete newData['core/edit-post'];
if (Object.keys((_newData$coreEditSi = newData?.['core/edit-site']) !== null && _newData$coreEditSi !== void 0 ? _newData$coreEditSi : {})?.length === 0) {
delete newData['core/edit-site'];
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/index.js
function convertPreferencesPackageData(data) {
let newData = convertComplementaryAreas(data);
newData = convertEditorSettings(newData);
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/index.js
* 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.
function __unstableCreatePersistenceLayer(serverData, userId) {
const localStorageRestoreKey = `WP_PREFERENCES_USER_${userId}`;
const localData = JSON.parse(window.localStorage.getItem(localStorageRestoreKey));
// Date parse returns NaN for invalid input. Coerce anything invalid
// into a conveniently comparable zero.
const serverModified = Date.parse(serverData && serverData._modified) || 0;
const localModified = Date.parse(localData && localData._modified) || 0;
if (serverData && serverModified >= localModified) {
preloadedData = convertPreferencesPackageData(serverData);
preloadedData = convertPreferencesPackageData(localData);
// Check if there is data in the legacy format from the old persistence system.
preloadedData = convertLegacyLocalStorageData(userId);
(window.wp = window.wp || {}).preferencesPersistence = __webpack_exports__;