Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new filter "render_block_core_navigation_link_allowed_post_status" #63181

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/block-library/src/navigation-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,22 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
// Don't render the block's subtree if it is a draft or if the ID does not exist.
if ( $is_post_type && $navigation_link_has_id ) {
$post = get_post( $attributes['id'] );
if ( ! $post || 'publish' !== $post->post_status ) {
/**
* Filter allowed post_status for navigation link block to render.
*
* @since 6.7.0
getdave marked this conversation as resolved.
Show resolved Hide resolved
*
* @param array $post_status
* @param array $attributes
* @param WP_Block $block
*/
$allowed_post_status = (array) apply_filters(
'render_block_core_navigation_link_allowed_post_status',
array( 'publish' ),
$attributes,
$block
);
if ( ! $post || ! in_array( $post->post_status, $allowed_post_status, true ) ) {
return '';
}
}
Expand Down
Loading