PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.0
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.0
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / admin / classes / class-merchant-silent-upgrader-skin.php

class-merchant-silent-upgrader-skin.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.0, at admin/classes/class-merchant-silent-upgrader-skin.php

78 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Silent Upgrader Skin.
5 * Suppresses the output of the upgrader while capturing errors for logging.
6 *
7 * @package Merchant
8 */
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
16
17 if ( ! class_exists( 'Merchant_Silent_Upgrader_Skin' ) ) {
18 class Merchant_Silent_Upgrader_Skin extends WP_Upgrader_Skin {
19
20 /**
21 * Captured errors during the upgrade process.
22 *
23 * @var string[]
24 */
25 private $captured_errors = array();
26
27 /**
28 * Suppress header output.
29 *
30 * @return void
31 */
32 public function header() {}
33
34 /**
35 * Suppress footer output.
36 *
37 * @return void
38 */
39 public function footer() {}
40
41 /**
42 * Capture errors instead of outputting them.
43 *
44 * @param string|WP_Error $errors The error(s) to capture.
45 *
46 * @return void
47 */
48 public function error( $errors ) {
49 if ( is_string( $errors ) ) {
50 $this->captured_errors[] = $errors;
51 } elseif ( is_wp_error( $errors ) ) {
52 foreach ( $errors->get_error_messages() as $message ) {
53 $this->captured_errors[] = $message;
54 }
55 }
56 }
57
58 /**
59 * Suppress feedback output.
60 *
61 * @param string $feedback The feedback string.
62 * @param mixed ...$args Optional text replacements.
63 *
64 * @return void
65 */
66 public function feedback( $feedback, ...$args ) {}
67
68 /**
69 * Get all captured errors.
70 *
71 * @return string[]
72 */
73 public function get_captured_errors() {
74 return $this->captured_errors;
75 }
76 }
77 }
78