The MU forums have moved to WordPress.org

What query can I run (18 posts)

  1. Konstan
    Member
    Posted 18 years ago #

    In phpmyadmin to view the most used themes? Or how can I write a small php file that will show me how many users are using what themes. I currently have 20 skins and I'd like to know how many users use which skin.

    Is this possible?

  2. andrea_r
    Moderator
    Posted 18 years ago #

    This is just rough, but I've been using it:

    <?php
    $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs
    ORDER BY last_updated DESC");
    if ($blogs) {
    foreach ($blogs as $blog) {
    // we need _posts and _options tables for this to work
    $blogOptionsTable = "wp_".$blog."_options";
    $opt = $wpdb->get_results("SELECT option_value FROM
    $blogOptionsTable WHERE
    option_name IN ('template','blogname') ORDER BY option_name DESC");
    echo '<li class="page_item">'
    .$opt[0]->option_value.' - '
    .$opt[1]->option_value."</li>";
    }
    ?>

    It's just a light mod of our get-last-updated. All it does is spew out a list of users and what theme they are using.

  3. drmike
    Member
    Posted 18 years ago #

    Please note that that's a php file and not something you can drop into phpMyAdmin. You have to put it with your WPMU files. :)

  4. bmonster99
    Member
    Posted 18 years ago #

    Nice idea. Thanks andrea :) I am using it too now. There is a curly brace missing in the code posted above. Here it is w/the brace:

    <?php
    $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs
    ORDER BY last_updated DESC");
    if ($blogs) {
    foreach ($blogs as $blog) {
    // we need _posts and _options tables for this to work
    $blogOptionsTable = "wp_".$blog."_options";
    $opt = $wpdb->get_results("SELECT option_value FROM
    $blogOptionsTable WHERE
    option_name IN ('template','blogname') ORDER BY option_name DESC");
    echo '<li class="page_item">'
    .$opt[0]->option_value.' - '
    .$opt[1]->option_value."</li>";
    }
    }
    ?>

  5. andrea_r
    Moderator
    Posted 18 years ago #

    Doh, yeah Mike. Forgot to mention I just placed this within an unused theme enabled for just a test blog. Someday we'll make it snazzy so it shows up in admin and stuff.

  6. bmonster99
    Member
    Posted 18 years ago #

    I added it to the wpmu-admin.php (site admin page - right before the closing div tag for the wrap div) since there was so much room on it. When I have some time, I would like to play around with it and try to get a list of each theme and how many people are using it.

    Probably better to just put it on its own page though so it is easier to update the files.

  7. andrea_r
    Moderator
    Posted 18 years ago #

    Yeah, and sorted or grouped by theme would be nice too. I bet AndrewBillets would suggest a nice bar graph. :)

  8. Konstan
    Member
    Posted 18 years ago #

    Thanks for that, but I dont think I will be counting 550+ blogs one by one :P

  9. boetter
    Member
    Posted 18 years ago #

    Would be nice if you could just show something like:

    Kubrick: 231
    Classic: 12
    K2: 2314

    And so on. Is that not possible?

  10. Konstan
    Member
    Posted 18 years ago #

    It should be.

    I know nearly nothing about php but I will try to have something tommorow or saturday. I promise nothing tho :P

  11. andrea_r
    Moderator
    Posted 18 years ago #

    Just thinking quick about it here, it need a quite bit more code in it, to stuff each user's theme in an array, then sort it and THEN spit it out.
    I know there's a few guys around here quite fond of arrays. ;) Maybe soemone else will tackle it for a quick brain exercise.

  12. boetter
    Member
    Posted 18 years ago #

    Konstan: Did you figure it out? :-)

  13. stutley
    Member
    Posted 18 years ago #

    I have a plugin that does that, which I wrote for internal use. I'll post it later if anyone's interested?

  14. Ovidiu
    Member
    Posted 18 years ago #

    release it man - we're waiting ;-)

  15. stutley
    Member
    Posted 18 years ago #

  16. andrea_r
    Moderator
    Posted 18 years ago #

    stutley, can I adopt you? :) Nice mod to our code there.

  17. stutley
    Member
    Posted 18 years ago #

    Hehe. Sure :) Gotta talk to my dad first, though :)

  18. bmonster99
    Member
    Posted 18 years ago #

    Very nice :) Thanks!

About this Topic

  • Started 18 years ago by Konstan
  • Latest reply from bmonster99