@@ -7,83 +7,83 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Wpml implements Contract |
| 9 | 9 | { |
| 10 | - public $pluginName = 'WPML'; |
|
| 11 | - public $supportedVersion = '3.3.5'; |
|
| 10 | + public $pluginName = 'WPML'; |
|
| 11 | + public $supportedVersion = '3.3.5'; |
|
| 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 | - $postId = apply_filters('wpml_object_id', $postId, 'any', true); |
|
| 24 | - } |
|
| 25 | - return get_post(intval($postId)); |
|
| 26 | - } |
|
| 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 | + $postId = apply_filters('wpml_object_id', $postId, 'any', true); |
|
| 24 | + } |
|
| 25 | + return get_post(intval($postId)); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function getPostIds(array $postIds) |
|
| 32 | - { |
|
| 33 | - if (!$this->isEnabled()) { |
|
| 34 | - return $postIds; |
|
| 35 | - } |
|
| 36 | - $newPostIds = []; |
|
| 37 | - foreach ($this->cleanIds($postIds) as $postId) { |
|
| 38 | - $postType = get_post_type($postId); |
|
| 39 | - if (!$postType) { |
|
| 40 | - continue; |
|
| 41 | - } |
|
| 42 | - $elementType = 'post_'.$postType; |
|
| 43 | - $trid = apply_filters('wpml_element_trid', null, $postId, $elementType); |
|
| 44 | - $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType); |
|
| 45 | - if (!is_array($translations)) { |
|
| 46 | - $translations = []; |
|
| 47 | - } |
|
| 48 | - $newPostIds = array_merge( |
|
| 49 | - $newPostIds, |
|
| 50 | - array_column($translations, 'element_id') |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - return $this->cleanIds($newPostIds); |
|
| 54 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function getPostIds(array $postIds) |
|
| 32 | + { |
|
| 33 | + if (!$this->isEnabled()) { |
|
| 34 | + return $postIds; |
|
| 35 | + } |
|
| 36 | + $newPostIds = []; |
|
| 37 | + foreach ($this->cleanIds($postIds) as $postId) { |
|
| 38 | + $postType = get_post_type($postId); |
|
| 39 | + if (!$postType) { |
|
| 40 | + continue; |
|
| 41 | + } |
|
| 42 | + $elementType = 'post_'.$postType; |
|
| 43 | + $trid = apply_filters('wpml_element_trid', null, $postId, $elementType); |
|
| 44 | + $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType); |
|
| 45 | + if (!is_array($translations)) { |
|
| 46 | + $translations = []; |
|
| 47 | + } |
|
| 48 | + $newPostIds = array_merge( |
|
| 49 | + $newPostIds, |
|
| 50 | + array_column($translations, 'element_id') |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + return $this->cleanIds($newPostIds); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * {@inheritdoc} |
|
| 58 | - */ |
|
| 59 | - public function isActive() |
|
| 60 | - { |
|
| 61 | - return defined('ICL_SITEPRESS_VERSION'); |
|
| 62 | - } |
|
| 56 | + /** |
|
| 57 | + * {@inheritdoc} |
|
| 58 | + */ |
|
| 59 | + public function isActive() |
|
| 60 | + { |
|
| 61 | + return defined('ICL_SITEPRESS_VERSION'); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * {@inheritdoc} |
|
| 66 | - */ |
|
| 67 | - public function isEnabled() |
|
| 68 | - { |
|
| 69 | - return $this->isActive() |
|
| 70 | - && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
| 71 | - } |
|
| 64 | + /** |
|
| 65 | + * {@inheritdoc} |
|
| 66 | + */ |
|
| 67 | + public function isEnabled() |
|
| 68 | + { |
|
| 69 | + return $this->isActive() |
|
| 70 | + && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * {@inheritdoc} |
|
| 75 | - */ |
|
| 76 | - public function isSupported() |
|
| 77 | - { |
|
| 78 | - return $this->isActive() |
|
| 79 | - && version_compare(ICL_SITEPRESS_VERSION, $this->supportedVersion, '>='); |
|
| 80 | - } |
|
| 73 | + /** |
|
| 74 | + * {@inheritdoc} |
|
| 75 | + */ |
|
| 76 | + public function isSupported() |
|
| 77 | + { |
|
| 78 | + return $this->isActive() |
|
| 79 | + && version_compare(ICL_SITEPRESS_VERSION, $this->supportedVersion, '>='); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @return array |
|
| 84 | - */ |
|
| 85 | - protected function cleanIds(array $postIds) |
|
| 86 | - { |
|
| 87 | - return array_filter(array_unique($postIds)); |
|
| 88 | - } |
|
| 82 | + /** |
|
| 83 | + * @return array |
|
| 84 | + */ |
|
| 85 | + protected function cleanIds(array $postIds) |
|
| 86 | + { |
|
| 87 | + return array_filter(array_unique($postIds)); |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -13,44 +13,44 @@ 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 | - $postId = apply_filters('wpml_object_id', $postId, 'any', true); |
|
| 22 | + if( $this->isEnabled() ) { |
|
| 23 | + $postId = apply_filters( 'wpml_object_id', $postId, 'any', true ); |
|
| 24 | 24 | } |
| 25 | - return get_post(intval($postId)); |
|
| 25 | + return get_post( intval( $postId ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * {@inheritdoc} |
| 30 | 30 | */ |
| 31 | - public function getPostIds(array $postIds) |
|
| 31 | + public function getPostIds( array $postIds ) |
|
| 32 | 32 | { |
| 33 | - if (!$this->isEnabled()) { |
|
| 33 | + if( !$this->isEnabled() ) { |
|
| 34 | 34 | return $postIds; |
| 35 | 35 | } |
| 36 | 36 | $newPostIds = []; |
| 37 | - foreach ($this->cleanIds($postIds) as $postId) { |
|
| 38 | - $postType = get_post_type($postId); |
|
| 39 | - if (!$postType) { |
|
| 37 | + foreach( $this->cleanIds( $postIds ) as $postId ) { |
|
| 38 | + $postType = get_post_type( $postId ); |
|
| 39 | + if( !$postType ) { |
|
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | 42 | $elementType = 'post_'.$postType; |
| 43 | - $trid = apply_filters('wpml_element_trid', null, $postId, $elementType); |
|
| 44 | - $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType); |
|
| 45 | - if (!is_array($translations)) { |
|
| 43 | + $trid = apply_filters( 'wpml_element_trid', null, $postId, $elementType ); |
|
| 44 | + $translations = apply_filters( 'wpml_get_element_translations', null, $trid, $elementType ); |
|
| 45 | + if( !is_array( $translations ) ) { |
|
| 46 | 46 | $translations = []; |
| 47 | 47 | } |
| 48 | 48 | $newPostIds = array_merge( |
| 49 | 49 | $newPostIds, |
| 50 | - array_column($translations, 'element_id') |
|
| 50 | + array_column( $translations, 'element_id' ) |
|
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | - return $this->cleanIds($newPostIds); |
|
| 53 | + return $this->cleanIds( $newPostIds ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function isActive() |
| 60 | 60 | { |
| 61 | - return defined('ICL_SITEPRESS_VERSION'); |
|
| 61 | + return defined( 'ICL_SITEPRESS_VERSION' ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | public function isEnabled() |
| 68 | 68 | { |
| 69 | 69 | return $this->isActive() |
| 70 | - && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
| 70 | + && 'wpml' == glsr( OptionManager::class )->get( 'settings.general.multilingual' ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | public function isSupported() |
| 77 | 77 | { |
| 78 | 78 | return $this->isActive() |
| 79 | - && version_compare(ICL_SITEPRESS_VERSION, $this->supportedVersion, '>='); |
|
| 79 | + && version_compare( ICL_SITEPRESS_VERSION, $this->supportedVersion, '>=' ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * @return array |
| 84 | 84 | */ |
| 85 | - protected function cleanIds(array $postIds) |
|
| 85 | + protected function cleanIds( array $postIds ) |
|
| 86 | 86 | { |
| 87 | - return array_filter(array_unique($postIds)); |
|
| 87 | + return array_filter( array_unique( $postIds ) ); |
|
| 88 | 88 | } |
| 89 | 89 | } |
@@ -7,79 +7,79 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Polylang implements Contract |
| 9 | 9 | { |
| 10 | - public $pluginName = 'Polylang'; |
|
| 11 | - public $supportedVersion = '2.3'; |
|
| 10 | + public $pluginName = 'Polylang'; |
|
| 11 | + public $supportedVersion = '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, $this->supportedVersion, '>='); |
|
| 76 | - } |
|
| 69 | + /** |
|
| 70 | + * {@inheritdoc} |
|
| 71 | + */ |
|
| 72 | + public function isSupported() |
|
| 73 | + { |
|
| 74 | + return defined('POLYLANG_VERSION') |
|
| 75 | + && version_compare(POLYLANG_VERSION, $this->supportedVersion, '>='); |
|
| 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, $this->supportedVersion, '>='); |
|
| 74 | + return defined( 'POLYLANG_VERSION' ) |
|
| 75 | + && version_compare( POLYLANG_VERSION, $this->supportedVersion, '>=' ); |
|
| 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 | } |
@@ -7,87 +7,87 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Multilingual implements Contract |
| 9 | 9 | { |
| 10 | - protected $integration; |
|
| 10 | + protected $integration; |
|
| 11 | 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 | - return false; |
|
| 26 | - } |
|
| 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 | + return false; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function getPost($postId) |
|
| 32 | - { |
|
| 33 | - return $this->isIntegrated() |
|
| 34 | - ? $this->integration->getPostIds($postId) |
|
| 35 | - : $postId; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function getPost($postId) |
|
| 32 | + { |
|
| 33 | + return $this->isIntegrated() |
|
| 34 | + ? $this->integration->getPostIds($postId) |
|
| 35 | + : $postId; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * {@inheritdoc} |
|
| 40 | - */ |
|
| 41 | - public function getPostIds(array $postIds) |
|
| 42 | - { |
|
| 43 | - return $this->isIntegrated() |
|
| 44 | - ? $this->integration->getPostIds($postIds) |
|
| 45 | - : $postIds; |
|
| 46 | - } |
|
| 38 | + /** |
|
| 39 | + * {@inheritdoc} |
|
| 40 | + */ |
|
| 41 | + public function getPostIds(array $postIds) |
|
| 42 | + { |
|
| 43 | + return $this->isIntegrated() |
|
| 44 | + ? $this->integration->getPostIds($postIds) |
|
| 45 | + : $postIds; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritdoc} |
|
| 50 | - */ |
|
| 51 | - public function isActive() |
|
| 52 | - { |
|
| 53 | - return $this->isIntegrated() |
|
| 54 | - ? $this->integration->isActive() |
|
| 55 | - : false; |
|
| 56 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritdoc} |
|
| 50 | + */ |
|
| 51 | + public function isActive() |
|
| 52 | + { |
|
| 53 | + return $this->isIntegrated() |
|
| 54 | + ? $this->integration->isActive() |
|
| 55 | + : false; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * {@inheritdoc} |
|
| 60 | - */ |
|
| 61 | - public function isEnabled() |
|
| 62 | - { |
|
| 63 | - return $this->isIntegrated() |
|
| 64 | - ? $this->integration->isEnabled() |
|
| 65 | - : false; |
|
| 66 | - } |
|
| 58 | + /** |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + */ |
|
| 61 | + public function isEnabled() |
|
| 62 | + { |
|
| 63 | + return $this->isIntegrated() |
|
| 64 | + ? $this->integration->isEnabled() |
|
| 65 | + : false; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * {@inheritdoc} |
|
| 70 | - */ |
|
| 71 | - public function isSupported() |
|
| 72 | - { |
|
| 73 | - return $this->isIntegrated() |
|
| 74 | - ? $this->integration->isSupported() |
|
| 75 | - : false; |
|
| 76 | - } |
|
| 68 | + /** |
|
| 69 | + * {@inheritdoc} |
|
| 70 | + */ |
|
| 71 | + public function isSupported() |
|
| 72 | + { |
|
| 73 | + return $this->isIntegrated() |
|
| 74 | + ? $this->integration->isSupported() |
|
| 75 | + : false; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * return bool |
|
| 80 | - */ |
|
| 81 | - protected function isIntegrated() |
|
| 82 | - { |
|
| 83 | - if (!empty($this->integration)) { |
|
| 84 | - return true; |
|
| 85 | - } |
|
| 86 | - if ($integration = $this->getIntegration()) { |
|
| 87 | - $this->integration = $integration; |
|
| 88 | - return true; |
|
| 89 | - } |
|
| 90 | - glsr_log()->error($integrationClass.' does not exist'); |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 78 | + /** |
|
| 79 | + * return bool |
|
| 80 | + */ |
|
| 81 | + protected function isIntegrated() |
|
| 82 | + { |
|
| 83 | + if (!empty($this->integration)) { |
|
| 84 | + return true; |
|
| 85 | + } |
|
| 86 | + if ($integration = $this->getIntegration()) { |
|
| 87 | + $this->integration = $integration; |
|
| 88 | + return true; |
|
| 89 | + } |
|
| 90 | + glsr_log()->error($integrationClass.' does not exist'); |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | * @param string $integration |
| 14 | 14 | * @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml |
| 15 | 15 | */ |
| 16 | - public function getIntegration($integration = '') |
|
| 16 | + public function getIntegration( $integration = '' ) |
|
| 17 | 17 | { |
| 18 | - if (empty($integration)) { |
|
| 19 | - $integration = ucfirst(glsr(OptionManager::class)->get('settings.general.multilingual')); |
|
| 18 | + if( empty($integration) ) { |
|
| 19 | + $integration = ucfirst( glsr( OptionManager::class )->get( 'settings.general.multilingual' ) ); |
|
| 20 | 20 | } |
| 21 | 21 | $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.$integration; |
| 22 | - if (class_exists($integrationClass)) { |
|
| 23 | - return glsr($integrationClass); |
|
| 22 | + if( class_exists( $integrationClass ) ) { |
|
| 23 | + return glsr( $integrationClass ); |
|
| 24 | 24 | } |
| 25 | 25 | return false; |
| 26 | 26 | } |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * {@inheritdoc} |
| 30 | 30 | */ |
| 31 | - public function getPost($postId) |
|
| 31 | + public function getPost( $postId ) |
|
| 32 | 32 | { |
| 33 | 33 | return $this->isIntegrated() |
| 34 | - ? $this->integration->getPostIds($postId) |
|
| 34 | + ? $this->integration->getPostIds( $postId ) |
|
| 35 | 35 | : $postId; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * {@inheritdoc} |
| 40 | 40 | */ |
| 41 | - public function getPostIds(array $postIds) |
|
| 41 | + public function getPostIds( array $postIds ) |
|
| 42 | 42 | { |
| 43 | 43 | return $this->isIntegrated() |
| 44 | - ? $this->integration->getPostIds($postIds) |
|
| 44 | + ? $this->integration->getPostIds( $postIds ) |
|
| 45 | 45 | : $postIds; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function isIntegrated() |
| 82 | 82 | { |
| 83 | - if (!empty($this->integration)) { |
|
| 83 | + if( !empty($this->integration) ) { |
|
| 84 | 84 | return true; |
| 85 | 85 | } |
| 86 | - if ($integration = $this->getIntegration()) { |
|
| 86 | + if( $integration = $this->getIntegration() ) { |
|
| 87 | 87 | $this->integration = $integration; |
| 88 | 88 | return true; |
| 89 | 89 | } |
| 90 | - glsr_log()->error($integrationClass.' does not exist'); |
|
| 90 | + glsr_log()->error( $integrationClass.' does not exist' ); |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -9,121 +9,121 @@ |
||
| 9 | 9 | |
| 10 | 10 | class SettingsController extends Controller |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @param mixed $input |
|
| 14 | - * @return array |
|
| 15 | - * @callback register_setting |
|
| 16 | - */ |
|
| 17 | - public function callbackRegisterSettings($input) |
|
| 18 | - { |
|
| 19 | - $settings = Arr::consolidateArray($input); |
|
| 20 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
| 21 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
| 22 | - $options = $this->sanitizeGeneral($input, $options); |
|
| 23 | - $options = $this->sanitizeSubmissions($input, $options); |
|
| 24 | - $options = $this->sanitizeTranslations($input, $options); |
|
| 25 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
| 26 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
| 27 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
| 28 | - } |
|
| 29 | - return $options; |
|
| 30 | - } |
|
| 31 | - return $input; |
|
| 32 | - } |
|
| 12 | + /** |
|
| 13 | + * @param mixed $input |
|
| 14 | + * @return array |
|
| 15 | + * @callback register_setting |
|
| 16 | + */ |
|
| 17 | + public function callbackRegisterSettings($input) |
|
| 18 | + { |
|
| 19 | + $settings = Arr::consolidateArray($input); |
|
| 20 | + if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
| 21 | + $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
| 22 | + $options = $this->sanitizeGeneral($input, $options); |
|
| 23 | + $options = $this->sanitizeSubmissions($input, $options); |
|
| 24 | + $options = $this->sanitizeTranslations($input, $options); |
|
| 25 | + $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
| 26 | + if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
| 27 | + glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
| 28 | + } |
|
| 29 | + return $options; |
|
| 30 | + } |
|
| 31 | + return $input; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @return void |
|
| 36 | - * @action admin_init |
|
| 37 | - */ |
|
| 38 | - public function registerSettings() |
|
| 39 | - { |
|
| 40 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
| 41 | - 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
| 42 | - ]); |
|
| 43 | - } |
|
| 34 | + /** |
|
| 35 | + * @return void |
|
| 36 | + * @action admin_init |
|
| 37 | + */ |
|
| 38 | + public function registerSettings() |
|
| 39 | + { |
|
| 40 | + register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
| 41 | + 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
| 42 | + ]); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 48 | - protected function sanitizeGeneral(array $input, array $options) |
|
| 49 | - { |
|
| 50 | - $key = 'settings.general'; |
|
| 51 | - $inputForm = Arr::get($input, $key); |
|
| 52 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
| 53 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
| 54 | - } |
|
| 55 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
| 56 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
| 57 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
| 58 | - } |
|
| 59 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
| 60 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
| 61 | - return $options; |
|
| 62 | - } |
|
| 45 | + /** |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | + protected function sanitizeGeneral(array $input, array $options) |
|
| 49 | + { |
|
| 50 | + $key = 'settings.general'; |
|
| 51 | + $inputForm = Arr::get($input, $key); |
|
| 52 | + if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
| 53 | + $options = Arr::set($options, $key.'.multilingual', ''); |
|
| 54 | + } |
|
| 55 | + if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
| 56 | + $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
| 57 | + $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
| 58 | + } |
|
| 59 | + $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
| 60 | + $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
| 61 | + return $options; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return array |
|
| 66 | - */ |
|
| 67 | - protected function sanitizeSubmissions(array $input, array $options) |
|
| 68 | - { |
|
| 69 | - $key = 'settings.submissions'; |
|
| 70 | - $inputForm = Arr::get($input, $key); |
|
| 71 | - $defaultValue = isset($inputForm['required']) |
|
| 72 | - ? $inputForm['required'] |
|
| 73 | - : []; |
|
| 74 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
| 75 | - return $options; |
|
| 76 | - } |
|
| 64 | + /** |
|
| 65 | + * @return array |
|
| 66 | + */ |
|
| 67 | + protected function sanitizeSubmissions(array $input, array $options) |
|
| 68 | + { |
|
| 69 | + $key = 'settings.submissions'; |
|
| 70 | + $inputForm = Arr::get($input, $key); |
|
| 71 | + $defaultValue = isset($inputForm['required']) |
|
| 72 | + ? $inputForm['required'] |
|
| 73 | + : []; |
|
| 74 | + $options = Arr::set($options, $key.'.required', $defaultValue); |
|
| 75 | + return $options; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - protected function sanitizeTranslations(array $input, array $options) |
|
| 82 | - { |
|
| 83 | - $key = 'settings.strings'; |
|
| 84 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
| 85 | - if (!empty($inputForm)) { |
|
| 86 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
| 87 | - $allowedTags = [ |
|
| 88 | - 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
| 89 | - 'span' => ['class' => []], |
|
| 90 | - ]; |
|
| 91 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
| 92 | - if (isset($string['s2'])) { |
|
| 93 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
| 94 | - } |
|
| 95 | - if (isset($string['p2'])) { |
|
| 96 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
| 97 | - } |
|
| 98 | - }); |
|
| 99 | - } |
|
| 100 | - return $options; |
|
| 101 | - } |
|
| 78 | + /** |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + protected function sanitizeTranslations(array $input, array $options) |
|
| 82 | + { |
|
| 83 | + $key = 'settings.strings'; |
|
| 84 | + $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
| 85 | + if (!empty($inputForm)) { |
|
| 86 | + $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
| 87 | + $allowedTags = [ |
|
| 88 | + 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
| 89 | + 'span' => ['class' => []], |
|
| 90 | + ]; |
|
| 91 | + array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
| 92 | + if (isset($string['s2'])) { |
|
| 93 | + $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
| 94 | + } |
|
| 95 | + if (isset($string['p2'])) { |
|
| 96 | + $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
| 97 | + } |
|
| 98 | + }); |
|
| 99 | + } |
|
| 100 | + return $options; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param string $integrationSlug |
|
| 105 | - * @return bool |
|
| 106 | - */ |
|
| 107 | - protected function hasMultilingualIntegration($integrationSlug) |
|
| 108 | - { |
|
| 109 | - $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
| 110 | - if (!$integration) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - if (!$integration->isActive()) { |
|
| 114 | - glsr(Notice::class)->addError(sprintf( |
|
| 115 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
| 116 | - $integration->pluginName |
|
| 117 | - )); |
|
| 118 | - return false; |
|
| 119 | - } elseif (!$integration->isSupported()) { |
|
| 120 | - glsr(Notice::class)->addError(sprintf( |
|
| 121 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
| 122 | - $integration->pluginName, |
|
| 123 | - $integration->supportedVersion |
|
| 124 | - )); |
|
| 125 | - return false; |
|
| 126 | - } |
|
| 127 | - return true; |
|
| 128 | - } |
|
| 103 | + /** |
|
| 104 | + * @param string $integrationSlug |
|
| 105 | + * @return bool |
|
| 106 | + */ |
|
| 107 | + protected function hasMultilingualIntegration($integrationSlug) |
|
| 108 | + { |
|
| 109 | + $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
| 110 | + if (!$integration) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + if (!$integration->isActive()) { |
|
| 114 | + glsr(Notice::class)->addError(sprintf( |
|
| 115 | + __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
| 116 | + $integration->pluginName |
|
| 117 | + )); |
|
| 118 | + return false; |
|
| 119 | + } elseif (!$integration->isSupported()) { |
|
| 120 | + glsr(Notice::class)->addError(sprintf( |
|
| 121 | + __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
| 122 | + $integration->pluginName, |
|
| 123 | + $integration->supportedVersion |
|
| 124 | + )); |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 127 | + return true; |
|
| 128 | + } |
|
| 129 | 129 | } |
@@ -14,17 +14,17 @@ discard block |
||
| 14 | 14 | * @return array |
| 15 | 15 | * @callback register_setting |
| 16 | 16 | */ |
| 17 | - public function callbackRegisterSettings($input) |
|
| 17 | + public function callbackRegisterSettings( $input ) |
|
| 18 | 18 | { |
| 19 | - $settings = Arr::consolidateArray($input); |
|
| 20 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
| 21 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
| 22 | - $options = $this->sanitizeGeneral($input, $options); |
|
| 23 | - $options = $this->sanitizeSubmissions($input, $options); |
|
| 24 | - $options = $this->sanitizeTranslations($input, $options); |
|
| 25 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
| 26 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
| 27 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
| 19 | + $settings = Arr::consolidateArray( $input ); |
|
| 20 | + if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) { |
|
| 21 | + $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
|
| 22 | + $options = $this->sanitizeGeneral( $input, $options ); |
|
| 23 | + $options = $this->sanitizeSubmissions( $input, $options ); |
|
| 24 | + $options = $this->sanitizeTranslations( $input, $options ); |
|
| 25 | + $options = apply_filters( 'site-reviews/settings/callback', $options, $settings ); |
|
| 26 | + if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
|
| 27 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
| 28 | 28 | } |
| 29 | 29 | return $options; |
| 30 | 30 | } |
@@ -37,63 +37,63 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function registerSettings() |
| 39 | 39 | { |
| 40 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
| 40 | + register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
| 41 | 41 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
| 42 | - ]); |
|
| 42 | + ] ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * @return array |
| 47 | 47 | */ |
| 48 | - protected function sanitizeGeneral(array $input, array $options) |
|
| 48 | + protected function sanitizeGeneral( array $input, array $options ) |
|
| 49 | 49 | { |
| 50 | 50 | $key = 'settings.general'; |
| 51 | - $inputForm = Arr::get($input, $key); |
|
| 52 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
| 53 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
| 51 | + $inputForm = Arr::get( $input, $key ); |
|
| 52 | + if( !$this->hasMultilingualIntegration( Arr::get( $inputForm, 'multilingual' ) ) ) { |
|
| 53 | + $options = Arr::set( $options, $key.'.multilingual', '' ); |
|
| 54 | 54 | } |
| 55 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
| 56 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
| 57 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
| 55 | + if( '' == trim( Arr::get( $inputForm, 'notification_message' ) ) ) { |
|
| 56 | + $defaultValue = Arr::get( glsr()->defaults, $key.'.notification_message' ); |
|
| 57 | + $options = Arr::set( $options, $key.'.notification_message', $defaultValue ); |
|
| 58 | 58 | } |
| 59 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
| 60 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
| 59 | + $defaultValue = Arr::get( $inputForm, 'notifications', [] ); |
|
| 60 | + $options = Arr::set( $options, $key.'.notifications', $defaultValue ); |
|
| 61 | 61 | return $options; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @return array |
| 66 | 66 | */ |
| 67 | - protected function sanitizeSubmissions(array $input, array $options) |
|
| 67 | + protected function sanitizeSubmissions( array $input, array $options ) |
|
| 68 | 68 | { |
| 69 | 69 | $key = 'settings.submissions'; |
| 70 | - $inputForm = Arr::get($input, $key); |
|
| 70 | + $inputForm = Arr::get( $input, $key ); |
|
| 71 | 71 | $defaultValue = isset($inputForm['required']) |
| 72 | 72 | ? $inputForm['required'] |
| 73 | 73 | : []; |
| 74 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
| 74 | + $options = Arr::set( $options, $key.'.required', $defaultValue ); |
|
| 75 | 75 | return $options; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | - protected function sanitizeTranslations(array $input, array $options) |
|
| 81 | + protected function sanitizeTranslations( array $input, array $options ) |
|
| 82 | 82 | { |
| 83 | 83 | $key = 'settings.strings'; |
| 84 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
| 85 | - if (!empty($inputForm)) { |
|
| 86 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
| 84 | + $inputForm = Arr::consolidateArray( Arr::get( $input, $key ) ); |
|
| 85 | + if( !empty($inputForm) ) { |
|
| 86 | + $options = Arr::set( $options, $key, array_values( array_filter( $inputForm ) ) ); |
|
| 87 | 87 | $allowedTags = [ |
| 88 | 88 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
| 89 | 89 | 'span' => ['class' => []], |
| 90 | 90 | ]; |
| 91 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
| 92 | - if (isset($string['s2'])) { |
|
| 93 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
| 91 | + array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) { |
|
| 92 | + if( isset($string['s2']) ) { |
|
| 93 | + $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
|
| 94 | 94 | } |
| 95 | - if (isset($string['p2'])) { |
|
| 96 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
| 95 | + if( isset($string['p2']) ) { |
|
| 96 | + $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
|
| 97 | 97 | } |
| 98 | 98 | }); |
| 99 | 99 | } |
@@ -104,24 +104,24 @@ discard block |
||
| 104 | 104 | * @param string $integrationSlug |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - protected function hasMultilingualIntegration($integrationSlug) |
|
| 107 | + protected function hasMultilingualIntegration( $integrationSlug ) |
|
| 108 | 108 | { |
| 109 | - $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
| 110 | - if (!$integration) { |
|
| 109 | + $integration = glsr( Multilingual::class )->getIntegration( $integrationSlug ); |
|
| 110 | + if( !$integration ) { |
|
| 111 | 111 | return false; |
| 112 | 112 | } |
| 113 | - if (!$integration->isActive()) { |
|
| 114 | - glsr(Notice::class)->addError(sprintf( |
|
| 115 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
| 113 | + if( !$integration->isActive() ) { |
|
| 114 | + glsr( Notice::class )->addError( sprintf( |
|
| 115 | + __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ), |
|
| 116 | 116 | $integration->pluginName |
| 117 | - )); |
|
| 117 | + ) ); |
|
| 118 | 118 | return false; |
| 119 | - } elseif (!$integration->isSupported()) { |
|
| 120 | - glsr(Notice::class)->addError(sprintf( |
|
| 121 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
| 119 | + } elseif( !$integration->isSupported() ) { |
|
| 120 | + glsr( Notice::class )->addError( sprintf( |
|
| 121 | + __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ), |
|
| 122 | 122 | $integration->pluginName, |
| 123 | 123 | $integration->supportedVersion |
| 124 | - )); |
|
| 124 | + ) ); |
|
| 125 | 125 | return false; |
| 126 | 126 | } |
| 127 | 127 | return true; |
@@ -116,7 +116,8 @@ |
||
| 116 | 116 | $integration->pluginName |
| 117 | 117 | )); |
| 118 | 118 | return false; |
| 119 | - } elseif (!$integration->isSupported()) { |
|
| 119 | + } |
|
| 120 | + elseif (!$integration->isSupported()) { |
|
| 120 | 121 | glsr(Notice::class)->addError(sprintf( |
| 121 | 122 | __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
| 122 | 123 | $integration->pluginName, |