Diff: STRATO-apps/wordpress_03/app/wp-includes/block-bindings/pattern-overrides.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Pattern Overrides source for the Block Bindings.
4 + *
5 + * @since 6.5.0
6 + * @package WordPress
7 + * @subpackage Block Bindings
8 + */
9 +
10 + /**
11 + * Gets value for the Pattern Overrides source.
12 + *
13 + * @since 6.5.0
14 + * @access private
15 + *
16 + * @param array $source_args Array containing source arguments used to look up the override value.
17 + * Example: array( "key" => "foo" ).
18 + * @param WP_Block $block_instance The block instance.
19 + * @param string $attribute_name The name of the target attribute.
20 + * @return mixed The value computed for the source.
21 + */
22 + function _block_bindings_pattern_overrides_get_value( array $source_args, $block_instance, string $attribute_name ) {
23 + if ( empty( $block_instance->attributes['metadata']['name'] ) ) {
24 + return null;
25 + }
26 + $metadata_name = $block_instance->attributes['metadata']['name'];
27 + return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $metadata_name, $attribute_name ), null );
28 + }
29 +
30 + /**
31 + * Registers Pattern Overrides source in the Block Bindings registry.
32 + *
33 + * @since 6.5.0
34 + * @access private
35 + */
36 + function _register_block_bindings_pattern_overrides_source() {
37 + register_block_bindings_source(
38 + 'core/pattern-overrides',
39 + array(
40 + 'label' => _x( 'Pattern Overrides', 'block bindings source' ),
41 + 'get_value_callback' => '_block_bindings_pattern_overrides_get_value',
42 + 'uses_context' => array( 'pattern/overrides' ),
43 + )
44 + );
45 + }
46 +
47 + add_action( 'init', '_register_block_bindings_pattern_overrides_source' );
48 +