Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Getting_Started_Entry | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
72 | |
0.00% |
0 / 1 |
| get | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
42 | |||
| set | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\Jetpack_Boost\Data_Sync; |
| 4 | |
| 5 | use Automattic\Jetpack\Status; |
| 6 | use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Entry_Can_Get; |
| 7 | use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Entry_Can_Set; |
| 8 | use Automattic\Jetpack_Boost\Lib\Connection; |
| 9 | use Automattic\Jetpack_Boost\Lib\Premium_Features; |
| 10 | |
| 11 | class Getting_Started_Entry implements Entry_Can_Get, Entry_Can_Set { |
| 12 | private $option_key = 'jb_get_started'; |
| 13 | |
| 14 | /** |
| 15 | * Determines if the user should be shown the Getting Started page. |
| 16 | */ |
| 17 | public function get( $fallback = false ) { |
| 18 | // No point in showing the page if the site is offline, it's probably localhost. |
| 19 | if ( ( new Status() )->is_offline_mode() ) { |
| 20 | return false; |
| 21 | } |
| 22 | |
| 23 | // No need to show the page if the site is private. |
| 24 | if ( ( new Status() )->is_private_site() ) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | // If there is no connection, the page must be shown to give them a chance to connect by choosing a plan. |
| 29 | if ( ! ( new Connection() )->is_connected() ) { |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | // If the site already has premium plan, there is no need to show the page. |
| 34 | if ( Premium_Features::has_any() ) { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | // For all other cases, the page should be shown only if the flag is set. It indicates that it's a new site. |
| 39 | if ( $fallback !== false ) { |
| 40 | return \get_option( $this->option_key, $fallback ); |
| 41 | } |
| 42 | return \get_option( $this->option_key ); |
| 43 | } |
| 44 | |
| 45 | public function set( $value ) { |
| 46 | if ( $value === true ) { |
| 47 | update_option( $this->option_key, $value, false ); |
| 48 | } else { |
| 49 | delete_option( $this->option_key ); |
| 50 | } |
| 51 | } |
| 52 | } |