PluginProbe
Gutenberg / 16.6.0
Gutenberg v16.6.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / lib / experimental / interactivity-api / directives / wp-context.php

wp-context.php in Gutenberg 16.6.0, at lib/experimental/interactivity-api/directives/wp-context.php

34 lines 702 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Process wp-context directive attribute.
4 *
5 * @package wp-directives
6 */
7
8 /**
9 * Process wp-context directive attribute.
10 *
11 * @param WP_Directive_Processor $tags Tags.
12 * @param WP_Directive_Context $context Directive context.
13 */
14 function gutenberg_interactivity_process_wp_context( $tags, $context ) {
15 if ( $tags->is_tag_closer() ) {
16 $context->rewind_context();
17 return;
18 }
19
20 $value = $tags->get_attribute( 'data-wp-context' );
21 if ( null === $value ) {
22 // No data-wp-context directive.
23 return;
24 }
25
26 $new_context = json_decode( $value, true );
27 if ( null === $new_context ) {
28 // Invalid JSON defined in the directive.
29 return;
30 }
31
32 $context->set_context( $new_context );
33 }
34