| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Controls whether the site is publicly visible | |
| 4 | + * Controls whether the site is publicly visible and indexable | |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | namespace Extendify; |
| 8 | 8 | |
| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | |
| 9 | 9 | defined('ABSPATH') || die('No direct access.'); |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | - * This class reads and writes the site's public visibility. | |
| 12 | + * This class reads and writes the site's public visibility and search engine indexing. | |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | class SiteVisibility |
| 16 | 16 | { |
| @@ -50,6 +50,36 @@ | ||
| 50 | 50 | */ |
| 51 | 51 | public static function markPublished() |
| 52 | 52 | { |
| 53 | 53 | \update_option(self::OPTION, 'published'); |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Whether WordPress's "Discourage search engines" setting is on. | |
| 58 | + * | |
| 59 | + * @return boolean | |
| 60 | + */ | |
| 61 | + public static function searchEnginesBlocked() | |
| 62 | + { | |
| 63 | + return (string) \get_option('blog_public') === '0'; | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Ask search engines not to index the site. | |
| 68 | + * | |
| 69 | + * @return void | |
| 70 | + */ | |
| 71 | + public static function blockIndexing() | |
| 72 | + { | |
| 73 | + \update_option('blog_public', '0'); | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * Let search engines index the site. | |
| 78 | + * | |
| 79 | + * @return void | |
| 80 | + */ | |
| 81 | + public static function allowIndexing() | |
| 82 | + { | |
| 83 | + \update_option('blog_public', '1'); | |
| 54 | 84 | } |
| 55 | 85 | } |