Changeset 57641 for trunk/src/wp-includes/block-bindings/post-meta.php
- Timestamp:
- 02/16/2024 12:53:16 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-bindings/post-meta.php
r57526 r57641 14 14 * @access private 15 15 * 16 * @param array $source_args Array containing source arguments used to look up the override value. 17 * Example: array( "key" => "foo" ). 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. 18 19 * @return mixed The value computed for the source. 19 20 */ 20 function _block_bindings_post_meta_get_value( array $source_args ) {21 if ( ! isset( $source_args['key'] ) ) {21 function _block_bindings_post_meta_get_value( array $source_args, $block_instance ) { 22 if ( empty( $source_args['key'] ) ) { 22 23 return null; 23 24 } 24 25 25 // Use the postId attribute if available. 26 if ( isset( $source_args['postId'] ) ) { 27 $post_id = $source_args['postId']; 28 } else { 29 // $block_instance->context['postId'] is not available in the Image block. 30 $post_id = get_the_ID(); 26 if ( empty( $block_instance->context['postId'] ) ) { 27 return null; 31 28 } 29 $post_id = $block_instance->context['postId']; 32 30 33 31 // If a post isn't public, we need to prevent unauthorized users from accessing the post meta. … … 52 50 'label' => _x( 'Post Meta', 'block bindings source' ), 53 51 'get_value_callback' => '_block_bindings_post_meta_get_value', 52 'uses_context' => array( 'postId', 'postType' ), 54 53 ) 55 54 );
Note: See TracChangeset
for help on using the changeset viewer.