New project structure init
This commit is contained in:
27
backend/app/plugins/wiaas/includes/class-wiaas-db-update.php
Normal file
27
backend/app/plugins/wiaas/includes/class-wiaas-db-update.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Wiaas_DB_Update {
|
||||
|
||||
private static $db_updates = array(
|
||||
'20180728222206' => 'wiaas_db_update_enable_product_by_user_role'
|
||||
);
|
||||
|
||||
public static function get_pending_db_updates() {
|
||||
$active_db_version = get_option( 'wiaas_db_version', '0' );
|
||||
$pending_db_updates = array();
|
||||
foreach (self::$db_updates as $version => $update_callback) {
|
||||
if ($active_db_version < $version) {
|
||||
$pending_db_updates[] = $update_callback;
|
||||
}
|
||||
}
|
||||
return $pending_db_updates;
|
||||
}
|
||||
|
||||
public static function execute_update($update_callback) {
|
||||
call_user_func($update_callback);
|
||||
$version = array_search($update_callback, self::$db_updates);
|
||||
update_option('wiaas_db_version', $version);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user