| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | use Yoast\WP\SEO\Dashboard\Infrastructure\Endpoints\Site_Kit_Consent_Management_Endpoint; |
| 10 | 10 | use Yoast\WP\SEO\Dashboard\Infrastructure\Integrations\Site_Kit; |
| 11 | 11 | use Yoast\WP\SEO\Helpers\Options_Helper; |
| 12 | 12 | use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 13 | +use Yoast\WP\SEO\MyYoast_Client\User_Interface\Integrations_Page_Script_Data as MyYoast_Connection_Script_Data; | |
| 13 | 14 | use Yoast\WP\SEO\Schema\Application\Configuration\Schema_Configuration; |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Integrations_Page class |
| @@ -17,8 +18,15 @@ | ||
| 17 | 18 | */ |
| 18 | 19 | class Integrations_Page implements Integration_Interface { |
| 19 | 20 | |
| 20 | 21 | /** |
| 22 | + * The page identifier of the integrations page. | |
| 23 | + * | |
| 24 | + * @var string | |
| 25 | + */ | |
| 26 | + public const PAGE = 'wpseo_integrations'; | |
| 27 | + | |
| 28 | + /** | |
| 21 | 29 | * The admin asset manager. |
| 22 | 30 | * |
| 23 | 31 | * @var WPSEO_Admin_Asset_Manager |
| 24 | 32 | */ |
| @@ -66,8 +74,15 @@ | ||
| 66 | 74 | */ |
| 67 | 75 | private $schema_configuration; |
| 68 | 76 | |
| 69 | 77 | /** |
| 78 | + * The MyYoast connection script-data provider. | |
| 79 | + * | |
| 80 | + * @var MyYoast_Connection_Script_Data | |
| 81 | + */ | |
| 82 | + private $myyoast_connection_script_data; | |
| 83 | + | |
| 84 | + /** | |
| 70 | 85 | * {@inheritDoc} |
| 71 | 86 | */ |
| 72 | 87 | public static function get_conditionals() { |
| 73 | 88 | return [ Admin_Conditional::class ]; |
| @@ -84,8 +99,10 @@ | ||
| 84 | 99 | * configuration data. |
| 85 | 100 | * @param Site_Kit_Consent_Management_Endpoint $site_kit_consent_management_endpoint The site kit consent |
| 86 | 101 | * management endpoint. |
| 87 | 102 | * @param Schema_Configuration $schema_configuration The schema configuration. |
| 103 | + * @param MyYoast_Connection_Script_Data $myyoast_connection_script_data The MyYoast connection | |
| 104 | + * script-data provider. | |
| 88 | 105 | */ |
| 89 | 106 | public function __construct( |
| 90 | 107 | WPSEO_Admin_Asset_Manager $admin_asset_manager, |
| 91 | 108 | Options_Helper $options_helper, |
| @@ -92,9 +109,10 @@ | ||
| 92 | 109 | Elementor_Activated_Conditional $elementor_conditional, |
| 93 | 110 | Jetpack_Conditional $jetpack_conditional, |
| 94 | 111 | Site_Kit $site_kit_integration_data, |
| 95 | 112 | Site_Kit_Consent_Management_Endpoint $site_kit_consent_management_endpoint, |
| 96 | - Schema_Configuration $schema_configuration | |
| 113 | + Schema_Configuration $schema_configuration, | |
| 114 | + MyYoast_Connection_Script_Data $myyoast_connection_script_data | |
| 97 | 115 | ) { |
| 98 | 116 | $this->admin_asset_manager = $admin_asset_manager; |
| 99 | 117 | $this->options_helper = $options_helper; |
| 100 | 118 | $this->elementor_conditional = $elementor_conditional; |
| @@ -101,8 +119,9 @@ | ||
| 101 | 119 | $this->jetpack_conditional = $jetpack_conditional; |
| 102 | 120 | $this->site_kit_integration_data = $site_kit_integration_data; |
| 103 | 121 | $this->site_kit_consent_management_endpoint = $site_kit_consent_management_endpoint; |
| 104 | 122 | $this->schema_configuration = $schema_configuration; |
| 123 | + $this->myyoast_connection_script_data = $myyoast_connection_script_data; | |
| 105 | 124 | } |
| 106 | 125 | |
| 107 | 126 | /** |
| 108 | 127 | * {@inheritDoc} |
| @@ -124,9 +143,9 @@ | ||
| 124 | 143 | 'wpseo_dashboard', |
| 125 | 144 | '', |
| 126 | 145 | \__( 'Integrations', 'wordpress-seo' ), |
| 127 | 146 | 'wpseo_manage_options', |
| 128 | - 'wpseo_integrations', | |
| 147 | + self::PAGE, | |
| 129 | 148 | [ $this, 'render_target' ], |
| 130 | 149 | ]; |
| 131 | 150 | |
| 132 | 151 | \array_splice( $submenu_pages, 1, 0, [ $integrations_page ] ); |
| @@ -140,9 +159,9 @@ | ||
| 140 | 159 | * @return void |
| 141 | 160 | */ |
| 142 | 161 | public function enqueue_assets() { |
| 143 | 162 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved. |
| 144 | - if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_integrations' ) { | |
| 163 | + if ( ! isset( $_GET['page'] ) || $_GET['page'] !== self::PAGE ) { | |
| 145 | 164 | return; |
| 146 | 165 | } |
| 147 | 166 | |
| 148 | 167 | $this->admin_asset_manager->enqueue_style( 'admin-css' ); |
| @@ -147,8 +166,9 @@ | ||
| 147 | 166 | |
| 148 | 167 | $this->admin_asset_manager->enqueue_style( 'admin-css' ); |
| 149 | 168 | $this->admin_asset_manager->enqueue_style( 'tailwind' ); |
| 150 | 169 | $this->admin_asset_manager->enqueue_style( 'monorepo' ); |
| 170 | + $this->admin_asset_manager->enqueue_style( 'integrations-page' ); | |
| 151 | 171 | |
| 152 | 172 | $this->admin_asset_manager->enqueue_script( 'integrations-page' ); |
| 153 | 173 | |
| 154 | 174 | $acf_seo_file = 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php'; |
| @@ -225,8 +245,9 @@ | ||
| 225 | 245 | 'plugin_url' => \plugins_url( '', \WPSEO_FILE ), |
| 226 | 246 | 'site_kit_configuration' => $this->site_kit_integration_data->to_array(), |
| 227 | 247 | 'site_kit_consent_management_url' => $this->site_kit_consent_management_endpoint->get_url(), |
| 228 | 248 | 'schema_framework_enabled' => $this->options_helper->get( 'enable_schema', true ) === true && ! $this->schema_configuration->is_schema_disabled_programmatically(), |
| 249 | + 'myyoast_connection' => $this->myyoast_connection_script_data->present(), | |
| 229 | 250 | ], |
| 230 | 251 | ); |
| 231 | 252 | } |
| 232 | 253 | |