From 14e51e1f16b2561f00eb9f3f2bfbf17700b7ffd9 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Tue, 11 Oct 2022 15:28:08 +0000 Subject: [PATCH] Editor: Reinstate old persistence system configuration for the block editor usage data. In [54182], the configuration for the old preference persistence system was removed. This system is still used for block usage data (to show the most frequently used blocks in the inserter). Furthermore some plugins may use this persistence system. This changeset reinstates the previous persistence system used by the "Most used blocks" feature in the block inserter. Follow-up to [54182]. Props talldanwp. Fixes #56778. git-svn-id: https://develop.svn.wordpress.org/trunk@54485 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index f3014a241f..5d842f5787 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -383,6 +383,22 @@ function wp_default_packages_inline_scripts( $scripts ) { ) ); + // Backwards compatibility - configure the old wp-data persistence system. + $scripts->add_inline_script( + 'wp-data', + implode( + "\n", + array( + '( function() {', + ' var userId = ' . get_current_user_ID() . ';', + ' var storageKey = "WP_DATA_USER_" + userId;', + ' wp.data', + ' .use( wp.data.plugins.persistence, { storageKey: storageKey } );', + '} )();', + ) + ) + ); + // Calculate the timezone abbr (EDT, PST) if possible. $timezone_string = get_option( 'timezone_string', 'UTC' ); $timezone_abbr = '';