-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththupdate-helper.php
62 lines (57 loc) · 1.81 KB
/
thupdate-helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
* Project: Update API
* Author: Vontainment
* URL: https://vontainment.com
* File: thupdate-helper.php
* Description: WordPress Update API
*/
$themes = glob(THEMES_DIR . "/*.zip");
function generateThemeTableRow($theme, $theme_name)
{
return '<tr>
<td>' . $theme_name . '</td>
<td>
<form name="delete_theme_form" action="/thupdate" method="POST">
<input type="hidden" name="theme_name" value="' . $theme . '">
<input class="th-submit" type="submit" name="delete_theme" value="Delete">
</form>
</td>
</tr>';
}
// Reverse the themes array
$themes = array_reverse($themes);
if (count($themes) > 0) {
// Split themes array into two halves
$half_count = ceil(count($themes) / 2);
$themes_column1 = array_slice($themes, 0, $half_count);
$themes_column2 = array_slice($themes, $half_count);
$themesTableHtml = '<div class="row"><div class="column">
<table>
<thead>
<tr>
<th>Theme Name</th>
<th>Delete</th>
</tr>
</thead>
<tbody>';
foreach ($themes_column1 as $theme) {
$theme_name = basename($theme);
$themesTableHtml .= generateThemeTableRow($theme, $theme_name);
}
$themesTableHtml .= '</tbody></table></div><div class="column"><table>
<thead>
<tr>
<th>Theme Name</th>
<th>Delete</th>
</tr>
</thead>
<tbody>';
foreach ($themes_column2 as $theme) {
$theme_name = basename($theme);
$themesTableHtml .= generateThemeTableRow($theme, $theme_name);
}
$themesTableHtml .= '</tbody></table></div></div>';
} else {
$themesTableHtml = "No themes found.";
}