This solution, Update widget form after drag-and-drop, works correctly but I want to adapt this function to affect only a specific plugin and not every plugin. How could I do it?

  • Please clarify your question. When you say "specific plugin," do you mean "one particular widget?"
    – mrwweb
    Commented May 14, 2013 at 14:22
  • Yes, any instance of one particular widget, for example Twitter Widget Pro
    – PoseLab
    Commented May 14, 2013 at 14:26
  • If this answers your question, please accept it with the checkmark next to the answer rather than up-voting. Then other people know that the question has been answered satisfactorily.
    – mrwweb
    Commented May 14, 2013 at 17:07

1 Answer 1


Update 27 July 2015: Added new test to make sure settings.data.search is defined to handle some non-standard sidebar implementations such as WPMU's Custom Sidebars.

I ran into this problem with one of my plugins, and am deeply indebted to this article for pointing me in the right direction.

The key is that the third parameter you get in the callback includes the widget's basename (derived from its class). I used a slightly different AJAX function than the example you linked to, but here's what I came up with:

$(document).ajaxSuccess(function(e, xhr, settings) {

    // test to see if any instance of a particular widget is saved
    if( undefined != typeof settings.data.search && settings.data.search('action=save-widget') != -1 && settings.data.search('id_base={YOUR BASENAME GOES HERE}') != -1 ) {
        // do something

    // test to see if any widget was added or re-ordered
    if(settings.data.search('action=widgets-order') != -1) {
        // do something


A couple notes:

  1. Make sure to fill in "{YOUR BASENAME GOES HERE}" above.
  2. Note that you can't see which particular widget was added or re-ordered. That's not passed.
  3. If you're unsure of your basename, just add console.log(settings); to the first line of the function and look at it in a JS browser console. You'll see your basename buried in there.
  • This is what I was looking for and your plugin code "Feature A Page Widget" shows very well how to use it. Thank you very much
    – PoseLab
    Commented May 15, 2013 at 13:49
  • Glad I could help!
    – mrwweb
    Commented May 15, 2013 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.