PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.22
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.22
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / freemius / includes / entities / class-fs-site.php

class-fs-site.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.22, at freemius/includes/entities/class-fs-site.php

261 lines 7.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 /**
14 * @property int $blog_id
15 */
16 #[AllowDynamicProperties]
17 class FS_Site extends FS_Scope_Entity {
18 /**
19 * @var number
20 */
21 public $site_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;
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, '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 function is_localhost() {
212 return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
213 }
214
215 /**
216 * Check if site in trial.
217 *
218 * @author Vova Feldman (@svovaf)
219 * @since 1.0.9
220 *
221 * @return bool
222 */
223 function is_trial() {
224 return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
225 }
226
227 /**
228 * Check if user already utilized the trial with the current install.
229 *
230 * @author Vova Feldman (@svovaf)
231 * @since 1.0.9
232 *
233 * @return bool
234 */
235 function is_trial_utilized() {
236 return is_numeric( $this->trial_plan_id );
237 }
238
239 /**
240 * @author Edgar Melkonyan
241 *
242 * @return bool
243 */
244 function is_beta() {
245 return ( isset( $this->is_beta ) && true === $this->is_beta );
246 }
247
248 /**
249 * @author Leo Fajardo (@leorw)
250 * @since 2.5.1
251 *
252 * @param string $site_url
253 *
254 * @return bool
255 */
256 function is_clone( $site_url ) {
257 $clone_install_url = trailingslashit( fs_strip_url_protocol( $this->url ) );
258
259 return ( $clone_install_url !== $site_url );
260 }
261 }