Based off the example @mrwweb provided above and some additional code, here is an answer that works. This answer forces a widget to save when a widget is added to a sidebar. It finds all the “Save” buttons and triggers their click event thus saving the widget. The count variable is used to stop an endless loop from occurring.
var count = 0;
$( document ).ajaxStop( function() {
var $saveBtns = $('#products_sidebar, #blog_sidebar').find('.widget-control-save');
if (count < $saveBtns.length) {
$saveBtns.each( function( index, value ){
$(value).trigger('click');
count++;
});
}
else {
count = 0;
return;
}
} );
Related Posts:
- Enabling jquery when dragging available widget to sidebar area
- How do I rebind event after widget save
- How to listen to color changes on the color picker?
- Ban certain widgets from certain sidebars
- Widget “Save” resetting jQuery hidden fields
- jQuery does not work in widget backend
- How to enable “shift-click to edit this widget” functionality on a custom widget?
- Using jQuery in widget development
- cannot drag and drop widgets since wordpress 3.2.1
- AJAX Contact Form Issue
- jQuery UI inside widget on admin page
- WP_enqueue_script() loads them always in wp_footer()?
- Wrap the widget content with a div and get the widget title outside? [closed]
- Access Customizer widget instance form
- How i can widget ID get after drag for wordpress with jquery?
- wordpress widget missing jquery
- Making jQuery .change() event persistent after widget save
- Jquery checkbox -show posts with checked tags
- Using AJAX in WordPress Widget
- Custom tabs widget don’t work in google chrome, is blocked, do not change the tabs. Why?
- Multiple widgets in wordpress
- jQuery “on” handler does not fire on newly inserted widgets [closed]
- Using AJAX in a Widget to Sort items [closed]
- How to refresh Theme Customizer after change color inside wpColorPicker?
- How to Remove All Widgets from Dashboard?
- Randomize widgets displayed in my sidebar [duplicate]
- Calling static method in the Widget Class
- What is the best way to include a widget in a Page?
- Difference between widget form code variables
- Custom shortcode in widget forced to top of widget
- Modifying recent post widget to include icons for post titles
- Unfiltered html in widget title not working
- How to process content in a widget? [duplicate]
- How to retrive widget title/data
- Separate backend “Widgets” page for each language
- How do I embed in a text widget?
- Where (what direcory) are the default WordPress Widget Codes stored?
- How do I pass arguments to dashboard widget callback functions?
- woocommerce featured products and categories
- Removing custom widget area WordPress 4.4 [closed]
- Insert widgets after theme installation [duplicate]
- How to change text widget title h2 to h1
- Widget code is not working on WordPress.com Hosted Blogs
- Show tags selection similar to category selection in WordPress
- Widgets not activated alert after using get_sidebar()
- Image Uploader API
- Is there any way to parse blocks inside widget area?
- How to output only blockquotes content from recent posts in a widget?
- WordPress Widget Multiselect Issue
- How to show all the filters with woocommerce layered nav filter widget
- Add default widgets to footer
- Trying to create dynamic widget area using post ID
- How to modify single widget in child theme?
- Display attachment, post and page in recent comments widget
- Dashboard Widget drawn before opening HTML tag
- How to fix wordpress site url attaching to social media links in the widget?
- Insert widgets into loop/custom query at every nth position
- Twenty Fourteen: how do they populate by default the sidebar?
- register_sidebar fails when using a include within functions.php
- get_the_title and get_permalink outside of the Loop
- How to load a stylesheet into wp_head from a custom widget?
- how to add the same Widget twice to a sidebar?
- WordPress widget not appearing in editors widget list
- How to insert widgets into a post?
- Widget’s Content Mssing in Child Theme
- My widget not printing before_widgets and after widgets
- wrapper div for widgets not showing with all widgets
- Address automatically generated ids in css [closed]
- Widget page stopped loading
- latest posts-widget displays all posts on archive page but works great anywhere else
- looping widgets to organize bootstrap grids
- How to get class from widget area
- How to change widget’s form color in admin?
- In widget, the value of select field doesn’t get updated, changes after saving
- Removing widget without using unregister_widget
- Text Widget to Show database fields based on post
- Editing Help Section
- SELECT field options disappear when saving widget
- WordPress text filed input only inter value?
- Need to delete the sidebar widget area and have the page a full page rather than just have a blank widget area
- Searching for a one page overview widget
- Adding pagination to my theme [closed]
- How do I add after the tag in WordPress widget?
- Creating a simple button inside of a widget
- Stop ‘extends WP_Widget’ displaying the (backend) form, frontend?
- How to check widget-cpt meta and display its custom css in the head?
- How to add WooCommerce Add to Cart button in widget?
- How to place a widget beside a div/text so that they display as a continuous line
- Editor Widget Role
- How can I build a widget area widget using the built in WordPress functionalities?
- How to Activate WordPress Widgets
- WordPress wiget admin panel
- Filter “widget_comments_args” won’t work
- How to output built-in widgets with number in range as class?
- widgets in contacts only
- How to hide sidebar widgets in all pages except Hompage?
- Extending Widgets – Exclude # of posts field from Recent Posts Widget
- How can I create my own widgets in WordPress? [closed]
- Theme Widget Area Defaults
- How to add the “page” post type to Recent Activity widget displayed in admin?