PluginProbe
ManageWP Worker / 3.8.3
ManageWP Worker v3.8.3
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / wp.class.php

wp.class.php in ManageWP Worker 3.8.3, at wp.class.php

118 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*************************************************************
3 *
4 * wp.class.php
5 *
6 * Upgrade WordPress
7 *
8 *
9 * Copyright (c) 2011 Prelovac Media
10 * www.prelovac.com
11 **************************************************************/
12 class MMB_WP extends MMB_Core
13 {
14 function __construct()
15 {
16 parent::__construct();
17 }
18
19 /*************************************************************
20 * FACADE functions
21 * (functions to be called after a remote call from Master)
22 **************************************************************/
23 function check_version()
24 {
25 require_once(ABSPATH . 'wp-includes/version.php');
26 require_once(ABSPATH . '/wp-admin/includes/update.php');
27
28 $updates = get_core_updates();
29 $update = $updates[0];
30 global $wp_version;
31
32 if (!isset($update->response) || 'latest' == $update->response) {
33 return array(
34 'current_version' => $wp_version,
35 'latest_version' => false
36 );
37 } else {
38 return array(
39 'current_version' => $wp_version,
40 'latest_version' => $update
41 );
42 }
43 }
44
45 /**
46 * Upgrades WordPress locally
47 *
48 */
49 function upgrade($params)
50 {
51 ob_start();
52 require_once(ABSPATH . 'wp-admin/includes/file.php');
53 require_once(ABSPATH . 'wp-admin/includes/misc.php');
54 require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
55
56 WP_Filesystem();
57 global $wp_version, $wp_filesystem;
58 $upgrader = new WP_Upgrader();
59 $updates = $this->mmb_get_transient('update_core');
60 $current = $updates->updates[0];
61
62
63 // Is an update available?
64 if (!isset($current->response) || $current->response == 'latest')
65 return array(
66 'upgraded' => ' has latest ' . $wp_version . ' WordPress version.'
67 );
68
69 $res = $upgrader->fs_connect(array(
70 ABSPATH,
71 WP_CONTENT_DIR
72 ));
73 if (is_wp_error($res))
74 return array(
75 'error' => $this->mmb_get_error($res)
76 );
77
78 $wp_dir = trailingslashit($wp_filesystem->abspath());
79
80 $download = $upgrader->download_package($current->package);
81 if (is_wp_error($download))
82 return array(
83 'error' => $this->mmb_get_error($download)
84 );
85
86 $working_dir = $upgrader->unpack_package($download);
87 if (is_wp_error($working_dir))
88 return array(
89 'error' => $this->mmb_get_error($working_dir)
90 );
91
92 if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
93 $wp_filesystem->delete($working_dir, true);
94 return array(
95 'error' => 'Unable to move update files.'
96 );
97 }
98
99 $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
100
101 require(ABSPATH . 'wp-admin/includes/update-core.php');
102 ob_end_clean();
103
104 $update_core = update_core($working_dir, $wp_dir);
105
106 if (is_wp_error($update_core))
107 return array(
108 'error' => $this->mmb_get_error($update_core)
109 );
110
111 $this->mmb_delete_transient('update_core');
112 return array(
113 'upgraded' => ' upgraded sucessfully.'
114 );
115 }
116
117 }
118 ?>