Opened 8 years ago
Closed 8 years ago
#43125 closed defect (bug) (fixed)
Deregistering WP_Widget_Media_Image breaks Text widget's "Add Media" button
| Reported by: | standardspace | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9.3 |
| Component: | Widgets | Version: | 4.9 |
| Severity: | normal | Keywords: | has-patch commit fixed-major |
| Cc: | Focuses: |
Description
Using:
<?php unregister_widget( 'WP_Widget_Media_Image' );
results in Text widget's "Add Media" button no longer working.
Attachments (1)
Change History (13)
#3
@
8 years ago
- Resolution → invalid
- Status new → closed
You're correct.
Sorry, I could have tried it with a standard theme. I guess the bug is with my code.
Please feel free to close.
#5
@
8 years ago
- Resolution invalid
- Status closed → reopened
I've investigated further and found that the "Add Media" button fails unless one of the Media widgets is active.
Adding this to the Twenty Seventeen theme:
<?php add_action( 'widgets_init', function() { unregister_widget( 'WP_Widget_Media_Image' ); unregister_widget( 'WP_Widget_Media_Audio' ); unregister_widget( 'WP_Widget_Media_Video' ); unregister_widget( 'WP_Widget_Media_Gallery' ); } );
causes the "Add Media" button to fail.
Looks like the required javascript may not be loaded when there are no "media" widgets present. This leaves the Text widget without the add media functionality.
#6
@
8 years ago
- Keywords needs-patch added
- Milestone → 4.9.3
- Version 4.9.2 → 4.9
Indeed. I just tested this using WP Widget Disable and am getting the same result now. That's certainly unexpected.
Adding to the 4.9.3 milestone for visibility, but needs a patch to get into that release.
#7
@
8 years ago
- Keywords has-patch added; needs-patch removed
@standardspace would you please try 43125.0.diff?
#8
@
8 years ago
Hi @westonruter,
I've tested that on a clean wp install all seems to work as I would expect.
I've added the following to my functions.php :
<?php add_action( 'widgets_init', function() { unregister_widget( 'WP_Widget_Media_Image' ); unregister_widget( 'WP_Widget_Media_Audio' ); unregister_widget( 'WP_Widget_Media_Video' ); unregister_widget( 'WP_Widget_Media_Gallery' ); } );
and the Text widget's "Add Media" was able to function without the other media widgets present.
Looks like a fix. Thanks
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hey there
Welcome to WordPress Trac!
I cannot reproduce this using
The "Add Media" button in the text widget is still there and I can successfully upload and insert images to the text widget.
Have you tried disabling all plugins and using a default theme to see if the error persists?