Skip to content

Commit 00360d4

Browse files
committed
[anonymous-mode] Support anonymous mode by default on sandbox sites.
1 parent f80b7a0 commit 00360d4

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

includes/class-freemius.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5236,7 +5236,14 @@ private function parse_settings( &$plugin_info ) {
52365236
$this->_anonymous_mode = false;
52375237
} else {
52385238
$this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
5239-
$this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
5239+
$this->_anonymous_mode = (
5240+
$this->get_bool_option( $plugin_info, 'anonymous_mode', false ) ||
5241+
(
5242+
$this->apply_filters( 'playground_anonymous_mode', true ) &&
5243+
! empty( $_SERVER['HTTP_HOST'] ) &&
5244+
FS_Site::is_playground_wp_environment_by_host( $_SERVER['HTTP_HOST'] )
5245+
)
5246+
);
52405247
}
52415248
$this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
52425249
$this->_is_bundle_license_auto_activation_enabled = $this->get_option( $plugin_info, 'bundle_license_auto_activation', false );

includes/entities/class-fs-site.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,39 @@ static function is_localhost_by_address( $url ) {
208208
);
209209
}
210210

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+
fs_ends_with( $host, '.' . $domain ) ||
235+
fs_ends_with( $host, '-' . $domain )
236+
) {
237+
return true;
238+
}
239+
}
240+
241+
return false;
242+
}
243+
211244
function is_localhost() {
212245
return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
213246
}

start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @var string
1717
*/
18-
$this_sdk_version = '2.9.0.1';
18+
$this_sdk_version = '2.9.0.2';
1919

2020
#region SDK Selection Logic --------------------------------------------------------------------
2121

0 commit comments

Comments
 (0)