#33128 closed defect (bug) (wontfix)
admin_menu not called when attachment form is loaded in a frame
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5 |
Component: | Media | Keywords: | |
Focuses: | ui, administration | Cc: |
Description
I used to register attachment_fields_to_edit and attachment_fields_to_save hooks during the admin_menu hook, and until recently it was working without a problem
However, at some point the core changed and when the attachment form is loaded in a frame, the admin_menu hooks are only executed when the page is loaded the first time.
When changes to the custom fields are committed (via JS on focus change) the page is posted and refreshed but admin_menu is not called again, thus the fields simply disappear and are not saved.
Now I have to register those hooks during admin_init, which is fine, however the behavior with admin_menu is not backward compatible and inconsistent. It makes sense that admin_menu wouldn't be called at all inside a frame, but the way it works now is confusing
Change History (6)
#2
@
10 years ago
the issue is that it was called anyway, and my code was working perfectly, until a recent release (4.2 probably) and now it's only called the first time the form is loaded but it's not called after the POST to update the data.
so, leaving aside that there was a non backward-compatible change, the fact that it is called only once is either inconsistent (it shouldn't be called at all) or a bug (it should also be called when the form is posted, like it was before)
#3
follow-up:
↓ 4
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
- Version changed from 4.2.2 to 3.5
Like @SergeyBiryukov said, 'admin_menu'
is only intended to run when the Admin Menu is being created, that's it. I'm sorry if that's where you were hooking previously, but it not firing when the modal / frame loads is not a breaking change. Unrelated contexts.
#4
in reply to:
↑ 3
@
10 years ago
Replying to wonderboymusic:
Like @SergeyBiryukov said,
'admin_menu'
is only intended to run when the Admin Menu is being created, that's it. I'm sorry if that's where you were hooking previously, but it not firing when the modal / frame loads is not a breaking change. Unrelated contexts.
In that case why is it firing the first time the frame is loaded (there's no menu in the frame) but not in the subsequent JS calls.
I will add that I used admin_menu to hook because this is what is documented everywhere you can find an example about adding custom fields to the media upload page. It was working, it's not working anymore, that's a breaking change whatever the reason for it.
#5
follow-up:
↓ 6
@
10 years ago
I will add that I used admin_menu to hook because this is what is documented everywhere you can find an example about adding custom fields to the media upload page
Where?
#6
in reply to:
↑ 5
@
10 years ago
Replying to wonderboymusic:
I will add that I used admin_menu to hook because this is what is documented everywhere you can find an example about adding custom fields to the media upload page
Where?
sorry, my bad, I mixed that up with another tutorial...
The admin_menu action is designed to run after the administration menu structure is set up, and before the menu is displayed.
It's not related in any way to the media frame, so I'm not sure I see the issue. Looks like
admin_init
is the proper action here.