| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Integrations\Third_Party; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Wincher_Conditional; |
| 6 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 7 |
|
| 8 |
/** |
| 9 |
* Adds the Wincher integration. |
| 10 |
*/ |
| 11 |
class Wincher implements Integration_Interface { |
| 12 |
|
| 13 |
/** |
| 14 |
* Initializes the integration. |
| 15 |
* |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
public function register_hooks() { |
| 19 |
/** |
| 20 |
* Called by Yoast_Integration_Toggles to add extra toggles to the ones defined there. |
| 21 |
*/ |
| 22 |
\add_filter( 'wpseo_integration_toggles', [ $this, 'add_integration_toggle' ] ); |
| 23 |
/** |
| 24 |
* Called in dashboard/integrations.php to put additional content after the toggle. |
| 25 |
*/ |
| 26 |
\add_action( 'Yoast\WP\SEO\admin_integration_after', [ $this, 'load_toggle_additional_content' ] ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Returns the conditionals based in which this loadable should be active. |
| 31 |
* |
| 32 |
* @return array The conditionals. |
| 33 |
*/ |
| 34 |
public static function get_conditionals() { |
| 35 |
return [ Wincher_Conditional::class ]; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Adds the Wincher integration toggle to the array. |
| 40 |
* |
| 41 |
* @param array $integration_toggles The integration toggles array. |
| 42 |
* |
| 43 |
* @return array The updated integration toggles array. |
| 44 |
*/ |
| 45 |
public function add_integration_toggle( $integration_toggles ) { |
| 46 |
if ( \is_array( $integration_toggles ) ) { |
| 47 |
$integration_toggles[] = (object) [ |
| 48 |
/* translators: %s: 'Wincher' */ |
| 49 |
'name' => \sprintf( \__( '%s integration', 'wordpress-seo' ), 'Wincher' ), |
| 50 |
'setting' => 'wincher_integration_active', |
| 51 |
'label' => \sprintf( |
| 52 |
/* translators: %s: 'Wincher' */ |
| 53 |
\__( 'The %s integration offers the option to track specific keyphrases and gain insights in their positions.', 'wordpress-seo' ), |
| 54 |
'Wincher' |
| 55 |
), |
| 56 |
'order' => 11, |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
return $integration_toggles; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Loads additional content for the passed integration. |
| 65 |
* |
| 66 |
* @param Object $integration The integration object. |
| 67 |
* |
| 68 |
* @return void |
| 69 |
*/ |
| 70 |
public function load_toggle_additional_content( $integration ) { |
| 71 |
switch ( $integration->setting ) { |
| 72 |
case 'wincher_integration_active': |
| 73 |
require WPSEO_PATH . 'admin/views/tabs/metas/paper-content/integrations/wincher.php'; |
| 74 |
break; |
| 75 |
default: |
| 76 |
break; |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|