# gutenberg/17.2.1/lib/experimental/interactivity-api/directives/wp-context.php

Gutenberg, version 17.2.1. 29 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/17.2.1/code/lib/experimental/interactivity-api/directives/wp-context.php
- Raw: https://pluginprobe.com/plugins/gutenberg/17.2.1/raw/lib/experimental/interactivity-api/directives/wp-context.php
- Modified: 2023-10-25T15:46:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/17.2.1/code/lib/experimental/interactivity-api/directives/wp-context.php#L10-L20`.

```php
<?php
/**
 * Process wp-context directive attribute.
 *
 * @package wp-directives
 */

/**
 * Process wp-context directive attribute.
 *
 * @param WP_Directive_Processor $tags Tags.
 * @param WP_Directive_Context   $context Directive context.
 */
function gutenberg_interactivity_process_wp_context( $tags, $context ) {
	if ( $tags->is_tag_closer() ) {
		$context->rewind_context();
		return;
	}

	$value = $tags->get_attribute( 'data-wp-context' );

	$new_context = json_decode(
		is_string( $value ) && ! empty( $value ) ? $value : '{}',
		true
	);

	$context->set_context( $new_context ?? array() );
}

```
