• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / e9ac8ff9a236e0ff1ad9a5c711d3617ceff44c62

16 Apr 2024 11:54AM UTC coverage: 52.267% (+0.03%) from 52.242%
e9ac8ff9a236e0ff1ad9a5c711d3617ceff44c62

push

github

web-flow
Merge pull request #21267 from Yoast/21186-refactor-integration-enabledisables

Refactor integration enable disabled for script data.

7551 of 13895 branches covered (54.34%)

Branch coverage included in aggregate %.

57 of 85 new or added lines in 8 files covered. (67.06%)

779 existing lines in 1 file now uncovered.

28618 of 55305 relevant lines covered (51.75%)

40616.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/editors/framework/integrations/multilingual.php
1
<?php
2
// @phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- This namespace should reflect the namespace of the original class.
3
namespace Yoast\WP\SEO\Editors\Framework\Integrations;
4

5
use Yoast\WP\SEO\Conditionals\Third_Party\Polylang_Conditional;
6
use Yoast\WP\SEO\Conditionals\Third_Party\TranslatePress_Conditional;
7
use Yoast\WP\SEO\Conditionals\Third_Party\WPML_Conditional;
8
use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface;
9

10
/**
11
 * Describes if the Multilingual integration is enabled.
12
 */
13
class Multilingual implements Integration_Data_Provider_Interface {
14

15
        /**
16
         * The WPML conditional.
17
         *
18
         * @var WPML_Conditional $wpml_conditional
19
         */
20
        private $wpml_conditional;
21

22
        /**
23
         * The Polylang conditional.
24
         *
25
         * @var Polylang_Conditional $polylang_conditional
26
         */
27
        private $polylang_conditional;
28

29
        /**
30
         * The TranslatePress conditional.
31
         *
32
         * @var TranslatePress_Conditional $translate_press_conditional
33
         */
34
        private $translate_press_conditional;
35

36
        /**
37
         * The constructor.
38
         *
39
         * @param WPML_Conditional           $wpml_conditional            The wpml conditional.
40
         * @param Polylang_Conditional       $polylang_conditional        The polylang conditional.
41
         * @param TranslatePress_Conditional $translate_press_conditional The translate press conditional.
42
         */
43
        public function __construct( WPML_Conditional $wpml_conditional, Polylang_Conditional $polylang_conditional, TranslatePress_Conditional $translate_press_conditional ) {
8✔
44
                $this->wpml_conditional            = $wpml_conditional;
8✔
45
                $this->polylang_conditional        = $polylang_conditional;
8✔
46
                $this->translate_press_conditional = $translate_press_conditional;
8✔
47
        }
4✔
48

49
        /**
50
         * If the integration is activated.
51
         *
52
         * @return bool If the integration is activated.
53
         */
54
        public function is_enabled(): bool {
8✔
55
                return $this->multilingual_plugin_active();
8✔
56
        }
57

58
        /**
59
         * Return this object represented by a key value array.
60
         *
61
         * @return array<string,bool> Returns the name and if the feature is enabled.
62
         */
NEW
63
        public function to_array(): array {
×
NEW
64
                return [ 'multilingualPluginActive' => $this->is_enabled() ];
×
65
        }
66

67
        /**
68
         * Returns this object represented by a key value structure that is compliant with the script data array.
69
         *
70
         * @return array<string,bool> Returns the legacy key and if the feature is enabled.
71
         */
72
        public function to_legacy_array(): array {
8✔
73
                return [ 'multilingualPluginActive' => $this->is_enabled() ];
8✔
74
        }
75

76
        /**
77
         * Checks whether a multilingual plugin is currently active. Currently, we only check the following plugins:
78
         * WPML, Polylang, and TranslatePress.
79
         *
80
         * @return bool Whether a multilingual plugin is currently active.
81
         */
82
        private function multilingual_plugin_active() {
8✔
83
                $wpml_active           = $this->wpml_conditional->is_met();
8✔
84
                $polylang_active       = $this->polylang_conditional->is_met();
8✔
85
                $translatepress_active = $this->translate_press_conditional->is_met();
8✔
86

87
                return ( $wpml_active || $polylang_active || $translatepress_active );
8✔
88
        }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc