1 | <?php # -*- coding: utf-8 -*- |
||||||
2 | declare(strict_types=1); |
||||||
3 | |||||||
4 | namespace MultisiteGlobalMedia; |
||||||
5 | |||||||
6 | /** |
||||||
7 | * Class SingleSwitcher |
||||||
8 | */ |
||||||
9 | class SingleSwitcher implements SiteSwitcher |
||||||
10 | { |
||||||
11 | /** |
||||||
12 | * @var bool |
||||||
13 | */ |
||||||
14 | private $switched = false; |
||||||
15 | |||||||
16 | /** |
||||||
17 | * Switch to blog if needed |
||||||
18 | * |
||||||
19 | * @param int $siteId |
||||||
20 | */ |
||||||
21 | public function switchToBlog(int $siteId) |
||||||
22 | { |
||||||
23 | if (get_current_blog_id() === $siteId) { |
||||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
24 | return; |
||||||
25 | } |
||||||
26 | |||||||
27 | switch_to_blog($siteId); |
||||||
0 ignored issues
–
show
The function
switch_to_blog was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
28 | |||||||
29 | $this->switched = true; |
||||||
30 | } |
||||||
31 | |||||||
32 | /** |
||||||
33 | * Restore the current blog if needed |
||||||
34 | */ |
||||||
35 | public function restoreBlog() |
||||||
36 | { |
||||||
37 | if (!$this->switched) { |
||||||
38 | return; |
||||||
39 | } |
||||||
40 | |||||||
41 | restore_current_blog(); |
||||||
0 ignored issues
–
show
The function
restore_current_blog was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
42 | |||||||
43 | $this->switched = false; |
||||||
44 | } |
||||||
45 | } |
||||||
46 |