0 ], $atts, 'alert_box' ); $pid = absint( $atts['id'] ); if ( ! $pid ) { return ''; } $post = get_post( $pid ); if ( ! $post || ABB_PostType::POST_TYPE !== $post->post_type ) { return ''; } if ( post_password_required( $post ) ) { return get_the_password_form( $post ); } $can_view = false; switch ( $post->post_status ) { case 'publish': $can_view = true; break; case 'private': $can_view = current_user_can( 'read_private_posts' ); break; case 'draft': case 'pending': case 'future': $can_view = current_user_can( 'edit_post', $pid ); break; } if ( ! $can_view ) { return ''; } // The one alert block — the free Alert Box or a Pro block chosen in the // "Alert Block" panel (skip any whitespace-only "freeform" entries // parse_blocks may add). foreach ( parse_blocks( $post->post_content ) as $block ) { if ( ! empty( $block['blockName'] ) ) { return render_block( $block ); } } return ''; } } }