1 | <?php |
||
20 | class Admin_Sidebar_Link { |
||
21 | |||
22 | const SCHEDULE_ACTION_HOOK = 'jetpack_scan_refresh_states_event'; |
||
23 | |||
24 | /** |
||
25 | * The singleton instance of this class. |
||
26 | * |
||
27 | * @var Admin_Sidebar_Link |
||
28 | */ |
||
29 | protected static $instance; |
||
30 | |||
31 | /** |
||
32 | * Used to check if we need to schedule the refresh or we need to do it. |
||
33 | * |
||
34 | * @var boolean | null |
||
35 | */ |
||
36 | private $schedule_refresh_checked; |
||
37 | |||
38 | /** |
||
39 | * Get the singleton instance of the class. |
||
40 | * |
||
41 | * @return Admin_Sidebar_Link |
||
42 | */ |
||
43 | public static function instance() { |
||
51 | |||
52 | /** |
||
53 | * Adds action hooks. |
||
54 | */ |
||
55 | public function init_hooks() { |
||
59 | |||
60 | /** |
||
61 | * Adds a link to the Scan and Backup page. |
||
62 | */ |
||
63 | public function maybe_add_admin_link() { |
||
74 | |||
75 | /** |
||
76 | * Retuns the new link. |
||
77 | * |
||
78 | * @return array Link array to be added to the sidebar. |
||
79 | */ |
||
80 | private function get_new_link() { |
||
102 | |||
103 | /** |
||
104 | * We create a menu offset by counting all the pages that have a jetpack_admin_page set as the link. |
||
105 | * |
||
106 | * This makes it so that the highlight of the pages works as expected. When you click on the Setting or Dashboard. |
||
107 | * |
||
108 | * @return int Menu offset. |
||
109 | */ |
||
110 | private function get_link_offset() { |
||
120 | |||
121 | /** |
||
122 | * Refreshes the state cache via API call. Called via cron. |
||
123 | */ |
||
124 | public function refresh_state_cache() { |
||
128 | |||
129 | /** |
||
130 | * Returns true if the link should appear. |
||
131 | * |
||
132 | * @return boolean |
||
133 | */ |
||
134 | private function should_show_link() { |
||
148 | |||
149 | /** |
||
150 | * Detects if Scan is enabled. |
||
151 | * |
||
152 | * @return boolean |
||
153 | */ |
||
154 | private function has_scan() { |
||
159 | |||
160 | /** |
||
161 | * Detects if Backup is enabled. |
||
162 | * |
||
163 | * @return boolean |
||
164 | */ |
||
165 | private function has_backup() { |
||
170 | |||
171 | /** |
||
172 | * Triggers a cron job to refresh the Scan and Rewind state cache. |
||
173 | */ |
||
174 | private function maybe_refresh_transient_cache() { |
||
190 | } |
||
191 | |||
193 |