| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Controller for site visibility |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Extendify\Shared\Controllers; |
| 8 |
|
| 9 |
defined('ABSPATH') || die('No direct access.'); |
| 10 |
|
| 11 |
use Extendify\SiteVisibility; |
| 12 |
|
| 13 |
/** |
| 14 |
* The controller for moving the site in and out of Coming Soon mode and for |
| 15 |
* WordPress's "Discourage search engines" setting |
| 16 |
*/ |
| 17 |
|
| 18 |
class SiteVisibilityController |
| 19 |
{ |
| 20 |
/** |
| 21 |
* Publish the site |
| 22 |
* |
| 23 |
* @return \WP_REST_Response |
| 24 |
*/ |
| 25 |
public static function publish() |
| 26 |
{ |
| 27 |
SiteVisibility::markPublished(); |
| 28 |
|
| 29 |
return new \WP_REST_Response(['success' => true]); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Unpublish the site |
| 34 |
* |
| 35 |
* @return \WP_REST_Response |
| 36 |
*/ |
| 37 |
public static function unpublish() |
| 38 |
{ |
| 39 |
SiteVisibility::markUnpublished(); |
| 40 |
|
| 41 |
return new \WP_REST_Response(['success' => true]); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Let search engines index the site |
| 46 |
* |
| 47 |
* @return \WP_REST_Response |
| 48 |
*/ |
| 49 |
public static function allowIndexing() |
| 50 |
{ |
| 51 |
SiteVisibility::allowIndexing(); |
| 52 |
|
| 53 |
return new \WP_REST_Response(['success' => true]); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Ask search engines not to index the site |
| 58 |
* |
| 59 |
* @return \WP_REST_Response |
| 60 |
*/ |
| 61 |
public static function blockIndexing() |
| 62 |
{ |
| 63 |
SiteVisibility::blockIndexing(); |
| 64 |
|
| 65 |
return new \WP_REST_Response(['success' => true]); |
| 66 |
} |
| 67 |
} |
| 68 |
|