PluginProbe
Extendify / 3.2.3
Extendify v3.2.3
3.2.3 3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 All 129 releases
extendify / app / SiteVisibility.php

SiteVisibility.php in Extendify 3.2.3, at app/SiteVisibility.php

86 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Controls whether the site is publicly visible and indexable
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 and search engine indexing.
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 /**
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');
84 }
85 }
86