| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Controls whether the site is publicly visible |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Extendify; |
| 8 |
|
| 9 |
defined('ABSPATH') || die('No direct access.'); |
| 10 |
|
| 11 |
/** |
| 12 |
* This class reads and writes the site's public visibility. |
| 13 |
*/ |
| 14 |
|
| 15 |
class SiteVisibility |
| 16 |
{ |
| 17 |
/** |
| 18 |
* The option holding the visibility state |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
// phpcs:ignore PSR12.Properties.ConstantVisibility.NotFound -- 7.0 floor: no const visibility |
| 23 |
const OPTION = 'extendify_site_visibility'; |
| 24 |
|
| 25 |
/** |
| 26 |
* Whether the site is visible to anonymous visitors. |
| 27 |
* |
| 28 |
* @return boolean |
| 29 |
*/ |
| 30 |
public static function isPublished() |
| 31 |
{ |
| 32 |
// A site with no marker predates the partner flag, so it stays public. |
| 33 |
return \get_option(self::OPTION) !== 'unpublished'; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Hide the site from anonymous visitors until the owner publishes it. |
| 38 |
* |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public static function markUnpublished() |
| 42 |
{ |
| 43 |
\update_option(self::OPTION, 'unpublished'); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Make the site visible to anonymous visitors. |
| 48 |
* |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
public static function markPublished() |
| 52 |
{ |
| 53 |
\update_option(self::OPTION, 'published'); |
| 54 |
} |
| 55 |
} |
| 56 |
|