PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 19.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v19.0
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 / integrations / third-party / wincher.php

wincher.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 19.0, at src/integrations/third-party/wincher.php

130 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Integrations\Third_Party;
4
5 use Yoast\WP\SEO\Conditionals\Admin_Conditional;
6 use Yoast\WP\SEO\Helpers\Wincher_Helper;
7 use Yoast\WP\SEO\Integrations\Integration_Interface;
8 use Yoast_Feature_Toggle;
9
10 /**
11 * Adds the Wincher integration.
12 */
13 class Wincher implements Integration_Interface {
14
15 /**
16 * The Wincher helper instance.
17 *
18 * @var Wincher_Helper
19 */
20 protected $wincher;
21
22 /**
23 * The Wincher integration toggle constructor.
24 *
25 * @param Wincher_Helper $wincher The Wincher helper instance.
26 */
27 public function __construct( Wincher_Helper $wincher ) {
28 $this->wincher = $wincher;
29 }
30
31 /**
32 * Initializes the integration.
33 *
34 * @return void
35 */
36 public function register_hooks() {
37 /**
38 * Called by Yoast_Integration_Toggles to add extra toggles to the ones defined there.
39 */
40 \add_filter( 'wpseo_integration_toggles', [ $this, 'add_integration_toggle' ] );
41
42 /**
43 * Called in dashboard/integrations.php to put additional content after the toggle.
44 */
45 \add_action( 'Yoast\WP\SEO\admin_integration_after', [ $this, 'after_integration_toggle' ] );
46
47 /**
48 * Add extra text after the network integration toggle if the toggle is disabled.
49 */
50 \add_action( 'Yoast\WP\SEO\admin_network_integration_after', [ $this, 'after_network_integration_toggle' ] );
51 }
52
53 /**
54 * Returns the conditionals based in which this loadable should be active.
55 *
56 * @return array The conditionals.
57 */
58 public static function get_conditionals() {
59 return [ Admin_Conditional::class ];
60 }
61
62 /**
63 * Adds the Wincher integration toggle to the $integration_toggles array.
64 *
65 * @param array $integration_toggles The integration toggles array.
66 *
67 * @return array The updated integration toggles array.
68 */
69 public function add_integration_toggle( $integration_toggles ) {
70 if ( \is_array( $integration_toggles ) ) {
71 $integration_toggles[] = (object) [
72 /* translators: %s: 'Wincher' */
73 'name' => \sprintf( \__( '%s integration', 'wordpress-seo' ), 'Wincher' ),
74 'setting' => 'wincher_integration_active',
75 'label' => \sprintf(
76 /* translators: %s: 'Wincher' */
77 \__( 'The %s integration offers the option to track specific keyphrases and gain insights in their positions.', 'wordpress-seo' ),
78 'Wincher'
79 ),
80 'order' => 11,
81 'disabled' => \is_multisite(),
82 ];
83 }
84
85 return $integration_toggles;
86 }
87
88 /**
89 * Adds the disabled note when the integration toggle is disabled.
90 *
91 * @param Yoast_Feature_Toggle $integration The integration toggle class.
92 */
93 public function after_integration_toggle( $integration ) {
94 if ( $integration->setting === 'wincher_integration_active' ) {
95
96 require \WPSEO_PATH . 'admin/views/tabs/metas/paper-content/integrations/wincher.php';
97
98 if ( \is_multisite() ) {
99 $this->get_disabled_note();
100 }
101 }
102 }
103
104 /**
105 * Adds the disabled note to the network integration toggle.
106 *
107 * @param Yoast_Feature_Toggle $integration The integration toggle class.
108 */
109 public function after_network_integration_toggle( $integration ) {
110 if ( $integration->setting === 'wincher_integration_active' ) {
111 $this->get_disabled_note();
112 }
113 }
114
115 /**
116 * Outputs the disabled note.
117 *
118 * @codeCoverageIgnore
119 *
120 * @return void
121 */
122 protected function get_disabled_note() {
123 echo '<p>', \sprintf(
124 /* translators: %s expands to Wincher */
125 \esc_html__( 'Currently, the %s integration is not available for multisites.', 'wordpress-seo' ),
126 'Wincher'
127 ), '</p>';
128 }
129 }
130