Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User localhost site #462

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -20346,6 +20346,14 @@ private function _sync_plugin_license(

$is_site_level_sync = ( $is_context_single_site || fs_is_blog_admin() || ! $this->_is_network_active );

// Get whitelisted domains.
$whitelisted_domains = $this->get_user_localhost_sites();

// Store whitelisted domains to $_accounts.
if (is_object($whitelisted_domains)) {
self::$_accounts->set_option( 'whitelisted_domains', $whitelisted_domains->localhost_sites );
}

if ( ! $send_installs_update ) {
$site = $this->_site;
} else {
Expand Down Expand Up @@ -25335,5 +25343,15 @@ function add_show_pending( $path ) {
return $path . ( false !== strpos( $path, '?' ) ? '&' : '?' ) . 'show_pending=true';
}

/**
* @author Edgar Melkonyan
*
* @return stdClass|false
*/
function get_user_localhost_sites()
{
return $this->get_api_plugin_scope()->get("/users/{$this->_user->id}/localhost_site");
}

#endregion
}
13 changes: 13 additions & 0 deletions includes/entities/class-fs-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ static function is_localhost_by_address( $url ) {

$subdomain = $url_parts['host'];

// Get whitelisted domains list.
$accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
$whitelisted_domains = $accounts->get_option('whitelisted_domains');

if (null !== $whitelisted_domains) {
// Checking if a subdomain is in the whitelisted domains list.
foreach ($whitelisted_domains as $whitelisted_domain) {
if ($subdomain === $whitelisted_domain->domain) {
return true;
}
}
}

return (
// Starts with.
fs_starts_with( $subdomain, 'local.' ) ||
Expand Down