• Hello,

    I would need to execute some code when an instance of a widget is created and destructed.

    For creation I mean when a widget is dragged in a sidebar in the Widget admin page.
    For destruction I mean when the widget is deleted form the same sidebar.

    I was not able to find any suitable action hooks, so I was wandering if it is something that should be added or if I am approaching the problem in a wrong way.

    If needed I can provide more details, thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • What exactly are you trying to fire and why?

    Thread Starter mgiulio

    (@giuliom)

    First of all, I am subclassing the WP_Widget class.

    The widget must support multiple instances.

    Each instance needs to store(for caching purposes) some data in a subdirectory like this: <plugindir>/cache/instance-<n>.

    So, I need to create and remove this directories and I was thinking that the most natural event would be when the user drag a new widget instance on the sidebar and when he clicks the delete link.

    I understand that i could create the subfolder in the overriden WP_Widget::update() method but it is not elegant (nor efficient).
    And what about the directory removal? How to catch this event?

    I hope I’ve been clear, sorry for my english.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Widgets creation and destruction hooks’ is closed to new replies.