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
booking / core / class / wpbc-class-upgrader-translation-skin.php

wpbc-class-upgrader-translation-skin.php in Booking Calendar 11.9, at core/class/wpbc-class-upgrader-translation-skin.php

121 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Translations Functions
6 * @category Functions
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email [email protected]
11 *
12 * @modified 29.09.2015
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 } // Exit if accessed directly.
18
19 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
20
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;
29
30 function __construct( $args = array() ) {
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 }
40
41 function header() {}
42
43 function footer() {}
44
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 }
67
68 function add_strings() {
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' );
70 $this->upgrader->strings['up_to_date'] = __( 'Your translations are all up to date.', 'booking' );
71 $this->upgrader->strings['no_package'] = __( 'Update package not available.', 'booking' );
72 /* translators: %s: Package URL. */
73 $this->upgrader->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s&#8230;', 'booking' ), '<span class="code">%s</span>' );
74 $this->upgrader->strings['unpack_package'] = __( 'Unpacking the update&#8230;', 'booking' );
75 $this->upgrader->strings['process_failed'] = __( 'Translation update failed.', 'booking' );
76 $this->upgrader->strings['process_success'] = __( 'Translation updated successfully.', 'booking' );
77 $this->upgrader->strings['remove_old'] = __( 'Removing the old version of the translation&#8230;', 'booking' );
78 $this->upgrader->strings['remove_old_failed'] = __( 'Could not remove the old translation.', 'booking' );
79
80 }
81
82 public function set_upgrader( &$upgrader ) {
83 if ( is_object( $upgrader ) ) {
84 $this->upgrader =& $upgrader;
85 }
86 $this->add_strings();
87 }
88
89 function before() {}
90
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 }
121