• Hi,
    I would like to have a image widget that can be enable/disable using checkbox inside the widget. Currently I’m using PB Image widget and have to delete it(disable) and recreate back if want to enable it back.

    Any helps/suggestion are welcome.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t think you can actually disable it because then there would be no admin form checkbox to re-enable it. However, you can cause it to not display anything based on a checkbox state, so it will appear to be disabled on the front end.

    You could work from the current widget code, renaming it and registering it under it’s new name. You would make three modifications. In the form() method you modify the form to output the checkbox field. In the update() method you save the checkbox state in the options table. Finally, in the widget() method you check the value saved in the options table to decide whether to output anything or not.

Viewing 1 replies (of 1 total)
  • The topic ‘How to have image widget that have enable/disable capability’ is closed to new replies.