| @@ -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,8 +36,9 @@ | ||
| 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 | */ |
| 40 | + #[\Override] | |
| 38 | 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; |
| @@ -57,8 +60,9 @@ | ||
| 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 | */ |
| 64 | + #[\Override] | |
| 61 | 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; |
| @@ -76,8 +80,9 @@ | ||
| 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 | */ |
| 84 | + #[\Override] | |
| 80 | 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; |
| @@ -94,9 +99,8 @@ | ||
| 94 | 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 |