PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
← All changes | core/class/wpbc-class-upgrader-translation-skin.php +69 -22 11.7 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -17,27 +17,54 @@
17 17 } // Exit if accessed directly.
18 18
19 19 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
20 20
21 -class WPBC_Upgrader_Translation_Skin extends WP_Upgrader_Skin {
21 +class WPBC_Upgrader_Translation_Skin extends WP_Upgrader_Skin {
22 +
23 + /**
24 + * Installer error captured without exposing it to an AJAX response.
25 + *
26 + * @var WP_Error|null
27 + */
28 + protected $installer_error = null;
22 29
23 30 function __construct( $args = array() ) {
24 - $defaults = array(
25 - 'url' => '',
26 - 'nonce' => '',
27 - 'title' => '',
28 - 'context' => false,
29 - );
30 - $this->options = wp_parse_args( $args, $defaults );
31 - }
31 + $defaults = array(
32 + 'url' => '',
33 + 'nonce' => '',
34 + 'title' => '',
35 + 'context' => false,
36 + 'suppress_output' => false,
37 + );
38 + $this->options = wp_parse_args( $args, $defaults );
39 + }
32 40
33 41 function header() {}
34 42
35 43 function footer() {}
36 44
37 - function error( $error ) {
38 - $this->installer_error = $error;
39 - }
45 + function error( $error ) {
46 + $this->installer_error = $error;
47 + }
48 +
49 + /**
50 + * Render or suppress one upgrader progress message.
51 + *
52 + * AJAX consumers use the silent mode because upgrader markup before a JSON
53 + * response makes a successful installation look like a failed request.
54 + * Existing Settings-page consumers retain the original visible feedback.
55 + *
56 + * @param string|array $feedback Message key, text, or structured feedback.
57 + * @param mixed ...$args Optional formatting arguments.
58 + * @return void
59 + */
60 + public function feedback( $feedback, ...$args ) {
61 + if ( ! empty( $this->options['suppress_output'] ) ) {
62 + return;
63 + }
64 +
65 + parent::feedback( $feedback, ...$args );
66 + }
40 67
41 68 function add_strings() {
42 69 $this->upgrader->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.', 'booking' );
43 70 $this->upgrader->strings['up_to_date'] = __( 'Your translations are all up to date.', 'booking' );
@@ -60,14 +87,34 @@
60 87 }
61 88
62 89 function before() {}
63 90
64 - function after() {
65 - if ( ! empty( $this->installer_error ) ) {
66 - if ( is_wp_error( $this->installer_error ) ) {
67 - $message = $this->installer_error->get_error_message() . ' (' . $this->installer_error->get_error_data() . ')';
68 -
69 - echo wp_kses_post( $message );
70 - }
71 - }
72 - }
73 -}
91 + function after() {
92 + if ( ! empty( $this->options['suppress_output'] ) ) {
93 + return;
94 + }
95 +
96 + if ( ! empty( $this->installer_error ) ) {
97 + if ( is_wp_error( $this->installer_error ) ) {
98 + $message = $this->installer_error->get_error_message();
99 + $error_data = $this->installer_error->get_error_data();
100 +
101 + if ( is_scalar( $error_data ) && '' !== (string) $error_data ) {
102 + $message .= ' (' . (string) $error_data . ')';
103 + }
104 +
105 + echo wp_kses_post( $message );
106 + }
107 + }
108 + }
109 +
110 + /**
111 + * Return the error captured from WordPress's upgrader, when present.
112 + *
113 + * @return WP_Error|null Installer error or null.
114 + */
115 + public function get_installer_error() {
116 + return is_wp_error( $this->installer_error ) && ! empty( $this->installer_error->get_error_codes() )
117 + ? $this->installer_error
118 + : null;
119 + }
120 +}