PluginProbe
InfiniteWP Client / trunk
InfiniteWP Client vtrunk
1.13.10 1.13.7 trunk 0.1.4 0.1.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.11.0 1.11.1 1.12.1 1.12.3 All 92 releases
iwp-client / updaterSkin.php

updaterSkin.php in InfiniteWP Client trunk, at updaterSkin.php

203 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * This plugin was modified by Revmakx
4 * Copyright (c) 2012 Revmakx
5 * www.revmakx.com
6 *
7
8 /**
9 * Taken from WordPress's automatic updater skin, which was added in version 3.7.
10 *
11 * @see Automatic_Upgrader_Skin
12 */
13
14 if ( ! defined('ABSPATH') )
15 die();
16 class IWP_Updater_TraceableUpdaterSkin
17 {
18
19 public $options = array(
20 'url' => '',
21 'nonce' => '',
22 'title' => '',
23 'context' => false,
24 );
25
26 public $upgrader;
27
28 public $result;
29
30 public $done_header = false;
31
32 protected $messages = array();
33
34 private $startedImplicit = false;
35
36 public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false)
37 {
38 if ($error instanceof WP_Error) {
39 return array('error' => $error->get_error_message(), 'error_code' => 'upgrade_plugins_wp_error');
40 }
41
42 if ($context) {
43 $this->options['context'] = $context;
44 }
45
46 // file.php and template.php are documented to be required; the rest are there to match
47 // the list in the MMB_Installer class.
48 require_once ABSPATH.'wp-admin/includes/file.php';
49 require_once ABSPATH.'wp-admin/includes/plugin.php';
50 require_once ABSPATH.'wp-admin/includes/theme.php';
51 require_once ABSPATH.'wp-admin/includes/misc.php';
52 require_once ABSPATH.'wp-admin/includes/template.php';
53 require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
54 // This will output a credentials form in event of failure; we don't want that, so just hide with a buffer.
55 ob_start();
56 /** @handled function */
57 $result = request_filesystem_credentials('', '', $error, $context, null, $allow_relaxed_file_ownership);
58 ob_end_clean();
59
60 return $result;
61 }
62
63 public function get_upgrade_messages()
64 {
65 return $this->messages;
66 }
67
68 /**
69 * @param string|array|WP_Error $data
70 */
71 public function feedback($data)
72 {
73 if (!$this->startedImplicit) {
74 $this->startedImplicit = true;
75 @ob_implicit_flush(true);
76 }
77
78 echo ' ';
79 @ob_flush();
80
81 if (is_wp_error($data)) {
82 $string = $data->get_error_message();
83 } else {
84 if (is_array($data)) {
85 return;
86 } else {
87 $string = $data;
88 }
89 }
90
91 if (!empty($this->upgrader->strings[$string])) {
92 $string = $this->upgrader->strings[$string];
93 }
94
95 if (strpos($string, '%') !== false) {
96 $args = func_get_args();
97 $args = array_splice($args, 1);
98 if (!empty($args)) {
99 $string = vsprintf($string, $args);
100 }
101 }
102
103 $string = trim($string);
104
105 /** @handled function */
106 // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
107 $string = wp_kses($string, array(
108 'a' => array(
109 'href' => true
110 ),
111 'br' => true,
112 'em' => true,
113 'strong' => true,
114 ));
115
116 if (empty($string)) {
117 return;
118 }
119
120 $this->messages[] = array(
121 'message' => $string,
122 'key' => $data,
123 'args' => isset($args) ? $args : array(),
124 );
125 }
126
127 public function header()
128 {
129 ob_start();
130 }
131
132 public function footer()
133 {
134 $output = ob_get_contents();
135 if (!empty($output)) {
136 $this->feedback($output);
137 }
138 ob_end_clean();
139 }
140
141 public function bulk_header()
142 {
143 }
144
145 public function bulk_footer()
146 {
147 }
148
149 public function before()
150 {
151 }
152
153 public function after()
154 {
155 }
156
157 // Below was taken from WP_Upgrader_Skin, so we don't autoload it and cause trouble.
158 public function decrement_update_count()
159 {
160 }
161
162 public function error($errors)
163 {
164 if (is_string($errors)) {
165 $this->feedback($errors);
166
167 return;
168 }
169
170 if (!$errors instanceof WP_Error || !$errors->get_error_code()) {
171 return;
172 }
173
174 foreach ($errors->get_error_messages() as $message) {
175 if ($errors->get_error_data() && is_string($errors->get_error_data())) {
176 $this->feedback($message.' '.esc_html(strip_tags($errors->get_error_data())));
177 } else {
178 $this->feedback($message);
179 }
180 }
181 }
182
183 /**
184 * @param WP_Upgrader $upgrader
185 */
186 public function set_upgrader($upgrader)
187 {
188 if (is_object($upgrader)) {
189 $this->upgrader = $upgrader;
190 }
191 $this->add_strings();
192 }
193
194 public function add_strings()
195 {
196 }
197
198 public function set_result($result)
199 {
200 $this->result = $result;
201 }
202 }
203