PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.78
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.78
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / freemius / includes / class-fs-user-lock.php

class-fs-user-lock.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.78, at freemius/includes/class-fs-user-lock.php

90 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 2.1.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 require_once WP_FS__DIR_INCLUDES . '/class-fs-lock.php';
14
15 /**
16 * Class FS_User_Lock
17 */
18 class FS_User_Lock {
19 /**
20 * @var FS_Lock
21 */
22 private $_lock;
23
24 #--------------------------------------------------------------------------------
25 #region Singleton
26 #--------------------------------------------------------------------------------
27
28 /**
29 * @var FS_User_Lock
30 */
31 private static $_instance;
32
33 /**
34 * @author Vova Feldman (@svovaf)
35 * @since 2.1.0
36 *
37 * @return FS_User_Lock
38 */
39 static function instance() {
40 if ( ! isset( self::$_instance ) ) {
41 self::$_instance = new self();
42 }
43
44 return self::$_instance;
45 }
46
47 #endregion
48
49 private function __construct() {
50 $current_user_id = Freemius::get_current_wp_user_id();
51
52 $this->_lock = new FS_Lock( "locked_{$current_user_id}" );
53 }
54
55 /**
56 * Try to acquire lock. If the lock is already set or is being acquired by another locker, don't do anything.
57 *
58 * @author Vova Feldman (@svovaf)
59 * @since 2.1.0
60 *
61 * @param int $expiration
62 *
63 * @return bool TRUE if successfully acquired lock.
64 */
65 function try_lock( $expiration = 0 ) {
66 return $this->_lock->try_lock( $expiration );
67 }
68
69 /**
70 * Acquire lock regardless if it's already acquired by another locker or not.
71 *
72 * @author Vova Feldman (@svovaf)
73 * @since 2.1.0
74 *
75 * @param int $expiration
76 */
77 function lock( $expiration = 0 ) {
78 $this->_lock->lock( $expiration );
79 }
80
81 /**
82 * Unlock the lock.
83 *
84 * @author Vova Feldman (@svovaf)
85 * @since 2.1.0
86 */
87 function unlock() {
88 $this->_lock->unlock();
89 }
90 }