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() { |
||
84 | |||
85 | /** |
||
86 | * We create a menu offset by counting all the pages that have a jetpack_admin_page set as the capability. |
||
87 | * |
||
88 | * This makes it so that the highlight of the pages works as expected. When you click on the Setting or Dashboard. |
||
89 | * |
||
90 | * @return int Menu offset. |
||
91 | */ |
||
92 | private function get_link_offset() { |
||
104 | |||
105 | /** |
||
106 | * Refreshes the state cache via API call. Called via cron. |
||
107 | */ |
||
108 | public function refresh_state_cache() { |
||
112 | |||
113 | /** |
||
114 | * Returns true if the link should appear. |
||
115 | * |
||
116 | * @return boolean |
||
117 | */ |
||
118 | private function should_show_link() { |
||
132 | |||
133 | /** |
||
134 | * Detects if Scan is enabled. |
||
135 | * |
||
136 | * @return boolean |
||
137 | */ |
||
138 | private function has_scan() { |
||
143 | |||
144 | /** |
||
145 | * Detects if Backup is enabled. |
||
146 | * |
||
147 | * @return boolean |
||
148 | */ |
||
149 | private function has_backup() { |
||
154 | |||
155 | /** |
||
156 | * Triggers a cron job to refresh the Scan and Rewind state cache. |
||
157 | */ |
||
158 | private function maybe_refresh_transient_cache() { |
||
174 | } |
||
175 | |||
177 |