Wordpress 4.6
[autoinstalls/wordpress.git] / wp-admin / includes / update-core.php
1 <?php
2 /**
3  * WordPress core upgrade functionality.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  * @since 2.7.0
8  */
9
10 /**
11  * Stores files to be deleted.
12  *
13  * @since 2.7.0
14  * @global array $_old_files
15  * @var array
16  * @name $_old_files
17  */
18 global $_old_files;
19
20 $_old_files = array(
21 // 2.0
22 'wp-admin/import-b2.php',
23 'wp-admin/import-blogger.php',
24 'wp-admin/import-greymatter.php',
25 'wp-admin/import-livejournal.php',
26 'wp-admin/import-mt.php',
27 'wp-admin/import-rss.php',
28 'wp-admin/import-textpattern.php',
29 'wp-admin/quicktags.js',
30 'wp-images/fade-butt.png',
31 'wp-images/get-firefox.png',
32 'wp-images/header-shadow.png',
33 'wp-images/smilies',
34 'wp-images/wp-small.png',
35 'wp-images/wpminilogo.png',
36 'wp.php',
37 // 2.0.8
38 'wp-includes/js/tinymce/plugins/inlinepopups/readme.txt',
39 // 2.1
40 'wp-admin/edit-form-ajax-cat.php',
41 'wp-admin/execute-pings.php',
42 'wp-admin/inline-uploading.php',
43 'wp-admin/link-categories.php',
44 'wp-admin/list-manipulation.js',
45 'wp-admin/list-manipulation.php',
46 'wp-includes/comment-functions.php',
47 'wp-includes/feed-functions.php',
48 'wp-includes/functions-compat.php',
49 'wp-includes/functions-formatting.php',
50 'wp-includes/functions-post.php',
51 'wp-includes/js/dbx-key.js',
52 'wp-includes/js/tinymce/plugins/autosave/langs/cs.js',
53 'wp-includes/js/tinymce/plugins/autosave/langs/sv.js',
54 'wp-includes/links.php',
55 'wp-includes/pluggable-functions.php',
56 'wp-includes/template-functions-author.php',
57 'wp-includes/template-functions-category.php',
58 'wp-includes/template-functions-general.php',
59 'wp-includes/template-functions-links.php',
60 'wp-includes/template-functions-post.php',
61 'wp-includes/wp-l10n.php',
62 // 2.2
63 'wp-admin/cat-js.php',
64 'wp-admin/import/b2.php',
65 'wp-includes/js/autosave-js.php',
66 'wp-includes/js/list-manipulation-js.php',
67 'wp-includes/js/wp-ajax-js.php',
68 // 2.3
69 'wp-admin/admin-db.php',
70 'wp-admin/cat.js',
71 'wp-admin/categories.js',
72 'wp-admin/custom-fields.js',
73 'wp-admin/dbx-admin-key.js',
74 'wp-admin/edit-comments.js',
75 'wp-admin/install-rtl.css',
76 'wp-admin/install.css',
77 'wp-admin/upgrade-schema.php',
78 'wp-admin/upload-functions.php',
79 'wp-admin/upload-rtl.css',
80 'wp-admin/upload.css',
81 'wp-admin/upload.js',
82 'wp-admin/users.js',
83 'wp-admin/widgets-rtl.css',
84 'wp-admin/widgets.css',
85 'wp-admin/xfn.js',
86 'wp-includes/js/tinymce/license.html',
87 // 2.5
88 'wp-admin/css/upload.css',
89 'wp-admin/images/box-bg-left.gif',
90 'wp-admin/images/box-bg-right.gif',
91 'wp-admin/images/box-bg.gif',
92 'wp-admin/images/box-butt-left.gif',
93 'wp-admin/images/box-butt-right.gif',
94 'wp-admin/images/box-butt.gif',
95 'wp-admin/images/box-head-left.gif',
96 'wp-admin/images/box-head-right.gif',
97 'wp-admin/images/box-head.gif',
98 'wp-admin/images/heading-bg.gif',
99 'wp-admin/images/login-bkg-bottom.gif',
100 'wp-admin/images/login-bkg-tile.gif',
101 'wp-admin/images/notice.gif',
102 'wp-admin/images/toggle.gif',
103 'wp-admin/includes/upload.php',
104 'wp-admin/js/dbx-admin-key.js',
105 'wp-admin/js/link-cat.js',
106 'wp-admin/profile-update.php',
107 'wp-admin/templates.php',
108 'wp-includes/images/wlw/WpComments.png',
109 'wp-includes/images/wlw/WpIcon.png',
110 'wp-includes/images/wlw/WpWatermark.png',
111 'wp-includes/js/dbx.js',
112 'wp-includes/js/fat.js',
113 'wp-includes/js/list-manipulation.js',
114 'wp-includes/js/tinymce/langs/en.js',
115 'wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js',
116 'wp-includes/js/tinymce/plugins/autosave/langs',
117 'wp-includes/js/tinymce/plugins/directionality/images',
118 'wp-includes/js/tinymce/plugins/directionality/langs',
119 'wp-includes/js/tinymce/plugins/inlinepopups/css',
120 'wp-includes/js/tinymce/plugins/inlinepopups/images',
121 'wp-includes/js/tinymce/plugins/inlinepopups/jscripts',
122 'wp-includes/js/tinymce/plugins/paste/images',
123 'wp-includes/js/tinymce/plugins/paste/jscripts',
124 'wp-includes/js/tinymce/plugins/paste/langs',
125 'wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php',
126 'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php',
127 'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php',
128 'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php',
129 'wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css',
130 'wp-includes/js/tinymce/plugins/spellchecker/images',
131 'wp-includes/js/tinymce/plugins/spellchecker/langs',
132 'wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php',
133 'wp-includes/js/tinymce/plugins/wordpress/images',
134 'wp-includes/js/tinymce/plugins/wordpress/langs',
135 'wp-includes/js/tinymce/plugins/wordpress/wordpress.css',
136 'wp-includes/js/tinymce/plugins/wphelp',
137 'wp-includes/js/tinymce/themes/advanced/css',
138 'wp-includes/js/tinymce/themes/advanced/images',
139 'wp-includes/js/tinymce/themes/advanced/jscripts',
140 'wp-includes/js/tinymce/themes/advanced/langs',
141 // 2.5.1
142 'wp-includes/js/tinymce/tiny_mce_gzip.php',
143 // 2.6
144 'wp-admin/bookmarklet.php',
145 'wp-includes/js/jquery/jquery.dimensions.min.js',
146 'wp-includes/js/tinymce/plugins/wordpress/popups.css',
147 'wp-includes/js/wp-ajax.js',
148 // 2.7
149 'wp-admin/css/press-this-ie-rtl.css',
150 'wp-admin/css/press-this-ie.css',
151 'wp-admin/css/upload-rtl.css',
152 'wp-admin/edit-form.php',
153 'wp-admin/images/comment-pill.gif',
154 'wp-admin/images/comment-stalk-classic.gif',
155 'wp-admin/images/comment-stalk-fresh.gif',
156 'wp-admin/images/comment-stalk-rtl.gif',
157 'wp-admin/images/del.png',
158 'wp-admin/images/gear.png',
159 'wp-admin/images/media-button-gallery.gif',
160 'wp-admin/images/media-buttons.gif',
161 'wp-admin/images/postbox-bg.gif',
162 'wp-admin/images/tab.png',
163 'wp-admin/images/tail.gif',
164 'wp-admin/js/forms.js',
165 'wp-admin/js/upload.js',
166 'wp-admin/link-import.php',
167 'wp-includes/images/audio.png',
168 'wp-includes/images/css.png',
169 'wp-includes/images/default.png',
170 'wp-includes/images/doc.png',
171 'wp-includes/images/exe.png',
172 'wp-includes/images/html.png',
173 'wp-includes/images/js.png',
174 'wp-includes/images/pdf.png',
175 'wp-includes/images/swf.png',
176 'wp-includes/images/tar.png',
177 'wp-includes/images/text.png',
178 'wp-includes/images/video.png',
179 'wp-includes/images/zip.png',
180 'wp-includes/js/tinymce/tiny_mce_config.php',
181 'wp-includes/js/tinymce/tiny_mce_ext.js',
182 // 2.8
183 'wp-admin/js/users.js',
184 'wp-includes/js/swfupload/plugins/swfupload.documentready.js',
185 'wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js',
186 'wp-includes/js/swfupload/swfupload_f9.swf',
187 'wp-includes/js/tinymce/plugins/autosave',
188 'wp-includes/js/tinymce/plugins/paste/css',
189 'wp-includes/js/tinymce/utils/mclayer.js',
190 'wp-includes/js/tinymce/wordpress.css',
191 // 2.8.5
192 'wp-admin/import/btt.php',
193 'wp-admin/import/jkw.php',
194 // 2.9
195 'wp-admin/js/page.dev.js',
196 'wp-admin/js/page.js',
197 'wp-admin/js/set-post-thumbnail-handler.dev.js',
198 'wp-admin/js/set-post-thumbnail-handler.js',
199 'wp-admin/js/slug.dev.js',
200 'wp-admin/js/slug.js',
201 'wp-includes/gettext.php',
202 'wp-includes/js/tinymce/plugins/wordpress/js',
203 'wp-includes/streams.php',
204 // MU
205 'README.txt',
206 'htaccess.dist',
207 'index-install.php',
208 'wp-admin/css/mu-rtl.css',
209 'wp-admin/css/mu.css',
210 'wp-admin/images/site-admin.png',
211 'wp-admin/includes/mu.php',
212 'wp-admin/wpmu-admin.php',
213 'wp-admin/wpmu-blogs.php',
214 'wp-admin/wpmu-edit.php',
215 'wp-admin/wpmu-options.php',
216 'wp-admin/wpmu-themes.php',
217 'wp-admin/wpmu-upgrade-site.php',
218 'wp-admin/wpmu-users.php',
219 'wp-includes/images/wordpress-mu.png',
220 'wp-includes/wpmu-default-filters.php',
221 'wp-includes/wpmu-functions.php',
222 'wpmu-settings.php',
223 // 3.0
224 'wp-admin/categories.php',
225 'wp-admin/edit-category-form.php',
226 'wp-admin/edit-page-form.php',
227 'wp-admin/edit-pages.php',
228 'wp-admin/images/admin-header-footer.png',
229 'wp-admin/images/browse-happy.gif',
230 'wp-admin/images/ico-add.png',
231 'wp-admin/images/ico-close.png',
232 'wp-admin/images/ico-edit.png',
233 'wp-admin/images/ico-viewpage.png',
234 'wp-admin/images/fav-top.png',
235 'wp-admin/images/screen-options-left.gif',
236 'wp-admin/images/wp-logo-vs.gif',
237 'wp-admin/images/wp-logo.gif',
238 'wp-admin/import',
239 'wp-admin/js/wp-gears.dev.js',
240 'wp-admin/js/wp-gears.js',
241 'wp-admin/options-misc.php',
242 'wp-admin/page-new.php',
243 'wp-admin/page.php',
244 'wp-admin/rtl.css',
245 'wp-admin/rtl.dev.css',
246 'wp-admin/update-links.php',
247 'wp-admin/wp-admin.css',
248 'wp-admin/wp-admin.dev.css',
249 'wp-includes/js/codepress',
250 'wp-includes/js/codepress/engines/khtml.js',
251 'wp-includes/js/codepress/engines/older.js',
252 'wp-includes/js/jquery/autocomplete.dev.js',
253 'wp-includes/js/jquery/autocomplete.js',
254 'wp-includes/js/jquery/interface.js',
255 'wp-includes/js/scriptaculous/prototype.js',
256 'wp-includes/js/tinymce/wp-tinymce.js',
257 // 3.1
258 'wp-admin/edit-attachment-rows.php',
259 'wp-admin/edit-link-categories.php',
260 'wp-admin/edit-link-category-form.php',
261 'wp-admin/edit-post-rows.php',
262 'wp-admin/images/button-grad-active-vs.png',
263 'wp-admin/images/button-grad-vs.png',
264 'wp-admin/images/fav-arrow-vs-rtl.gif',
265 'wp-admin/images/fav-arrow-vs.gif',
266 'wp-admin/images/fav-top-vs.gif',
267 'wp-admin/images/list-vs.png',
268 'wp-admin/images/screen-options-right-up.gif',
269 'wp-admin/images/screen-options-right.gif',
270 'wp-admin/images/visit-site-button-grad-vs.gif',
271 'wp-admin/images/visit-site-button-grad.gif',
272 'wp-admin/link-category.php',
273 'wp-admin/sidebar.php',
274 'wp-includes/classes.php',
275 'wp-includes/js/tinymce/blank.htm',
276 'wp-includes/js/tinymce/plugins/media/css/content.css',
277 'wp-includes/js/tinymce/plugins/media/img',
278 'wp-includes/js/tinymce/plugins/safari',
279 // 3.2
280 'wp-admin/images/logo-login.gif',
281 'wp-admin/images/star.gif',
282 'wp-admin/js/list-table.dev.js',
283 'wp-admin/js/list-table.js',
284 'wp-includes/default-embeds.php',
285 'wp-includes/js/tinymce/plugins/wordpress/img/help.gif',
286 'wp-includes/js/tinymce/plugins/wordpress/img/more.gif',
287 'wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif',
288 'wp-includes/js/tinymce/themes/advanced/img/fm.gif',
289 'wp-includes/js/tinymce/themes/advanced/img/sflogo.png',
290 // 3.3
291 'wp-admin/css/colors-classic-rtl.css',
292 'wp-admin/css/colors-classic-rtl.dev.css',
293 'wp-admin/css/colors-fresh-rtl.css',
294 'wp-admin/css/colors-fresh-rtl.dev.css',
295 'wp-admin/css/dashboard-rtl.dev.css',
296 'wp-admin/css/dashboard.dev.css',
297 'wp-admin/css/global-rtl.css',
298 'wp-admin/css/global-rtl.dev.css',
299 'wp-admin/css/global.css',
300 'wp-admin/css/global.dev.css',
301 'wp-admin/css/install-rtl.dev.css',
302 'wp-admin/css/login-rtl.dev.css',
303 'wp-admin/css/login.dev.css',
304 'wp-admin/css/ms.css',
305 'wp-admin/css/ms.dev.css',
306 'wp-admin/css/nav-menu-rtl.css',
307 'wp-admin/css/nav-menu-rtl.dev.css',
308 'wp-admin/css/nav-menu.css',
309 'wp-admin/css/nav-menu.dev.css',
310 'wp-admin/css/plugin-install-rtl.css',
311 'wp-admin/css/plugin-install-rtl.dev.css',
312 'wp-admin/css/plugin-install.css',
313 'wp-admin/css/plugin-install.dev.css',
314 'wp-admin/css/press-this-rtl.dev.css',
315 'wp-admin/css/press-this.dev.css',
316 'wp-admin/css/theme-editor-rtl.css',
317 'wp-admin/css/theme-editor-rtl.dev.css',
318 'wp-admin/css/theme-editor.css',
319 'wp-admin/css/theme-editor.dev.css',
320 'wp-admin/css/theme-install-rtl.css',
321 'wp-admin/css/theme-install-rtl.dev.css',
322 'wp-admin/css/theme-install.css',
323 'wp-admin/css/theme-install.dev.css',
324 'wp-admin/css/widgets-rtl.dev.css',
325 'wp-admin/css/widgets.dev.css',
326 'wp-admin/includes/internal-linking.php',
327 'wp-includes/images/admin-bar-sprite-rtl.png',
328 'wp-includes/js/jquery/ui.button.js',
329 'wp-includes/js/jquery/ui.core.js',
330 'wp-includes/js/jquery/ui.dialog.js',
331 'wp-includes/js/jquery/ui.draggable.js',
332 'wp-includes/js/jquery/ui.droppable.js',
333 'wp-includes/js/jquery/ui.mouse.js',
334 'wp-includes/js/jquery/ui.position.js',
335 'wp-includes/js/jquery/ui.resizable.js',
336 'wp-includes/js/jquery/ui.selectable.js',
337 'wp-includes/js/jquery/ui.sortable.js',
338 'wp-includes/js/jquery/ui.tabs.js',
339 'wp-includes/js/jquery/ui.widget.js',
340 'wp-includes/js/l10n.dev.js',
341 'wp-includes/js/l10n.js',
342 'wp-includes/js/tinymce/plugins/wplink/css',
343 'wp-includes/js/tinymce/plugins/wplink/img',
344 'wp-includes/js/tinymce/plugins/wplink/js',
345 'wp-includes/js/tinymce/themes/advanced/img/wpicons.png',
346 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png',
347 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/button_bg.png',
348 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif',
349 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png',
350 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/separator.gif',
351 // Don't delete, yet: 'wp-rss.php',
352 // Don't delete, yet: 'wp-rdf.php',
353 // Don't delete, yet: 'wp-rss2.php',
354 // Don't delete, yet: 'wp-commentsrss2.php',
355 // Don't delete, yet: 'wp-atom.php',
356 // Don't delete, yet: 'wp-feed.php',
357 // 3.4
358 'wp-admin/images/gray-star.png',
359 'wp-admin/images/logo-login.png',
360 'wp-admin/images/star.png',
361 'wp-admin/index-extra.php',
362 'wp-admin/network/index-extra.php',
363 'wp-admin/user/index-extra.php',
364 'wp-admin/images/screenshots/admin-flyouts.png',
365 'wp-admin/images/screenshots/coediting.png',
366 'wp-admin/images/screenshots/drag-and-drop.png',
367 'wp-admin/images/screenshots/help-screen.png',
368 'wp-admin/images/screenshots/media-icon.png',
369 'wp-admin/images/screenshots/new-feature-pointer.png',
370 'wp-admin/images/screenshots/welcome-screen.png',
371 'wp-includes/css/editor-buttons.css',
372 'wp-includes/css/editor-buttons.dev.css',
373 'wp-includes/js/tinymce/plugins/paste/blank.htm',
374 'wp-includes/js/tinymce/plugins/wordpress/css',
375 'wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js',
376 'wp-includes/js/tinymce/plugins/wordpress/img/embedded.png',
377 'wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif',
378 'wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif',
379 'wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js',
380 'wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css',
381 'wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js',
382 'wp-includes/js/tinymce/plugins/wpfullscreen/editor_plugin.dev.js',
383 'wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js',
384 'wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png',
385 'wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js',
386 // Don't delete, yet: 'wp-pass.php',
387 // Don't delete, yet: 'wp-register.php',
388 // 3.5
389 'wp-admin/gears-manifest.php',
390 'wp-admin/includes/manifest.php',
391 'wp-admin/images/archive-link.png',
392 'wp-admin/images/blue-grad.png',
393 'wp-admin/images/button-grad-active.png',
394 'wp-admin/images/button-grad.png',
395 'wp-admin/images/ed-bg-vs.gif',
396 'wp-admin/images/ed-bg.gif',
397 'wp-admin/images/fade-butt.png',
398 'wp-admin/images/fav-arrow-rtl.gif',
399 'wp-admin/images/fav-arrow.gif',
400 'wp-admin/images/fav-vs.png',
401 'wp-admin/images/fav.png',
402 'wp-admin/images/gray-grad.png',
403 'wp-admin/images/loading-publish.gif',
404 'wp-admin/images/logo-ghost.png',
405 'wp-admin/images/logo.gif',
406 'wp-admin/images/menu-arrow-frame-rtl.png',
407 'wp-admin/images/menu-arrow-frame.png',
408 'wp-admin/images/menu-arrows.gif',
409 'wp-admin/images/menu-bits-rtl-vs.gif',
410 'wp-admin/images/menu-bits-rtl.gif',
411 'wp-admin/images/menu-bits-vs.gif',
412 'wp-admin/images/menu-bits.gif',
413 'wp-admin/images/menu-dark-rtl-vs.gif',
414 'wp-admin/images/menu-dark-rtl.gif',
415 'wp-admin/images/menu-dark-vs.gif',
416 'wp-admin/images/menu-dark.gif',
417 'wp-admin/images/required.gif',
418 'wp-admin/images/screen-options-toggle-vs.gif',
419 'wp-admin/images/screen-options-toggle.gif',
420 'wp-admin/images/toggle-arrow-rtl.gif',
421 'wp-admin/images/toggle-arrow.gif',
422 'wp-admin/images/upload-classic.png',
423 'wp-admin/images/upload-fresh.png',
424 'wp-admin/images/white-grad-active.png',
425 'wp-admin/images/white-grad.png',
426 'wp-admin/images/widgets-arrow-vs.gif',
427 'wp-admin/images/widgets-arrow.gif',
428 'wp-admin/images/wpspin_dark.gif',
429 'wp-includes/images/upload.png',
430 'wp-includes/js/prototype.js',
431 'wp-includes/js/scriptaculous',
432 'wp-admin/css/wp-admin-rtl.dev.css',
433 'wp-admin/css/wp-admin.dev.css',
434 'wp-admin/css/media-rtl.dev.css',
435 'wp-admin/css/media.dev.css',
436 'wp-admin/css/colors-classic.dev.css',
437 'wp-admin/css/customize-controls-rtl.dev.css',
438 'wp-admin/css/customize-controls.dev.css',
439 'wp-admin/css/ie-rtl.dev.css',
440 'wp-admin/css/ie.dev.css',
441 'wp-admin/css/install.dev.css',
442 'wp-admin/css/colors-fresh.dev.css',
443 'wp-includes/js/customize-base.dev.js',
444 'wp-includes/js/json2.dev.js',
445 'wp-includes/js/comment-reply.dev.js',
446 'wp-includes/js/customize-preview.dev.js',
447 'wp-includes/js/wplink.dev.js',
448 'wp-includes/js/tw-sack.dev.js',
449 'wp-includes/js/wp-list-revisions.dev.js',
450 'wp-includes/js/autosave.dev.js',
451 'wp-includes/js/admin-bar.dev.js',
452 'wp-includes/js/quicktags.dev.js',
453 'wp-includes/js/wp-ajax-response.dev.js',
454 'wp-includes/js/wp-pointer.dev.js',
455 'wp-includes/js/hoverIntent.dev.js',
456 'wp-includes/js/colorpicker.dev.js',
457 'wp-includes/js/wp-lists.dev.js',
458 'wp-includes/js/customize-loader.dev.js',
459 'wp-includes/js/jquery/jquery.table-hotkeys.dev.js',
460 'wp-includes/js/jquery/jquery.color.dev.js',
461 'wp-includes/js/jquery/jquery.color.js',
462 'wp-includes/js/jquery/jquery.hotkeys.dev.js',
463 'wp-includes/js/jquery/jquery.form.dev.js',
464 'wp-includes/js/jquery/suggest.dev.js',
465 'wp-admin/js/xfn.dev.js',
466 'wp-admin/js/set-post-thumbnail.dev.js',
467 'wp-admin/js/comment.dev.js',
468 'wp-admin/js/theme.dev.js',
469 'wp-admin/js/cat.dev.js',
470 'wp-admin/js/password-strength-meter.dev.js',
471 'wp-admin/js/user-profile.dev.js',
472 'wp-admin/js/theme-preview.dev.js',
473 'wp-admin/js/post.dev.js',
474 'wp-admin/js/media-upload.dev.js',
475 'wp-admin/js/word-count.dev.js',
476 'wp-admin/js/plugin-install.dev.js',
477 'wp-admin/js/edit-comments.dev.js',
478 'wp-admin/js/media-gallery.dev.js',
479 'wp-admin/js/custom-fields.dev.js',
480 'wp-admin/js/custom-background.dev.js',
481 'wp-admin/js/common.dev.js',
482 'wp-admin/js/inline-edit-tax.dev.js',
483 'wp-admin/js/gallery.dev.js',
484 'wp-admin/js/utils.dev.js',
485 'wp-admin/js/widgets.dev.js',
486 'wp-admin/js/wp-fullscreen.dev.js',
487 'wp-admin/js/nav-menu.dev.js',
488 'wp-admin/js/dashboard.dev.js',
489 'wp-admin/js/link.dev.js',
490 'wp-admin/js/user-suggest.dev.js',
491 'wp-admin/js/postbox.dev.js',
492 'wp-admin/js/tags.dev.js',
493 'wp-admin/js/image-edit.dev.js',
494 'wp-admin/js/media.dev.js',
495 'wp-admin/js/customize-controls.dev.js',
496 'wp-admin/js/inline-edit-post.dev.js',
497 'wp-admin/js/categories.dev.js',
498 'wp-admin/js/editor.dev.js',
499 'wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js',
500 'wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js',
501 'wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog.dev.js',
502 'wp-includes/js/plupload/handlers.dev.js',
503 'wp-includes/js/plupload/wp-plupload.dev.js',
504 'wp-includes/js/swfupload/handlers.dev.js',
505 'wp-includes/js/jcrop/jquery.Jcrop.dev.js',
506 'wp-includes/js/jcrop/jquery.Jcrop.js',
507 'wp-includes/js/jcrop/jquery.Jcrop.css',
508 'wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js',
509 'wp-includes/css/wp-pointer.dev.css',
510 'wp-includes/css/editor.dev.css',
511 'wp-includes/css/jquery-ui-dialog.dev.css',
512 'wp-includes/css/admin-bar-rtl.dev.css',
513 'wp-includes/css/admin-bar.dev.css',
514 'wp-includes/js/jquery/ui/jquery.effects.clip.min.js',
515 'wp-includes/js/jquery/ui/jquery.effects.scale.min.js',
516 'wp-includes/js/jquery/ui/jquery.effects.blind.min.js',
517 'wp-includes/js/jquery/ui/jquery.effects.core.min.js',
518 'wp-includes/js/jquery/ui/jquery.effects.shake.min.js',
519 'wp-includes/js/jquery/ui/jquery.effects.fade.min.js',
520 'wp-includes/js/jquery/ui/jquery.effects.explode.min.js',
521 'wp-includes/js/jquery/ui/jquery.effects.slide.min.js',
522 'wp-includes/js/jquery/ui/jquery.effects.drop.min.js',
523 'wp-includes/js/jquery/ui/jquery.effects.highlight.min.js',
524 'wp-includes/js/jquery/ui/jquery.effects.bounce.min.js',
525 'wp-includes/js/jquery/ui/jquery.effects.pulsate.min.js',
526 'wp-includes/js/jquery/ui/jquery.effects.transfer.min.js',
527 'wp-includes/js/jquery/ui/jquery.effects.fold.min.js',
528 'wp-admin/images/screenshots/captions-1.png',
529 'wp-admin/images/screenshots/captions-2.png',
530 'wp-admin/images/screenshots/flex-header-1.png',
531 'wp-admin/images/screenshots/flex-header-2.png',
532 'wp-admin/images/screenshots/flex-header-3.png',
533 'wp-admin/images/screenshots/flex-header-media-library.png',
534 'wp-admin/images/screenshots/theme-customizer.png',
535 'wp-admin/images/screenshots/twitter-embed-1.png',
536 'wp-admin/images/screenshots/twitter-embed-2.png',
537 'wp-admin/js/utils.js',
538 'wp-admin/options-privacy.php',
539 'wp-app.php',
540 'wp-includes/class-wp-atom-server.php',
541 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css',
542 // 3.5.2
543 'wp-includes/js/swfupload/swfupload-all.js',
544 // 3.6
545 'wp-admin/js/revisions-js.php',
546 'wp-admin/images/screenshots',
547 'wp-admin/js/categories.js',
548 'wp-admin/js/categories.min.js',
549 'wp-admin/js/custom-fields.js',
550 'wp-admin/js/custom-fields.min.js',
551 // 3.7
552 'wp-admin/js/cat.js',
553 'wp-admin/js/cat.min.js',
554 'wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.min.js',
555 // 3.8
556 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/page_bug.gif',
557 'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/more_bug.gif',
558 'wp-includes/js/thickbox/tb-close-2x.png',
559 'wp-includes/js/thickbox/tb-close.png',
560 'wp-includes/images/wpmini-blue-2x.png',
561 'wp-includes/images/wpmini-blue.png',
562 'wp-admin/css/colors-fresh.css',
563 'wp-admin/css/colors-classic.css',
564 'wp-admin/css/colors-fresh.min.css',
565 'wp-admin/css/colors-classic.min.css',
566 'wp-admin/js/about.min.js',
567 'wp-admin/js/about.js',
568 'wp-admin/images/arrows-dark-vs-2x.png',
569 'wp-admin/images/wp-logo-vs.png',
570 'wp-admin/images/arrows-dark-vs.png',
571 'wp-admin/images/wp-logo.png',
572 'wp-admin/images/arrows-pr.png',
573 'wp-admin/images/arrows-dark.png',
574 'wp-admin/images/press-this.png',
575 'wp-admin/images/press-this-2x.png',
576 'wp-admin/images/arrows-vs-2x.png',
577 'wp-admin/images/welcome-icons.png',
578 'wp-admin/images/wp-logo-2x.png',
579 'wp-admin/images/stars-rtl-2x.png',
580 'wp-admin/images/arrows-dark-2x.png',
581 'wp-admin/images/arrows-pr-2x.png',
582 'wp-admin/images/menu-shadow-rtl.png',
583 'wp-admin/images/arrows-vs.png',
584 'wp-admin/images/about-search-2x.png',
585 'wp-admin/images/bubble_bg-rtl-2x.gif',
586 'wp-admin/images/wp-badge-2x.png',
587 'wp-admin/images/wordpress-logo-2x.png',
588 'wp-admin/images/bubble_bg-rtl.gif',
589 'wp-admin/images/wp-badge.png',
590 'wp-admin/images/menu-shadow.png',
591 'wp-admin/images/about-globe-2x.png',
592 'wp-admin/images/welcome-icons-2x.png',
593 'wp-admin/images/stars-rtl.png',
594 'wp-admin/images/wp-logo-vs-2x.png',
595 'wp-admin/images/about-updates-2x.png',
596 // 3.9
597 'wp-admin/css/colors.css',
598 'wp-admin/css/colors.min.css',
599 'wp-admin/css/colors-rtl.css',
600 'wp-admin/css/colors-rtl.min.css',
601 // Following files added back in 4.5 see #36083
602 // 'wp-admin/css/media-rtl.min.css',
603 // 'wp-admin/css/media.min.css',
604 // 'wp-admin/css/farbtastic-rtl.min.css',
605 'wp-admin/images/lock-2x.png',
606 'wp-admin/images/lock.png',
607 'wp-admin/js/theme-preview.js',
608 'wp-admin/js/theme-install.min.js',
609 'wp-admin/js/theme-install.js',
610 'wp-admin/js/theme-preview.min.js',
611 'wp-includes/js/plupload/plupload.html4.js',
612 'wp-includes/js/plupload/plupload.html5.js',
613 'wp-includes/js/plupload/changelog.txt',
614 'wp-includes/js/plupload/plupload.silverlight.js',
615 'wp-includes/js/plupload/plupload.flash.js',
616 'wp-includes/js/plupload/plupload.js',
617 'wp-includes/js/tinymce/plugins/spellchecker',
618 'wp-includes/js/tinymce/plugins/inlinepopups',
619 'wp-includes/js/tinymce/plugins/media/js',
620 'wp-includes/js/tinymce/plugins/media/css',
621 'wp-includes/js/tinymce/plugins/wordpress/img',
622 'wp-includes/js/tinymce/plugins/wpdialogs/js',
623 'wp-includes/js/tinymce/plugins/wpeditimage/img',
624 'wp-includes/js/tinymce/plugins/wpeditimage/js',
625 'wp-includes/js/tinymce/plugins/wpeditimage/css',
626 'wp-includes/js/tinymce/plugins/wpgallery/img',
627 'wp-includes/js/tinymce/plugins/wpfullscreen/css',
628 'wp-includes/js/tinymce/plugins/paste/js',
629 'wp-includes/js/tinymce/themes/advanced',
630 'wp-includes/js/tinymce/tiny_mce.js',
631 'wp-includes/js/tinymce/mark_loaded_src.js',
632 'wp-includes/js/tinymce/wp-tinymce-schema.js',
633 'wp-includes/js/tinymce/plugins/media/editor_plugin.js',
634 'wp-includes/js/tinymce/plugins/media/editor_plugin_src.js',
635 'wp-includes/js/tinymce/plugins/media/media.htm',
636 'wp-includes/js/tinymce/plugins/wpview/editor_plugin_src.js',
637 'wp-includes/js/tinymce/plugins/wpview/editor_plugin.js',
638 'wp-includes/js/tinymce/plugins/directionality/editor_plugin.js',
639 'wp-includes/js/tinymce/plugins/directionality/editor_plugin_src.js',
640 'wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js',
641 'wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js',
642 'wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin_src.js',
643 'wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js',
644 'wp-includes/js/tinymce/plugins/wpeditimage/editimage.html',
645 'wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js',
646 'wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js',
647 'wp-includes/js/tinymce/plugins/fullscreen/editor_plugin_src.js',
648 'wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm',
649 'wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js',
650 'wp-includes/js/tinymce/plugins/wplink/editor_plugin_src.js',
651 'wp-includes/js/tinymce/plugins/wplink/editor_plugin.js',
652 'wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js',
653 'wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js',
654 'wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js',
655 'wp-includes/js/tinymce/plugins/tabfocus/editor_plugin_src.js',
656 'wp-includes/js/tinymce/plugins/wpfullscreen/editor_plugin.js',
657 'wp-includes/js/tinymce/plugins/wpfullscreen/editor_plugin_src.js',
658 'wp-includes/js/tinymce/plugins/paste/editor_plugin.js',
659 'wp-includes/js/tinymce/plugins/paste/pasteword.htm',
660 'wp-includes/js/tinymce/plugins/paste/editor_plugin_src.js',
661 'wp-includes/js/tinymce/plugins/paste/pastetext.htm',
662 'wp-includes/js/tinymce/langs/wp-langs.php',
663 // 4.1
664 'wp-includes/js/jquery/ui/jquery.ui.accordion.min.js',
665 'wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js',
666 'wp-includes/js/jquery/ui/jquery.ui.button.min.js',
667 'wp-includes/js/jquery/ui/jquery.ui.core.min.js',
668 'wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js',
669 'wp-includes/js/jquery/ui/jquery.ui.dialog.min.js',
670 'wp-includes/js/jquery/ui/jquery.ui.draggable.min.js',
671 'wp-includes/js/jquery/ui/jquery.ui.droppable.min.js',
672 'wp-includes/js/jquery/ui/jquery.ui.effect-blind.min.js',
673 'wp-includes/js/jquery/ui/jquery.ui.effect-bounce.min.js',
674 'wp-includes/js/jquery/ui/jquery.ui.effect-clip.min.js',
675 'wp-includes/js/jquery/ui/jquery.ui.effect-drop.min.js',
676 'wp-includes/js/jquery/ui/jquery.ui.effect-explode.min.js',
677 'wp-includes/js/jquery/ui/jquery.ui.effect-fade.min.js',
678 'wp-includes/js/jquery/ui/jquery.ui.effect-fold.min.js',
679 'wp-includes/js/jquery/ui/jquery.ui.effect-highlight.min.js',
680 'wp-includes/js/jquery/ui/jquery.ui.effect-pulsate.min.js',
681 'wp-includes/js/jquery/ui/jquery.ui.effect-scale.min.js',
682 'wp-includes/js/jquery/ui/jquery.ui.effect-shake.min.js',
683 'wp-includes/js/jquery/ui/jquery.ui.effect-slide.min.js',
684 'wp-includes/js/jquery/ui/jquery.ui.effect-transfer.min.js',
685 'wp-includes/js/jquery/ui/jquery.ui.effect.min.js',
686 'wp-includes/js/jquery/ui/jquery.ui.menu.min.js',
687 'wp-includes/js/jquery/ui/jquery.ui.mouse.min.js',
688 'wp-includes/js/jquery/ui/jquery.ui.position.min.js',
689 'wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js',
690 'wp-includes/js/jquery/ui/jquery.ui.resizable.min.js',
691 'wp-includes/js/jquery/ui/jquery.ui.selectable.min.js',
692 'wp-includes/js/jquery/ui/jquery.ui.slider.min.js',
693 'wp-includes/js/jquery/ui/jquery.ui.sortable.min.js',
694 'wp-includes/js/jquery/ui/jquery.ui.spinner.min.js',
695 'wp-includes/js/jquery/ui/jquery.ui.tabs.min.js',
696 'wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js',
697 'wp-includes/js/jquery/ui/jquery.ui.widget.min.js',
698 'wp-includes/js/tinymce/skins/wordpress/images/dashicon-no-alt.png',
699 // 4.3
700 'wp-admin/js/wp-fullscreen.js',
701 'wp-admin/js/wp-fullscreen.min.js',
702 'wp-includes/js/tinymce/wp-mce-help.php',
703 'wp-includes/js/tinymce/plugins/wpfullscreen',
704 // 4.5
705 'wp-includes/theme-compat/comments-popup.php',
706 // 4.6
707 'wp-admin/includes/class-wp-automatic-upgrader.php', // Wrong file name, see #37628.
708 );
709
710 /**
711  * Stores new files in wp-content to copy
712  *
713  * The contents of this array indicate any new bundled plugins/themes which
714  * should be installed with the WordPress Upgrade. These items will not be
715  * re-installed in future upgrades, this behaviour is controlled by the
716  * introduced version present here being older than the current installed version.
717  *
718  * The content of this array should follow the following format:
719  * Filename (relative to wp-content) => Introduced version
720  * Directories should be noted by suffixing it with a trailing slash (/)
721  *
722  * @since 3.2.0
723  * @since 4.4.0 New themes are not automatically installed on upgrade.
724  *              This can still be explicitly asked for by defining
725  *              CORE_UPGRADE_SKIP_NEW_BUNDLED as false.
726  * @global array $_new_bundled_files
727  * @var array
728  * @name $_new_bundled_files
729  */
730 global $_new_bundled_files;
731
732 $_new_bundled_files = array(
733         'plugins/akismet/'       => '2.0',
734         'themes/twentyten/'      => '3.0',
735         'themes/twentyeleven/'   => '3.2',
736         'themes/twentytwelve/'   => '3.5',
737         'themes/twentythirteen/' => '3.6',
738         'themes/twentyfourteen/' => '3.8',
739         'themes/twentyfifteen/'  => '4.1',
740         'themes/twentysixteen/'  => '4.4',
741 );
742
743 // If not explicitly defined as false, don't install new default themes.
744 if ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || CORE_UPGRADE_SKIP_NEW_BUNDLED ) {
745         $_new_bundled_files = array( 'plugins/akismet/' => '2.0' );
746 }
747
748 /**
749  * Upgrades the core of WordPress.
750  *
751  * This will create a .maintenance file at the base of the WordPress directory
752  * to ensure that people can not access the web site, when the files are being
753  * copied to their locations.
754  *
755  * The files in the `$_old_files` list will be removed and the new files
756  * copied from the zip file after the database is upgraded.
757  *
758  * The files in the `$_new_bundled_files` list will be added to the installation
759  * if the version is greater than or equal to the old version being upgraded.
760  *
761  * The steps for the upgrader for after the new release is downloaded and
762  * unzipped is:
763  *   1. Test unzipped location for select files to ensure that unzipped worked.
764  *   2. Create the .maintenance file in current WordPress base.
765  *   3. Copy new WordPress directory over old WordPress files.
766  *   4. Upgrade WordPress to new version.
767  *     4.1. Copy all files/folders other than wp-content
768  *     4.2. Copy any language files to WP_LANG_DIR (which may differ from WP_CONTENT_DIR
769  *     4.3. Copy any new bundled themes/plugins to their respective locations
770  *   5. Delete new WordPress directory path.
771  *   6. Delete .maintenance file.
772  *   7. Remove old files.
773  *   8. Delete 'update_core' option.
774  *
775  * There are several areas of failure. For instance if PHP times out before step
776  * 6, then you will not be able to access any portion of your site. Also, since
777  * the upgrade will not continue where it left off, you will not be able to
778  * automatically remove old files and remove the 'update_core' option. This
779  * isn't that bad.
780  *
781  * If the copy of the new WordPress over the old fails, then the worse is that
782  * the new WordPress directory will remain.
783  *
784  * If it is assumed that every file will be copied over, including plugins and
785  * themes, then if you edit the default theme, you should rename it, so that
786  * your changes remain.
787  *
788  * @since 2.7.0
789  *
790  * @global WP_Filesystem_Base $wp_filesystem
791  * @global array              $_old_files
792  * @global array              $_new_bundled_files
793  * @global wpdb               $wpdb
794  * @global string             $wp_version
795  * @global string             $required_php_version
796  * @global string             $required_mysql_version
797  *
798  * @param string $from New release unzipped path.
799  * @param string $to   Path to old WordPress installation.
800  * @return WP_Error|null WP_Error on failure, null on success.
801  */
802 function update_core($from, $to) {
803         global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
804
805         @set_time_limit( 300 );
806
807         /**
808          * Filters feedback messages displayed during the core update process.
809          *
810          * The filter is first evaluated after the zip file for the latest version
811          * has been downloaded and unzipped. It is evaluated five more times during
812          * the process:
813          *
814          * 1. Before WordPress begins the core upgrade process.
815          * 2. Before Maintenance Mode is enabled.
816          * 3. Before WordPress begins copying over the necessary files.
817          * 4. Before Maintenance Mode is disabled.
818          * 5. Before the database is upgraded.
819          *
820          * @since 2.5.0
821          *
822          * @param string $feedback The core update feedback messages.
823          */
824         apply_filters( 'update_feedback', __( 'Verifying the unpacked files&#8230;' ) );
825
826         // Sanity check the unzipped distribution.
827         $distro = '';
828         $roots = array( '/wordpress/', '/wordpress-mu/' );
829         foreach ( $roots as $root ) {
830                 if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) {
831                         $distro = $root;
832                         break;
833                 }
834         }
835         if ( ! $distro ) {
836                 $wp_filesystem->delete( $from, true );
837                 return new WP_Error( 'insane_distro', __('The update could not be unpacked') );
838         }
839
840
841         /**
842          * Import $wp_version, $required_php_version, and $required_mysql_version from the new version
843          * $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
844          *
845          * @global string $wp_version
846          * @global string $required_php_version
847          * @global string $required_mysql_version
848          */
849         global $wp_version, $required_php_version, $required_mysql_version;
850
851         $versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
852         if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
853                 $wp_filesystem->delete( $from, true );
854                 return new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
855         }
856
857         $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
858         require( WP_CONTENT_DIR . '/upgrade/version-current.php' );
859         $wp_filesystem->delete( $versions_file );
860
861         $php_version    = phpversion();
862         $mysql_version  = $wpdb->db_version();
863         $old_wp_version = $wp_version; // The version of WordPress we're updating from
864         $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' )  ); // a dash in the version indicates a Development release
865         $php_compat     = version_compare( $php_version, $required_php_version, '>=' );
866         if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
867                 $mysql_compat = true;
868         else
869                 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
870
871         if ( !$mysql_compat || !$php_compat )
872                 $wp_filesystem->delete($from, true);
873
874         if ( !$mysql_compat && !$php_compat )
875                 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 ) );
876         elseif ( !$php_compat )
877                 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 ) );
878         elseif ( !$mysql_compat )
879                 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 ) );
880
881         /** This filter is documented in wp-admin/includes/update-core.php */
882         apply_filters( 'update_feedback', __( 'Preparing to install the latest version&#8230;' ) );
883
884         // Don't copy wp-content, we'll deal with that below
885         // We also copy version.php last so failed updates report their old version
886         $skip = array( 'wp-content', 'wp-includes/version.php' );
887         $check_is_writable = array();
888
889         // Check to see which files don't really need updating - only available for 3.7 and higher
890         if ( function_exists( 'get_core_checksums' ) ) {
891                 // Find the local version of the working directory
892                 $working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
893
894                 $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
895                 if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) )
896                         $checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2
897                 if ( is_array( $checksums ) ) {
898                         foreach ( $checksums as $file => $checksum ) {
899                                 if ( 'wp-content' == substr( $file, 0, 10 ) )
900                                         continue;
901                                 if ( ! file_exists( ABSPATH . $file ) )
902                                         continue;
903                                 if ( ! file_exists( $working_dir_local . $file ) )
904                                         continue;
905                                 if ( md5_file( ABSPATH . $file ) === $checksum )
906                                         $skip[] = $file;
907                                 else
908                                         $check_is_writable[ $file ] = ABSPATH . $file;
909                         }
910                 }
911         }
912
913         // If we're using the direct method, we can predict write failures that are due to permissions.
914         if ( $check_is_writable && 'direct' === $wp_filesystem->method ) {
915                 $files_writable = array_filter( $check_is_writable, array( $wp_filesystem, 'is_writable' ) );
916                 if ( $files_writable !== $check_is_writable ) {
917                         $files_not_writable = array_diff_key( $check_is_writable, $files_writable );
918                         foreach ( $files_not_writable as $relative_file_not_writable => $file_not_writable ) {
919                                 // If the writable check failed, chmod file to 0644 and try again, same as copy_dir().
920                                 $wp_filesystem->chmod( $file_not_writable, FS_CHMOD_FILE );
921                                 if ( $wp_filesystem->is_writable( $file_not_writable ) )
922                                         unset( $files_not_writable[ $relative_file_not_writable ] );
923                         }
924
925                         // Store package-relative paths (the key) of non-writable files in the WP_Error object.
926                         $error_data = version_compare( $old_wp_version, '3.7-beta2', '>' ) ? array_keys( $files_not_writable ) : '';
927
928                         if ( $files_not_writable )
929                                 return new WP_Error( 'files_not_writable', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), implode( ', ', $error_data ) );
930                 }
931         }
932
933         /** This filter is documented in wp-admin/includes/update-core.php */
934         apply_filters( 'update_feedback', __( 'Enabling Maintenance mode&#8230;' ) );
935         // Create maintenance file to signal that we are upgrading
936         $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
937         $maintenance_file = $to . '.maintenance';
938         $wp_filesystem->delete($maintenance_file);
939         $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
940
941         /** This filter is documented in wp-admin/includes/update-core.php */
942         apply_filters( 'update_feedback', __( 'Copying the required files&#8230;' ) );
943         // Copy new versions of WP files into place.
944         $result = _copy_dir( $from . $distro, $to, $skip );
945         if ( is_wp_error( $result ) )
946                 $result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
947
948         // Since we know the core files have copied over, we can now copy the version file
949         if ( ! is_wp_error( $result ) ) {
950                 if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) {
951                         $wp_filesystem->delete( $from, true );
952                         $result = new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
953                 }
954                 $wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE );
955         }
956
957         // Check to make sure everything copied correctly, ignoring the contents of wp-content
958         $skip = array( 'wp-content' );
959         $failed = array();
960         if ( isset( $checksums ) && is_array( $checksums ) ) {
961                 foreach ( $checksums as $file => $checksum ) {
962                         if ( 'wp-content' == substr( $file, 0, 10 ) )
963                                 continue;
964                         if ( ! file_exists( $working_dir_local . $file ) )
965                                 continue;
966                         if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum )
967                                 $skip[] = $file;
968                         else
969                                 $failed[] = $file;
970                 }
971         }
972
973         // Some files didn't copy properly
974         if ( ! empty( $failed ) ) {
975                 $total_size = 0;
976                 foreach ( $failed as $file ) {
977                         if ( file_exists( $working_dir_local . $file ) )
978                                 $total_size += filesize( $working_dir_local . $file );
979                 }
980
981                 // If we don't have enough free space, it isn't worth trying again.
982                 // Unlikely to be hit due to the check in unzip_file().
983                 $available_space = @disk_free_space( ABSPATH );
984                 if ( $available_space && $total_size >= $available_space ) {
985                         $result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
986                 } else {
987                         $result = _copy_dir( $from . $distro, $to, $skip );
988                         if ( is_wp_error( $result ) )
989                                 $result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
990                 }
991         }
992
993         // Custom Content Directory needs updating now.
994         // Copy Languages
995         if ( !is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) {
996                 if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir(WP_LANG_DIR) )
997                         $lang_dir = WP_LANG_DIR;
998                 else
999                         $lang_dir = WP_CONTENT_DIR . '/languages';
1000
1001                 if ( !@is_dir($lang_dir) && 0 === strpos($lang_dir, ABSPATH) ) { // Check the language directory exists first
1002                         $wp_filesystem->mkdir($to . str_replace(ABSPATH, '', $lang_dir), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
1003                         clearstatcache(); // for FTP, Need to clear the stat cache
1004                 }
1005
1006                 if ( @is_dir($lang_dir) ) {
1007                         $wp_lang_dir = $wp_filesystem->find_folder($lang_dir);
1008                         if ( $wp_lang_dir ) {
1009                                 $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir);
1010                                 if ( is_wp_error( $result ) )
1011                                         $result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), substr( $result->get_error_data(), strlen( $wp_lang_dir ) ) );
1012                         }
1013                 }
1014         }
1015
1016         /** This filter is documented in wp-admin/includes/update-core.php */
1017         apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) );
1018         // Remove maintenance file, we're done with potential site-breaking changes
1019         $wp_filesystem->delete( $maintenance_file );
1020
1021         // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve.
1022         if ( '3.5' == $old_wp_version ) {
1023                 if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' )  ) {
1024                         $wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' );
1025                 }
1026         }
1027
1028         // Copy New bundled plugins & themes
1029         // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
1030         // $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated
1031         if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
1032                 foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
1033                         // If a $development_build or if $introduced version is greater than what the site was previously running
1034                         if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
1035                                 $directory = ('/' == $file[ strlen($file)-1 ]);
1036                                 list($type, $filename) = explode('/', $file, 2);
1037
1038                                 // Check to see if the bundled items exist before attempting to copy them
1039                                 if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) )
1040                                         continue;
1041
1042                                 if ( 'plugins' == $type )
1043                                         $dest = $wp_filesystem->wp_plugins_dir();
1044                                 elseif ( 'themes' == $type )
1045                                         $dest = trailingslashit($wp_filesystem->wp_themes_dir()); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
1046                                 else
1047                                         continue;
1048
1049                                 if ( ! $directory ) {
1050                                         if ( ! $development_build && $wp_filesystem->exists( $dest . $filename ) )
1051                                                 continue;
1052
1053                                         if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) )
1054                                                 $result = new WP_Error( "copy_failed_for_new_bundled_$type", __( 'Could not copy file.' ), $dest . $filename );
1055                                 } else {
1056                                         if ( ! $development_build && $wp_filesystem->is_dir( $dest . $filename ) )
1057                                                 continue;
1058
1059                                         $wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR);
1060                                         $_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename);
1061
1062                                         // If a error occurs partway through this final step, keep the error flowing through, but keep process going.
1063                                         if ( is_wp_error( $_result ) ) {
1064                                                 if ( ! is_wp_error( $result ) )
1065                                                         $result = new WP_Error;
1066                                                 $result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
1067                                         }
1068                                 }
1069                         }
1070                 } //end foreach
1071         }
1072
1073         // Handle $result error from the above blocks
1074         if ( is_wp_error($result) ) {
1075                 $wp_filesystem->delete($from, true);
1076                 return $result;
1077         }
1078
1079         // Remove old files
1080         foreach ( $_old_files as $old_file ) {
1081                 $old_file = $to . $old_file;
1082                 if ( !$wp_filesystem->exists($old_file) )
1083                         continue;
1084                 $wp_filesystem->delete($old_file, true);
1085         }
1086
1087         // Remove any Genericons example.html's from the filesystem
1088         _upgrade_422_remove_genericons();
1089
1090         // Remove the REST API plugin if its version is Beta 4 or lower
1091         _upgrade_440_force_deactivate_incompatible_plugins();
1092
1093         // Upgrade DB with separate request
1094         /** This filter is documented in wp-admin/includes/update-core.php */
1095         apply_filters( 'update_feedback', __( 'Upgrading database&#8230;' ) );
1096         $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
1097         wp_remote_post($db_upgrade_url, array('timeout' => 60));
1098
1099         // Clear the cache to prevent an update_option() from saving a stale db_version to the cache
1100         wp_cache_flush();
1101         // (Not all cache back ends listen to 'flush')
1102         wp_cache_delete( 'alloptions', 'options' );
1103
1104         // Remove working directory
1105         $wp_filesystem->delete($from, true);
1106
1107         // Force refresh of update information
1108         if ( function_exists('delete_site_transient') )
1109                 delete_site_transient('update_core');
1110         else
1111                 delete_option('update_core');
1112
1113         /**
1114          * Fires after WordPress core has been successfully updated.
1115          *
1116          * @since 3.3.0
1117          *
1118          * @param string $wp_version The current WordPress version.
1119          */
1120         do_action( '_core_updated_successfully', $wp_version );
1121
1122         // Clear the option that blocks auto updates after failures, now that we've been successful.
1123         if ( function_exists( 'delete_site_option' ) )
1124                 delete_site_option( 'auto_core_update_failed' );
1125
1126         return $wp_version;
1127 }
1128
1129 /**
1130  * Copies a directory from one location to another via the WordPress Filesystem Abstraction.
1131  * Assumes that WP_Filesystem() has already been called and setup.
1132  *
1133  * This is a temporary function for the 3.1 -> 3.2 upgrade, as well as for those upgrading to
1134  * 3.7+
1135  *
1136  * @ignore
1137  * @since 3.2.0
1138  * @since 3.7.0 Updated not to use a regular expression for the skip list
1139  * @see copy_dir()
1140  *
1141  * @global WP_Filesystem_Base $wp_filesystem
1142  *
1143  * @param string $from     source directory
1144  * @param string $to       destination directory
1145  * @param array $skip_list a list of files/folders to skip copying
1146  * @return mixed WP_Error on failure, True on success.
1147  */
1148 function _copy_dir($from, $to, $skip_list = array() ) {
1149         global $wp_filesystem;
1150
1151         $dirlist = $wp_filesystem->dirlist($from);
1152
1153         $from = trailingslashit($from);
1154         $to = trailingslashit($to);
1155
1156         foreach ( (array) $dirlist as $filename => $fileinfo ) {
1157                 if ( in_array( $filename, $skip_list ) )
1158                         continue;
1159
1160                 if ( 'f' == $fileinfo['type'] ) {
1161                         if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
1162                                 // If copy failed, chmod file to 0644 and try again.
1163                                 $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
1164                                 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
1165                                         return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename );
1166                         }
1167                 } elseif ( 'd' == $fileinfo['type'] ) {
1168                         if ( !$wp_filesystem->is_dir($to . $filename) ) {
1169                                 if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
1170                                         return new WP_Error( 'mkdir_failed__copy_dir', __( 'Could not create directory.' ), $to . $filename );
1171                         }
1172
1173                         /*
1174                          * Generate the $sub_skip_list for the subdirectory as a sub-set
1175                          * of the existing $skip_list.
1176                          */
1177                         $sub_skip_list = array();
1178                         foreach ( $skip_list as $skip_item ) {
1179                                 if ( 0 === strpos( $skip_item, $filename . '/' ) )
1180                                         $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
1181                         }
1182
1183                         $result = _copy_dir($from . $filename, $to . $filename, $sub_skip_list);
1184                         if ( is_wp_error($result) )
1185                                 return $result;
1186                 }
1187         }
1188         return true;
1189 }
1190
1191 /**
1192  * Redirect to the About WordPress page after a successful upgrade.
1193  *
1194  * This function is only needed when the existing install is older than 3.4.0.
1195  *
1196  * @since 3.3.0
1197  *
1198  * @global string $wp_version
1199  * @global string $pagenow
1200  * @global string $action
1201  *
1202  * @param string $new_version
1203  */
1204 function _redirect_to_about_wordpress( $new_version ) {
1205         global $wp_version, $pagenow, $action;
1206
1207         if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
1208                 return;
1209
1210         // Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.
1211         if ( 'update-core.php' != $pagenow )
1212                 return;
1213
1214         if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action )
1215                 return;
1216
1217         // Load the updated default text localization domain for new strings.
1218         load_default_textdomain();
1219
1220         // See do_core_upgrade()
1221         show_message( __('WordPress updated successfully') );
1222
1223         // self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
1224         show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
1225         show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
1226         echo '</div>';
1227         ?>
1228 <script type="text/javascript">
1229 window.location = 'about.php?updated';
1230 </script>
1231         <?php
1232
1233         // Include admin-footer.php and exit.
1234         include(ABSPATH . 'wp-admin/admin-footer.php');
1235         exit();
1236 }
1237
1238 /**
1239  * Cleans up Genericons example files.
1240  *
1241  * @since 4.2.2
1242  *
1243  * @global array              $wp_theme_directories
1244  * @global WP_Filesystem_Base $wp_filesystem
1245  */
1246 function _upgrade_422_remove_genericons() {
1247         global $wp_theme_directories, $wp_filesystem;
1248
1249         // A list of the affected files using the filesystem absolute paths.
1250         $affected_files = array();
1251
1252         // Themes
1253         foreach ( $wp_theme_directories as $directory ) {
1254                 $affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory );
1255                 $affected_files       = array_merge( $affected_files, $affected_theme_files );
1256         }
1257
1258         // Plugins
1259         $affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR );
1260         $affected_files        = array_merge( $affected_files, $affected_plugin_files );
1261
1262         foreach ( $affected_files as $file ) {
1263                 $gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) );
1264                 if ( empty( $gen_dir ) ) {
1265                         continue;
1266                 }
1267
1268                 // The path when the file is accessed via WP_Filesystem may differ in the case of FTP
1269                 $remote_file = $gen_dir . basename( $file );
1270
1271                 if ( ! $wp_filesystem->exists( $remote_file ) ) {
1272                         continue;
1273                 }
1274
1275                 if ( ! $wp_filesystem->delete( $remote_file, false, 'f' ) ) {
1276                         $wp_filesystem->put_contents( $remote_file, '' );
1277                 }
1278         }
1279 }
1280
1281 /**
1282  * Recursively find Genericons example files in a given folder.
1283  *
1284  * @ignore
1285  * @since 4.2.2
1286  *
1287  * @param string $directory Directory path. Expects trailingslashed.
1288  * @return array
1289  */
1290 function _upgrade_422_find_genericons_files_in_folder( $directory ) {
1291         $directory = trailingslashit( $directory );
1292         $files     = array();
1293
1294         if ( file_exists( "{$directory}example.html" ) && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' ) ) {
1295                 $files[] = "{$directory}example.html";
1296         }
1297
1298         $dirs = glob( $directory . '*', GLOB_ONLYDIR );
1299         if ( $dirs ) {
1300                 foreach ( $dirs as $dir ) {
1301                         $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
1302                 }
1303         }
1304
1305         return $files;
1306 }
1307
1308 /**
1309  * @ignore
1310  * @since 4.4.0
1311  */
1312 function _upgrade_440_force_deactivate_incompatible_plugins() {
1313         if ( defined( 'REST_API_VERSION' ) && version_compare( REST_API_VERSION, '2.0-beta4', '<=' ) ) {
1314                 deactivate_plugins( array( 'rest-api/plugin.php' ), true );
1315         }
1316 }