1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Modules; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Database\OptionManager; |
6
|
|
|
use GeminiLabs\SiteReviews\Helpers\Arr; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @method \WP_Post|void|null getPost(int|string $postId) |
10
|
|
|
* @method array getPostIds(array $postIds) |
11
|
|
|
* @method bool isActive() |
12
|
|
|
* @method bool isEnabled() |
13
|
|
|
* @method bool isSupported() |
14
|
|
|
*/ |
15
|
|
|
class Multilingual |
16
|
|
|
{ |
17
|
|
|
protected $integration; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param string $method |
21
|
|
|
* @param array $args |
22
|
|
|
* @return |
23
|
|
|
*/ |
24
|
|
|
public function __call($method, $args = []) |
25
|
|
|
{ |
26
|
|
|
if ($this->isIntegrated() && method_exists($this->integration, $method)) { |
27
|
|
|
return call_user_func_array([$this->integration, $method], $args); |
28
|
|
|
} |
29
|
|
|
return Arr::get($args, 0, false); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $integration |
34
|
|
|
* @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml |
35
|
|
|
*/ |
36
|
|
|
public function getIntegration($integration = '') |
37
|
|
|
{ |
38
|
|
|
if (empty($integration)) { |
39
|
|
|
$integration = ucfirst(glsr(OptionManager::class)->get('settings.general.multilingual')); |
40
|
|
|
} |
41
|
|
|
$integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.$integration; |
42
|
|
|
if (class_exists($integrationClass)) { |
43
|
|
|
return glsr($integrationClass); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
glsr_log()->error($integrationClass.' does not exist'); |
46
|
|
|
return false; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* return bool |
51
|
|
|
*/ |
52
|
|
|
public function isIntegrated() |
53
|
|
|
{ |
54
|
|
|
if (!empty($this->integration)) { |
55
|
|
|
return true; |
56
|
|
|
} |
57
|
|
|
if ($integration = $this->getIntegration()) { |
58
|
|
|
$this->integration = $integration; |
59
|
|
|
return true; |
60
|
|
|
} |
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|