WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] possible to activate a theme through a plugin ? (3 posts)

  1. wpprogrammeurs.nl
    Member
    Posted 1 year ago #

    Is it possible to activate a theme through PHP / API ?

    Would like my plugin to perform one of the following in order of preference:

    - upon plugin activation, check for theme presence, if not present, upload and activate it (from wordpress.org repository)

    OR IF NEEDED

    - upon plugin activation, copy A piggybacked theme folder from my plugin folder to themes folder, then activate theme.

  2. dc5ala
    Member
    Posted 1 year ago #

    Though i haven't tried something like that myself, there is a function called switch_theme().

    When you hover your mouse in the Design/Themes menu on a activation link, you can see the two parameters passed to this function, namely 'template' and 'stylesheet'.

    You can have a look at the file wp-admin/themes.php where this function is being used.

  3. wpprogrammeurs.nl
    Member
    Posted 1 year ago #

    In the meantime I have tried it and converted it into a working plugin.

    Works great ! Thank you much ...

Topic Closed

This topic has been closed to new replies.

About this Topic