exists($from . '/wordpress/wp-settings.php') || !$wp_filesystem->exists($from . '/wordpress/wp-admin/admin.php') || !$wp_filesystem->exists($from . '/wordpress/wp-includes/functions.php') ) { $wp_filesystem->delete($from, true); return new WP_Error('insane_distro', __('The update could not be unpacked') ); } include( $from . '/wordpress/wp-includes/version.php' ); $php_version = phpversion(); $mysql_version = $wpdb->db_version(); $php_compat = version_compare( $php_version, $required_php_version, '>=' ); $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); if ( !$mysql_compat && !$php_compat ) return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) ); elseif ( !$php_compat ) return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) ); elseif ( !$mysql_compat ) return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) ); apply_filters('update_feedback', __('Installing the latest version')); // Create maintenance file to signal that we are upgrading $maintenance_string = ''; $maintenance_file = $to . '.maintenance'; $wp_filesystem->delete($maintenance_file); $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); // Copy new versions of WP files into place. $result = copy_dir($from . '/wordpress', $to); if ( is_wp_error($result) ) { $wp_filesystem->delete($maintenance_file); $wp_filesystem->delete($from, true); return $result; } // Remove old files foreach ( $_old_files as $old_file ) { $old_file = $to . $old_file; if ( !$wp_filesystem->exists($old_file) ) continue; $wp_filesystem->delete($old_file, true); } // Upgrade DB with separate request apply_filters('update_feedback', __('Upgrading database')); $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db'); wp_remote_post($db_upgrade_url, array('timeout' => 60)); // Remove working directory $wp_filesystem->delete($from, true); // Force refresh of update information if ( function_exists('delete_transient') ) delete_transient('update_core'); else delete_option('update_core'); // Remove maintenance file, we're done. $wp_filesystem->delete($maintenance_file); } ?>