PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 1.3.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v1.3.2
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | core/class-login.php +64 -0 1-final1.3.2 View file →
@@ -1,0 +1,64 @@
1 +<?php
2 +
3 +namespace Templately;
4 +
5 +class Login {
6 +
7 + /**
8 + * Save global sign in flag based on user choice.
9 + *
10 + * @param $choice
11 + *
12 + * @return bool true|false
13 + */
14 + public static function set_user_login_choice( $user, $choice ) {
15 + if( ! self::already_signedin_globally() ) {
16 + return update_option( '_templately_user_login_choice', array (
17 + 'id' => $user,
18 + 'choice' => $choice
19 + ) );
20 + }
21 + return false;
22 + }
23 +
24 + public static function get_user_login_choice() {
25 + return get_option( '_templately_user_login_choice', array () );
26 + }
27 +
28 + public static function user_can_logout( $user = null ) {
29 + $userdata = self::get_user_login_choice();
30 + if( ! empty( $userdata ) ) {
31 + if( isset( $userdata['choice'] ) ) {
32 + return isset( $userdata['id'] ) ? $userdata['id'] === get_current_user_id() : false;
33 + }
34 + }
35 + return false;
36 + }
37 +
38 + public static function already_signedin_globally() {
39 + $userdata = self::get_user_login_choice();
40 + return isset( $userdata['choice'] ) && \boolval( $userdata['choice'] );
41 + }
42 +
43 + public static function get_global_signed_in_by_user( $user_id = null ) {
44 + if( is_null( $user_id ) ) {
45 + return false;
46 + }
47 + $userdata = self::get_user_login_choice();
48 + return isset( $userdata['id'] ) && $userdata['id'] == $user_id;
49 + }
50 +
51 + public static function set_link_my_account() {
52 + return update_user_meta( get_current_user_id(), '_templately_link_my_account', true );
53 + }
54 +
55 + public static function get_link_my_account() {
56 + $user_meta = get_user_meta( get_current_user_id(), '_templately_link_my_account', true );
57 + return ! empty( $user_meta ) ? $user_meta : false;
58 + }
59 +
60 + public static function delete_link_my_account() {
61 + return delete_user_meta( get_current_user_id(), '_templately_link_my_account' );
62 + }
63 +
64 +}