Ticket #11976 (closed defect (bug): fixed)
wp_iframe() style inclusion when using objects/methods
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Media | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | vericgar |
Description
Small bug in wp_iframe() pertaining to the inclusion of the media stylesheet. The determination of whether to include the media stylesheet is based on the assumption that the callback passed to wp_iframe() is a function name and ignores the possibility of inclusion of a class/method array pair.
Attached patch corrects this problem.
Attachments
Change History
- Keywords has-patch added; css wp-admin media removed
- Component changed from General to Media
- Milestone changed from Unassigned to 3.0
It would probably be better to rewrite the logic of the function, which is a mess: Allowing an indefinite number and arrangement of arguments; assuming the function is a string in one place but checking whether it is in another. None of which is necessary since almost all of the media_* functions have a similar argument structure.
And this is a good example of how having PHP 5 would help make things more robust. You could make the media functions to be objects that implement a media interface. Type hinting in wp_iframe would cover the necessary check, and then you could use the sub-classed media object to enqueue scripts, provide class names, or whatever.
/rant
comment:4
technosailor — 2 years ago
I think what you're expressing is having a generic media object that could be extended by a variety of extension classes. WordPress would come bundled with the class that extends the media object to create the default media upload interface but a different subclass could be provided via plugin, such as is done now when creating widgets with the new Widget API.
I don't think you need PHP 5 for that. But your point is well received that PHP 5 would make it easier. Unfortunately, I don't have the time to rewrite the whole damn function but wouldn't mind if it was because, you're right, it's a nasty mess. The patch I provided is low hanging fruit to get the bug, as it exists now, fixed up.
- Owner changed from technosailor to nacin
- Status changed from new to accepted
- Status changed from accepted to closed
- Resolution set to fixed
- Cc vericgar added
- Status changed from closed to reopened
- Resolution fixed deleted
I just ran into this bug using Wordpress 3.0.1
The fix provided has a small logic error, and causes this message when WP_DEBUG is on:
Notice: Array to string conversion in [omitted]/wp-admin/includes/media.php on line 310
I will attach another patch.

