setup(); } function infinite_uploads_upgrade() { // Install the needed DB table if not already. $installed = get_site_option( 'iup_installed' ); if ( INFINITE_UPLOADS_VERSION != $installed ) { infinite_uploads_install(); } } function infinite_uploads_install() { global $wpdb; //prevent race condition during upgrade by setting option before running potentially long query if ( is_multisite() ) { update_site_option( 'iup_installed', INFINITE_UPLOADS_VERSION ); } else { update_option( 'iup_installed', INFINITE_UPLOADS_VERSION, true ); } $charset_collate = $wpdb->get_charset_collate(); //191 is the maximum innodb default key length on utf8mb4 $sql = "CREATE TABLE {$wpdb->base_prefix}infinite_uploads_files ( `file` VARCHAR(255) NOT NULL, `size` BIGINT UNSIGNED NOT NULL DEFAULT '0', `modified` INT UNSIGNED NOT NULL, `type` VARCHAR(20) NOT NULL, `transferred` BIGINT UNSIGNED NOT NULL DEFAULT '0', `synced` BOOLEAN NOT NULL DEFAULT '0', `deleted` BOOLEAN NOT NULL DEFAULT '0', `errors` INT UNSIGNED NOT NULL DEFAULT '0', `transfer_status` TEXT NULL DEFAULT NULL, PRIMARY KEY (`file`(191)), KEY `type` (`type`), KEY `synced` (`synced`), KEY `deleted` (`deleted`) ) {$charset_collate};"; if ( ! function_exists( 'dbDelta' ) ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; } return dbDelta( $sql ); } /** * Check whether the environment meets the plugin's requirements, like the minimum PHP version. * * @return bool True if the requirements are met, else false. */ function infinite_uploads_check_requirements() { global $wp_version; $hook = is_multisite() ? 'network_admin_notices' : 'admin_notices'; if ( version_compare( PHP_VERSION, '5.5.0', '<' ) ) { add_action( $hook, 'infinite_uploads_outdated_php_version_notice' ); return false; } if ( version_compare( $wp_version, '5.3.0', '<' ) ) { add_action( $hook, 'infinite_uploads_outdated_wp_version_notice' ); return false; } return true; } /** * Print an admin notice when the PHP version is not high enough. * * This has to be a named function for compatibility with PHP 5.2. */ function infinite_uploads_outdated_php_version_notice() { ?>