foreach ($scanned_files as $plugin_name => $files) { foreach ($files as $file) { // skip if no php file if (!strpos($file, '.php')) { continue; } $child_path = get_stylesheet_directory() . '/' . $file; // Exclude functions.php if (file_exists($child_path) && basename($file) !== 'functions.php') { $theme_file = $child_path; } else { $theme_file = false; } if ($theme_file) { $parent_version = TPLC_Admin_Status::get_file_version(get_template_directory() . '/' . $file); $child_version = TPLC_Admin_Status::get_file_version($theme_file); if ($parent_version && $child_version && version_compare($child_version, $parent_version, '<')) { $found_files[$plugin_name][] = sprintf(__('%s <code>%s</code>: Child theme version <strong style="color:red">%s</strong> is out of date. The parent theme version is <strong>%s</strong>.', 'tl-template-checker'), '<span class="dashicons dashicons-no-alt" style="color:red"></span>', basename($theme_file), $child_version ? $child_version : '-', $parent_version); } elseif (!$child_version && $parent_version) { $found_files[$plugin_name][] = sprintf(__('%s <code>%s</code>: Child theme is missing version keyword. The parent theme version is <strong>%s</strong>.', 'tl-template-checker'), '<span class="dashicons dashicons-info" style="color:orange"></span>', basename($theme_file), $parent_version); } elseif (!$parent_version) { $found_files[$plugin_name][] = sprintf(__('%s <code>%s</code>: Parent theme is missing version keyword.', 'tl-template-checker'), '<span class="dashicons dashicons-minus"></span>', basename($theme_file)); } else { $found_files[$plugin_name][] = sprintf(__('%s <code>%s</code>: Child theme version <strong style="color:green">%s</strong> matches parent theme.', 'tl-template-checker'), '<span class="dashicons dashicons-yes" style="color:green"></span>', basename($theme_file), $child_version ? $child_version : '-', $parent_version); } } } } if ($found_files) { foreach ($found_files as $plugin_name => $found_plugin_files) { $theme = wp_get_theme();
/** * Show a notice highlighting bad template files */ public function template_file_check_notice() { require_once 'class-tplc-admin-status.php'; $template_path = get_template_directory() . '/'; $parent_theme_templates = TPLC_Admin_Status::scan_template_files($template_path); // TPLC_Admin_Status::scan_template_files( WC()->plugin_path() . '/templates' ); $outdated = false; foreach ($parent_theme_templates as $file) { $theme_file = false; $child_path = get_stylesheet_directory() . '/' . $file; // Exclude functions.php if (file_exists($child_path) && basename($file) !== 'functions.php') { $theme_file = $child_path; } else { $theme_file = false; } if ($theme_file) { $parent_version = TPLC_Admin_Status::get_file_version(get_template_directory() . '/' . $file); $child_version = TPLC_Admin_Status::get_file_version($theme_file); if ($parent_version && $child_version && version_compare($child_version, $parent_version, '<')) { $outdated = true; break; } } } if ($outdated) { include 'views/html-notice-template-check.php'; } else { self::remove_notice('template_files'); } }