| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Framework\Migrations\Actions; |
| 4 |
|
| 5 |
use Give\Framework\Migrations\MigrationsRegister; |
| 6 |
use Give\MigrationLog\MigrationLogRepository; |
| 7 |
use Give\MigrationLog\MigrationLogStatus; |
| 8 |
|
| 9 |
/** |
| 10 |
* @since 4.3.0 |
| 11 |
* |
| 12 |
* Show reversed migration notice |
| 13 |
*/ |
| 14 |
class Notices |
| 15 |
{ |
| 16 |
public function __invoke() |
| 17 |
{ |
| 18 |
$migrations = give(MigrationLogRepository::class)->getMigrationsByStatus(MigrationLogStatus::REVERSED); |
| 19 |
|
| 20 |
foreach ($migrations as $migration) { |
| 21 |
$migrationClass = give(MigrationsRegister::class)->getMigration($migration->getId()); |
| 22 |
|
| 23 |
$listTableLink = sprintf( |
| 24 |
'<a href="%s">%s</a>', |
| 25 |
admin_url('edit.php?post_type=give_forms&page=give-tools&tab=data'), |
| 26 |
esc_html__('Run update', 'give') |
| 27 |
); |
| 28 |
|
| 29 |
give()->notices->register_notice( |
| 30 |
[ |
| 31 |
'id' => $migration->getId(), |
| 32 |
'type' => 'warning', |
| 33 |
'description' => sprintf( |
| 34 |
__('<strong>GiveWP</strong> Pending database update: "%s". %s', 'give'), |
| 35 |
$migrationClass::title(), |
| 36 |
$listTableLink |
| 37 |
), |
| 38 |
] |
| 39 |
); |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|