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