| @@ -9,8 +9,10 @@ | ||
| 9 | 9 | * @author Tobias Bäthge |
| 10 | 10 | * @since 1.0.0 |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | +declare(strict_types=1); | |
| 14 | + | |
| 13 | 15 | // Prohibit direct script loading. |
| 14 | 16 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 15 | 17 | |
| 16 | 18 | // Load parent class. |
| @@ -34,9 +36,10 @@ | ||
| 34 | 36 | * @param string $option_name Name of the WP User Option. |
| 35 | 37 | * @param mixed $default_value Default value of the WP User Option. |
| 36 | 38 | * @return mixed Current value of the WP User Option, or $default_value if it does not exist. |
| 37 | 39 | */ |
| 38 | - protected function _get_option( $option_name, $default_value ) { | |
| 40 | + #[\Override] | |
| 41 | + protected function _get_option( string $option_name, /* string|int|float|bool|array|null */ $default_value ) /* : string|int|float|bool|array|null */ { | |
| 39 | 42 | // Non-logged-in user can never have a saved option value. |
| 40 | 43 | if ( ! is_user_logged_in() ) { |
| 41 | 44 | return $default_value; |
| 42 | 45 | } |
| @@ -57,9 +60,10 @@ | ||
| 57 | 60 | * @param string $option_name Name of the WP User Option. |
| 58 | 61 | * @param string $new_value New value of the WP User Option (not slashed). |
| 59 | 62 | * @return bool True on success, false on failure. |
| 60 | 63 | */ |
| 61 | - protected function _update_option( $option_name, $new_value ) { | |
| 64 | + #[\Override] | |
| 65 | + protected function _update_option( string $option_name, string $new_value ): bool { | |
| 62 | 66 | // Non-logged-in user can never have a saved option value to be updated. |
| 63 | 67 | if ( ! is_user_logged_in() ) { |
| 64 | 68 | return false; |
| 65 | 69 | } |
| @@ -76,9 +80,10 @@ | ||
| 76 | 80 | * |
| 77 | 81 | * @param string $option_name Name of the WP User Option. |
| 78 | 82 | * @return bool True on success, false on failure. |
| 79 | 83 | */ |
| 80 | - protected function _delete_option( $option_name ) { | |
| 84 | + #[\Override] | |
| 85 | + protected function _delete_option( string $option_name ): bool { | |
| 81 | 86 | // Non-logged-in user can never have a saved option value to be deleted. |
| 82 | 87 | if ( ! is_user_logged_in() ) { |
| 83 | 88 | return false; |
| 84 | 89 | } |
| @@ -90,13 +95,12 @@ | ||
| 90 | 95 | * Delete a WP User Option with the WP User Options API, for all users of the site. |
| 91 | 96 | * |
| 92 | 97 | * @since 1.0.0 |
| 93 | 98 | */ |
| 94 | - public function delete_for_all_users() { | |
| 99 | + public function delete_for_all_users(): void { | |
| 95 | 100 | $users = get_users(); |
| 96 | 101 | foreach ( $users as $user ) { |
| 97 | 102 | delete_user_option( $user->ID, $this->option_name, false ); |
| 98 | - // @TODO: Add other user options for different actions as well. | |
| 99 | 103 | } |
| 100 | 104 | } |
| 101 | 105 | |
| 102 | 106 | } // class TablePress_WP_User_Option |