PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.3.3
StreamCast – bring live radio to your site with a sleek player v2.3.3
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / freemius / includes / entities / class-fs-site.php

class-fs-site.php in StreamCast – bring live radio to your site with a sleek player 2.3.3, at freemius/includes/entities/class-fs-site.php

295 lines 8.5 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 int
20 */
21 public $blog_id;
22 /**
23 * @var number
24 */
25 public $plugin_id;
26 /**
27 * @var number
28 */
29 public $user_id;
30 /**
31 * @var string
32 */
33 public $title;
34 /**
35 * @var string
36 */
37 public $url;
38 /**
39 * @var string
40 */
41 public $version;
42 /**
43 * @var string E.g. en-GB
44 */
45 public $language;
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 * @deprecated Since 2.5.1
90 * @todo Remove after a few releases.
91 *
92 * @var bool
93 */
94 public $is_disconnected = false;
95 /**
96 * @since 2.0.0
97 *
98 * @var bool
99 */
100 public $is_active = true;
101 /**
102 * @since 2.0.0
103 *
104 * @var bool
105 */
106 public $is_uninstalled = false;
107 /**
108 * @author Edgar Melkonyan
109 *
110 * @since 2.4.2
111 *
112 * @var bool
113 */
114 public $is_beta;
115
116 /**
117 * @param stdClass|bool $site
118 */
119 function __construct( $site = false ) {
120 parent::__construct( $site );
121
122 if ( is_object( $site ) ) {
123 $this->plan_id = $site->plan_id ?? null;
124 }
125
126 if ( ! is_bool( $this->is_disconnected ) ) {
127 $this->is_disconnected = false;
128 }
129 }
130
131 static function get_type() {
132 return 'install';
133 }
134
135 /**
136 * @author Vova Feldman (@svovaf)
137 * @since 2.0.0
138 *
139 * @param string $url
140 *
141 * @return bool
142 */
143 static function is_localhost_by_address( $url ) {
144 if ( false !== strpos( $url, '127.0.0.1' ) ||
145 false !== strpos( $url, 'localhost' )
146 ) {
147 return true;
148 }
149
150 if ( ! fs_starts_with( $url, 'http' ) ) {
151 $url = 'http://' . $url;
152 }
153
154 $url_parts = parse_url( $url );
155
156 $subdomain = $url_parts['host'];
157
158 return (
159 // Starts with.
160 fs_starts_with( $subdomain, 'local.' ) ||
161 fs_starts_with( $subdomain, 'dev.' ) ||
162 fs_starts_with( $subdomain, 'test.' ) ||
163 fs_starts_with( $subdomain, 'stage.' ) ||
164 fs_starts_with( $subdomain, 'staging.' ) ||
165
166 // Ends with.
167 fs_ends_with( $subdomain, '.dev' ) ||
168 fs_ends_with( $subdomain, '.test' ) ||
169 fs_ends_with( $subdomain, '.staging' ) ||
170 fs_ends_with( $subdomain, '.local' ) ||
171 fs_ends_with( $subdomain, '.example' ) ||
172 fs_ends_with( $subdomain, '.invalid' ) ||
173 // GoDaddy test/dev.
174 fs_ends_with( $subdomain, '.myftpupload.com' ) ||
175 // ngrok tunneling.
176 fs_ends_with( $subdomain, '.ngrok.io' ) ||
177 // wpsandbox.
178 fs_ends_with( $subdomain, '.wpsandbox.pro' ) ||
179 // SiteGround staging.
180 fs_starts_with( $subdomain, 'staging' ) ||
181 // WPEngine staging.
182 fs_ends_with( $subdomain, '.staging.wpengine.com' ) ||
183 fs_ends_with( $subdomain, '.dev.wpengine.com' ) ||
184 fs_ends_with( $subdomain, '.wpengine.com' ) ||
185 fs_ends_with( $subdomain, '.wpenginepowered.com' ) ||
186 // Pantheon
187 ( fs_ends_with( $subdomain, 'pantheonsite.io' ) &&
188 ( fs_starts_with( $subdomain, 'test-' ) || fs_starts_with( $subdomain, 'dev-' ) ) ) ||
189 // Cloudways
190 fs_ends_with( $subdomain, '.cloudwaysapps.com' ) ||
191 // Kinsta
192 (
193 ( fs_starts_with( $subdomain, 'stg-' ) || fs_starts_with( $subdomain, 'staging-' ) || fs_starts_with( $subdomain, 'env-' ) ) &&
194 ( fs_ends_with( $subdomain, '.kinsta.com' ) || fs_ends_with( $subdomain, '.kinsta.cloud' ) )
195 ) ||
196 // DesktopServer
197 fs_ends_with( $subdomain, '.dev.cc' ) ||
198 // Pressable
199 fs_ends_with( $subdomain, '.mystagingwebsite.com' ) ||
200 // WPMU DEV
201 ( fs_ends_with( $subdomain, '.tempurl.host' ) || fs_ends_with( $subdomain, '.wpmudev.host' ) ) ||
202 // Vendasta
203 ( fs_ends_with( $subdomain, '.websitepro-staging.com' ) || fs_ends_with( $subdomain, '.websitepro.hosting' ) ) ||
204 // InstaWP
205 fs_ends_with( $subdomain, '.instawp.xyz' ) ||
206 // 10Web Hosting
207 ( fs_ends_with( $subdomain, '-dev.10web.site' ) || fs_ends_with( $subdomain, '-dev.10web.cloud' ) )
208 );
209 }
210
211 /**
212 * @author Leo Fajardo (@leorw)
213 * @since 2.9.1
214 *
215 * @param string $host
216 *
217 * @return bool
218 */
219 static function is_playground_wp_environment_by_host( $host ) {
220 // Services aimed at providing a WordPress sandbox environment.
221 $sandbox_wp_environment_domains = array(
222 // InstaWP
223 'instawp.xyz',
224
225 // TasteWP
226 'tastewp.com',
227
228 // WordPress Playground
229 'playground.wordpress.net',
230 );
231
232 foreach ( $sandbox_wp_environment_domains as $domain) {
233 if (
234 ( $host === $domain ) ||
235 fs_ends_with( $host, '.' . $domain ) ||
236 fs_ends_with( $host, '-' . $domain )
237 ) {
238 return true;
239 }
240 }
241
242 return false;
243 }
244
245 function is_localhost() {
246 return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
247 }
248
249 /**
250 * Check if site in trial.
251 *
252 * @author Vova Feldman (@svovaf)
253 * @since 1.0.9
254 *
255 * @return bool
256 */
257 function is_trial() {
258 return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
259 }
260
261 /**
262 * Check if user already utilized the trial with the current install.
263 *
264 * @author Vova Feldman (@svovaf)
265 * @since 1.0.9
266 *
267 * @return bool
268 */
269 function is_trial_utilized() {
270 return is_numeric( $this->trial_plan_id );
271 }
272
273 /**
274 * @author Edgar Melkonyan
275 *
276 * @return bool
277 */
278 function is_beta() {
279 return ( isset( $this->is_beta ) && true === $this->is_beta );
280 }
281
282 /**
283 * @author Leo Fajardo (@leorw)
284 * @since 2.5.1
285 *
286 * @param string $site_url
287 *
288 * @return bool
289 */
290 function is_clone( $site_url ) {
291 $clone_install_url = trailingslashit( fs_strip_url_protocol( $this->url ) );
292
293 return ( $clone_install_url !== $site_url );
294 }
295 }