PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | classes/class-wp_user_option.php +10 -5 1.14 → 3.4 View file →
@@ -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.
@@ -17,8 +19,9 @@
17 19 TablePress::load_file( 'class-wp_option.php', 'classes' );
18 20
19 21 /**
20 22 * TablePress WP User Option Wrapper class
23 + *
21 24 * @package TablePress
22 25 * @subpackage Classes
23 26 * @author Tobias Bäthge
24 27 * @since 1.0.0
@@ -33,9 +36,10 @@
33 36 * @param string $option_name Name of the WP User Option.
34 37 * @param mixed $default_value Default value of the WP User Option.
35 38 * @return mixed Current value of the WP User Option, or $default_value if it does not exist.
36 39 */
37 - 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 */ {
38 42 // Non-logged-in user can never have a saved option value.
39 43 if ( ! is_user_logged_in() ) {
40 44 return $default_value;
41 45 }
@@ -56,9 +60,10 @@
56 60 * @param string $option_name Name of the WP User Option.
57 61 * @param string $new_value New value of the WP User Option (not slashed).
58 62 * @return bool True on success, false on failure.
59 63 */
60 - protected function _update_option( $option_name, $new_value ) {
64 + #[\Override]
65 + protected function _update_option( string $option_name, string $new_value ): bool {
61 66 // Non-logged-in user can never have a saved option value to be updated.
62 67 if ( ! is_user_logged_in() ) {
63 68 return false;
64 69 }
@@ -75,9 +80,10 @@
75 80 *
76 81 * @param string $option_name Name of the WP User Option.
77 82 * @return bool True on success, false on failure.
78 83 */
79 - protected function _delete_option( $option_name ) {
84 + #[\Override]
85 + protected function _delete_option( string $option_name ): bool {
80 86 // Non-logged-in user can never have a saved option value to be deleted.
81 87 if ( ! is_user_logged_in() ) {
82 88 return false;
83 89 }
@@ -89,13 +95,12 @@
89 95 * Delete a WP User Option with the WP User Options API, for all users of the site.
90 96 *
91 97 * @since 1.0.0
92 98 */
93 - public function delete_for_all_users() {
99 + public function delete_for_all_users(): void {
94 100 $users = get_users();
95 101 foreach ( $users as $user ) {
96 102 delete_user_option( $user->ID, $this->option_name, false );
97 - // @TODO: Add other user options for different actions as well.
98 103 }
99 104 }
100 105
101 106 } // class TablePress_WP_User_Option