How To Activate Plugins via Code?

Question

If possible, how can installed plugins (meaning the files have been placed in wp-content/plugins directory) be activated from other plugins?

in progress 0
, rsman 12 years 2010-11-14T06:24:24-05:00 0 Answer 116 views 0

Answer ( 1 )

    0
    2021-10-12T13:53:47-05:00

    Plugin activation process is coded to work with WP admin interface. It performs some checks to prevent enabling plugins with errors (loading such on start might break WP).

    It is handled by activate_plugin() function (source) which is documented as unusable elsewhere.

    So if you want to activate plugin by code the goal itself is relatively easy – to change active_plugins option to include that plugin. But you will have to re-create related activation hooks from scratch and will risk breaking site by activating without sandbox step.

Leave an answer

Browse
Browse