PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / editors / framework / integrations / wincher.php

wincher.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/editors/framework/integrations/wincher.php

77 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // @phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- This namespace should reflect the namespace of the original class.
4 namespace Yoast\WP\SEO\Editors\Framework\Integrations;
5
6 use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface;
7 use Yoast\WP\SEO\Helpers\Options_Helper;
8 use Yoast\WP\SEO\Helpers\Wincher_Helper;
9
10 /**
11 * Describes if the Wincher integration is enabled.
12 */
13 class Wincher implements Integration_Data_Provider_Interface {
14
15 /**
16 * The Wincher helper.
17 *
18 * @var Wincher_Helper
19 */
20 private $wincher_helper;
21
22 /**
23 * The options helper.
24 *
25 * @var Options_Helper
26 */
27 private $options_helper;
28
29 /**
30 * The constructor.
31 *
32 * @param Wincher_Helper $wincher_helper The Wincher helper.
33 * @param Options_Helper $options_helper The options helper.
34 */
35 public function __construct( Wincher_Helper $wincher_helper, Options_Helper $options_helper ) {
36 $this->wincher_helper = $wincher_helper;
37 $this->options_helper = $options_helper;
38 }
39
40 /**
41 * If the integration is activated.
42 *
43 * @return bool If the integration is activated.
44 */
45 public function is_enabled(): bool {
46 return $this->wincher_helper->is_active();
47 }
48
49 /**
50 * Return this object represented by a key value array.
51 *
52 * @return array<string, bool> Returns the name and if the feature is enabled.
53 */
54 public function to_array(): array {
55 return [
56 'active' => $this->is_enabled(),
57 'loginStatus' => $this->is_enabled() && $this->wincher_helper->login_status(),
58 'websiteId' => $this->options_helper->get( 'wincher_website_id', '' ),
59 'autoAddKeyphrases' => $this->options_helper->get( 'wincher_automatically_add_keyphrases', false ),
60 ];
61 }
62
63 /**
64 * Returns this object represented by a key value structure that is compliant with the script data array.
65 *
66 * @return array<string, bool> Returns the legacy key and if the feature is enabled.
67 */
68 public function to_legacy_array(): array {
69 return [
70 'wincherIntegrationActive' => $this->is_enabled(),
71 'wincherLoginStatus' => $this->is_enabled() && $this->wincher_helper->login_status(),
72 'wincherWebsiteId' => $this->options_helper->get( 'wincher_website_id', '' ),
73 'wincherAutoAddKeyphrases' => $this->options_helper->get( 'wincher_automatically_add_keyphrases', false ),
74 ];
75 }
76 }
77