Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add 2 new methods to detect whether a site is private or not.
2 changes: 1 addition & 1 deletion projects/packages/status/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"link-template": "https://github.com/Automattic/jetpack-status/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "1.15.x-dev"
"dev-trunk": "1.16.x-dev"
}
}
}
37 changes: 37 additions & 0 deletions projects/packages/status/src/class-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,43 @@ public function is_onboarding() {
return \Jetpack_Options::get_option( 'onboarding' ) !== false;
}

/**
* Whether the site is currently private or not.
* On WordPress.com and WoA, sites can be marked as private
*
* @since $$next-version$$
*
* @return bool True if the site is private.
*/
public function is_private_site() {
$ret = Cache::get( 'is_private_site' );
if ( null === $ret ) {
$is_private_site = '-1' === get_option( 'blog_public' );
Cache::set( 'is_private_site', $is_private_site );
return $is_private_site;
}
return $ret;
}

/**
* Whether the site is currently unlaunched or not.
* On WordPress.com and WoA, sites can be marked as "coming soon", aka unlaunched
*
* @since $$next-version$$
*
* @return bool True if the site is not launched.
*/
public function is_coming_soon() {
$ret = Cache::get( 'is_coming_soon' );
if ( null === $ret ) {
$is_coming_soon = (bool) ( function_exists( 'site_is_coming_soon' ) && \site_is_coming_soon() )
|| get_option( 'wpcom_public_coming_soon' );
Cache::set( 'is_coming_soon', $is_coming_soon );
return $is_coming_soon;
}
return $ret;
}

/**
* Returns the site slug suffix to be used as part of Calypso URLs.
*
Expand Down
40 changes: 40 additions & 0 deletions projects/packages/status/tests/php/test-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,44 @@ public function provide_cached() {
);
}

/**
* Test that is_private_site returns true when get_option is set to -1.
*
* @covers Automattic\Jetpack\Status::is_private_site
*/
public function test_is_private_site() {
Functions\when( 'get_option' )->justReturn( '-1' );

$this->assertTrue( $this->status_obj->is_private_site() );
}

/**
* Test that is_coming_soon returns true when a site is set to coming soon.
*
* @covers Automattic\Jetpack\Status::is_coming_soon
* @dataProvider get_coming_soon_status
*
* @param bool $site_is_coming_soon Site is coming soon value.
* @param int $wpcom_public_coming_soon wpcom_public_coming_soon option value.
* @param bool $expected Expected result.
*/
public function test_is_coming_soon( $site_is_coming_soon, $wpcom_public_coming_soon, $expected ) {
Functions\when( 'site_is_coming_soon' )->justReturn( $site_is_coming_soon );
Functions\when( 'get_option' )->justReturn( $wpcom_public_coming_soon );
$this->assertSame( $expected, $this->status_obj->is_coming_soon() );
}

/**
* Mock data for test_is_coming_soon
*
* @return array
*/
public function get_coming_soon_status() {
return array(
'Jetpack public site' => array( null, false, false ),
'WoA public site' => array( false, false, false ),
'WoA private site' => array( true, false, true ),
'wpcom simple private site' => array( null, true, true ),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/backup/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/boost/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/jetpack/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/protect/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/search/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/social/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/starter-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/videopress/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.