From 1296208866c0d191a7467c92f49da99e5d62cd93 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Sun, 22 Feb 2026 11:03:54 +0100 Subject: [PATCH] refactor: set `site_url` from method instead of static property (#13) `site_url` is not needed for every operation, let's make it a method that can be called as needed instead of always setting it as static property on the `Database` class. Reviewed-on: https://codeberg.org/vlw/wp/pulls/13 --- src/Database.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Database.php b/src/Database.php index 7a224c1..e85f780 100644 --- a/src/Database.php +++ b/src/Database.php @@ -9,7 +9,6 @@ class Database extends DatabaseFramework { public static string $name = ""; - public static string $site_url = ""; private static string $prefix = "wp"; private static string $hostname = ""; @@ -71,8 +70,6 @@ $database ); - $this->set_site_url(); - parent::__construct(); } @@ -90,11 +87,11 @@ } /** - * Fetch and set the WordPress siteurl from the options table + * Fetch the WordPress siteurl from the options table * * @return void */ - public function set_site_url() { + public function site_url() { $query = new DatabaseFramework() ->from(static::$prefix . "_options") ->where(["option_name" => "siteurl"]) @@ -105,6 +102,6 @@ throw new Exception("Failed to fetch siteurl from options table"); } - self::$site_url = $query->fetch_assoc()["option_value"]; + return $query->fetch_assoc()["option_value"]; } }