PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.5
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.5
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / includes / entities / class-fs-site.php

class-fs-site.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.5, at freemius/includes/entities/class-fs-site.php

223 lines 5.7 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 1.0.3
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class FS_Site extends FS_Scope_Entity {
14 /**
15 * @var number
16 */
17 public $site_id;
18 /**
19 * @var number
20 */
21 public $plugin_id;
22 /**
23 * @var number
24 */
25 public $user_id;
26 /**
27 * @var string
28 */
29 public $title;
30 /**
31 * @var string
32 */
33 public $url;
34 /**
35 * @var string
36 */
37 public $version;
38 /**
39 * @var string E.g. en-GB
40 */
41 public $language;
42 /**
43 * @var string E.g. UTF-8
44 */
45 public $charset;
46 /**
47 * @var string Platform version (e.g WordPress version).
48 */
49 public $platform_version;
50 /**
51 * Freemius SDK version
52 *
53 * @author Leo Fajardo (@leorw)
54 * @since 1.2.2
55 *
56 * @var string SDK version (e.g.: 1.2.2)
57 */
58 public $sdk_version;
59 /**
60 * @var string Programming language version (e.g PHP version).
61 */
62 public $programming_language_version;
63 /**
64 * @var number|null
65 */
66 public $plan_id;
67 /**
68 * @var number|null
69 */
70 public $license_id;
71 /**
72 * @var number|null
73 */
74 public $trial_plan_id;
75 /**
76 * @var string|null
77 */
78 public $trial_ends;
79 /**
80 * @since 1.0.9
81 *
82 * @var bool
83 */
84 public $is_premium = false;
85 /**
86 * @author Leo Fajardo (@leorw)
87 *
88 * @since 1.2.1.5
89 *
90 * @var bool
91 */
92 public $is_disconnected = false;
93 /**
94 * @since 2.0.0
95 *
96 * @var bool
97 */
98 public $is_active = true;
99 /**
100 * @since 2.0.0
101 *
102 * @var bool
103 */
104 public $is_uninstalled = false;
105
106 /**
107 * @param stdClass|bool $site
108 */
109 function __construct( $site = false ) {
110 parent::__construct( $site );
111
112 if ( is_object( $site ) ) {
113 $this->plan_id = $site->plan_id;
114 }
115
116 if ( ! is_bool( $this->is_disconnected ) ) {
117 $this->is_disconnected = false;
118 }
119 }
120
121 static function get_type() {
122 return 'install';
123 }
124
125 /**
126 * @author Vova Feldman (@svovaf)
127 * @since 2.0.0
128 *
129 * @param string $url
130 *
131 * @return bool
132 */
133 static function is_localhost_by_address( $url ) {
134 if ( false !== strpos( $url, '127.0.0.1' ) ||
135 false !== strpos( $url, 'localhost' )
136 ) {
137 return true;
138 }
139
140 if ( ! fs_starts_with( $url, 'http' ) ) {
141 $url = 'http://' . $url;
142 }
143
144 $url_parts = parse_url( $url );
145
146 $subdomain = $url_parts['host'];
147
148 return (
149 // Starts with.
150 fs_starts_with( $subdomain, 'local.' ) ||
151 fs_starts_with( $subdomain, 'dev.' ) ||
152 fs_starts_with( $subdomain, 'test.' ) ||
153 fs_starts_with( $subdomain, 'staging.' ) ||
154
155 // Ends with.
156 fs_ends_with( $subdomain, '.dev' ) ||
157 fs_ends_with( $subdomain, '.test' ) ||
158 fs_ends_with( $subdomain, '.staging' ) ||
159 fs_ends_with( $subdomain, '.local' ) ||
160 fs_ends_with( $subdomain, '.example' ) ||
161 fs_ends_with( $subdomain, '.invalid' ) ||
162 // GoDaddy test/dev.
163 fs_ends_with( $subdomain, '.myftpupload.com' ) ||
164 // ngrok tunneling.
165 fs_ends_with( $subdomain, '.ngrok.io' ) ||
166 // SiteGround staging.
167 fs_starts_with( $subdomain, 'staging' ) ||
168 // WPEngine staging.
169 fs_ends_with( $subdomain, '.staging.wpengine.com' ) ||
170 // Pantheon
171 ( fs_ends_with($subdomain, 'pantheonsite.io') &&
172 (fs_starts_with($subdomain, 'test-') || fs_starts_with($subdomain, 'dev-')))
173 );
174 }
175
176 function is_localhost() {
177 return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
178 }
179
180 /**
181 * Check if site in trial.
182 *
183 * @author Vova Feldman (@svovaf)
184 * @since 1.0.9
185 *
186 * @return bool
187 */
188 function is_trial() {
189 return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
190 }
191
192 /**
193 * Check if user already utilized the trial with the current install.
194 *
195 * @author Vova Feldman (@svovaf)
196 * @since 1.0.9
197 *
198 * @return bool
199 */
200 function is_trial_utilized() {
201 return is_numeric( $this->trial_plan_id );
202 }
203
204 /**
205 * @author Vova Feldman (@svovaf)
206 * @since 2.0.0
207 *
208 * @return bool
209 */
210 function is_tracking_allowed() {
211 return ( true !== $this->is_disconnected );
212 }
213
214 /**
215 * @author Vova Feldman (@svovaf)
216 * @since 2.0.0
217 *
218 * @return bool
219 */
220 function is_tracking_prohibited() {
221 return ! $this->is_tracking_allowed();
222 }
223 }