Skip to content

Commit

Permalink
Re-introduce data_wp_context() with _deprecated_function() call (W…
Browse files Browse the repository at this point in the history
…ordPress#59834)

* Re-introduce `data_wp_context()` with `_deprecated_function()` call

Following its removal in WordPress#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 <georgestephanis@git.wordpress.org>
Co-authored-by: c4rl0sbr4v0 <cbravobernal@git.wordpress.org>
  • Loading branch information
3 people authored and carstingaxion committed Mar 27, 2024
1 parent 7eaac3d commit a2dcbcf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

0 comments on commit a2dcbcf

Please sign in to comment.