Opened 6 years ago
Closed 6 years ago
#46795 closed defect (bug) (fixed)
Fatal error: Call to undefined function get_available_post_mime_types on frontend
Reported by: | david.binda | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | 5.2 | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Hello there,
When testing r44947 from #43658 I'm getting following fatal error:
Fatal error: Uncaught Error: Call to undefined function get_available_post_mime_types() in wp-includes/media.php:3612
The above fatal error can be reproduced using the P2 theme, since it includes wp-includes/media.php
and calls do_action( 'media_buttons' );
which calls wp_enqueue_media
in a non-admin context / on front-end.
Since the r44947 any call to wp_enqueue_media
on front-end would result in the above fatal error.
To solve the issue, the get_available_post_mime_types
function, imho, needs to be moved to some more commonly available file, eg.: wp-includes/post.php
.
Attachments (1)
Change History (9)
#4
@
6 years ago
@davidbinda moving this seems fine, wondering if there is any chance code could expect the function where it is and fatal after this move? Another approach would be load the existing file on the fly if the function is not available.
#5
@
6 years ago
- Keywords has-patch 2nd-opinion added
- Owner set to adamsilverstein
- Status changed from new to assigned
Testing the P2 theme I can see the fatal and I verified it is resolved by the patch. i do see wp_enqueue_media
is generally intended for back end use however get_available_post_mime_types gets far less use in plugins and themes.
I'd like to get a second opinion on this change to make sure I am not missing a potential side effect.
#6
@
6 years ago
- Keywords commit added; 2nd-opinion removed
I see no reason why this function needs to be limited to an admin context and can imagine many reasons why someone might want to get this information on the front end. +1 from me.
@adamsilverstein Can you take a look as this is a follow up to [44947] and #43658.