PluginProbe
Passster – Password Protect Pages and Content / 4.0
Passster – Password Protect Pages and Content v4.0
4.3.16 4.3.15 4.3.14 4.3.12 4.3.13 4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.5 trunk 3.5.4 3.5.5.2 3.5.5.8 3.5.5.9 4.0 4.1.4 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.15 All 48 releases
content-protector / inc / freemius / includes / entities / class-fs-site.php

class-fs-site.php in Passster – Password Protect Pages and Content 4.0, at inc/freemius/includes/entities/class-fs-site.php

254 lines 7.2 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 /**
14 * @property int $blog_id
15 */
16 class FS_Site extends FS_Scope_Entity {
17 /**
18 * @var number
19 */
20 public $site_id;
21 /**
22 * @var number
23 */
24 public $plugin_id;
25 /**
26 * @var number
27 */
28 public $user_id;
29 /**
30 * @var string
31 */
32 public $title;
33 /**
34 * @var string
35 */
36 public $url;
37 /**
38 * @var string
39 */
40 public $version;
41 /**
42 * @var string E.g. en-GB
43 */
44 public $language;
45 /**
46 * @var string Platform version (e.g WordPress version).
47 */
48 public $platform_version;
49 /**
50 * Freemius SDK version
51 *
52 * @author Leo Fajardo (@leorw)
53 * @since 1.2.2
54 *
55 * @var string SDK version (e.g.: 1.2.2)
56 */
57 public $sdk_version;
58 /**
59 * @var string Programming language version (e.g PHP version).
60 */
61 public $programming_language_version;
62 /**
63 * @var number|null
64 */
65 public $plan_id;
66 /**
67 * @var number|null
68 */
69 public $license_id;
70 /**
71 * @var number|null
72 */
73 public $trial_plan_id;
74 /**
75 * @var string|null
76 */
77 public $trial_ends;
78 /**
79 * @since 1.0.9
80 *
81 * @var bool
82 */
83 public $is_premium = false;
84 /**
85 * @author Leo Fajardo (@leorw)
86 *
87 * @since 1.2.1.5
88 * @deprecated Since 2.5.1
89 * @todo Remove after a few releases.
90 *
91 * @var bool
92 */
93 public $is_disconnected = false;
94 /**
95 * @since 2.0.0
96 *
97 * @var bool
98 */
99 public $is_active = true;
100 /**
101 * @since 2.0.0
102 *
103 * @var bool
104 */
105 public $is_uninstalled = false;
106 /**
107 * @author Edgar Melkonyan
108 *
109 * @since 2.4.2
110 *
111 * @var bool
112 */
113 public $is_beta;
114
115 /**
116 * @param stdClass|bool $site
117 */
118 function __construct( $site = false ) {
119 parent::__construct( $site );
120
121 if ( is_object( $site ) ) {
122 $this->plan_id = $site->plan_id;
123 }
124
125 if ( ! is_bool( $this->is_disconnected ) ) {
126 $this->is_disconnected = false;
127 }
128 }
129
130 static function get_type() {
131 return 'install';
132 }
133
134 /**
135 * @author Vova Feldman (@svovaf)
136 * @since 2.0.0
137 *
138 * @param string $url
139 *
140 * @return bool
141 */
142 static function is_localhost_by_address( $url ) {
143 if ( false !== strpos( $url, '127.0.0.1' ) ||
144 false !== strpos( $url, 'localhost' )
145 ) {
146 return true;
147 }
148
149 if ( ! fs_starts_with( $url, 'http' ) ) {
150 $url = 'http://' . $url;
151 }
152
153 $url_parts = parse_url( $url );
154
155 $subdomain = $url_parts['host'];
156
157 return (
158 // Starts with.
159 fs_starts_with( $subdomain, 'local.' ) ||
160 fs_starts_with( $subdomain, 'dev.' ) ||
161 fs_starts_with( $subdomain, 'test.' ) ||
162 fs_starts_with( $subdomain, 'stage.' ) ||
163 fs_starts_with( $subdomain, 'staging.' ) ||
164
165 // Ends with.
166 fs_ends_with( $subdomain, '.dev' ) ||
167 fs_ends_with( $subdomain, '.test' ) ||
168 fs_ends_with( $subdomain, '.staging' ) ||
169 fs_ends_with( $subdomain, '.local' ) ||
170 fs_ends_with( $subdomain, '.example' ) ||
171 fs_ends_with( $subdomain, '.invalid' ) ||
172 // GoDaddy test/dev.
173 fs_ends_with( $subdomain, '.myftpupload.com' ) ||
174 // ngrok tunneling.
175 fs_ends_with( $subdomain, '.ngrok.io' ) ||
176 // wpsandbox.
177 fs_ends_with( $subdomain, '.wpsandbox.pro' ) ||
178 // SiteGround staging.
179 fs_starts_with( $subdomain, 'staging' ) ||
180 // WPEngine staging.
181 fs_ends_with( $subdomain, '.staging.wpengine.com' ) ||
182 fs_ends_with( $subdomain, '.dev.wpengine.com' ) ||
183 fs_ends_with( $subdomain, '.wpengine.com' ) ||
184 // Pantheon
185 ( fs_ends_with( $subdomain, 'pantheonsite.io' ) &&
186 ( fs_starts_with( $subdomain, 'test-' ) || fs_starts_with( $subdomain, 'dev-' ) ) ) ||
187 // Cloudways
188 fs_ends_with( $subdomain, '.cloudwaysapps.com' ) ||
189 // Kinsta
190 ( fs_starts_with( $subdomain, 'staging-' ) && ( fs_ends_with( $subdomain, '.kinsta.com' ) || fs_ends_with( $subdomain, '.kinsta.cloud' ) ) ) ||
191 // DesktopServer
192 fs_ends_with( $subdomain, '.dev.cc' ) ||
193 // Pressable
194 fs_ends_with( $subdomain, '.mystagingwebsite.com' ) ||
195 // WPMU DEV
196 ( fs_ends_with( $subdomain, '.tempurl.host' ) || fs_ends_with( $subdomain, '.wpmudev.host' ) ) ||
197 // Vendasta
198 ( fs_ends_with( $subdomain, '.websitepro-staging.com' ) || fs_ends_with( $subdomain, '.websitepro.hosting' ) ) ||
199 // InstaWP
200 fs_ends_with( $subdomain, '.instawp.xyz' )
201 );
202 }
203
204 function is_localhost() {
205 return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
206 }
207
208 /**
209 * Check if site in trial.
210 *
211 * @author Vova Feldman (@svovaf)
212 * @since 1.0.9
213 *
214 * @return bool
215 */
216 function is_trial() {
217 return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
218 }
219
220 /**
221 * Check if user already utilized the trial with the current install.
222 *
223 * @author Vova Feldman (@svovaf)
224 * @since 1.0.9
225 *
226 * @return bool
227 */
228 function is_trial_utilized() {
229 return is_numeric( $this->trial_plan_id );
230 }
231
232 /**
233 * @author Edgar Melkonyan
234 *
235 * @return bool
236 */
237 function is_beta() {
238 return ( isset( $this->is_beta ) && true === $this->is_beta );
239 }
240
241 /**
242 * @author Leo Fajardo (@leorw)
243 * @since 2.5.1
244 *
245 * @param string $site_url
246 *
247 * @return bool
248 */
249 function is_clone( $site_url ) {
250 $clone_install_url = trailingslashit( fs_strip_url_protocol( $this->url ) );
251
252 return ( $clone_install_url !== $site_url );
253 }
254 }