One way around this I’ve discovered since posting the above question is to instantiate inline via WP_Widget::form()
, with wp_enqueue_script()
loading the necessary JavaScript (exactly as mentioned above) — except, and here’s the key part, load the JavaScript in the header instead of the footer (fifth argument of wp_enqueue_script()
).
Which makes a lot of sense now that I think about it.
Even still, I hate using inline JavaScript — ever — and loading everything in the header is less than ideal.
As such, am leaving this question open in case anyone has a better idea.
Related Posts:
- WordPress 4.8: Using multiple WYSIWYG-Editors with media inside of Widgets how to?
- AJAX Contact Form Issue
- jQuery UI inside widget on admin page
- How do I pass the id of my widget to javascript in the form function?
- Render repeatable widget fields properly with Backbone.js
- Executing Javascript When a Widget is Added in the Backend
- Loading scripts only if a particular shortcode or widget is present
- changing wp-admin/widgets.php
- How to refresh Theme Customizer after change color inside wpColorPicker?
- How to Remove All Widgets from Dashboard?
- How can I delete all inactive widgets?
- How to Use JSON With AJAX?
- Completely disabling widgets
- add_page_menu to make shortcut to widgets
- How to get sidebar’s content inside admin-ajax?
- Remove/Add widgets from/to the Available Widgets pool
- wp-admin AJAX with Fetch API is done without user
- Run JS after widget settings are saved?
- How can I use AJAX to save/update a widget form?
- Widget code is not working on WordPress.com Hosted Blogs
- Include chat (HTML, js, css) in all pages of WordPress
- How to determine the number of widgets contained in a sidebar via customizer JS
- WP_enqueue_script() loads them always in wp_footer()?
- Add field to dashboard to update embedded URL on homepage?
- Dashboard Widgets – Add Admin Page With Same Functionality
- Drafts widget for admin page
- wp.template() returns tags in Ajax response
- Access Customizer widget instance form
- Issue understanding and using WordPress filters and actions
- Grabbing how Many Posts by Month for a Dashboard Widget
- Validating widget’s configuration data on Admin page
- Unable to load “wpColorPicker” on theme customize page
- wordpress widget missing jquery
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Custom widget is not appearing in the admin area
- How to remove Help tab and the Dashboard widget area’s empty border
- Widget page stopped loading
- How to add Ajax to the default widget calendar to support next/previous months loading?
- Issue with checked() echoing on to page
- Calling PHP function with AJAX
- Reload widget with AJAX
- Widget outputting JS as plain text
- admin-ajax.php & my wp-admin folder url showing in header
- Simple SCript Not Displayed in WIdth
- Loading scripts only if a particular shortcode or widget is present
- Handling dozens of sidebars
- Widget Admin page and Javascript enqueuing
- Widget stuck at particular point when dragging to bottom
- Widget Areas Still Appearing in WP ADMIN When They Shouldn’t
- Using AJAX in WordPress Widget
- how to use get_field_name in external ajax handler
- List.js inside WordPress widget
- Add text to Text Widget using Javascript
- jQuery “on” handler does not fire on newly inserted widgets [closed]
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]
- Adding Widgets to Draft Pages
- Add default widgets to footer
- Query in query for Widget
- Mapping Backbone Models to serialized array in wp_options table
- How to display first post thumbnail as a background image of a widget?
- custom widget does not saved value
- How to select multiple media files for a widget form?
- Widget page is missing from menu and default widgets are not showing
- Trying to create dynamic widget area using post ID
- How to modify single widget in child theme?
- Radio buttons live refresh in the customizer
- Is there a media_upload_tabs-similar filter to add tabs to the simple/featured image picker?
- Modify ‘Sizes’ Attribute for Images with Specific Class
- Create widget in dashboard displaying a custom user field?
- wp_editor in widget breaks after save (no buttons and visual tab broken)
- Setting value of session with Ajax not working
- How to use a dropdown to populate a list of post from CPT
- AJAX success response is not working but it’s saving my changes
- Add visual editor style only on widgets.php page
- Dynamic Custom Fields
- Create an extra Widget Areas in WordPress TwentyTwelve
- Create tabs in admin options page from custom post type loop
- Gravity Forms closes my popup on Validation Error [closed]
- How to load wp_editor via AJAX
- How can I inject options into an select tag inside the widget form?
- Problem creating an array instance in a widget in 4.4 update
- Can you target a widget_class in a register_sidebar?
- AJAX not Working with php as supposed
- Widget without DIV wrapper
- Widgets not displaying since 4.3
- Widget – link to page rather than absolute url
- template_redirect or admin-ajax.php?
- Redirect to page after a widget form submit
- Trouble with WordPress Ajax Login System – 302
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fire on widgets_init only on dashboard
- Custom widget with WYSIWYG
- Limit number of widgets in widget area
- How to create pagination for homepage with widgetized area?
- Dynamically add content to an existing widget area
- WordPress: How to embed a widget on a separate website?
- Hooking action once but called twice
- php to add a link into wp widget without specific url
- How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?
- Allow shortcode for custom widget