Upgrades Plugin – Upgrade packages for themes

I am trying to use the "Upgrades Plugin" to allow customers to purchase "Premium Themes/Templates". I am having problems with activating/deactivating themes.

Does anyone know how this can be done?

I created my own plugin called premium-themes.php

And the code looks a little like this:

$upgrade_premium_themes = md5("premium-themes":wink:;

upgrades_register_feature("$upgrade_premium_themes", "Premium Themes", "An auto detect plugin that will allow for easy integration with Premium Themes.":wink:;

if(upgrades_active_feature("$upgrade_premium_themes":wink: == "active":wink:{

// This is where I am having problems….

// I cant figure out how to activate/deactivate a theme.


I have tried using functions like:

update_site_option(); but everything I do doesn’t seem to work.

  • drmike
    • DEV MAN’s Mascot

    We’ve talked about it a couple of times but I don’t think anyone’s really worked on it. At least I don’t recall.

    For those of my clients who do it, they just add them in manually via Edit Blog.

    It’s the blog option "allowed_themes", isn’t it?

  • jbolanosmd
    • New Recruit

    I think your right. I was trying to use something like this:

    $value = ‘a:1:{s:4:"home";b:1;}’;

    update_site_option(‘allowedthemes’, ‘$value’:wink:;

    But it seems to keep doing weird things to the database.

    I think I am close to the solution, but before I put to much more effort into it I wanted to see if anyone else had a solution to the problem.

    I guess I will keep forging ahead.

  • drmike
    • DEV MAN’s Mascot

    I’m not in a position to check right now (and I was going out the door when you posted last night so I couldn’t check then either) but I could have sworn that each blog had it’s own allowed_themes option and that should be what you;re trying to change,

    Just had a thought: An easy way to do this actually is figure out what the allowed theme strings should be for normal blogs and blogs with benefits. If they upgrade, just replace the string completely instead fooling around with adding to it.

    I would setup a second option though to note that a change has been made.

    If the change options is false and they don;t have the upgrade, move on. (ie normal user.)

    If the change option is true (ie the allowed_themes option has been modified) and they have the upgrade, move on.

    If the change option is false but they do have the upgrade, (ie they just got it) give them the updated allowed_themes option and save it.

    If the change option is true but they do not have the option, (ie it just expired) give them the original allowed_themes option, save and maybe a note on their dashboard telling them it;s expired.

    You would have to work out a method to update though if you add a theme. I actually have an idea for that but I’m not publishing that one yet.

  • Aaron
    • CTO

    The problem is you need to use update_blog_option(), not update_site_option() as the allowed_themes option is per blog. But then you have to disable them also.

    There is a filter that is called in themes.php when listing the themes, why not try tying into that to add to the array on the fly? Seems like it would be a little simpler.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.