@@ -7,87 +7,87 @@ |
||
7 | 7 | |
8 | 8 | class Wpml implements Contract |
9 | 9 | { |
10 | - const PLUGIN_NAME = 'WPML'; |
|
11 | - const SUPPORTED_VERSION = '3.3.5'; |
|
10 | + const PLUGIN_NAME = 'WPML'; |
|
11 | + const SUPPORTED_VERSION = '3.3.5'; |
|
12 | 12 | |
13 | - /** |
|
14 | - * {@inheritdoc} |
|
15 | - */ |
|
16 | - public function getPost($postId) |
|
17 | - { |
|
18 | - apply_filters('console', $postId); |
|
19 | - $postId = trim($postId); |
|
20 | - if (!is_numeric($postId)) { |
|
21 | - return; |
|
22 | - } |
|
23 | - if ($this->isEnabled()) { |
|
24 | - apply_filters('console', $postId); |
|
25 | - $postId = apply_filters('wpml_object_id', $postId, 'any', true); |
|
26 | - apply_filters('console', $postId); |
|
27 | - } |
|
28 | - return get_post(intval($postId)); |
|
29 | - } |
|
13 | + /** |
|
14 | + * {@inheritdoc} |
|
15 | + */ |
|
16 | + public function getPost($postId) |
|
17 | + { |
|
18 | + apply_filters('console', $postId); |
|
19 | + $postId = trim($postId); |
|
20 | + if (!is_numeric($postId)) { |
|
21 | + return; |
|
22 | + } |
|
23 | + if ($this->isEnabled()) { |
|
24 | + apply_filters('console', $postId); |
|
25 | + $postId = apply_filters('wpml_object_id', $postId, 'any', true); |
|
26 | + apply_filters('console', $postId); |
|
27 | + } |
|
28 | + return get_post(intval($postId)); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * {@inheritdoc} |
|
33 | - */ |
|
34 | - public function getPostIds(array $postIds) |
|
35 | - { |
|
36 | - apply_filters('console', $postIds); |
|
37 | - if (!$this->isEnabled()) { |
|
38 | - return $postIds; |
|
39 | - } |
|
40 | - $newPostIds = []; |
|
41 | - foreach ($this->cleanIds($postIds) as $postId) { |
|
42 | - $postType = get_post_type($postId); |
|
43 | - if (!$postType) { |
|
44 | - continue; |
|
45 | - } |
|
46 | - $elementType = 'post_'.$postType; |
|
47 | - $trid = apply_filters('wpml_element_trid', null, $postId, $elementType); |
|
48 | - $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType); |
|
49 | - if (!is_array($translations)) { |
|
50 | - $translations = []; |
|
51 | - } |
|
52 | - $newPostIds = array_merge( |
|
53 | - $newPostIds, |
|
54 | - array_column($translations, 'element_id') |
|
55 | - ); |
|
56 | - } |
|
57 | - return $this->cleanIds($newPostIds); |
|
58 | - } |
|
31 | + /** |
|
32 | + * {@inheritdoc} |
|
33 | + */ |
|
34 | + public function getPostIds(array $postIds) |
|
35 | + { |
|
36 | + apply_filters('console', $postIds); |
|
37 | + if (!$this->isEnabled()) { |
|
38 | + return $postIds; |
|
39 | + } |
|
40 | + $newPostIds = []; |
|
41 | + foreach ($this->cleanIds($postIds) as $postId) { |
|
42 | + $postType = get_post_type($postId); |
|
43 | + if (!$postType) { |
|
44 | + continue; |
|
45 | + } |
|
46 | + $elementType = 'post_'.$postType; |
|
47 | + $trid = apply_filters('wpml_element_trid', null, $postId, $elementType); |
|
48 | + $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType); |
|
49 | + if (!is_array($translations)) { |
|
50 | + $translations = []; |
|
51 | + } |
|
52 | + $newPostIds = array_merge( |
|
53 | + $newPostIds, |
|
54 | + array_column($translations, 'element_id') |
|
55 | + ); |
|
56 | + } |
|
57 | + return $this->cleanIds($newPostIds); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - */ |
|
63 | - public function isActive() |
|
64 | - { |
|
65 | - return defined('ICL_SITEPRESS_VERSION'); |
|
66 | - } |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + */ |
|
63 | + public function isActive() |
|
64 | + { |
|
65 | + return defined('ICL_SITEPRESS_VERSION'); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * {@inheritdoc} |
|
70 | - */ |
|
71 | - public function isEnabled() |
|
72 | - { |
|
73 | - return $this->isActive() |
|
74 | - && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
75 | - } |
|
68 | + /** |
|
69 | + * {@inheritdoc} |
|
70 | + */ |
|
71 | + public function isEnabled() |
|
72 | + { |
|
73 | + return $this->isActive() |
|
74 | + && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * {@inheritdoc} |
|
79 | - */ |
|
80 | - public function isSupported() |
|
81 | - { |
|
82 | - return $this->isActive() |
|
83 | - && version_compare(ICL_SITEPRESS_VERSION, self::SUPPORTED_VERSION, '>='); |
|
84 | - } |
|
77 | + /** |
|
78 | + * {@inheritdoc} |
|
79 | + */ |
|
80 | + public function isSupported() |
|
81 | + { |
|
82 | + return $this->isActive() |
|
83 | + && version_compare(ICL_SITEPRESS_VERSION, self::SUPPORTED_VERSION, '>='); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - protected function cleanIds(array $postIds) |
|
90 | - { |
|
91 | - return array_filter(array_unique($postIds)); |
|
92 | - } |
|
86 | + /** |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + protected function cleanIds(array $postIds) |
|
90 | + { |
|
91 | + return array_filter(array_unique($postIds)); |
|
92 | + } |
|
93 | 93 | } |
@@ -7,79 +7,79 @@ |
||
7 | 7 | |
8 | 8 | class Polylang implements Contract |
9 | 9 | { |
10 | - const PLUGIN_NAME = 'Polylang'; |
|
11 | - const SUPPORTED_VERSION = '2.3'; |
|
10 | + const PLUGIN_NAME = 'Polylang'; |
|
11 | + const SUPPORTED_VERSION = '2.3'; |
|
12 | 12 | |
13 | - /** |
|
14 | - * {@inheritdoc} |
|
15 | - */ |
|
16 | - public function getPost($postId) |
|
17 | - { |
|
18 | - $postId = trim($postId); |
|
19 | - if (!is_numeric($postId)) { |
|
20 | - return; |
|
21 | - } |
|
22 | - if ($this->isEnabled()) { |
|
23 | - $polylangPostId = pll_get_post($postId, pll_get_post_language(get_the_ID())); |
|
24 | - } |
|
25 | - if (!empty($polylangPostId)) { |
|
26 | - $postId = $polylangPostId; |
|
27 | - } |
|
28 | - return get_post(intval($postId)); |
|
29 | - } |
|
13 | + /** |
|
14 | + * {@inheritdoc} |
|
15 | + */ |
|
16 | + public function getPost($postId) |
|
17 | + { |
|
18 | + $postId = trim($postId); |
|
19 | + if (!is_numeric($postId)) { |
|
20 | + return; |
|
21 | + } |
|
22 | + if ($this->isEnabled()) { |
|
23 | + $polylangPostId = pll_get_post($postId, pll_get_post_language(get_the_ID())); |
|
24 | + } |
|
25 | + if (!empty($polylangPostId)) { |
|
26 | + $postId = $polylangPostId; |
|
27 | + } |
|
28 | + return get_post(intval($postId)); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * {@inheritdoc} |
|
33 | - */ |
|
34 | - public function getPostIds(array $postIds) |
|
35 | - { |
|
36 | - if (!$this->isEnabled()) { |
|
37 | - return $postIds; |
|
38 | - } |
|
39 | - $newPostIds = []; |
|
40 | - foreach ($this->cleanIds($postIds) as $postId) { |
|
41 | - $newPostIds = array_merge( |
|
42 | - $newPostIds, |
|
43 | - array_values(pll_get_post_translations($postId)) |
|
44 | - ); |
|
45 | - } |
|
46 | - return $this->cleanIds($newPostIds); |
|
47 | - } |
|
31 | + /** |
|
32 | + * {@inheritdoc} |
|
33 | + */ |
|
34 | + public function getPostIds(array $postIds) |
|
35 | + { |
|
36 | + if (!$this->isEnabled()) { |
|
37 | + return $postIds; |
|
38 | + } |
|
39 | + $newPostIds = []; |
|
40 | + foreach ($this->cleanIds($postIds) as $postId) { |
|
41 | + $newPostIds = array_merge( |
|
42 | + $newPostIds, |
|
43 | + array_values(pll_get_post_translations($postId)) |
|
44 | + ); |
|
45 | + } |
|
46 | + return $this->cleanIds($newPostIds); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * {@inheritdoc} |
|
51 | - */ |
|
52 | - public function isActive() |
|
53 | - { |
|
54 | - return function_exists('PLL') |
|
55 | - && function_exists('pll_get_post') |
|
56 | - && function_exists('pll_get_post_language') |
|
57 | - && function_exists('pll_get_post_translations'); |
|
58 | - } |
|
49 | + /** |
|
50 | + * {@inheritdoc} |
|
51 | + */ |
|
52 | + public function isActive() |
|
53 | + { |
|
54 | + return function_exists('PLL') |
|
55 | + && function_exists('pll_get_post') |
|
56 | + && function_exists('pll_get_post_language') |
|
57 | + && function_exists('pll_get_post_translations'); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * {@inheritdoc} |
|
62 | - */ |
|
63 | - public function isEnabled() |
|
64 | - { |
|
65 | - return $this->isActive() |
|
66 | - && 'polylang' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
67 | - } |
|
60 | + /** |
|
61 | + * {@inheritdoc} |
|
62 | + */ |
|
63 | + public function isEnabled() |
|
64 | + { |
|
65 | + return $this->isActive() |
|
66 | + && 'polylang' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * {@inheritdoc} |
|
71 | - */ |
|
72 | - public function isSupported() |
|
73 | - { |
|
74 | - return defined('POLYLANG_VERSION') |
|
75 | - && version_compare(POLYLANG_VERSION, self::SUPPORTED_VERSION, '>='); |
|
76 | - } |
|
69 | + /** |
|
70 | + * {@inheritdoc} |
|
71 | + */ |
|
72 | + public function isSupported() |
|
73 | + { |
|
74 | + return defined('POLYLANG_VERSION') |
|
75 | + && version_compare(POLYLANG_VERSION, self::SUPPORTED_VERSION, '>='); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - protected function cleanIds(array $postIds) |
|
82 | - { |
|
83 | - return array_filter(array_unique($postIds)); |
|
84 | - } |
|
78 | + /** |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + protected function cleanIds(array $postIds) |
|
82 | + { |
|
83 | + return array_filter(array_unique($postIds)); |
|
84 | + } |
|
85 | 85 | } |