PluginProbe
Image Source Control Lite – Show Image Credits and Captions / trunk
Image Source Control Lite – Show Image Credits and Captions vtrunk
3.12.0 3.11.0 trunk 1.1 1.1.1 1.1.2 1.1.2.1 1.1.3 1.10 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.2 1.2.0.1 1.2.0.2 1.2.0.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.4.1 1.3.5 All 110 releases
image-source-control-isc / includes / user.php

user.php in Image Source Control Lite – Show Image Credits and Captions trunk, at includes/user.php

64 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ISC;
4
5 /**
6 * Handle user-related attributes
7 */
8 class User {
9 /**
10 * Check if the current user is WP_User
11 *
12 * @return bool
13 */
14 public static function is_user(): bool {
15 $user = wp_get_current_user();
16 return $user instanceof \WP_User;
17 }
18
19 /**
20 * Get the current user email address
21 *
22 * @return string|false email address or false if none is set
23 */
24 public static function get_email() {
25 if ( ! self::is_user() ) {
26 return false;
27 }
28
29 $email = trim( wp_get_current_user()->user_email );
30
31 return is_email( $email ) ? $email : false;
32 }
33
34 /**
35 * Get the current user’s public name
36 *
37 * @return string display name
38 */
39 public static function get_name(): string {
40 if ( ! self::is_user() ) {
41 return '';
42 }
43
44 return ! empty( wp_get_current_user()->nickname ) ? wp_get_current_user()->nickname : wp_get_current_user()->display_name;
45 }
46
47 /**
48 * Get the current user language
49 *
50 * @return string
51 */
52 public static function get_user_language(): string {
53 return strpos( determine_locale(), 'de_' ) === 0 ? 'de' : 'en';
54 }
55
56 /**
57 * Is the backend language in German?
58 *
59 * @return bool
60 */
61 public static function has_german_backend(): bool {
62 return self::get_user_language() === 'de';
63 }
64 }