1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Modules; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Contracts\MultilingualContract as Contract; |
6
|
|
|
use GeminiLabs\SiteReviews\Database\OptionManager; |
7
|
|
|
|
8
|
|
|
class Multilingual implements Contract |
9
|
|
|
{ |
10
|
|
|
protected $integration; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @param string $integration |
14
|
|
|
* @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml |
15
|
|
|
*/ |
16
|
|
|
public function getIntegration($integration = '') |
17
|
|
|
{ |
18
|
|
|
if (empty($integration)) { |
19
|
|
|
$integration = ucfirst(glsr(OptionManager::class)->get('settings.general.multilingual')); |
20
|
|
|
} |
21
|
|
|
$integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.$integration; |
22
|
|
|
if (class_exists($integrationClass)) { |
23
|
|
|
return glsr($integrationClass); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
glsr_log()->error($integrationClass.' does not exist'); |
26
|
|
|
return false; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function getPost($postId) |
33
|
|
|
{ |
34
|
|
|
return $this->isIntegrated() |
35
|
|
|
? $this->integration->getPostIds($postId) |
36
|
|
|
: $postId; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function getPostIds(array $postIds) |
43
|
|
|
{ |
44
|
|
|
return $this->isIntegrated() |
45
|
|
|
? $this->integration->getPostIds($postIds) |
46
|
|
|
: $postIds; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function isActive() |
53
|
|
|
{ |
54
|
|
|
return $this->isIntegrated() |
55
|
|
|
? $this->integration->isActive() |
56
|
|
|
: false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function isEnabled() |
63
|
|
|
{ |
64
|
|
|
return $this->isIntegrated() |
65
|
|
|
? $this->integration->isEnabled() |
66
|
|
|
: false; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
public function isSupported() |
73
|
|
|
{ |
74
|
|
|
return $this->isIntegrated() |
75
|
|
|
? $this->integration->isSupported() |
76
|
|
|
: false; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* return bool |
81
|
|
|
*/ |
82
|
|
|
protected function isIntegrated() |
83
|
|
|
{ |
84
|
|
|
if (!empty($this->integration)) { |
85
|
|
|
return true; |
86
|
|
|
} |
87
|
|
|
if ($integration = $this->getIntegration()) { |
88
|
|
|
$this->integration = $integration; |
89
|
|
|
return true; |
90
|
|
|
} |
91
|
|
|
return false; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|