| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Integrations\Admin; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Admin_Conditional; |
| 6 |
use Yoast\WP\SEO\Config\Migration_Status; |
| 7 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 8 |
use Yoast\WP\SEO\Presenters\Admin\Migration_Error_Presenter; |
| 9 |
|
| 10 |
/** |
| 11 |
* Migration_Error_Integration class. |
| 12 |
*/ |
| 13 |
class Migration_Error_Integration implements Integration_Interface { |
| 14 |
|
| 15 |
/** |
| 16 |
* The migration status object. |
| 17 |
* |
| 18 |
* @var Migration_Status |
| 19 |
*/ |
| 20 |
protected $migration_status; |
| 21 |
|
| 22 |
/** |
| 23 |
* {@inheritDoc} |
| 24 |
*/ |
| 25 |
public static function get_conditionals() { |
| 26 |
return [ Admin_Conditional::class ]; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Migration_Error_Integration constructor. |
| 31 |
* |
| 32 |
* @param Migration_Status $migration_status The migration status object. |
| 33 |
*/ |
| 34 |
public function __construct( Migration_Status $migration_status ) { |
| 35 |
$this->migration_status = $migration_status; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* {@inheritDoc} |
| 40 |
*/ |
| 41 |
public function register_hooks() { |
| 42 |
if ( $this->migration_status->get_error( 'free' ) === false ) { |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
\add_action( 'admin_notices', [ $this, 'render_migration_error' ] ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Renders the migration error. |
| 51 |
* |
| 52 |
* @return void |
| 53 |
*/ |
| 54 |
public function render_migration_error() { |
| 55 |
// phpcs:ignore WordPress.Security.EscapeOutput -- The Migration_Error_Presenter already escapes it's output. |
| 56 |
echo new Migration_Error_Presenter( $this->migration_status->get_error( 'free' ) ); |
| 57 |
} |
| 58 |
} |
| 59 |
|