allowedthemes in wp_sitemeta polluted

Hello :slight_smile:

I got a WPMU, like you may know :smiley:, and I just upgraded a user’s account in Pro Sites.

But before I could do that I had to remove his permanent status.

This reverted him back to free.

And what happened next? Well, his premium theme got removed (as it should) and reverted back to a free theme (as it should).

However, the user got a non-existing theme that hasn’t been installed for 9 months!!!

Now I checked my database for that theme name and it seems it’s in wp_sitemeta -> allowedthemes

The values are a bit weird and I think it contains too much information to be displayed here.

What I want to know is the following:

1. Why does Pro Sites revert him back to a non-existing theme?

2. Is there a way I can select a theme to be reverted to as a Default fallback (From Pro theme to Free)?

3. Does anyone here have a clean meta_value for allowedthemes in wp_sitemeta lying around?

Nowhere in the WP codex I could find any explanation for what the values mean, and the code in themes.php shows a big list of “maybe” deprecated values, but no way to remove the themes from that list.

Anyway, this is caused by pollution over time (I wasn’t planning on using WPMU 9 months ago and I’m still using the same installation).

If anything, please advise :slight_smile:


  • Sybre Waaijer
    • The Incredible Code Injector

    I found this piece of code in wp-admin/includes/upgrade.php

    function upgrade_network() {
    global $wp_current_db_version, $wpdb;

    // Always.
    if ( is_main_network() ) {
    * Deletes all expired transients. The multi-table delete syntax is used
    * to delete the transient record from table a, and the corresponding
    * transient_timeout record from table b.
    $time = time();
    $sql = "DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b
    WHERE a.meta_key LIKE %s
    AND a.meta_key NOT LIKE %s
    AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
    AND b.meta_value < %d";
    $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );

    if ( $wp_current_db_version < 20148 ) {
    // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
    $allowedthemes = get_site_option( 'allowedthemes' );
    $allowed_themes = get_site_option( 'allowed_themes' );
    if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
    $converted = array();
    $themes = wp_get_themes();
    foreach ( $themes as $stylesheet => $theme_data ) {
    if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
    $converted[ $stylesheet ] = true;
    update_site_option( 'allowedthemes', $converted );
    delete_site_option( 'allowed_themes' );

    Should I force it? :smiley: Although my current_db_version is way over 20148.

  • Sybre Waaijer
    • The Incredible Code Injector

    OK so far so good, here’s the code:


    a:221 = 221 themes

    s:1 = 1 character,

    s:5 = 5 characters

    b:1 = ??? No idea, maybe the 1 is “true”, and thus not “default”?

    But I think I’ll just make it this for now:


    Will let you know if it works out =p


    On the NOPE-train here, now the theme defaults back to, uhm, well, nothing :smiley:.

    All themes seem to be deactivated.

    EDIT2: It seems this just deactivated all my themes XD

  • Ash
    • WordPress Hacker

    Hello @Sybre

    I hope you are well today and thanks for asking the question.

    This is definitely an odd issue. Maybe this theme was active at some time and the information is not removed from your database.

    Would you please try this?


    Make sure the theme is network activated.

    Please let us know if that works.



  • Sybre Waaijer
    • The Incredible Code Injector

    Hi @ashok,

    Thanks for dropping by.

    I think this is related to another issue to which some blogs get an empty theme with this plugin:

    I noticed I wrote a comment on that one with another member a while back.

    I can’t find the topic regarding this unfortunately.

    I’ll definitely try your line, but first I’m making a list of the currently network activated themes (90 of them! D:slight_smile:

    In the massive code with 221 themes I have now I notice most themes are WPMUdev’s pre-Upfront themes which aren’t available on the network anymore. I think I manually deleted them in FTP. But some of the themes as for example Karma are deleted within WordPress itself. Weird…

  • Sybre Waaijer
    • The Incredible Code Injector

    Update: I network deactivated all themes and it seems that I’m down to 129 themes in the database. Those themes are not available anymore on my network and have been deleted through FTP.

    What did we learn from this?



    To reset the value, set it to:


    The code @ashok provided is the code that is automatically provided if you activate the twentyfifteen theme. So that’s good :slight_smile:

    It just now seems Pro Sites’ Premium Themes aren’t working but I’ll check into that in a moment. Hold your thought ^^

  • Sybre Waaijer
    • The Incredible Code Injector


    The problem:

    Users get random blank themes.

    The solution: (keep the order)

    1. Network deactivate ALL themes

    2. Deactivate Multisite Theme Manager (WPMUdev plugin) if active

    3. Deactivate Pro Sites if active

    4. set defaultthemes in wp_sitemeta to “a:0:{}” (without the ” “:wink:

    5. Network activate the themes you want to be active again.

    6. Activate Pro Sites if you want to

    7. Activate MultiSite Theme Manager if you want to

    It takes some time but then you’ll have a clean working website again =)

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.