get_charset_collate(); require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $backups = $wpdb->prefix . 'wpmigpro_backups'; $logs = $wpdb->prefix . 'wpmigpro_logs'; dbDelta("CREATE TABLE $backups ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, backup_name varchar(255) NOT NULL DEFAULT '', backup_type varchar(50) NOT NULL DEFAULT '', file_path text NOT NULL, file_size bigint(20) unsigned NOT NULL DEFAULT 0, status varchar(50) NOT NULL DEFAULT 'pending', progress int(11) NOT NULL DEFAULT 0, created_at datetime NULL DEFAULT NULL, notes text NULL, PRIMARY KEY (id), KEY status (status), KEY created_at (created_at) ) $charset_collate;"); dbDelta("CREATE TABLE $logs ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, backup_id bigint(20) unsigned NULL DEFAULT NULL, level varchar(20) NOT NULL DEFAULT 'info', message text NOT NULL, created_at datetime NULL DEFAULT NULL, PRIMARY KEY (id), KEY backup_id (backup_id), KEY level (level), KEY created_at (created_at) ) $charset_collate;"); foreach (array($backups, $logs) as $table) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- checking that dbDelta() created the table. if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $table)) !== $table) { return false; } } return true; } private static function set_default_options() { if (get_option('wpmigpro_settings') === false) { add_option('wpmigpro_settings', WPMigPro_Plugin::default_settings(), '', false); } } /** * Requirements and install problems, shown on the plugin screens and the Plugins page. */ public static function admin_notices() { if (!current_user_can('manage_options')) { return; } $screen = function_exists('get_current_screen') ? get_current_screen() : null; if (!$screen || ($screen->id !== 'plugins' && strpos($screen->id, 'wpmigpro') === false)) { return; } if (!class_exists('ZipArchive')) { printf( '

%s %s

', esc_html__('EnMigrate Pro:', 'enmigrate-pro'), esc_html__('the PHP "zip" extension (ZipArchive) is not available on this server, so backups can\'t be created or restored. Ask your hosting provider to enable it.', 'enmigrate-pro') ); } if (get_option('wpmigpro_install_error')) { printf( '

%s %s

', esc_html__('EnMigrate Pro:', 'enmigrate-pro'), esc_html__('the plugin database tables could not be created. Check that the database user can create tables, then deactivate and activate the plugin again.', 'enmigrate-pro') ); } } }