Yoast\WP\SEO\Config

Migration_Status::should_run_migration()publicYoast 1.0

Checks if a given migration should be run.

Метод класса: Migration_Status{}

Хуков нет.

Возвращает

true|false. Whether or not the migration should be run.

Использование

$Migration_Status = new Migration_Status();
$Migration_Status->should_run_migration( $name, $version );
$name(строка) (обязательный)
The name of the migration.
$version(строка)
The current version.
По умолчанию: \WPSEO_VERSION

Код Migration_Status::should_run_migration() Yoast 22.4

public function should_run_migration( $name, $version = \WPSEO_VERSION ) {
	$migration_status = $this->get_migration_status( $name );

	// Check if we've attempted to run this migration in the past 10 minutes. If so, it may still be running.
	if ( \array_key_exists( 'lock', $migration_status ) ) {
		$timestamp = \strtotime( '-10 minutes' );

		return $timestamp > $migration_status['lock'];
	}

	// Is the migration version less than the current version.
	return \version_compare( $migration_status['version'], $version, '<' );
}