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 / plugin.class.php

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

91 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*************************************************************
3 *
4 * plugin.class.php
5 *
6 * Upgrade Plugins
7 *
8 *
9 * Copyright (c) 2011 Prelovac Media
10 * www.prelovac.com
11 **************************************************************/
12 class MMB_Plugin extends MMB_Core
13 {
14 var $worker_maitanance_mode = false;
15 function __construct()
16 {
17 parent::__construct();
18 }
19
20 /**
21 * Upgrades all upgradable plugins on this blog
22 *
23 * @param mixed $args
24 */
25 function upgrade_all($params)
26 {
27 $upgradable_plugins = $this->get_upgradable_plugins();
28
29 $ready_for_upgrade = array();
30 if (!empty($upgradable_plugins)) {
31 foreach ($upgradable_plugins as $upgrade) {
32 $ready_for_upgrade[] = $upgrade->file;
33 }
34 }
35 $return = '';
36 if (!empty($ready_for_upgrade)) {
37 ob_start();
38 include_once(ABSPATH . 'wp-admin/includes/file.php');
39 include_once(ABSPATH . 'wp-admin/includes/plugin.php');
40 require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
41 if (class_exists('Plugin_Upgrader')) {
42 $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
43 $result = $upgrader->bulk_upgrade($ready_for_upgrade);
44 ob_end_clean();
45 foreach ($result as $plugin_slug => $plugin_info) {
46 $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_slug);
47 if (!$plugin_info || is_wp_error($plugin_info)) {
48 $return .= '<code title="Please upgrade manually">' . $data['Name'] . '</code> was not upgraded.<br />';
49 } else {
50 $return .= '<code>' . $data['Name'] . '</code> successfully upgraded.<br />';
51 }
52 }
53 ob_end_clean();
54 return array(
55 'upgraded' => $return
56 );
57 } else {
58 ob_end_clean();
59 return array(
60 'error' => 'Could not initialize upgrader.'
61 );
62 }
63 }
64 return array(
65 'error' => 'No plugins to upgrade at the moment'
66 );
67 }
68
69 function get_upgradable_plugins()
70 {
71 $current = $this->mmb_get_transient('update_plugins');
72 $upgradable_plugins = array();
73 if (!empty($current->response)) {
74 foreach ($current->response as $plugin_path => $plugin_data) {
75 if (!function_exists('get_plugin_data'))
76 include_once ABSPATH . 'wp-admin/includes/plugin.php';
77 $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
78
79 $current->response[$plugin_path]->name = $data['Name'];
80 $current->response[$plugin_path]->old_version = $data['Version'];
81 $current->response[$plugin_path]->file = $plugin_path;
82 $upgradable_plugins[] = $current->response[$plugin_path];
83 }
84 return $upgradable_plugins;
85 } else
86 return array();
87
88 }
89
90 }
91 ?>