PluginProbe
ManageWP Worker / 3.8.0
ManageWP Worker v3.8.0
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.0, at wp.class.php

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