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

when fetching posts for items, exclude drafts #101

Merged
merged 5 commits into from
Sep 28, 2018

Conversation

mnelson4
Copy link
Contributor

When fetching posts from the project organizer, exclude draft posts by default. Specifically, only include published, pending, future, and private posts.
Maybe we should only include published and private posts by default, though?
Or maybe we should have a group of checkboxes (or multi-select) to show all the post statuses to choose from?
This isn't really meant to be the final PR, this is mostly meant to just get the ball rolling.

@mnelson4
Copy link
Contributor Author

this is a PR for issue #98

@boonebgorges
Copy link
Collaborator

Thanks for starting this. I'm guessing that, in the vast majority of cases, public and private will be enough. I wouldn't want to go to the trouble of introducing new UI for the very rare case where someone wants to include future or pending items (or items from custom statuses). On the flip side, I'd wager that most sites have so few items in future and pending that it doesn't actually do any harm to include them in the query. So, my inclination is to go with all four status, but run it through apply_filters() so that anyone who really wants the to change the behavior can do so via plugin. Seem reasonable?

@mnelson4
Copy link
Contributor Author

Yeah that seems fine by me. I added a filter so the post statuses could be changed easily. I put the same filter in two spots, which seems a bit weird to me. Normally, I'd put that logic into a function/method, and add the filter onto its return value, and call it from the two spots. But I'm not sure if we want to embark on that extra bit of refactoring here...

Copy link
Collaborator

@boonebgorges boonebgorges left a comment

Choose a reason for hiding this comment

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

@mnelson4 Thanks for working on this! The technique looks good to me. Since we're using the same filter in two places, would you mind moving the logic into a standalone function (maybe in functions.php)? That'll also make it easier to add the proper hook documentation.

'order' => 'DESC'
'order' => 'DESC',
'post_status' => apply_filters(
'anth_included_post_stasuses',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we please change this to 'anthologize_source_item_post_statuses'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@mnelson4
Copy link
Contributor Author

yeah I'll give it a shot

@mnelson4
Copy link
Contributor Author

I presumptuously added a new method to Anthologize_Project_Organizer instead of to functions.php because it seemed to be in that vein, and the class was easily available for the two places we want to use it. But I'm totally not offended if you'd still rather it be in functions.php.
Also, I notice a lot of the other filters used the prefix anth_ instead of anthologize_ (also they didn't have the normal php doc above them). Is that just old code, nowadays we'd rather filters start with anthologize_?

Copy link
Collaborator

@boonebgorges boonebgorges left a comment

Choose a reason for hiding this comment

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

Perfect! Thank you.

@boonebgorges
Copy link
Collaborator

Also, I notice a lot of the other filters used the prefix anth_ instead of anthologize_ (also they didn't have the normal php doc above them). Is that just old code, nowadays we'd rather filters start with anthologize_?

Ah, I hadn't noticed. In general, best to use the whole unique identifier, unless there are character limits (like the 20-character limit on post type names, thus anth_library_item.)

@boonebgorges boonebgorges merged commit 0c18863 into chnm:master Sep 28, 2018
@mnelson4 mnelson4 deleted the exclude-drafts branch September 28, 2018 16:38
@mnelson4
Copy link
Contributor Author

👍

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.

None yet

2 participants