PluginProbe
ManageWP Worker / 3.8.5
ManageWP Worker v3.8.5
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 / installer.class.php

installer.class.php in ManageWP Worker 3.8.5, at installer.class.php

162 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*************************************************************
3 *
4 * installer.class.php
5 *
6 * Upgrade WordPress
7 *
8 *
9 * Copyright (c) 2011 Prelovac Media
10 * www.prelovac.com
11 **************************************************************/
12
13 include_once(ABSPATH . 'wp-admin/includes/file.php');
14 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
15 include_once(ABSPATH . 'wp-admin/includes/theme.php');
16 include_once(ABSPATH . 'wp-admin/includes/misc.php');
17 include_once(ABSPATH . 'wp-admin/includes/template.php');
18 include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
19 if(!$wp_filesystem){
20 WP_Filesystem();
21 }
22 class MMB_Installer extends MMB_Core
23 {
24 function __construct()
25 {
26 @set_time_limit( 300 );
27 parent::__construct();
28 }
29
30 function mmb_maintenance_mode($enable = false, $maintenance_message = '') {
31 global $wp_filesystem;
32
33 $maintenance_message .= '<?php $upgrading = ' . time() . '; ?>';
34
35 $file = $wp_filesystem->abspath() . '.maintenance';
36 if($enable){
37 $wp_filesystem->delete($file);
38 $wp_filesystem->put_contents($file, $maintenance_message, FS_CHMOD_FILE);
39 }else {
40 $wp_filesystem->delete($file);
41 }
42 }
43
44 function install_remote_file($params){
45
46 global $wp_filesystem;
47 extract($params);
48
49 if(!isset($package) || empty($package))
50 return array('error' => '<p>No files received. Internal error.</p>');
51
52 if(defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
53 return array('error' => '<p>Site under maintanace.</p>');;
54
55 $upgrader = new WP_Upgrader();
56 $destination = $type == 'themes' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR;
57
58
59 foreach($package as $package_url){
60 $key = basename($package_url);
61 $install_info[$key] = @$upgrader->run(array(
62 'package' => $package_url,
63 'destination' => $destination,
64 'clear_destination' => false, //Do not overwrite files.
65 'clear_working' => true,
66 'hook_extra' => array()
67 ));
68 }
69
70 if($activate){
71 $all_plugins = get_plugins();
72 foreach($all_plugins as $plugin_slug => $plugin){
73 $plugin_dir = preg_split('/\//', $plugin_slug);
74 foreach($install_info as $key => $install){
75 if(!$install || is_wp_error($install))
76 continue;
77
78 if($install['destination_name'] == $plugin_dir[0]){
79 $install_info[$key]['activated'] = activate_plugin($plugin_slug, '', false);
80 }
81 }
82 }
83 }
84 return $install_info;
85 }
86
87 /**
88 * Upgrades WordPress locally
89 *
90 */
91 function upgrade($params)
92 {
93 ob_start();
94 require_once(ABSPATH . 'wp-admin/includes/file.php');
95 require_once(ABSPATH . 'wp-admin/includes/misc.php');
96 require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
97
98 if(!$wp_filesystem)
99 WP_Filesystem();
100
101 global $wp_version, $wp_filesystem;
102 $upgrader = new WP_Upgrader();
103 $updates = $this->mmb_get_transient('update_core');
104 $current = $updates->updates[0];
105
106
107 // Is an update available?
108 if (!isset($current->response) || $current->response == 'latest')
109 return array(
110 'upgraded' => ' has latest ' . $wp_version . ' WordPress version.'
111 );
112
113 $res = $upgrader->fs_connect(array(
114 ABSPATH,
115 WP_CONTENT_DIR
116 ));
117 if (is_wp_error($res))
118 return array(
119 'error' => $this->mmb_get_error($res)
120 );
121
122 $wp_dir = trailingslashit($wp_filesystem->abspath());
123
124 $download = $upgrader->download_package($current->package);
125 if (is_wp_error($download))
126 return array(
127 'error' => $this->mmb_get_error($download)
128 );
129
130 $working_dir = $upgrader->unpack_package($download);
131 if (is_wp_error($working_dir))
132 return array(
133 'error' => $this->mmb_get_error($working_dir)
134 );
135
136 if (!$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true)) {
137 $wp_filesystem->delete($working_dir, true);
138 return array(
139 'error' => 'Unable to move update files.'
140 );
141 }
142
143 $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
144
145 require(ABSPATH . 'wp-admin/includes/update-core.php');
146 ob_end_clean();
147
148 $update_core = update_core($working_dir, $wp_dir);
149
150 if (is_wp_error($update_core))
151 return array(
152 'error' => $this->mmb_get_error($update_core)
153 );
154
155 $this->mmb_delete_transient('update_core');
156 return array(
157 'upgraded' => ' upgraded sucessfully.'
158 );
159 }
160
161 }
162 ?>