Is there a way to programmatically enable a widget from a plugin in WordPress?

I have a plugin that I wrote for wordpress, and I need the Pages widget to be turned on so that everything works correctly. It would be nice if I could include it myself in the plugin, and not ask the user to do it.

Do you know how to do this?

+3
source share
1 answer

It’s not clear how your widget works, but you can automatically activate the page widget by adding it to the parameters table, but you will need to add code to read the widget storage type, and then decide whether the widget will be accessible in the correct sidebar (you don’t say whether the widget should be included within the same sidebar in the theme, but I assume that it is). Then you also need to figure out where to place the page widget relative to the others in the sidebar, since the position is what wp admin normally does on the widget's admin tool.

, , - , , , . , . , , .

+1

All Articles