PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | modules/logs/connectors/class-connector-installer.php +37 -44 5.2 → 6.2.1 View file →
@@ -78,9 +78,9 @@
78 78 * Log plugin|theme installations.
79 79 *
80 80 * @action mainwp_install_update_actions.
81 81 *
82 - * @param array $website website.
82 + * @param object $website website.
83 83 * @param string $pAction install action.
84 84 * @param array $data data result.
85 85 * @param string $type action type.
86 86 * @param mixed $post_data post data (option).
@@ -111,9 +111,11 @@
111 111 }
112 112
113 113 $logs_args = array();
114 114
115 - $action = $pAction;
115 + $action = $pAction;
116 + $duration = 0;
117 + $created = 0;
116 118
117 119 $args = array();
118 120
119 121 if ( 'install' === $action ) {
@@ -134,10 +136,8 @@
134 136 $args = array(
135 137 'name' => $item['name'],
136 138 'version' => $item['version'],
137 139 'upload' => $upload ? 1 : 0,
138 - 'siteurl' => $website->url,
139 - 'site_name' => $website->name,
140 140 'extra_info' => $item,
141 141 );
142 142 $logs_args[] = $args;
143 143 }
@@ -146,16 +146,19 @@
146 146 if ( empty( $logs_args ) ) {
147 147 return false;
148 148 }
149 149
150 - $message = esc_html_x(
151 - '%1$s',
152 - 'Plugin/theme installation. 1: Plugins/themes namess, 2: vesion',
153 - 'mainwp'
154 - );
150 + $message = '%1$s';
155 151
156 152 } elseif ( 'updated' === $action && ( in_array( $type, array( 'plugin', 'theme', 'trans' ) ) ) ) {
153 + if ( isset( $data['duration'] ) ) {
154 + $duration = $data['duration'];
155 + }
157 156
157 + if ( isset( $data['created'] ) ) {
158 + $created = $data['created'];
159 + }
160 +
158 161 $updated_data = isset( $data['updated_data'] ) ? $data['updated_data'] : array();
159 162
160 163 if ( ! is_array( $updated_data ) ) {
161 164 $updated_data = array();
@@ -171,11 +174,8 @@
171 174 );
172 175 if ( isset( $item['version'] ) ) {
173 176 $args['version'] = $item['version'];
174 177 }
175 - $args['siteurl'] = $website->url;
176 - $args['site_name'] = $website->name;
177 -
178 178 $save_info = $item;
179 179 if ( ! empty( $item['rollback'] ) ) {
180 180 $save_info['rollback_info'] = $item;
181 181 }
@@ -188,25 +188,19 @@
188 188 return false;
189 189 }
190 190
191 191 if ( 'plugin' === $type || 'theme' === $type || 'trans' === $type ) {
192 - $message = esc_html_x(
193 - '%1$s',
194 - 'Update. 1: name',
195 - 'mainwp'
196 - );
192 + $message = '%1$s';
197 193 } else {
198 194 return;
199 195 }
200 196 } elseif ( 'updated' === $action && 'core' === $type ) {
201 - $message = esc_html__( '%1$s', 'mainwp' );
197 + $message = '%1$s';
202 198 $args = array(
203 199 'name' => 'WordPress', // label.
204 200 'version' => isset( $data['version'] ) ? $data['version'] : '',
205 201 'old_version' => isset( $data['old_version'] ) ? $data['old_version'] : '',
206 202 'error' => isset( $data['error'] ) ? $data['error'] : '',
207 - 'siteurl' => $website->url,
208 - 'site_name' => $website->name,
209 203 );
210 204 $logs_args[] = $args;
211 205
212 206 } else {
@@ -216,8 +210,16 @@
216 210 $count_bulk = count( $logs_args );
217 211 foreach ( $logs_args as $args ) {
218 212 $args['duration_bulk'] = $count_bulk;
219 213
214 + if ( ! empty( $duration ) ) {
215 + $args['duration'] = $duration;
216 + }
217 +
218 + if ( ! empty( $created ) ) {
219 + $args['created'] = $created;
220 + }
221 +
220 222 $state = 1;
221 223 if ( isset( $args['extra_info'] ) && is_array( $args['extra_info'] ) ) {
222 224 if ( isset( $args['extra_info']['success'] ) ) {
223 225 $state = ! empty( $args['extra_info']['success'] ) ? 1 : 0;
@@ -246,9 +248,9 @@
246 248 * @param string $plugin_act plugin action: activate, deactivate, delete.
247 249 * @param array $params params array.
248 250 * @param array $action_data response data.
249 251 */
250 - public function callback_mainwp_install_plugin_action( $website, $plugin_act, $params, $action_data ) {
252 + public function callback_mainwp_install_plugin_action( $website, $plugin_act, $params, $action_data ) { // phpcs:ignore -- NOSONAR - complex method.
251 253
252 254 if ( empty( $website ) || ! is_object( $website ) || empty( $website->id ) || empty( $plugin_act ) || ! is_string( $plugin_act ) || ! is_array( $params ) ) {
253 255 return;
254 256 }
@@ -265,15 +267,17 @@
265 267
266 268 foreach ( $action_data as $item ) {
267 269 $item = $this->sanitize_data( $item );
268 270 if ( ! empty( $item ) && isset( $item['name'] ) ) {
269 - $logs_args[] = array(
270 - 'name' => $item['name'],
271 - 'version' => $item['version'],
272 - 'slug' => $item['slug'],
273 - 'siteurl' => $website->url,
274 - 'site_name' => $website->name,
271 + $log_arg = array(
272 + 'name' => $item['name'],
273 + 'version' => $item['version'],
274 + 'slug' => $item['slug'],
275 275 );
276 + if ( ! empty( $item['created'] ) ) {
277 + $log_arg['created'] = $item['created'];
278 + }
279 + $logs_args[] = $log_arg;
276 280 }
277 281 }
278 282
279 283 if ( empty( $logs_args ) ) {
@@ -282,19 +286,14 @@
282 286
283 287 $action = $plugin_act;
284 288 $context = 'plugin';
285 289
286 - $message = esc_html_x(
287 - '%1$s',
288 - '1: Plugin name, 2: plugin version',
289 - 'mainwp'
290 - );
290 + $message = '%1$s';
291 291
292 292 $state = 1;
293 293
294 - $count_bulk = count( $logs_args );
295 294 foreach ( $logs_args as $args ) {
296 - $args['duration_bulk'] = $count_bulk;
295 + $args['duration_bulk'] = is_array( $params ) && ! empty( $params['duration_bulk'] ) ? $params['duration_bulk'] : count( $logs_args );
297 296 $this->log(
298 297 $message,
299 298 $args,
300 299 $website->id,
@@ -334,13 +333,11 @@
334 333 foreach ( $action_data as $item ) {
335 334 $item = $this->sanitize_data( $item );
336 335 if ( ! empty( $item ) && isset( $item['name'] ) ) {
337 336 $logs_args[] = array(
338 - 'name' => $item['name'],
339 - 'version' => $item['version'],
340 - 'slug' => $item['slug'],
341 - 'siteurl' => $website->url,
342 - 'site_name' => $website->name,
337 + 'name' => $item['name'],
338 + 'version' => $item['version'],
339 + 'slug' => $item['slug'],
343 340 );
344 341 }
345 342 }
346 343
@@ -350,13 +347,9 @@
350 347
351 348 $action = $theme_act;
352 349 $context = 'theme';
353 350
354 - $message = esc_html_x(
355 - '%1$s',
356 - '1: Theme name, 2: Theme version',
357 - 'mainwp'
358 - );
351 + $message = '%1$s';
359 352
360 353 $state = 1;
361 354
362 355 $count_bulk = count( $logs_args );