Opened 15 years ago
Closed 14 years ago
#8657 closed enhancement (wontfix)
add filter to get_post_status() to allow overriding the status of objects
Reported by: | DD32 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.7 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
At present, For an attachment to be visible on the front end, The attachment needs to be either attached to a published post, or the user needs to be logged in and be able to edit the attachment.
Sometimes this'll cause problems with those designing websites focused around attachment items (A Unique Photo-orientated site for example, focused around Images rather than Posts)
While there are a lot of issues (in my mind) of separate interlinked issues with having attachments published on the front end, They can all be worked around, Aside from get_post_status()
returning false for attachments, This ends up causing a 404 for non-attachment-editors/non-logged-in-users; Attaching a filter to this will allow for being able to set a attachment as 'publish'ed while not modifying the way the rest of the wordpress media management works, Eg:
add_filter('post_status-attachment', 'theme_attachment_publish'); function theme_attachment_publish($status) { return is_admin() ? $status : 'publish'; }
Attachments (2)
Change History (15)
#5
@
15 years ago
- Keywords tested commit removed
You shouldn't do an is_integer check on the post id for get_post_type(). Because PHP is loosely typed, WordPress ends up passing around as strings a lot of things that look and act like integers. So checking that the id is actually an integer is going to produce some perplexing bugs somewhere.
#6
follow-up:
↓ 8
@
15 years ago
Also, aren't there better, existing ways to solve the main problem?
It seems like you're changing the business logic to solve a presentation logic problem.
#8
in reply to:
↑ 6
@
15 years ago
- Keywords dev-feedback added
Replying to filosofo:
Also, aren't there better, existing ways to solve the main problem?
It seems like you're changing the business logic to solve a presentation logic problem.
isn't there a workflow issue underneath that is causing issues?
#13
@
14 years ago
- Milestone 3.0 deleted
- Resolution set to wontfix
- Status changed from new to closed
I'm closing as wontfix instead.
A filter would be handy in some cases, especially in the outlined case. However, There are better ways to achieve that hack than this.
I'm only closing this in the hope that 3.1 will bring a change to media that allows them to be treated as first class citizens rather than the Tag-alongs that they are now.
The modification to
get_post_type()
was made to allow passing of a $post object to the function, It seems the (int) check was preventing the $post object being passed as originally intended.