Merge pull request #38 from djav1985/codex/fix-codebase-errors-and-optimize

Fix plugin/theme updater and API scanning
This commit is contained in:
Vontainment 2025-07-07 00:55:36 -04:00 committed by GitHub
commit 745b8145ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 3 deletions

View file

@ -55,7 +55,10 @@ function vontmnt_plugin_updater_run_updates(): void
if (! is_main_site()) {
return;
}
$plugins = get_plugins();
if (! function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
foreach ($plugins as $plugin_path => $plugin) {
$plugin_slug = dirname($plugin_path);
$installed_version = $plugin['Version'];

View file

@ -46,6 +46,9 @@ add_action('vontmnt_plugin_updater_check_updates', 'vontmnt_plugin_updater_run_u
* Run plugin updates for all installed plugins. */
function vontmnt_plugin_updater_run_updates(): void
{
if (! function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
foreach ($plugins as $plugin_path => $plugin) {
$plugin_slug = dirname($plugin_path);

View file

@ -47,6 +47,9 @@ add_action('vontmnt_theme_updater_check_updates', 'vontmnt_theme_updater_run_upd
* Run theme updates for all installed themes. */
function vontmnt_theme_updater_run_updates(): void
{
if (! function_exists('wp_get_themes')) {
require_once ABSPATH . 'wp-includes/theme.php';
}
$themes = wp_get_themes();
foreach ($themes as $theme) {
$theme_slug = $theme->get_stylesheet();

View file

@ -202,7 +202,7 @@ class HomeController // @phpcs:disable PSR1.Classes.ClassDeclaration.MissingName
public static function getHostsTableHtml(): string
{
$hostsFile = HOSTS_ACL . '/HOSTS';
$entries = file($hostsFile, FILE_IGNORE_NEW_LINES);
$entries = file_exists($hostsFile) ? file($hostsFile, FILE_IGNORE_NEW_LINES) : [];
$hostsTableHtml = '';
if (count($entries) > 0) {
$halfCount = ceil(count($entries) / 2);

View file

@ -84,11 +84,14 @@ if (UtilityHandler::isBlacklisted($ip) || $_SERVER['REQUEST_METHOD'] !== 'GET')
fclose($host_file);
// Find and serve update if available
foreach (scandir($dir) as $filename) {
if ($filename === '.' || $filename === '..') {
continue;
}
if (strpos($filename, $slug) === 0) {
$filename_parts = explode('_', $filename);
if (isset($filename_parts[1]) && version_compare($filename_parts[1], $version, '>')) {
$file_path = $dir . '/' . $filename;
if (file_exists($file_path)) {
if (is_file($file_path)) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file_path) . '"');
header('Content-Length: ' . filesize($file_path));