From cf5b5e2c1067b4d88b28c44eb973f2f358bf9d56 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Mon, 5 Jun 2023 10:43:48 +0100 Subject: [PATCH] Add a theme-stats command Prints usage counters for all themes. --- bin/noblogs.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/noblogs.in b/bin/noblogs.in index d93f497..0a8ae8f 100755 --- a/bin/noblogs.in +++ b/bin/noblogs.in @@ -186,6 +186,25 @@ function do_set_theme($args) { } } +// 'theme-stats': Prints statistics on theme usage for all local blogs. +function do_theme_stats($args) { + $counters = array(); + foreach (noblogs_get_local_blog_objects() as $blog) { + switch_to_blog($blog->blog_id); + $theme = get_option('template'); + if ($theme) { + if (in_array($theme, $counters)) { + $counters[$theme]++; + } else { + $counters[$theme] = 1; + } + } + } + foreach ($counters as $theme => $n) { + echo("{$theme} {$n}\n"); + } +} + // 'dump-shards': Print a JSON dictionary representing the full map // of backend -> blogs database mappings. function do_dump_shards($args) { -- GitLab