From ee219919aa30ed9005ead997dbc9be25f70114a6 Mon Sep 17 00:00:00 2001 From: Jason Rouet <56646501+jaz-on@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:47:52 +0200 Subject: [PATCH 1/4] Update .gitattributes to ignore .svcode files --- .gitattributes | 10 ++++++++++ .vscode/settings.json | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.gitattributes b/.gitattributes index 6e9e67f..5d9319a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,13 @@ /.gitattributes export-ignore /.gitignore export-ignore /readme.md export-ignore + +# Ignore vscode files +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets +.history/ +*.vsix \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6c2ff60 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "master" + ] +} \ No newline at end of file From d04144fe1694e9560a878a1a4548bfb85c87f496 Mon Sep 17 00:00:00 2001 From: Jason Rouet <56646501+jaz-on@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:52:09 +0200 Subject: [PATCH 2/4] revert previous commit --- .gitattributes | 12 +----------- .vscode/settings.json | 5 ----- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitattributes b/.gitattributes index 5d9319a..2629d26 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,14 +4,4 @@ /.eslintrc.js export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/readme.md export-ignore - -# Ignore vscode files -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets -.history/ -*.vsix \ No newline at end of file +/readme.md export-ignore \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6c2ff60..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "githubPullRequests.ignoredPullRequestBranches": [ - "master" - ] -} \ No newline at end of file From 4c884be9520890d776ab5e514772129c4ebd3906 Mon Sep 17 00:00:00 2001 From: Jason Rouet <56646501+jaz-on@users.noreply.github.com> Date: Tue, 8 Aug 2023 18:41:42 +0200 Subject: [PATCH 3/4] Rewrite get_wind_angle and rename to . Resolves #33 --- includes/traits/DataUnitConversion.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/includes/traits/DataUnitConversion.php b/includes/traits/DataUnitConversion.php index 84f014d..d27a8ee 100644 --- a/includes/traits/DataUnitConversion.php +++ b/includes/traits/DataUnitConversion.php @@ -703,16 +703,19 @@ protected function get_reverse_illuminance($value) } /** - * Get the wind angle expressed in its unique unit. - * - * @param mixed $value The value of the wind angle. - * @return string The wind angle expressed in its unique unit. - * @since 1.0.0 - */ - protected function get_wind_angle($value) + * Get the wind angle expressed in its unique unit. + * + * @param mixed $windAngle The value of the wind angle. (Assumed to be numeric) + * @return string The wind angle expressed in its unique unit. + * @since 1.0.0 + */ + protected function get_wind_angle($windAngle) { - $result = $value; - return sprintf('%d', round($result, 0)); + if (is_numeric()) { + return sprintf('%d', round($windAngle, 0)); + } else { + return 'Invalid input'; + } } /** From 47dfac932095b2b856abc4fb736db4a2f60c13fc Mon Sep 17 00:00:00 2001 From: Jason Rouet <56646501+jaz-on@users.noreply.github.com> Date: Tue, 8 Aug 2023 21:44:44 +0200 Subject: [PATCH 4/4] Refactor is_autoupdatable and is_updated for better readability and maintainability (renaming variables, rewriting docstring...) Linked to #17 --- includes/system/Environment.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/includes/system/Environment.php b/includes/system/Environment.php index 627b8b9..2e45a0e 100644 --- a/includes/system/Environment.php +++ b/includes/system/Environment.php @@ -723,25 +723,15 @@ public static function is_updated($old) { } /** - * Is the WP update system enabled? - * - * @since 3.1.3 - */ - public static function is_updatable() { - $result = true; - if (defined('AUTOMATIC_UPDATER_DISABLED')) { - $result = !AUTOMATIC_UPDATER_DISABLED; - } - return $result; - } - - /** - * Is the plugin auto-update enabled? + * Checks if the plugin's auto-update is enabled. * * @since 3.1.3 + * @return bool Returns true if auto-update is enabled, false otherwise. */ public static function is_autoupdatable() { - return (self::is_updatable() && get_option('live_weather_station_auto_update')); + $is_updatable = self::is_updatable(); + $auto_update_option = get_option('live_weather_station_auto_update'); + return ($is_updatable && $auto_update_option); } /**