diff --git a/classes/plugin/Gpm.php b/classes/plugin/Gpm.php index 689da802..fc076438 100644 --- a/classes/plugin/Gpm.php +++ b/classes/plugin/Gpm.php @@ -423,6 +423,25 @@ class Gpm $script = $folder . '/system/install.php'; /** Install $installer */ if ((file_exists($script) && $install = include $script) && is_callable($install)) { + // Run preflight from the NEW package's installer if available + if (is_object($install) && method_exists($install, 'generatePreflightReport')) { + $report = $install->generatePreflightReport(); + $blocking = $report['blocking'] ?? []; + $incompatible = $report['incompatible_packages'] ?? []; + + if (!empty($blocking) || !empty($incompatible['blocking'])) { + $errors = []; + foreach ($blocking as $reason) { + $errors[] = $reason; + } + foreach ($incompatible['blocking'] ?? [] as $slug => $info) { + $errors[] = sprintf('%s (%s v%s) — not compatible with Grav %s. Disable it to proceed.', + $slug, $info['type'] ?? 'plugin', $info['version'] ?? '?', $incompatible['target'] ?? '?'); + } + Installer::setError(implode('
', $errors)); + return; + } + } $install($zip); } else { Installer::install( diff --git a/themes/grav/scss/template/_gpm.scss b/themes/grav/scss/template/_gpm.scss index bd560f6f..91460b6d 100644 --- a/themes/grav/scss/template/_gpm.scss +++ b/themes/grav/scss/template/_gpm.scss @@ -84,6 +84,29 @@ line-height: 1.3; } + .gpm-compat { + @extend .badge; + border-radius: 3px; + padding: 0 4px; + font-size: 0.75rem; + margin-left: 2px; + } + + .gpm-compat-17 { + background: #3b82f6; + color: white; + } + + .gpm-compat-18 { + background: #22c55e; + color: white; + } + + .gpm-compat-api { + background: #06b6d4; + color: white; + } + .gpm-actions { .enabled, .disabled { diff --git a/themes/grav/templates/partials/plugin-data.html.twig b/themes/grav/templates/partials/plugin-data.html.twig index 435b0671..6f0f6a4e 100644 --- a/themes/grav/templates/partials/plugin-data.html.twig +++ b/themes/grav/templates/partials/plugin-data.html.twig @@ -49,6 +49,18 @@ {% endif %} + + Compatibility: + + {% set compat = plugin.compatibility.grav ?? ['1.7'] %} + {% if '1.7' in compat %}1.7{% endif %} + {% if '1.8' in compat %}1.8{% endif %} + {% if plugin.compatibility.api is defined %} + {% for v in plugin.compatibility.api %}api:{{ v }}{% endfor %} + {% endif %} + + + {% if plugin.description %} {{ "PLUGIN_ADMIN.DESCRIPTION"|t }}: diff --git a/themes/grav/templates/partials/plugins-list.html.twig b/themes/grav/templates/partials/plugins-list.html.twig index d0ce2edd..ec8ecfdd 100644 --- a/themes/grav/templates/partials/plugins-list.html.twig +++ b/themes/grav/templates/partials/plugins-list.html.twig @@ -41,6 +41,9 @@ {% endif %} v{{ plugin.version }} {% if isTestingRelease %}test release{% endif %} + {% set compat = plugin.compatibility.grav ?? ['1.7'] %} + {% if '1.7' in compat %}1.7{% endif %} + {% if '1.8' in compat %}1.8{% endif %} {% if (not installing and (plugin.form.fields.enabled.type != 'hidden' and plugin.form.fields.tabs.fields.options.fields.enabled.type != 'hidden')) %} diff --git a/themes/grav/templates/partials/themes-list.html.twig b/themes/grav/templates/partials/themes-list.html.twig index 8005c742..4f663a62 100644 --- a/themes/grav/templates/partials/themes-list.html.twig +++ b/themes/grav/templates/partials/themes-list.html.twig @@ -43,6 +43,9 @@ {% endif %} v{{ theme.version }} {% if isTestingRelease %}test release{% endif %} + {% set compat = theme.compatibility.grav ?? ['1.7'] %} + {% if '1.7' in compat %}1.7{% endif %} + {% if '1.8' in compat %}1.8{% endif %}
{% set thumb = installing ? '//getgrav.org/images/' ~ theme.screenshot : theme.thumbnail %}