parent(); $parent = $is_child ? $active->parent() : null; $f[] = $this->finding( 'active_theme', 'info', 'Active theme', (string) $active->get('Name') . ' v' . (string) $active->get('Version'), 'Slug: ' . $active->get_stylesheet() . ($is_child ? ' (child of ' . $parent->get_stylesheet() . ')' : '') ); // Child theme practice: warn if active theme has been customised but isn't a child $is_default = preg_match('/^twenty/i', $active->get_stylesheet()); if (!$is_child && !$is_default) { $style_mtime = file_exists($active->get_stylesheet_directory() . '/style.css') ? filemtime($active->get_stylesheet_directory() . '/style.css') : 0; $functions_mtime = file_exists($active->get_stylesheet_directory() . '/functions.php') ? filemtime($active->get_stylesheet_directory() . '/functions.php') : 0; $modified = max($style_mtime, $functions_mtime); $f[] = $this->finding( 'no_child_theme', 'warn', 'Child theme practice', 'no child theme', 'Parent theme is being used directly. Last edit to style.css/functions.php: ' . ($modified ? date('Y-m-d', $modified) : 'unknown') . '. An update may overwrite customisations — confirm with client first.' ); } else { $f[] = $this->finding( 'child_theme_ok', 'ok', 'Child theme practice', $is_child ? 'using a child theme' : 'default theme — no customisation expected', '' ); } // Updates available if (!function_exists('wp_get_themes')) require_once ABSPATH . 'wp-includes/theme.php'; if (function_exists('wp_update_themes')) wp_update_themes(); $updates = get_site_transient('update_themes'); $update_map = isset($updates->response) && is_array($updates->response) ? $updates->response : []; if (isset($update_map[$active->get_stylesheet()])) { $new = $update_map[$active->get_stylesheet()]['new_version'] ?? '?'; $f[] = $this->finding( 'active_update', 'warn', 'Active theme update', 'v' . $new . ' available', $is_child ? 'Safe to apply (child in use).' : 'Caution — may overwrite parent-theme customisations.' ); } else { $f[] = $this->finding('active_update', 'ok', 'Active theme update', 'up to date', ''); } // Inactive themes $all = wp_get_themes(); $inactive = []; foreach ($all as $slug => $t) { if ($slug === $active->get_stylesheet() || ($is_child && $slug === $parent->get_stylesheet())) continue; $inactive[$slug] = (string) $t->get('Name'); } $f[] = $this->finding( 'inactive_themes', count($inactive) > 3 ? 'warn' : 'info', 'Inactive themes', (string) count($inactive), $inactive ? implode(', ', array_slice($inactive, 0, 6)) . (count($inactive) > 6 ? ' …' : '') : '' ); return $f; } };