Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@johnalarcon
Last active October 16, 2020 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnalarcon/b8711588676c5d6c026b599485b92985 to your computer and use it in GitHub Desktop.
Save johnalarcon/b8711588676c5d6c026b599485b92985 to your computer and use it in GitHub Desktop.
Hook in to the ClassicPress widget update process
jQuery(document).ajaxSuccess(function(e, xhr, settings) {
// This is the data of interest.
console.log(settings);
// Identifier for your (or whatever) particular widget.
var widget_id_base = 'text'; // text, search, my-widget, et al.
// Check if updating a widget of this type.
if((settings.data.search('action=save-widget') != -1) && (settings.data.search('id_base='+widget_id_base) != -1)) {
// The data from the widget.
console.log(settings.data);
// Do amazing things here.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment