PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.4
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.4
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / freemius / includes / entities / class-fs-site.php

class-fs-site.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.1.4, at freemius/includes/entities/class-fs-site.php

257 lines 7.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 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 (
191 ( fs_starts_with( $subdomain, 'staging-' ) || fs_starts_with( $subdomain, 'env-' ) ) &&
192 ( fs_ends_with( $subdomain, '.kinsta.com' ) || fs_ends_with( $subdomain, '.kinsta.cloud' ) )
193 ) ||
194 // DesktopServer
195 fs_ends_with( $subdomain, '.dev.cc' ) ||
196 // Pressable
197 fs_ends_with( $subdomain, '.mystagingwebsite.com' ) ||
198 // WPMU DEV
199 ( fs_ends_with( $subdomain, '.tempurl.host' ) || fs_ends_with( $subdomain, '.wpmudev.host' ) ) ||
200 // Vendasta
201 ( fs_ends_with( $subdomain, '.websitepro-staging.com' ) || fs_ends_with( $subdomain, '.websitepro.hosting' ) ) ||
202 // InstaWP
203 fs_ends_with( $subdomain, '.instawp.xyz' )
204 );
205 }
206
207 function is_localhost() {
208 return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
209 }
210
211 /**
212 * Check if site in trial.
213 *
214 * @author Vova Feldman (@svovaf)
215 * @since 1.0.9
216 *
217 * @return bool
218 */
219 function is_trial() {
220 return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
221 }
222
223 /**
224 * Check if user already utilized the trial with the current install.
225 *
226 * @author Vova Feldman (@svovaf)
227 * @since 1.0.9
228 *
229 * @return bool
230 */
231 function is_trial_utilized() {
232 return is_numeric( $this->trial_plan_id );
233 }
234
235 /**
236 * @author Edgar Melkonyan
237 *
238 * @return bool
239 */
240 function is_beta() {
241 return ( isset( $this->is_beta ) && true === $this->is_beta );
242 }
243
244 /**
245 * @author Leo Fajardo (@leorw)
246 * @since 2.5.1
247 *
248 * @param string $site_url
249 *
250 * @return bool
251 */
252 function is_clone( $site_url ) {
253 $clone_install_url = trailingslashit( fs_strip_url_protocol( $this->url ) );
254
255 return ( $clone_install_url !== $site_url );
256 }
257 }