Skip to content

Commit 0354858

Browse files
Refactor plugins controller and filter out all archived plugins
1 parent c63eb14 commit 0354858

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

assets/css/framework/buttons.css

-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,3 @@ button {
4343
.btn--filled svg {
4444
color: var(--color-yellow-600);
4545
}
46-
.btn--yellow {
47-
background: var(--color-yellow-400) !important;
48-
color: var(--color-black); !important;
49-
}

site/controllers/plugins.php

+10-16
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,26 @@
1010
$category = param('category');
1111
$heading = 'Featured';
1212

13-
if ($category && array_key_exists($category, $categories) === true) {
14-
$plugins = $page
15-
->children()
16-
->children()
17-
->filterBy('recommended', '')
18-
->sortBy('title', 'asc');
13+
// get all plugins
14+
$plugins = $page
15+
->grandChildren()
16+
->filter('archived', '')
17+
->sortBy('title', 'asc');
1918

20-
$plugins = $plugins->filterBy('category', $category);
21-
$heading = $categories[$category]['label'];
2219

20+
if ($category && array_key_exists($category, $categories) === true) {
21+
$heading = $categories[$category]['label'];
22+
$plugins = $plugins->filter('recommended', '')->filter('category', $category);
2323
} elseif ($category === 'all') {
2424
$heading = 'All plugins';
2525
$category = 'all';
26-
$plugins = $page
27-
->grandChildren()
28-
->sortBy('title', 'asc');
2926
} elseif ($filter === 'k4') {
3027
$heading = 'Kirby 4 plugins';
3128
$category = 'k4';
32-
$plugins = $page
33-
->grandChildren()
34-
->filter('versions', '*=', '4')
35-
->sortBy('title', 'asc');
29+
$plugins = $plugins->filter('versions', '*=', '4');
3630
} elseif ($filter) {
3731
$heading = 'Newly added plugins';
38-
$plugins = $page->grandChildren()->filterBy('isNew', true);
32+
$plugins = $plugins->filter('isNew', true);
3933
} else {
4034
$category = null;
4135
$plugins = new Pages();

site/snippets/templates/plugins/versions.php

-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@
22
<?php foreach($plugin->versions()->split() as $version): ?>
33
<li class="px-1 rounded bg-<?= $version === '4' ? 'yellow' : $bg ?? 'light' ?>" title="This plugin supports Kirby <?= $version ?>">K<?= $version ?></li>
44
<?php endforeach ?>
5-
6-
<?php if($plugin->archived()->isNotEmpty()): ?>
7-
<li class="px-1 rounded bg-dark color-white" title="This plugin is archived and no longer maintained">Archived</li>
8-
<?php endif ?>
95
</ul>

site/templates/plugin.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@
114114
.plugin-links .plugin-paid {
115115
background: var(--color-purple-300);
116116
}
117+
118+
.btn--yellow {
119+
background: var(--color-yellow-400) !important;
120+
color: var(--color-black);
121+
}
117122
</style>
118123

119124
<article>
@@ -245,7 +250,7 @@
245250
<?php if($page->archived()->isNotEmpty()): ?>
246251
<a class="btn btn--yellow" href="<?= url('releases') ?>" title="This plugin is archived and no longer maintained">
247252
<span><?= icon('alert') ?></span>
248-
The plugin is archived
253+
Archived
249254
</a>
250255
<?php endif ?>
251256

0 commit comments

Comments
 (0)