Skip to content

Commit

Permalink
Add check in post meta source
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jan 30, 2024
1 parent 4a0b155 commit f3f8f78
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/compat/wordpress-6.5/block-bindings/sources/post-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ function gutenberg_block_bindings_post_meta_callback( $source_attrs ) {
$post_id = get_the_ID();
}

// If a post isn't public, we need to prevent
// unauthorized users from accessing the post meta.
$post = get_post( $post_id );
if ( ( $post && 'publish' !== $post->post_status && ! current_user_can( 'read_post', $post_id ) ) || post_password_required( $post_id ) ) {
return null;
}

return get_post_meta( $post_id, $source_attrs['key'], true );
}

Expand Down

0 comments on commit f3f8f78

Please sign in to comment.