From a2dcbcfbfe25f548a969f9d067d94d253d468ca3 Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Thu, 14 Mar 2024 10:03:57 -0400 Subject: [PATCH] Re-introduce `data_wp_context()` with `_deprecated_function()` call (#59834) * Re-introduce `data_wp_context()` with `_deprecated_function()` call Following its removal in https://github.com/WordPress/gutenberg/pull/59465 and release in Gutenberg 17.9, this can potentially result in fatal errors on sites where plugins or themes are calling `data_wp_context()` instead of the newer function name. This should backfill it in, and provide a reminder to update to the newer function. * Typo'd version number. * Adding deprecated to phpdoc. --------- Co-authored-by: georgestephanis Co-authored-by: c4rl0sbr4v0 --- .../interactivity-api/interactivity-api.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php index c4c0ac37519f4..aa0f66a54fb65 100644 --- a/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php +++ b/lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php @@ -182,3 +182,24 @@ function wp_interactivity_data_wp_context( array $context, string $store_namespa '\''; } } + +if ( ! function_exists( 'data_wp_context' ) ) { + /** + * `data_wp_context()` was renamed to follow WordPress Core naming schemes. + * + * @link https://github.com/WordPress/gutenberg/pull/59465/ + * @link https://core.trac.wordpress.org/ticket/60575 + * + * @since 6.5.0 + * @deprecated 6.5.0 + * + * @param array $context The array of context data to encode. + * @param string $store_namespace Optional. The unique store namespace identifier. + * @return string A complete `data-wp-context` directive with a JSON encoded value representing the context array and + * the store namespace if specified. + */ + function data_wp_context( array $context, string $store_namespace = '' ): string { + _deprecated_function( __FUNCTION__, '6.5', 'wp_interactivity_data_wp_context()' ); + return wp_interactivity_data_wp_context( $context, $store_namespace ); + } +}