| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Presenters\Admin; |
| 4 |
|
| 5 |
use WPSEO_Shortlinker; |
| 6 |
use Yoast\WP\SEO\Presenters\Abstract_Presenter; |
| 7 |
|
| 8 |
/** |
| 9 |
* Presenter class for the migration error. |
| 10 |
*/ |
| 11 |
class Migration_Error_Presenter extends Abstract_Presenter { |
| 12 |
|
| 13 |
/** |
| 14 |
* Holds the migration error. |
| 15 |
* |
| 16 |
* The array holds the following values if filled: |
| 17 |
* - int|false $time The timestamp. |
| 18 |
* - string $version The Yoast SEO version. |
| 19 |
* - string $message The error message. |
| 20 |
* |
| 21 |
* @var array |
| 22 |
*/ |
| 23 |
protected $migration_error; |
| 24 |
|
| 25 |
/** |
| 26 |
* Migration_Error_Presenter constructor. |
| 27 |
* |
| 28 |
* @param array $migration_error The migration error. |
| 29 |
*/ |
| 30 |
public function __construct( $migration_error ) { |
| 31 |
$this->migration_error = $migration_error; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Presents the migration error that occurred. |
| 36 |
* |
| 37 |
* @return string The error HTML. |
| 38 |
*/ |
| 39 |
public function present() { |
| 40 |
$header = \sprintf( |
| 41 |
/* translators: %s: Yoast SEO. */ |
| 42 |
\esc_html__( '%s is unable to create database tables', 'wordpress-seo' ), |
| 43 |
'Yoast SEO', |
| 44 |
); |
| 45 |
$message = \sprintf( |
| 46 |
/* translators: %s: Yoast SEO. */ |
| 47 |
\esc_html__( '%s had problems creating the database tables needed to speed up your site.', 'wordpress-seo' ), |
| 48 |
'Yoast SEO', |
| 49 |
); |
| 50 |
$support = \sprintf( |
| 51 |
/* translators: %1$s: link to help article about solving table issue. %2$s: is anchor closing. */ |
| 52 |
\esc_html__( 'Please read %1$sthis help article%2$s to find out how to resolve this problem.', 'wordpress-seo' ), |
| 53 |
'<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/3-6' ) . '">', |
| 54 |
'</a>', |
| 55 |
); |
| 56 |
$reassurance = \sprintf( |
| 57 |
/* translators: %s: Yoast SEO. */ |
| 58 |
\esc_html__( 'Your site will continue to work normally, but won\'t take full advantage of %s.', 'wordpress-seo' ), |
| 59 |
'Yoast SEO', |
| 60 |
); |
| 61 |
|
| 62 |
$debug_info = \sprintf( |
| 63 |
'<details><summary>%1$s</summary><p>%2$s</p></details>', |
| 64 |
\esc_html__( 'Show debug information', 'wordpress-seo' ), |
| 65 |
\esc_html( $this->migration_error['message'] ), |
| 66 |
); |
| 67 |
|
| 68 |
return \sprintf( |
| 69 |
'<div class="notice notice-error yoast-migrated-notice"><h4 class="yoast-notice-migrated-header">%1$s</h4><div class="notice-yoast-content"><p>%2$s</p><p>%3$s</p><p>%4$s</p>%5$s</div></div>', |
| 70 |
$header, |
| 71 |
$message, |
| 72 |
$support, |
| 73 |
$reassurance, |
| 74 |
$debug_info, |
| 75 |
); |
| 76 |
} |
| 77 |
} |
| 78 |
|