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

Hotfix/unpublished posts filter #234

Merged
merged 6 commits into from
Sep 16, 2024
Merged

Conversation

mogmarsh
Copy link
Collaborator

use array_map instead of array_filter so we hold the space for curated posts that were deleted

Copy link
Contributor

@mboynes mboynes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 an optional suggestion for you, but it's also just dandy as-is

Comment on lines 77 to 82
$pinned_posts = array_map( function ( $id ) {
if ( ! $id ) {
return null;
}
return 'publish' === get_post_status( $id ) ? $id : null;
}, $pinned_posts );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic can be simplified to $id && 'publish' === get_post_status( $id )... which means this could use an arrow function if you felt so inclined:

Suggested change
$pinned_posts = array_map( function ( $id ) {
if ( ! $id ) {
return null;
}
return 'publish' === get_post_status( $id ) ? $id : null;
}, $pinned_posts );
$pinned_posts = array_map( fn ( $id ) => $id && 'publish' === get_post_status( $id ) ? $id : null, $pinned_posts );

@mogmarsh mogmarsh merged commit dcf9298 into develop Sep 16, 2024
5 checks passed
@mogmarsh mogmarsh deleted the hotfix/unpublished-posts-filter branch September 16, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants