Passed
Push — master ( a15c21...706a80 )
by Stiofan
04:34
created
widgets/invoice-receipt.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,15 +44,15 @@
 block discarded – undo
44 44
         parent::__construct( $options );
45 45
     }
46 46
 
47
-	/**
48
-	 * The Super block output function.
49
-	 *
50
-	 * @param array $args
51
-	 * @param array $widget_args
52
-	 * @param string $content
53
-	 *
54
-	 * @return mixed|string|bool
55
-	 */
47
+    /**
48
+     * The Super block output function.
49
+     *
50
+     * @param array $args
51
+     * @param array $widget_args
52
+     * @param string $content
53
+     *
54
+     * @return mixed|string|bool
55
+     */
56 56
     public function output( $args = array(), $widget_args = array(), $content = '' ) {
57 57
         return wpinv_payment_receipt();
58 58
     }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
             'block-keywords'=> "['invoicing','receipt']",
23 23
             'class_name'     => __CLASS__,
24 24
             'base_id'       => 'wpinv_receipt',
25
-            'name'          => __('GetPaid > Invoice Receipt','invoicing'),
25
+            'name'          => __('GetPaid > Invoice Receipt', 'invoicing'),
26 26
             'widget_ops'    => array(
27 27
                 'classname'   => 'wpinv-receipt-class bsui',
28
-                'description' => esc_html__('Displays invoice receipt after checkout.','invoicing'),
28
+                'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'),
29 29
             ),
30 30
             'arguments'     => array(
31 31
                 'title'  => array(
32
-                    'title'       => __( 'Widget title', 'invoicing' ),
33
-                    'desc'        => __( 'Enter widget title.', 'invoicing' ),
32
+                    'title'       => __('Widget title', 'invoicing'),
33
+                    'desc'        => __('Enter widget title.', 'invoicing'),
34 34
                     'type'        => 'text',
35 35
                     'desc_tip'    => true,
36 36
                     'default'     => '',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         );
42 42
 
43 43
 
44
-        parent::__construct( $options );
44
+        parent::__construct($options);
45 45
     }
46 46
 
47 47
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return mixed|string|bool
55 55
 	 */
56
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
56
+    public function output($args = array(), $widget_args = array(), $content = '') {
57 57
         return wpinv_payment_receipt();
58 58
     }
59 59
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-worldpay-gateway.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -13,65 +13,65 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Worldpay_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'worldpay';
21 21
 
22 22
     /**
23
-	 * Payment method order.
24
-	 *
25
-	 * @var int
26
-	 */
23
+     * Payment method order.
24
+     *
25
+     * @var int
26
+     */
27 27
     public $order = 5;
28 28
 
29 29
     /**
30
-	 * Endpoint for requests from Worldpay.
31
-	 *
32
-	 * @var string
33
-	 */
34
-	protected $notify_url;
35
-
36
-	/**
37
-	 * Endpoint for requests to Worldpay.
38
-	 *
39
-	 * @var string
40
-	 */
30
+     * Endpoint for requests from Worldpay.
31
+     *
32
+     * @var string
33
+     */
34
+    protected $notify_url;
35
+
36
+    /**
37
+     * Endpoint for requests to Worldpay.
38
+     *
39
+     * @var string
40
+     */
41 41
     protected $endpoint;
42 42
 
43 43
     /**
44
-	 * An array of features that this gateway supports.
45
-	 *
46
-	 * @var array
47
-	 */
44
+     * An array of features that this gateway supports.
45
+     *
46
+     * @var array
47
+     */
48 48
     protected $supports = array( 'sandbox' );
49 49
     
50 50
     /**
51
-	 * Currencies this gateway is allowed for.
52
-	 *
53
-	 * @var array
54
-	 */
55
-	public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
51
+     * Currencies this gateway is allowed for.
52
+     *
53
+     * @var array
54
+     */
55
+    public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
56 56
 
57 57
     /**
58
-	 * URL to view a transaction.
59
-	 *
60
-	 * @var string
61
-	 */
58
+     * URL to view a transaction.
59
+     *
60
+     * @var string
61
+     */
62 62
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
63 63
 
64 64
     /**
65
-	 * URL to view a subscription.
66
-	 *
67
-	 * @var string
68
-	 */
69
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
65
+     * URL to view a subscription.
66
+     *
67
+     * @var string
68
+     */
69
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
70 70
 
71 71
     /**
72
-	 * Class constructor.
73
-	 */
74
-	public function __construct() {
72
+     * Class constructor.
73
+     */
74
+    public function __construct() {
75 75
 
76 76
         $this->method_title         = __( 'Worldpay', 'invoicing' );
77 77
         $this->title                = __( 'Worldpay - Credit Card / Debit Card', 'invoicing' );
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     /**
88
-	 * Process Payment.
89
-	 *
90
-	 *
91
-	 * @param WPInv_Invoice $invoice Invoice.
92
-	 * @param array $submission_data Posted checkout fields.
93
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94
-	 * @return array
95
-	 */
96
-	public function process_payment( $invoice, $submission_data, $submission ) {
88
+     * Process Payment.
89
+     *
90
+     *
91
+     * @param WPInv_Invoice $invoice Invoice.
92
+     * @param array $submission_data Posted checkout fields.
93
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94
+     * @return array
95
+     */
96
+    public function process_payment( $invoice, $submission_data, $submission ) {
97 97
 
98 98
         // Get redirect url.
99 99
         $worldpay_redirect = esc_url( $this->get_request_url( $invoice ) );
@@ -128,31 +128,31 @@  discard block
 block discarded – undo
128 128
     }
129 129
 
130 130
     /**
131
-	 * Get the Worldpay request URL for an invoice.
132
-	 *
133
-	 * @param  WPInv_Invoice $invoice Invoice object.
134
-	 * @return string
135
-	 */
136
-	public function get_request_url( $invoice ) {
131
+     * Get the Worldpay request URL for an invoice.
132
+     *
133
+     * @param  WPInv_Invoice $invoice Invoice object.
134
+     * @return string
135
+     */
136
+    public function get_request_url( $invoice ) {
137 137
 
138 138
         // Endpoint for this request
139
-		$this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
139
+        $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
140 140
 
141 141
         return $this->endpoint;
142 142
 
143
-	}
143
+    }
144 144
 
145 145
     /**
146
-	 * Get Worldpay Args for passing to Worldpay.
147
-	 *
148
-	 * @param  WPInv_Invoice $invoice Invoice object.
149
-	 * @return array
150
-	 */
151
-	protected function get_worldpay_args( $invoice ) {
152
-
153
-		return apply_filters(
154
-			'getpaid_worldpay_args',
155
-			array(
146
+     * Get Worldpay Args for passing to Worldpay.
147
+     *
148
+     * @param  WPInv_Invoice $invoice Invoice object.
149
+     * @return array
150
+     */
151
+    protected function get_worldpay_args( $invoice ) {
152
+
153
+        return apply_filters(
154
+            'getpaid_worldpay_args',
155
+            array(
156 156
                 'amount'         => wpinv_sanitize_amount( $invoice->get_total() ), // mandatory
157 157
                 'cartId'         => wpinv_clean( $invoice->get_number() ), // mandatory reference for the item purchased
158 158
                 'currency'       => wpinv_clean( $invoice->get_currency() ), // mandatory
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
                 'countryString'  => wpinv_clean( wpinv_country_name( $invoice->get_country() ) ),
178 178
                 'compName'       => wpinv_clean( $invoice->get_company() ),
179 179
             ),
180
-			$invoice
181
-		);
180
+            $invoice
181
+        );
182 182
 
183 183
     }
184 184
 
185 185
     /**
186
-	 * Secures worldpay args with an md5 hash.
187
-	 *
188
-	 * @param  array $args Gateway args.
189
-	 * @return array
190
-	 */
191
-	public function hash_args( $args ) {
186
+     * Secures worldpay args with an md5 hash.
187
+     *
188
+     * @param  array $args Gateway args.
189
+     * @return array
190
+     */
191
+    public function hash_args( $args ) {
192 192
 
193 193
         $md5_secret = $this->get_option( 'md5_secret' );
194 194
 
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
     }
205 205
 
206 206
     /**
207
-	 * Processes ipns and marks payments as complete.
208
-	 *
209
-	 * @return void
210
-	 */
211
-	public function verify_ipn() {
207
+     * Processes ipns and marks payments as complete.
208
+     *
209
+     * @return void
210
+     */
211
+    public function verify_ipn() {
212 212
 
213 213
         // Validate the IPN.
214 214
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
215
-		    wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
216
-		}
215
+            wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
216
+        }
217 217
 
218 218
         // Process the IPN.
219 219
         $posted  = wp_unslash( $_POST );
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
                 $invoice->set_transaction_id( wpinv_clean( $posted['transId'] ) );
230 230
             }
231 231
 
232
-             // Update the ip address.
233
-             if ( ! empty( $posted['ipAddress'] ) ) {
232
+                // Update the ip address.
233
+                if ( ! empty( $posted['ipAddress'] ) ) {
234 234
                 $invoice->set_ip( wpinv_clean( $posted['ipAddress'] ) );
235 235
             }
236 236
 
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
     }
258 258
 
259 259
     /**
260
-	 * Check Worldpay IPN validity.
261
-	 */
262
-	public function validate_ipn() {
260
+     * Check Worldpay IPN validity.
261
+     */
262
+    public function validate_ipn() {
263 263
 
264 264
         wpinv_error_log( 'Validating Worldpay IPN response' );
265 265
 
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
     /**
308
-	 * Filters the gateway settings.
309
-	 * 
310
-	 * @param array $admin_settings
311
-	 */
312
-	public function admin_settings( $admin_settings ) {
308
+     * Filters the gateway settings.
309
+     * 
310
+     * @param array $admin_settings
311
+     */
312
+    public function admin_settings( $admin_settings ) {
313 313
 
314 314
         $currencies = sprintf(
315 315
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             'readonly' => true
351 351
         );
352 352
 
353
-		return $admin_settings;
354
-	}
353
+        return $admin_settings;
354
+    }
355 355
 
356 356
 }
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Worldpay Payment Gateway class.
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @var array
47 47
 	 */
48
-    protected $supports = array( 'sandbox' );
48
+    protected $supports = array('sandbox');
49 49
     
50 50
     /**
51 51
 	 * Currencies this gateway is allowed for.
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
55
+	public $currencies = array('AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function __construct() {
75 75
 
76
-        $this->method_title         = __( 'Worldpay', 'invoicing' );
77
-        $this->title                = __( 'Worldpay - Credit Card / Debit Card', 'invoicing' );
78
-        $this->checkout_button_text = __( 'Proceed to Worldpay', 'invoicing' );
79
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
76
+        $this->method_title         = __('Worldpay', 'invoicing');
77
+        $this->title                = __('Worldpay - Credit Card / Debit Card', 'invoicing');
78
+        $this->checkout_button_text = __('Proceed to Worldpay', 'invoicing');
79
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
80 80
 
81
-        add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 );
82
-        add_filter( 'getpaid_worldpay_args', array( $this, 'hash_args' ) );
81
+        add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2);
82
+        add_filter('getpaid_worldpay_args', array($this, 'hash_args'));
83 83
 
84 84
         parent::__construct();
85 85
     }
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94 94
 	 * @return array
95 95
 	 */
96
-	public function process_payment( $invoice, $submission_data, $submission ) {
96
+	public function process_payment($invoice, $submission_data, $submission) {
97 97
 
98 98
         // Get redirect url.
99
-        $worldpay_redirect = esc_url( $this->get_request_url( $invoice ) );
99
+        $worldpay_redirect = esc_url($this->get_request_url($invoice));
100 100
 
101 101
         // Get submission args.
102
-        $worldpay_args     = $this->get_worldpay_args( $invoice );
102
+        $worldpay_args     = $this->get_worldpay_args($invoice);
103 103
 
104 104
         $form = "<form action='$worldpay_redirect' name='wpi_worldpay_form' method='POST'>";
105 105
 
106
-        foreach ( $worldpay_args as $key => $value ) {
106
+        foreach ($worldpay_args as $key => $value) {
107 107
 
108
-            if ( false === $value || '' === trim( $value ) ) {
108
+            if (false === $value || '' === trim($value)) {
109 109
                 continue;
110 110
             }
111 111
 
112
-            $value = esc_attr( $value );
113
-            $key   = wpinv_clean( $key );
112
+            $value = esc_attr($value);
113
+            $key   = wpinv_clean($key);
114 114
             $form .= "<input type='hidden' name='$key' value='$value'>";
115 115
         }
116 116
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	 * @param  WPInv_Invoice $invoice Invoice object.
134 134
 	 * @return string
135 135
 	 */
136
-	public function get_request_url( $invoice ) {
136
+	public function get_request_url($invoice) {
137 137
 
138 138
         // Endpoint for this request
139
-		$this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
139
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
140 140
 
141 141
         return $this->endpoint;
142 142
 
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
 	 * @param  WPInv_Invoice $invoice Invoice object.
149 149
 	 * @return array
150 150
 	 */
151
-	protected function get_worldpay_args( $invoice ) {
151
+	protected function get_worldpay_args($invoice) {
152 152
 
153 153
 		return apply_filters(
154 154
 			'getpaid_worldpay_args',
155 155
 			array(
156
-                'amount'         => wpinv_sanitize_amount( $invoice->get_total() ), // mandatory
157
-                'cartId'         => wpinv_clean( $invoice->get_number() ), // mandatory reference for the item purchased
158
-                'currency'       => wpinv_clean( $invoice->get_currency() ), // mandatory
159
-                'instId'         => wpinv_clean( $this->get_option( 'instId', '' ) ), // mandatory
160
-                'testMode'       => $this->is_sandbox( $invoice ) ? 100 : 0, // mandatory
161
-                'name'           => wpinv_clean( $invoice->get_full_name() ),
162
-                'address'        => wpinv_clean( $invoice->get_address() ),
163
-                'postcode'       => wpinv_clean( $invoice->get_zip() ),
164
-                'tel'            => wpinv_clean( $invoice->get_phone() ),
165
-                'email'          => sanitize_email( $invoice->get_email() ),
166
-                'country'        => wpinv_clean( $invoice->get_country() ),
167
-                'desc'           => sprintf( __( 'Payment for invoice %s.', 'invoicing' ), wpinv_clean( $invoice->get_number() ) ),
168
-                'MC_description' => sprintf( __( 'Payment for invoice %s.', 'invoicing' ), wpinv_clean( $invoice->get_number() ) ),
169
-                'MC_callback'    => esc_url_raw( $this->notify_url ),
170
-                'resultfile'     => esc_url_raw( $this->get_return_url( $invoice ) ),
171
-                'MC_key'         => wpinv_clean( $invoice->get_key() ),
156
+                'amount'         => wpinv_sanitize_amount($invoice->get_total()), // mandatory
157
+                'cartId'         => wpinv_clean($invoice->get_number()), // mandatory reference for the item purchased
158
+                'currency'       => wpinv_clean($invoice->get_currency()), // mandatory
159
+                'instId'         => wpinv_clean($this->get_option('instId', '')), // mandatory
160
+                'testMode'       => $this->is_sandbox($invoice) ? 100 : 0, // mandatory
161
+                'name'           => wpinv_clean($invoice->get_full_name()),
162
+                'address'        => wpinv_clean($invoice->get_address()),
163
+                'postcode'       => wpinv_clean($invoice->get_zip()),
164
+                'tel'            => wpinv_clean($invoice->get_phone()),
165
+                'email'          => sanitize_email($invoice->get_email()),
166
+                'country'        => wpinv_clean($invoice->get_country()),
167
+                'desc'           => sprintf(__('Payment for invoice %s.', 'invoicing'), wpinv_clean($invoice->get_number())),
168
+                'MC_description' => sprintf(__('Payment for invoice %s.', 'invoicing'), wpinv_clean($invoice->get_number())),
169
+                'MC_callback'    => esc_url_raw($this->notify_url),
170
+                'resultfile'     => esc_url_raw($this->get_return_url($invoice)),
171
+                'MC_key'         => wpinv_clean($invoice->get_key()),
172 172
                 'MC_invoice_id'  => $invoice->get_id(),
173
-                'address1'       => wpinv_clean( $invoice->get_address() ),
174
-                'town'           => wpinv_clean( $invoice->get_city() ),
175
-                'region'         => wpinv_clean( $invoice->get_state() ),
176
-                'amountString'   => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
177
-                'countryString'  => wpinv_clean( wpinv_country_name( $invoice->get_country() ) ),
178
-                'compName'       => wpinv_clean( $invoice->get_company() ),
173
+                'address1'       => wpinv_clean($invoice->get_address()),
174
+                'town'           => wpinv_clean($invoice->get_city()),
175
+                'region'         => wpinv_clean($invoice->get_state()),
176
+                'amountString'   => wpinv_price($invoice->get_total(), $invoice->get_currency()),
177
+                'countryString'  => wpinv_clean(wpinv_country_name($invoice->get_country())),
178
+                'compName'       => wpinv_clean($invoice->get_company()),
179 179
             ),
180 180
 			$invoice
181 181
 		);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 	 * @param  array $args Gateway args.
189 189
 	 * @return array
190 190
 	 */
191
-	public function hash_args( $args ) {
191
+	public function hash_args($args) {
192 192
 
193
-        $md5_secret = $this->get_option( 'md5_secret' );
193
+        $md5_secret = $this->get_option('md5_secret');
194 194
 
195 195
         // Abort if there is no secret.
196
-        if ( empty( $md5_secret ) ) {
196
+        if (empty($md5_secret)) {
197 197
             return $args;
198 198
         }
199 199
 
200 200
         // Hash the args.
201
-        $args['signature'] = md5( "$md5_secret:{$args['instId']}:{$args['amount']}:{$args['currency']}:{$args['cartId']}" );
201
+        $args['signature'] = md5("$md5_secret:{$args['instId']}:{$args['amount']}:{$args['currency']}:{$args['cartId']}");
202 202
 
203 203
         return $args;
204 204
     }
@@ -211,43 +211,43 @@  discard block
 block discarded – undo
211 211
 	public function verify_ipn() {
212 212
 
213 213
         // Validate the IPN.
214
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
215
-		    wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
214
+        if (empty($_POST) || !$this->validate_ipn()) {
215
+		    wp_die('Worldpay IPN Request Failure', 'Worldpay IPN', array('response' => 500));
216 216
 		}
217 217
 
218 218
         // Process the IPN.
219
-        $posted  = wp_unslash( $_POST );
220
-        $invoice = wpinv_get_invoice( $posted['MC_invoice_id'] );
219
+        $posted  = wp_unslash($_POST);
220
+        $invoice = wpinv_get_invoice($posted['MC_invoice_id']);
221 221
 
222
-        if ( $invoice && $this->id == $invoice->get_gateway() ) {
222
+        if ($invoice && $this->id == $invoice->get_gateway()) {
223 223
 
224
-            wpinv_error_log( 'Found invoice #' . $invoice->get_number() );
225
-            wpinv_error_log( 'Payment status:' . $posted['transStatus'] );
224
+            wpinv_error_log('Found invoice #' . $invoice->get_number());
225
+            wpinv_error_log('Payment status:' . $posted['transStatus']);
226 226
 
227 227
             // Update the transaction id.
228
-            if ( ! empty( $posted['transId'] ) ) {
229
-                $invoice->set_transaction_id( wpinv_clean( $posted['transId'] ) );
228
+            if (!empty($posted['transId'])) {
229
+                $invoice->set_transaction_id(wpinv_clean($posted['transId']));
230 230
             }
231 231
 
232 232
              // Update the ip address.
233
-             if ( ! empty( $posted['ipAddress'] ) ) {
234
-                $invoice->set_ip( wpinv_clean( $posted['ipAddress'] ) );
233
+             if (!empty($posted['ipAddress'])) {
234
+                $invoice->set_ip(wpinv_clean($posted['ipAddress']));
235 235
             }
236 236
 
237
-            if ( $posted['transStatus'] == 'Y' ) {
238
-                $invoice->set_completed_date( date( 'Y-m-d H:i:s', $posted['transTime'] ) );
237
+            if ($posted['transStatus'] == 'Y') {
238
+                $invoice->set_completed_date(date('Y-m-d H:i:s', $posted['transTime']));
239 239
                 $invoice->mark_paid();
240 240
                 return;
241 241
             }
242 242
 
243
-            if ( $posted['transStatus'] == 'C' ) {
244
-                $invoice->set_status( 'wpi-failed' );
245
-                $invoice->add_note( __( 'Payment transaction failed while processing Worldpay payment.', 'invoicing' ), false, false, true );
243
+            if ($posted['transStatus'] == 'C') {
244
+                $invoice->set_status('wpi-failed');
245
+                $invoice->add_note(__('Payment transaction failed while processing Worldpay payment.', 'invoicing'), false, false, true);
246 246
                 $invoice->save();
247 247
                 return;
248 248
             }
249 249
 
250
-            wpinv_error_log( 'Aborting, Invalid transaction status:' . $posted['transStatus'] );
250
+            wpinv_error_log('Aborting, Invalid transaction status:' . $posted['transStatus']);
251 251
             $invoice->save();
252 252
 
253 253
         }
@@ -261,27 +261,27 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function validate_ipn() {
263 263
 
264
-        wpinv_error_log( 'Validating Worldpay IPN response' );
264
+        wpinv_error_log('Validating Worldpay IPN response');
265 265
 
266
-        $data = wp_unslash( $_POST );
266
+        $data = wp_unslash($_POST);
267 267
 
268 268
         // Verify installation.
269
-        if ( empty( $data['instId'] ) || $data['instId'] != wpinv_clean( $this->get_option( 'instId', '' ) ) ) {
270
-            wpinv_error_log( 'Received invalid installation ID from Worldpay IPN' );
269
+        if (empty($data['instId']) || $data['instId'] != wpinv_clean($this->get_option('instId', ''))) {
270
+            wpinv_error_log('Received invalid installation ID from Worldpay IPN');
271 271
             return false;
272 272
         }
273 273
 
274 274
         // Verify invoice.
275
-        if ( empty( $data['cartId'] ) || !  wpinv_get_id_by_invoice_number( $data['cartId'] ) ) {
276
-            wpinv_error_log( 'Received invalid invoice number from Worldpay IPN' );
275
+        if (empty($data['cartId']) || !wpinv_get_id_by_invoice_number($data['cartId'])) {
276
+            wpinv_error_log('Received invalid invoice number from Worldpay IPN');
277 277
             return false;
278 278
         }
279 279
         
280 280
         // (maybe) verify password.
281
-        $password = $this->get_option( 'callback_password' );
281
+        $password = $this->get_option('callback_password');
282 282
 
283
-        if ( ! empty( $password ) && ( empty( $data['callbackPW'] ) || $password != $data['callbackPW'] ) ) {
284
-            wpinv_error_log( 'Received invalid invoice number from Worldpay IPN' );
283
+        if (!empty($password) && (empty($data['callbackPW']) || $password != $data['callbackPW'])) {
284
+            wpinv_error_log('Received invalid invoice number from Worldpay IPN');
285 285
             return false;
286 286
         }
287 287
 
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
     /**
293 293
      * Displays a notice on the checkout page if sandbox is enabled.
294 294
      */
295
-    public function sandbox_notice( $description, $gateway ) {
296
-        if ( 'worldpay' == $gateway && wpinv_is_test_mode( 'worldpay' ) ) {
295
+    public function sandbox_notice($description, $gateway) {
296
+        if ('worldpay' == $gateway && wpinv_is_test_mode('worldpay')) {
297 297
             $description .= '<br>' . sprintf(
298
-                __( 'SANDBOX ENABLED. See the %sWorldpay Sandbox Testing Guide%s for more details.', 'invoicing' ),
298
+                __('SANDBOX ENABLED. See the %sWorldpay Sandbox Testing Guide%s for more details.', 'invoicing'),
299 299
                 '<a href="https://developer.worldpay.com/docs/wpg/directintegration/abouttesting">',
300 300
                 '</a>'
301 301
             );
@@ -309,43 +309,43 @@  discard block
 block discarded – undo
309 309
 	 * 
310 310
 	 * @param array $admin_settings
311 311
 	 */
312
-	public function admin_settings( $admin_settings ) {
312
+	public function admin_settings($admin_settings) {
313 313
 
314 314
         $currencies = sprintf(
315
-            __( 'Supported Currencies: %s', 'invoicing' ),
316
-            implode( ', ', $this->currencies )
315
+            __('Supported Currencies: %s', 'invoicing'),
316
+            implode(', ', $this->currencies)
317 317
         );
318 318
 
319 319
         $admin_settings['worldpay_active']['desc'] = $admin_settings['worldpay_active']['desc'] . " ($currencies)";
320
-        $admin_settings['worldpay_desc']['std']    = __( 'Pay securely via Worldpay using your PayPal account, credit or debit card.', 'invoicing' );
320
+        $admin_settings['worldpay_desc']['std']    = __('Pay securely via Worldpay using your PayPal account, credit or debit card.', 'invoicing');
321 321
 
322 322
         $admin_settings['worldpay_instId'] = array(
323 323
             'type' => 'text',
324 324
             'id'   => 'worldpay_instId',
325
-            'name' => __( 'Installation Id', 'invoicing' ),
326
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
325
+            'name' => __('Installation Id', 'invoicing'),
326
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
327 327
         );
328 328
 
329 329
         $admin_settings['worldpay_md5_secret'] = array(
330 330
             'type' => 'text',
331 331
             'id'   => 'worldpay_md5_secret',
332
-            'name' => __( 'MD5 secret', 'invoicing' ),
333
-            'desc' => __( 'Optionally enter your MD5 secret here. Next, open your installation settings and ensure that your SignatureFields parameter is set to ', 'invoicing' ) . '<code>instId:amount:currency:cartId</code>',
332
+            'name' => __('MD5 secret', 'invoicing'),
333
+            'desc' => __('Optionally enter your MD5 secret here. Next, open your installation settings and ensure that your SignatureFields parameter is set to ', 'invoicing') . '<code>instId:amount:currency:cartId</code>',
334 334
         );
335 335
 
336 336
         $admin_settings['worldpay_callbackPW'] = array(
337 337
             'type' => 'text',
338 338
             'id'   => 'worldpay_callbackPW',
339
-            'name' => __( 'Payment Response password', 'invoicing' ),
340
-            'desc' => __( 'Recommended. Enter your WorldPay response password to validate payment notifications.', 'invoicing' ),
339
+            'name' => __('Payment Response password', 'invoicing'),
340
+            'desc' => __('Recommended. Enter your WorldPay response password to validate payment notifications.', 'invoicing'),
341 341
         );
342 342
 
343 343
         $admin_settings['worldpay_ipn_url'] = array(
344 344
             'type'     => 'ipn_url',
345 345
             'id'       => 'worldpay_ipn_url',
346
-            'name'     => __( 'Payment Response URL', 'invoicing' ),
346
+            'name'     => __('Payment Response URL', 'invoicing'),
347 347
             'std'      => $this->notify_url,
348
-            'desc'     => __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and enter the above URL.', 'invoicing' ),
348
+            'desc'     => __('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and enter the above URL.', 'invoicing'),
349 349
             'custom'   => 'worldpay',
350 350
             'readonly' => true
351 351
         );
Please login to merge, or discard this patch.
includes/data/currency-symbols.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -11,166 +11,166 @@
 block discarded – undo
11 11
 defined( 'ABSPATH' ) || exit;
12 12
 
13 13
 return array(
14
-	'AED' => '&#x62f;.&#x625;',
15
-	'AFN' => '&#x60b;',
16
-	'ALL' => 'L',
17
-	'AMD' => 'AMD',
18
-	'ANG' => '&fnof;',
19
-	'AOA' => 'Kz',
20
-	'ARS' => '&#36;',
21
-	'AUD' => '&#36;',
22
-	'AWG' => '&fnof;',
23
-	'AZN' => 'AZN',
24
-	'BAM' => 'KM',
25
-	'BBD' => '&#36;',
26
-	'BDT' => '&#2547;',
27
-	'BGN' => '&#1083;&#1074;.',
28
-	'BHD' => '.&#x62f;.&#x628;',
29
-	'BIF' => 'Fr',
30
-	'BMD' => '&#36;',
31
-	'BND' => '&#36;',
32
-	'BOB' => 'Bs.',
33
-	'BRL' => '&#82;&#36;',
34
-	'BSD' => '&#36;',
35
-	'BTC' => '&#3647;',
36
-	'BTN' => 'Nu.',
37
-	'BWP' => 'P',
38
-	'BYN' => 'Br',
39
-	'BZD' => '&#36;',
40
-	'CAD' => '&#36;',
41
-	'CDF' => 'Fr',
42
-	'CHF' => '&#67;&#72;&#70;',
43
-	'CLP' => '&#36;',
44
-	'CNY' => '&yen;',
45
-	'COP' => '&#36;',
46
-	'CRC' => '&#x20a1;',
47
-	'CUC' => '&#36;',
48
-	'CUP' => '&#36;',
49
-	'CVE' => '&#36;',
50
-	'CZK' => '&#75;&#269;',
51
-	'DJF' => 'Fr',
52
-	'DKK' => 'DKK',
53
-	'DOP' => 'RD&#36;',
54
-	'DZD' => '&#x62f;.&#x62c;',
55
-	'EGP' => 'EGP',
56
-	'ERN' => 'Nfk',
57
-	'ETB' => 'Br',
58
-	'EUR' => '&euro;',
59
-	'FJD' => '&#36;',
60
-	'FKP' => '&pound;',
61
-	'GBP' => '&pound;',
62
-	'GEL' => '&#x10da;',
63
-	'GGP' => '&pound;',
64
-	'GHS' => '&#x20b5;',
65
-	'GIP' => '&pound;',
66
-	'GMD' => 'D',
67
-	'GNF' => 'Fr',
68
-	'GTQ' => 'Q',
69
-	'GYD' => '&#36;',
70
-	'HKD' => '&#36;',
71
-	'HNL' => 'L',
72
-	'HRK' => 'Kn',
73
-	'HTG' => 'G',
74
-	'HUF' => '&#70;&#116;',
75
-	'IDR' => 'Rp',
76
-	'ILS' => '&#8362;',
77
-	'IMP' => '&pound;',
78
-	'INR' => '&#8377;',
79
-	'IQD' => '&#x639;.&#x62f;',
80
-	'IRR' => '&#xfdfc;',
81
-	'IRT' => '&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;',
82
-	'ISK' => 'kr.',
83
-	'JEP' => '&pound;',
84
-	'JMD' => '&#36;',
85
-	'JOD' => '&#x62f;.&#x627;',
86
-	'JPY' => '&yen;',
87
-	'KES' => 'KSh',
88
-	'KGS' => '&#x441;&#x43e;&#x43c;',
89
-	'KHR' => '&#x17db;',
90
-	'KMF' => 'Fr',
91
-	'KPW' => '&#x20a9;',
92
-	'KRW' => '&#8361;',
93
-	'KWD' => '&#x62f;.&#x643;',
94
-	'KYD' => '&#36;',
95
-	'KZT' => 'KZT',
96
-	'LAK' => '&#8365;',
97
-	'LBP' => '&#x644;.&#x644;',
98
-	'LKR' => '&#xdbb;&#xdd4;',
99
-	'LRD' => '&#36;',
100
-	'LSL' => 'L',
101
-	'LYD' => '&#x644;.&#x62f;',
102
-	'MAD' => '&#x62f;.&#x645;.',
103
-	'MDL' => 'MDL',
104
-	'MGA' => 'Ar',
105
-	'MKD' => '&#x434;&#x435;&#x43d;',
106
-	'MMK' => 'Ks',
107
-	'MNT' => '&#x20ae;',
108
-	'MOP' => 'P',
109
-	'MRO' => 'UM',
110
-	'MUR' => '&#x20a8;',
111
-	'MVR' => '.&#x783;',
112
-	'MWK' => 'MK',
113
-	'MXN' => '&#36;',
114
-	'MYR' => '&#82;&#77;',
115
-	'MZN' => 'MT',
116
-	'NAD' => '&#36;',
117
-	'NGN' => '&#8358;',
118
-	'NIO' => 'C&#36;',
119
-	'NOK' => '&#107;&#114;',
120
-	'NPR' => '&#8360;',
121
-	'NZD' => '&#36;',
122
-	'OMR' => '&#x631;.&#x639;.',
123
-	'PAB' => 'B/.',
124
-	'PEN' => 'S/.',
125
-	'PGK' => 'K',
126
-	'PHP' => '&#8369;',
127
-	'PKR' => '&#8360;',
128
-	'PLN' => '&#122;&#322;',
129
-	'PRB' => '&#x440;.',
130
-	'PYG' => '&#8370;',
131
-	'QAR' => '&#x631;.&#x642;',
132
-	'RMB' => '&yen;',
133
-	'RON' => 'lei',
134
-	'RSD' => '&#x434;&#x438;&#x43d;.',
135
-	'RUB' => '&#8381;',
136
-	'RWF' => 'Fr',
137
-	'SAR' => '&#x631;.&#x633;',
138
-	'SBD' => '&#36;',
139
-	'SCR' => '&#x20a8;',
140
-	'SDG' => '&#x62c;.&#x633;.',
141
-	'SEK' => '&#107;&#114;',
142
-	'SGD' => '&#36;',
143
-	'SHP' => '&pound;',
144
-	'SLL' => 'Le',
145
-	'SOS' => 'Sh',
146
-	'SRD' => '&#36;',
147
-	'SSP' => '&pound;',
148
-	'STD' => 'Db',
149
-	'SYP' => '&#x644;.&#x633;',
150
-	'SZL' => 'L',
151
-	'THB' => '&#3647;',
152
-	'TJS' => '&#x405;&#x41c;',
153
-	'TMT' => 'm',
154
-	'TND' => '&#x62f;.&#x62a;',
155
-	'TOP' => 'T&#36;',
156
-	'TRY' => '&#8378;',
157
-	'TTD' => '&#36;',
158
-	'TWD' => '&#78;&#84;&#36;',
159
-	'TZS' => 'Sh',
160
-	'UAH' => '&#8372;',
161
-	'UGX' => 'UGX',
162
-	'USD' => '&#36;',
163
-	'UYU' => '&#36;',
164
-	'UZS' => 'UZS',
165
-	'VEF' => 'Bs.',
166
-	'VND' => '&#8363;',
167
-	'VUV' => 'Vt',
168
-	'WST' => 'T',
169
-	'XAF' => 'Fr',
170
-	'XCD' => '&#36;',
171
-	'XOF' => 'Fr',
172
-	'XPF' => 'Fr',
173
-	'YER' => '&#xfdfc;',
174
-	'ZAR' => '&#82;',
175
-	'ZMW' => 'ZK',
14
+    'AED' => '&#x62f;.&#x625;',
15
+    'AFN' => '&#x60b;',
16
+    'ALL' => 'L',
17
+    'AMD' => 'AMD',
18
+    'ANG' => '&fnof;',
19
+    'AOA' => 'Kz',
20
+    'ARS' => '&#36;',
21
+    'AUD' => '&#36;',
22
+    'AWG' => '&fnof;',
23
+    'AZN' => 'AZN',
24
+    'BAM' => 'KM',
25
+    'BBD' => '&#36;',
26
+    'BDT' => '&#2547;',
27
+    'BGN' => '&#1083;&#1074;.',
28
+    'BHD' => '.&#x62f;.&#x628;',
29
+    'BIF' => 'Fr',
30
+    'BMD' => '&#36;',
31
+    'BND' => '&#36;',
32
+    'BOB' => 'Bs.',
33
+    'BRL' => '&#82;&#36;',
34
+    'BSD' => '&#36;',
35
+    'BTC' => '&#3647;',
36
+    'BTN' => 'Nu.',
37
+    'BWP' => 'P',
38
+    'BYN' => 'Br',
39
+    'BZD' => '&#36;',
40
+    'CAD' => '&#36;',
41
+    'CDF' => 'Fr',
42
+    'CHF' => '&#67;&#72;&#70;',
43
+    'CLP' => '&#36;',
44
+    'CNY' => '&yen;',
45
+    'COP' => '&#36;',
46
+    'CRC' => '&#x20a1;',
47
+    'CUC' => '&#36;',
48
+    'CUP' => '&#36;',
49
+    'CVE' => '&#36;',
50
+    'CZK' => '&#75;&#269;',
51
+    'DJF' => 'Fr',
52
+    'DKK' => 'DKK',
53
+    'DOP' => 'RD&#36;',
54
+    'DZD' => '&#x62f;.&#x62c;',
55
+    'EGP' => 'EGP',
56
+    'ERN' => 'Nfk',
57
+    'ETB' => 'Br',
58
+    'EUR' => '&euro;',
59
+    'FJD' => '&#36;',
60
+    'FKP' => '&pound;',
61
+    'GBP' => '&pound;',
62
+    'GEL' => '&#x10da;',
63
+    'GGP' => '&pound;',
64
+    'GHS' => '&#x20b5;',
65
+    'GIP' => '&pound;',
66
+    'GMD' => 'D',
67
+    'GNF' => 'Fr',
68
+    'GTQ' => 'Q',
69
+    'GYD' => '&#36;',
70
+    'HKD' => '&#36;',
71
+    'HNL' => 'L',
72
+    'HRK' => 'Kn',
73
+    'HTG' => 'G',
74
+    'HUF' => '&#70;&#116;',
75
+    'IDR' => 'Rp',
76
+    'ILS' => '&#8362;',
77
+    'IMP' => '&pound;',
78
+    'INR' => '&#8377;',
79
+    'IQD' => '&#x639;.&#x62f;',
80
+    'IRR' => '&#xfdfc;',
81
+    'IRT' => '&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;',
82
+    'ISK' => 'kr.',
83
+    'JEP' => '&pound;',
84
+    'JMD' => '&#36;',
85
+    'JOD' => '&#x62f;.&#x627;',
86
+    'JPY' => '&yen;',
87
+    'KES' => 'KSh',
88
+    'KGS' => '&#x441;&#x43e;&#x43c;',
89
+    'KHR' => '&#x17db;',
90
+    'KMF' => 'Fr',
91
+    'KPW' => '&#x20a9;',
92
+    'KRW' => '&#8361;',
93
+    'KWD' => '&#x62f;.&#x643;',
94
+    'KYD' => '&#36;',
95
+    'KZT' => 'KZT',
96
+    'LAK' => '&#8365;',
97
+    'LBP' => '&#x644;.&#x644;',
98
+    'LKR' => '&#xdbb;&#xdd4;',
99
+    'LRD' => '&#36;',
100
+    'LSL' => 'L',
101
+    'LYD' => '&#x644;.&#x62f;',
102
+    'MAD' => '&#x62f;.&#x645;.',
103
+    'MDL' => 'MDL',
104
+    'MGA' => 'Ar',
105
+    'MKD' => '&#x434;&#x435;&#x43d;',
106
+    'MMK' => 'Ks',
107
+    'MNT' => '&#x20ae;',
108
+    'MOP' => 'P',
109
+    'MRO' => 'UM',
110
+    'MUR' => '&#x20a8;',
111
+    'MVR' => '.&#x783;',
112
+    'MWK' => 'MK',
113
+    'MXN' => '&#36;',
114
+    'MYR' => '&#82;&#77;',
115
+    'MZN' => 'MT',
116
+    'NAD' => '&#36;',
117
+    'NGN' => '&#8358;',
118
+    'NIO' => 'C&#36;',
119
+    'NOK' => '&#107;&#114;',
120
+    'NPR' => '&#8360;',
121
+    'NZD' => '&#36;',
122
+    'OMR' => '&#x631;.&#x639;.',
123
+    'PAB' => 'B/.',
124
+    'PEN' => 'S/.',
125
+    'PGK' => 'K',
126
+    'PHP' => '&#8369;',
127
+    'PKR' => '&#8360;',
128
+    'PLN' => '&#122;&#322;',
129
+    'PRB' => '&#x440;.',
130
+    'PYG' => '&#8370;',
131
+    'QAR' => '&#x631;.&#x642;',
132
+    'RMB' => '&yen;',
133
+    'RON' => 'lei',
134
+    'RSD' => '&#x434;&#x438;&#x43d;.',
135
+    'RUB' => '&#8381;',
136
+    'RWF' => 'Fr',
137
+    'SAR' => '&#x631;.&#x633;',
138
+    'SBD' => '&#36;',
139
+    'SCR' => '&#x20a8;',
140
+    'SDG' => '&#x62c;.&#x633;.',
141
+    'SEK' => '&#107;&#114;',
142
+    'SGD' => '&#36;',
143
+    'SHP' => '&pound;',
144
+    'SLL' => 'Le',
145
+    'SOS' => 'Sh',
146
+    'SRD' => '&#36;',
147
+    'SSP' => '&pound;',
148
+    'STD' => 'Db',
149
+    'SYP' => '&#x644;.&#x633;',
150
+    'SZL' => 'L',
151
+    'THB' => '&#3647;',
152
+    'TJS' => '&#x405;&#x41c;',
153
+    'TMT' => 'm',
154
+    'TND' => '&#x62f;.&#x62a;',
155
+    'TOP' => 'T&#36;',
156
+    'TRY' => '&#8378;',
157
+    'TTD' => '&#36;',
158
+    'TWD' => '&#78;&#84;&#36;',
159
+    'TZS' => 'Sh',
160
+    'UAH' => '&#8372;',
161
+    'UGX' => 'UGX',
162
+    'USD' => '&#36;',
163
+    'UYU' => '&#36;',
164
+    'UZS' => 'UZS',
165
+    'VEF' => 'Bs.',
166
+    'VND' => '&#8363;',
167
+    'VUV' => 'Vt',
168
+    'WST' => 'T',
169
+    'XAF' => 'Fr',
170
+    'XCD' => '&#36;',
171
+    'XOF' => 'Fr',
172
+    'XPF' => 'Fr',
173
+    'YER' => '&#xfdfc;',
174
+    'ZAR' => '&#82;',
175
+    'ZMW' => 'ZK',
176 176
 );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14 14
 	'AED' => '&#x62f;.&#x625;',
Please login to merge, or discard this patch.
includes/data/currencies.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -11,165 +11,165 @@
 block discarded – undo
11 11
 defined( 'ABSPATH' ) || exit;
12 12
 
13 13
 return array(
14
-	'USD' => __( 'US Dollar', 'invoicing' ),
15
-	'EUR' => __( 'Euro', 'invoicing' ),
16
-	'GBP' => __( 'Pound Sterling', 'invoicing' ),
17
-	'AED' => __( 'United Arab Emirates', 'invoicing' ),
18
-	'AFN' => __( 'Afghan Afghani', 'invoicing' ),
19
-	'ALL' => __( 'Albanian Lek', 'invoicing' ),
20
-	'AMD' => __( 'Armenian Dram', 'invoicing' ),
21
-	'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
22
-	'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
23
-	'ARS' => __( 'Argentine Peso', 'invoicing' ),
24
-	'AUD' => __( 'Australian Dollar', 'invoicing' ),
25
-	'AWG' => __( 'Aruban Florin', 'invoicing' ),
26
-	'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
27
-	'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
28
-	'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
29
-	'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
30
-	'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
31
-	'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
32
-	'BIF' => __( 'Burundian Franc', 'invoicing' ),
33
-	'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
34
-	'BND' => __( 'Brunei Dollar', 'invoicing' ),
35
-	'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
36
-	'BRL' => __( 'Brazilian Real', 'invoicing' ),
37
-	'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
38
-	'BTC' => __( 'Bitcoin', 'invoicing' ),
39
-	'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
40
-	'BWP' => __( 'Botswana Pula', 'invoicing' ),
41
-	'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
42
-	'BZD' => __( 'Belize Dollar', 'invoicing' ),
43
-	'CAD' => __( 'Canadian Dollar', 'invoicing' ),
44
-	'CDF' => __( 'Congolese Franc', 'invoicing' ),
45
-	'CHF' => __( 'Swiss Franc', 'invoicing' ),
46
-	'CLP' => __( 'Chilean Peso', 'invoicing' ),
47
-	'CNY' => __( 'Chinese Yuan', 'invoicing' ),
48
-	'COP' => __( 'Colombian Peso', 'invoicing' ),
49
-	'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
50
-	'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
51
-	'CUP' => __( 'Cuban Peso', 'invoicing' ),
52
-	'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
53
-	'CZK' => __( 'Czech Koruna', 'invoicing' ),
54
-	'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
55
-	'DKK' => __( 'Danish Krone', 'invoicing' ),
56
-	'DOP' => __( 'Dominican Peso', 'invoicing' ),
57
-	'DZD' => __( 'Algerian Dinar', 'invoicing' ),
58
-	'EGP' => __( 'Egyptian Pound', 'invoicing' ),
59
-	'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
60
-	'ETB' => __( 'Ethiopian Irr', 'invoicing' ),
61
-	'FJD' => __( 'Fijian Dollar', 'invoicing' ),
62
-	'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
63
-	'GEL' => __( 'Georgian Lari', 'invoicing' ),
64
-	'GGP' => __( 'Guernsey Pound', 'invoicing' ),
65
-	'GHS' => __( 'Ghana Cedi', 'invoicing' ),
66
-	'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
67
-	'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
68
-	'GNF' => __( 'Guinean Franc', 'invoicing' ),
69
-	'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
70
-	'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
71
-	'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
72
-	'HNL' => __( 'Honduran Lempira', 'invoicing' ),
73
-	'HRK' => __( 'Croatian Kuna', 'invoicing' ),
74
-	'HTG' => __( 'Haitian Gourde', 'invoicing' ),
75
-	'HUF' => __( 'Hungarian Forint', 'invoicing' ),
76
-	'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
77
-	'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
78
-	'IMP' => __( 'Manx Pound', 'invoicing' ),
79
-	'INR' => __( 'Indian Rupee', 'invoicing' ),
80
-	'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
81
-	'IRR' => __( 'Iranian Rial', 'invoicing' ),
82
-	'IRT' => __( 'Iranian Toman', 'invoicing' ),
83
-	'ISK' => __( 'Icelandic Krona', 'invoicing' ),
84
-	'JEP' => __( 'Jersey Pound', 'invoicing' ),
85
-	'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
86
-	'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
87
-	'JPY' => __( 'Japanese Yen', 'invoicing' ),
88
-	'KES' => __( 'Kenyan Shilling', 'invoicing' ),
89
-	'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
90
-	'KHR' => __( 'Cambodian Riel', 'invoicing' ),
91
-	'KMF' => __( 'Comorian Franc', 'invoicing' ),
92
-	'KPW' => __( 'North Korean Won', 'invoicing' ),
93
-	'KRW' => __( 'South Korean Won', 'invoicing' ),
94
-	'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
95
-	'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
96
-	'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
97
-	'LAK' => __( 'Lao Kip', 'invoicing' ),
98
-	'LBP' => __( 'Lebanese Pound', 'invoicing' ),
99
-	'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
100
-	'LRD' => __( 'Liberian Dollar', 'invoicing' ),
101
-	'LSL' => __( 'Lesotho Loti', 'invoicing' ),
102
-	'LYD' => __( 'Libyan Dinar', 'invoicing' ),
103
-	'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
104
-	'MDL' => __( 'Moldovan Leu', 'invoicing' ),
105
-	'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
106
-	'MKD' => __( 'Macedonian Denar', 'invoicing' ),
107
-	'MMK' => __( 'Burmese Kyat', 'invoicing' ),
108
-	'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
109
-	'MOP' => __( 'Macanese Pataca', 'invoicing' ),
110
-	'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
111
-	'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
112
-	'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
113
-	'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
114
-	'MXN' => __( 'Mexican Peso', 'invoicing' ),
115
-	'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
116
-	'MZN' => __( 'Mozambican Metical', 'invoicing' ),
117
-	'NAD' => __( 'Namibian Dollar', 'invoicing' ),
118
-	'NGN' => __( 'Nigerian Naira', 'invoicing' ),
119
-	'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
120
-	'NOK' => __( 'Norwegian Krone', 'invoicing' ),
121
-	'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
122
-	'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
123
-	'OMR' => __( 'Omani Rial', 'invoicing' ),
124
-	'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
125
-	'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
126
-	'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
127
-	'PHP' => __( 'Philippine Peso', 'invoicing' ),
128
-	'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
129
-	'PLN' => __( 'Polish Zloty', 'invoicing' ),
130
-	'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
131
-	'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
132
-	'QAR' => __( 'Qatari Riyal', 'invoicing' ),
133
-	'RON' => __( 'Romanian Leu', 'invoicing' ),
134
-	'RSD' => __( 'Serbian Dinar', 'invoicing' ),
135
-	'RUB' => __( 'Russian Ruble', 'invoicing' ),
136
-	'RWF' => __( 'Rwandan Franc', 'invoicing' ),
137
-	'SAR' => __( 'Saudi Riyal', 'invoicing' ),
138
-	'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
139
-	'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
140
-	'SDG' => __( 'Sudanese Pound', 'invoicing' ),
141
-	'SEK' => __( 'Swedish Krona', 'invoicing' ),
142
-	'SGD' => __( 'Singapore Dollar', 'invoicing' ),
143
-	'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
144
-	'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
145
-	'SOS' => __( 'Somali Shilling', 'invoicing' ),
146
-	'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
147
-	'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
148
-	'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
149
-	'SYP' => __( 'Syrian Pound', 'invoicing' ),
150
-	'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
151
-	'THB' => __( 'Thai Baht', 'invoicing' ),
152
-	'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
153
-	'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
154
-	'TND' => __( 'Tunisian Dinar', 'invoicing' ),
155
-	'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
156
-	'TRY' => __( 'Turkish Lira', 'invoicing' ),
157
-	'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
158
-	'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
159
-	'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
160
-	'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
161
-	'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
162
-	'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
163
-	'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
164
-	'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
165
-	'VND' => __( 'Vietnamese Dong', 'invoicing' ),
166
-	'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
167
-	'WST' => __( 'Samoan Tala', 'invoicing' ),
168
-	'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
169
-	'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
170
-	'XOF' => __( 'West African CFA Franc', 'invoicing' ),
171
-	'XPF' => __( 'CFP Franc', 'invoicing' ),
172
-	'YER' => __( 'Yemeni Rial', 'invoicing' ),
173
-	'ZAR' => __( 'South African Rand', 'invoicing' ),
174
-	'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
14
+    'USD' => __( 'US Dollar', 'invoicing' ),
15
+    'EUR' => __( 'Euro', 'invoicing' ),
16
+    'GBP' => __( 'Pound Sterling', 'invoicing' ),
17
+    'AED' => __( 'United Arab Emirates', 'invoicing' ),
18
+    'AFN' => __( 'Afghan Afghani', 'invoicing' ),
19
+    'ALL' => __( 'Albanian Lek', 'invoicing' ),
20
+    'AMD' => __( 'Armenian Dram', 'invoicing' ),
21
+    'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
22
+    'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
23
+    'ARS' => __( 'Argentine Peso', 'invoicing' ),
24
+    'AUD' => __( 'Australian Dollar', 'invoicing' ),
25
+    'AWG' => __( 'Aruban Florin', 'invoicing' ),
26
+    'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
27
+    'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
28
+    'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
29
+    'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
30
+    'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
31
+    'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
32
+    'BIF' => __( 'Burundian Franc', 'invoicing' ),
33
+    'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
34
+    'BND' => __( 'Brunei Dollar', 'invoicing' ),
35
+    'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
36
+    'BRL' => __( 'Brazilian Real', 'invoicing' ),
37
+    'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
38
+    'BTC' => __( 'Bitcoin', 'invoicing' ),
39
+    'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
40
+    'BWP' => __( 'Botswana Pula', 'invoicing' ),
41
+    'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
42
+    'BZD' => __( 'Belize Dollar', 'invoicing' ),
43
+    'CAD' => __( 'Canadian Dollar', 'invoicing' ),
44
+    'CDF' => __( 'Congolese Franc', 'invoicing' ),
45
+    'CHF' => __( 'Swiss Franc', 'invoicing' ),
46
+    'CLP' => __( 'Chilean Peso', 'invoicing' ),
47
+    'CNY' => __( 'Chinese Yuan', 'invoicing' ),
48
+    'COP' => __( 'Colombian Peso', 'invoicing' ),
49
+    'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
50
+    'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
51
+    'CUP' => __( 'Cuban Peso', 'invoicing' ),
52
+    'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
53
+    'CZK' => __( 'Czech Koruna', 'invoicing' ),
54
+    'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
55
+    'DKK' => __( 'Danish Krone', 'invoicing' ),
56
+    'DOP' => __( 'Dominican Peso', 'invoicing' ),
57
+    'DZD' => __( 'Algerian Dinar', 'invoicing' ),
58
+    'EGP' => __( 'Egyptian Pound', 'invoicing' ),
59
+    'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
60
+    'ETB' => __( 'Ethiopian Irr', 'invoicing' ),
61
+    'FJD' => __( 'Fijian Dollar', 'invoicing' ),
62
+    'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
63
+    'GEL' => __( 'Georgian Lari', 'invoicing' ),
64
+    'GGP' => __( 'Guernsey Pound', 'invoicing' ),
65
+    'GHS' => __( 'Ghana Cedi', 'invoicing' ),
66
+    'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
67
+    'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
68
+    'GNF' => __( 'Guinean Franc', 'invoicing' ),
69
+    'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
70
+    'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
71
+    'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
72
+    'HNL' => __( 'Honduran Lempira', 'invoicing' ),
73
+    'HRK' => __( 'Croatian Kuna', 'invoicing' ),
74
+    'HTG' => __( 'Haitian Gourde', 'invoicing' ),
75
+    'HUF' => __( 'Hungarian Forint', 'invoicing' ),
76
+    'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
77
+    'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
78
+    'IMP' => __( 'Manx Pound', 'invoicing' ),
79
+    'INR' => __( 'Indian Rupee', 'invoicing' ),
80
+    'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
81
+    'IRR' => __( 'Iranian Rial', 'invoicing' ),
82
+    'IRT' => __( 'Iranian Toman', 'invoicing' ),
83
+    'ISK' => __( 'Icelandic Krona', 'invoicing' ),
84
+    'JEP' => __( 'Jersey Pound', 'invoicing' ),
85
+    'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
86
+    'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
87
+    'JPY' => __( 'Japanese Yen', 'invoicing' ),
88
+    'KES' => __( 'Kenyan Shilling', 'invoicing' ),
89
+    'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
90
+    'KHR' => __( 'Cambodian Riel', 'invoicing' ),
91
+    'KMF' => __( 'Comorian Franc', 'invoicing' ),
92
+    'KPW' => __( 'North Korean Won', 'invoicing' ),
93
+    'KRW' => __( 'South Korean Won', 'invoicing' ),
94
+    'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
95
+    'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
96
+    'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
97
+    'LAK' => __( 'Lao Kip', 'invoicing' ),
98
+    'LBP' => __( 'Lebanese Pound', 'invoicing' ),
99
+    'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
100
+    'LRD' => __( 'Liberian Dollar', 'invoicing' ),
101
+    'LSL' => __( 'Lesotho Loti', 'invoicing' ),
102
+    'LYD' => __( 'Libyan Dinar', 'invoicing' ),
103
+    'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
104
+    'MDL' => __( 'Moldovan Leu', 'invoicing' ),
105
+    'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
106
+    'MKD' => __( 'Macedonian Denar', 'invoicing' ),
107
+    'MMK' => __( 'Burmese Kyat', 'invoicing' ),
108
+    'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
109
+    'MOP' => __( 'Macanese Pataca', 'invoicing' ),
110
+    'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
111
+    'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
112
+    'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
113
+    'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
114
+    'MXN' => __( 'Mexican Peso', 'invoicing' ),
115
+    'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
116
+    'MZN' => __( 'Mozambican Metical', 'invoicing' ),
117
+    'NAD' => __( 'Namibian Dollar', 'invoicing' ),
118
+    'NGN' => __( 'Nigerian Naira', 'invoicing' ),
119
+    'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
120
+    'NOK' => __( 'Norwegian Krone', 'invoicing' ),
121
+    'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
122
+    'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
123
+    'OMR' => __( 'Omani Rial', 'invoicing' ),
124
+    'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
125
+    'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
126
+    'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
127
+    'PHP' => __( 'Philippine Peso', 'invoicing' ),
128
+    'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
129
+    'PLN' => __( 'Polish Zloty', 'invoicing' ),
130
+    'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
131
+    'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
132
+    'QAR' => __( 'Qatari Riyal', 'invoicing' ),
133
+    'RON' => __( 'Romanian Leu', 'invoicing' ),
134
+    'RSD' => __( 'Serbian Dinar', 'invoicing' ),
135
+    'RUB' => __( 'Russian Ruble', 'invoicing' ),
136
+    'RWF' => __( 'Rwandan Franc', 'invoicing' ),
137
+    'SAR' => __( 'Saudi Riyal', 'invoicing' ),
138
+    'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
139
+    'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
140
+    'SDG' => __( 'Sudanese Pound', 'invoicing' ),
141
+    'SEK' => __( 'Swedish Krona', 'invoicing' ),
142
+    'SGD' => __( 'Singapore Dollar', 'invoicing' ),
143
+    'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
144
+    'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
145
+    'SOS' => __( 'Somali Shilling', 'invoicing' ),
146
+    'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
147
+    'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
148
+    'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
149
+    'SYP' => __( 'Syrian Pound', 'invoicing' ),
150
+    'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
151
+    'THB' => __( 'Thai Baht', 'invoicing' ),
152
+    'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
153
+    'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
154
+    'TND' => __( 'Tunisian Dinar', 'invoicing' ),
155
+    'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
156
+    'TRY' => __( 'Turkish Lira', 'invoicing' ),
157
+    'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
158
+    'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
159
+    'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
160
+    'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
161
+    'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
162
+    'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
163
+    'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
164
+    'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
165
+    'VND' => __( 'Vietnamese Dong', 'invoicing' ),
166
+    'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
167
+    'WST' => __( 'Samoan Tala', 'invoicing' ),
168
+    'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
169
+    'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
170
+    'XOF' => __( 'West African CFA Franc', 'invoicing' ),
171
+    'XPF' => __( 'CFP Franc', 'invoicing' ),
172
+    'YER' => __( 'Yemeni Rial', 'invoicing' ),
173
+    'ZAR' => __( 'South African Rand', 'invoicing' ),
174
+    'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
175 175
 );
Please login to merge, or discard this patch.
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -8,168 +8,168 @@
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14
-	'USD' => __( 'US Dollar', 'invoicing' ),
15
-	'EUR' => __( 'Euro', 'invoicing' ),
16
-	'GBP' => __( 'Pound Sterling', 'invoicing' ),
17
-	'AED' => __( 'United Arab Emirates', 'invoicing' ),
18
-	'AFN' => __( 'Afghan Afghani', 'invoicing' ),
19
-	'ALL' => __( 'Albanian Lek', 'invoicing' ),
20
-	'AMD' => __( 'Armenian Dram', 'invoicing' ),
21
-	'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
22
-	'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
23
-	'ARS' => __( 'Argentine Peso', 'invoicing' ),
24
-	'AUD' => __( 'Australian Dollar', 'invoicing' ),
25
-	'AWG' => __( 'Aruban Florin', 'invoicing' ),
26
-	'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
27
-	'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
28
-	'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
29
-	'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
30
-	'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
31
-	'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
32
-	'BIF' => __( 'Burundian Franc', 'invoicing' ),
33
-	'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
34
-	'BND' => __( 'Brunei Dollar', 'invoicing' ),
35
-	'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
36
-	'BRL' => __( 'Brazilian Real', 'invoicing' ),
37
-	'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
38
-	'BTC' => __( 'Bitcoin', 'invoicing' ),
39
-	'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
40
-	'BWP' => __( 'Botswana Pula', 'invoicing' ),
41
-	'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
42
-	'BZD' => __( 'Belize Dollar', 'invoicing' ),
43
-	'CAD' => __( 'Canadian Dollar', 'invoicing' ),
44
-	'CDF' => __( 'Congolese Franc', 'invoicing' ),
45
-	'CHF' => __( 'Swiss Franc', 'invoicing' ),
46
-	'CLP' => __( 'Chilean Peso', 'invoicing' ),
47
-	'CNY' => __( 'Chinese Yuan', 'invoicing' ),
48
-	'COP' => __( 'Colombian Peso', 'invoicing' ),
49
-	'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
50
-	'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
51
-	'CUP' => __( 'Cuban Peso', 'invoicing' ),
52
-	'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
53
-	'CZK' => __( 'Czech Koruna', 'invoicing' ),
54
-	'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
55
-	'DKK' => __( 'Danish Krone', 'invoicing' ),
56
-	'DOP' => __( 'Dominican Peso', 'invoicing' ),
57
-	'DZD' => __( 'Algerian Dinar', 'invoicing' ),
58
-	'EGP' => __( 'Egyptian Pound', 'invoicing' ),
59
-	'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
60
-	'ETB' => __( 'Ethiopian Irr', 'invoicing' ),
61
-	'FJD' => __( 'Fijian Dollar', 'invoicing' ),
62
-	'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
63
-	'GEL' => __( 'Georgian Lari', 'invoicing' ),
64
-	'GGP' => __( 'Guernsey Pound', 'invoicing' ),
65
-	'GHS' => __( 'Ghana Cedi', 'invoicing' ),
66
-	'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
67
-	'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
68
-	'GNF' => __( 'Guinean Franc', 'invoicing' ),
69
-	'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
70
-	'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
71
-	'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
72
-	'HNL' => __( 'Honduran Lempira', 'invoicing' ),
73
-	'HRK' => __( 'Croatian Kuna', 'invoicing' ),
74
-	'HTG' => __( 'Haitian Gourde', 'invoicing' ),
75
-	'HUF' => __( 'Hungarian Forint', 'invoicing' ),
76
-	'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
77
-	'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
78
-	'IMP' => __( 'Manx Pound', 'invoicing' ),
79
-	'INR' => __( 'Indian Rupee', 'invoicing' ),
80
-	'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
81
-	'IRR' => __( 'Iranian Rial', 'invoicing' ),
82
-	'IRT' => __( 'Iranian Toman', 'invoicing' ),
83
-	'ISK' => __( 'Icelandic Krona', 'invoicing' ),
84
-	'JEP' => __( 'Jersey Pound', 'invoicing' ),
85
-	'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
86
-	'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
87
-	'JPY' => __( 'Japanese Yen', 'invoicing' ),
88
-	'KES' => __( 'Kenyan Shilling', 'invoicing' ),
89
-	'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
90
-	'KHR' => __( 'Cambodian Riel', 'invoicing' ),
91
-	'KMF' => __( 'Comorian Franc', 'invoicing' ),
92
-	'KPW' => __( 'North Korean Won', 'invoicing' ),
93
-	'KRW' => __( 'South Korean Won', 'invoicing' ),
94
-	'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
95
-	'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
96
-	'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
97
-	'LAK' => __( 'Lao Kip', 'invoicing' ),
98
-	'LBP' => __( 'Lebanese Pound', 'invoicing' ),
99
-	'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
100
-	'LRD' => __( 'Liberian Dollar', 'invoicing' ),
101
-	'LSL' => __( 'Lesotho Loti', 'invoicing' ),
102
-	'LYD' => __( 'Libyan Dinar', 'invoicing' ),
103
-	'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
104
-	'MDL' => __( 'Moldovan Leu', 'invoicing' ),
105
-	'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
106
-	'MKD' => __( 'Macedonian Denar', 'invoicing' ),
107
-	'MMK' => __( 'Burmese Kyat', 'invoicing' ),
108
-	'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
109
-	'MOP' => __( 'Macanese Pataca', 'invoicing' ),
110
-	'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
111
-	'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
112
-	'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
113
-	'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
114
-	'MXN' => __( 'Mexican Peso', 'invoicing' ),
115
-	'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
116
-	'MZN' => __( 'Mozambican Metical', 'invoicing' ),
117
-	'NAD' => __( 'Namibian Dollar', 'invoicing' ),
118
-	'NGN' => __( 'Nigerian Naira', 'invoicing' ),
119
-	'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
120
-	'NOK' => __( 'Norwegian Krone', 'invoicing' ),
121
-	'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
122
-	'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
123
-	'OMR' => __( 'Omani Rial', 'invoicing' ),
124
-	'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
125
-	'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
126
-	'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
127
-	'PHP' => __( 'Philippine Peso', 'invoicing' ),
128
-	'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
129
-	'PLN' => __( 'Polish Zloty', 'invoicing' ),
130
-	'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
131
-	'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
132
-	'QAR' => __( 'Qatari Riyal', 'invoicing' ),
133
-	'RON' => __( 'Romanian Leu', 'invoicing' ),
134
-	'RSD' => __( 'Serbian Dinar', 'invoicing' ),
135
-	'RUB' => __( 'Russian Ruble', 'invoicing' ),
136
-	'RWF' => __( 'Rwandan Franc', 'invoicing' ),
137
-	'SAR' => __( 'Saudi Riyal', 'invoicing' ),
138
-	'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
139
-	'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
140
-	'SDG' => __( 'Sudanese Pound', 'invoicing' ),
141
-	'SEK' => __( 'Swedish Krona', 'invoicing' ),
142
-	'SGD' => __( 'Singapore Dollar', 'invoicing' ),
143
-	'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
144
-	'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
145
-	'SOS' => __( 'Somali Shilling', 'invoicing' ),
146
-	'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
147
-	'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
148
-	'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
149
-	'SYP' => __( 'Syrian Pound', 'invoicing' ),
150
-	'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
151
-	'THB' => __( 'Thai Baht', 'invoicing' ),
152
-	'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
153
-	'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
154
-	'TND' => __( 'Tunisian Dinar', 'invoicing' ),
155
-	'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
156
-	'TRY' => __( 'Turkish Lira', 'invoicing' ),
157
-	'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
158
-	'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
159
-	'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
160
-	'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
161
-	'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
162
-	'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
163
-	'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
164
-	'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
165
-	'VND' => __( 'Vietnamese Dong', 'invoicing' ),
166
-	'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
167
-	'WST' => __( 'Samoan Tala', 'invoicing' ),
168
-	'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
169
-	'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
170
-	'XOF' => __( 'West African CFA Franc', 'invoicing' ),
171
-	'XPF' => __( 'CFP Franc', 'invoicing' ),
172
-	'YER' => __( 'Yemeni Rial', 'invoicing' ),
173
-	'ZAR' => __( 'South African Rand', 'invoicing' ),
174
-	'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
14
+	'USD' => __('US Dollar', 'invoicing'),
15
+	'EUR' => __('Euro', 'invoicing'),
16
+	'GBP' => __('Pound Sterling', 'invoicing'),
17
+	'AED' => __('United Arab Emirates', 'invoicing'),
18
+	'AFN' => __('Afghan Afghani', 'invoicing'),
19
+	'ALL' => __('Albanian Lek', 'invoicing'),
20
+	'AMD' => __('Armenian Dram', 'invoicing'),
21
+	'ANG' => __('Netherlands Antillean Guilder', 'invoicing'),
22
+	'AOA' => __('Angolan Kwanza', 'invoicing'),
23
+	'ARS' => __('Argentine Peso', 'invoicing'),
24
+	'AUD' => __('Australian Dollar', 'invoicing'),
25
+	'AWG' => __('Aruban Florin', 'invoicing'),
26
+	'AZN' => __('Azerbaijani Manat', 'invoicing'),
27
+	'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'),
28
+	'BBD' => __('Barbadian Dollar', 'invoicing'),
29
+	'BDT' => __('Bangladeshi Taka', 'invoicing'),
30
+	'BGN' => __('Bulgarian Lev', 'invoicing'),
31
+	'BHD' => __('Bahraini Dinar', 'invoicing'),
32
+	'BIF' => __('Burundian Franc', 'invoicing'),
33
+	'BMD' => __('Bermudian Dollar', 'invoicing'),
34
+	'BND' => __('Brunei Dollar', 'invoicing'),
35
+	'BOB' => __('Bolivian Boliviano', 'invoicing'),
36
+	'BRL' => __('Brazilian Real', 'invoicing'),
37
+	'BSD' => __('Bahamian Dollar', 'invoicing'),
38
+	'BTC' => __('Bitcoin', 'invoicing'),
39
+	'BTN' => __('Bhutanese Ngultrum', 'invoicing'),
40
+	'BWP' => __('Botswana Pula', 'invoicing'),
41
+	'BYN' => __('Belarusian Ruble', 'invoicing'),
42
+	'BZD' => __('Belize Dollar', 'invoicing'),
43
+	'CAD' => __('Canadian Dollar', 'invoicing'),
44
+	'CDF' => __('Congolese Franc', 'invoicing'),
45
+	'CHF' => __('Swiss Franc', 'invoicing'),
46
+	'CLP' => __('Chilean Peso', 'invoicing'),
47
+	'CNY' => __('Chinese Yuan', 'invoicing'),
48
+	'COP' => __('Colombian Peso', 'invoicing'),
49
+	'CRC' => __('Costa Rican Colon', 'invoicing'),
50
+	'CUC' => __('Cuban Convertible Peso', 'invoicing'),
51
+	'CUP' => __('Cuban Peso', 'invoicing'),
52
+	'CVE' => __('Cape Verdean escudo', 'invoicing'),
53
+	'CZK' => __('Czech Koruna', 'invoicing'),
54
+	'DJF' => __('Djiboutian Franc', 'invoicing'),
55
+	'DKK' => __('Danish Krone', 'invoicing'),
56
+	'DOP' => __('Dominican Peso', 'invoicing'),
57
+	'DZD' => __('Algerian Dinar', 'invoicing'),
58
+	'EGP' => __('Egyptian Pound', 'invoicing'),
59
+	'ERN' => __('Eritrean Nakfa', 'invoicing'),
60
+	'ETB' => __('Ethiopian Irr', 'invoicing'),
61
+	'FJD' => __('Fijian Dollar', 'invoicing'),
62
+	'FKP' => __('Falkland Islands Pound', 'invoicing'),
63
+	'GEL' => __('Georgian Lari', 'invoicing'),
64
+	'GGP' => __('Guernsey Pound', 'invoicing'),
65
+	'GHS' => __('Ghana Cedi', 'invoicing'),
66
+	'GIP' => __('Gibraltar Pound', 'invoicing'),
67
+	'GMD' => __('Gambian Dalasi', 'invoicing'),
68
+	'GNF' => __('Guinean Franc', 'invoicing'),
69
+	'GTQ' => __('Guatemalan Quetzal', 'invoicing'),
70
+	'GYD' => __('Guyanese Dollar', 'invoicing'),
71
+	'HKD' => __('Hong Kong Dollar', 'invoicing'),
72
+	'HNL' => __('Honduran Lempira', 'invoicing'),
73
+	'HRK' => __('Croatian Kuna', 'invoicing'),
74
+	'HTG' => __('Haitian Gourde', 'invoicing'),
75
+	'HUF' => __('Hungarian Forint', 'invoicing'),
76
+	'IDR' => __('Indonesian Rupiah', 'invoicing'),
77
+	'ILS' => __('Israeli New Shekel', 'invoicing'),
78
+	'IMP' => __('Manx Pound', 'invoicing'),
79
+	'INR' => __('Indian Rupee', 'invoicing'),
80
+	'IQD' => __('Iraqi Dinar', 'invoicing'),
81
+	'IRR' => __('Iranian Rial', 'invoicing'),
82
+	'IRT' => __('Iranian Toman', 'invoicing'),
83
+	'ISK' => __('Icelandic Krona', 'invoicing'),
84
+	'JEP' => __('Jersey Pound', 'invoicing'),
85
+	'JMD' => __('Jamaican Dollar', 'invoicing'),
86
+	'JOD' => __('Jordanian Dinar', 'invoicing'),
87
+	'JPY' => __('Japanese Yen', 'invoicing'),
88
+	'KES' => __('Kenyan Shilling', 'invoicing'),
89
+	'KGS' => __('Kyrgyzstani Som', 'invoicing'),
90
+	'KHR' => __('Cambodian Riel', 'invoicing'),
91
+	'KMF' => __('Comorian Franc', 'invoicing'),
92
+	'KPW' => __('North Korean Won', 'invoicing'),
93
+	'KRW' => __('South Korean Won', 'invoicing'),
94
+	'KWD' => __('Kuwaiti Dinar', 'invoicing'),
95
+	'KYD' => __('Cayman Islands Dollar', 'invoicing'),
96
+	'KZT' => __('Kazakhstani Tenge', 'invoicing'),
97
+	'LAK' => __('Lao Kip', 'invoicing'),
98
+	'LBP' => __('Lebanese Pound', 'invoicing'),
99
+	'LKR' => __('Sri Lankan Rupee', 'invoicing'),
100
+	'LRD' => __('Liberian Dollar', 'invoicing'),
101
+	'LSL' => __('Lesotho Loti', 'invoicing'),
102
+	'LYD' => __('Libyan Dinar', 'invoicing'),
103
+	'MAD' => __('Moroccan Dirham', 'invoicing'),
104
+	'MDL' => __('Moldovan Leu', 'invoicing'),
105
+	'MGA' => __('Malagasy Ariary', 'invoicing'),
106
+	'MKD' => __('Macedonian Denar', 'invoicing'),
107
+	'MMK' => __('Burmese Kyat', 'invoicing'),
108
+	'MNT' => __('Mongolian Tughrik', 'invoicing'),
109
+	'MOP' => __('Macanese Pataca', 'invoicing'),
110
+	'MRO' => __('Mauritanian Ouguiya', 'invoicing'),
111
+	'MUR' => __('Mauritian Rupee', 'invoicing'),
112
+	'MVR' => __('Maldivian Rufiyaa', 'invoicing'),
113
+	'MWK' => __('Malawian Kwacha', 'invoicing'),
114
+	'MXN' => __('Mexican Peso', 'invoicing'),
115
+	'MYR' => __('Malaysian Ringgit', 'invoicing'),
116
+	'MZN' => __('Mozambican Metical', 'invoicing'),
117
+	'NAD' => __('Namibian Dollar', 'invoicing'),
118
+	'NGN' => __('Nigerian Naira', 'invoicing'),
119
+	'NIO' => __('Nicaraguan Cordoba', 'invoicing'),
120
+	'NOK' => __('Norwegian Krone', 'invoicing'),
121
+	'NPR' => __('Nepalese Rupee', 'invoicing'),
122
+	'NZD' => __('New Zealand Dollar', 'invoicing'),
123
+	'OMR' => __('Omani Rial', 'invoicing'),
124
+	'PAB' => __('Panamanian Balboa', 'invoicing'),
125
+	'PEN' => __('Peruvian Nuevo Sol', 'invoicing'),
126
+	'PGK' => __('Papua New Guinean Kina', 'invoicing'),
127
+	'PHP' => __('Philippine Peso', 'invoicing'),
128
+	'PKR' => __('Pakistani Rupee', 'invoicing'),
129
+	'PLN' => __('Polish Zloty', 'invoicing'),
130
+	'PRB' => __('Transnistrian Ruble', 'invoicing'),
131
+	'PYG' => __('Paraguayan Guarani', 'invoicing'),
132
+	'QAR' => __('Qatari Riyal', 'invoicing'),
133
+	'RON' => __('Romanian Leu', 'invoicing'),
134
+	'RSD' => __('Serbian Dinar', 'invoicing'),
135
+	'RUB' => __('Russian Ruble', 'invoicing'),
136
+	'RWF' => __('Rwandan Franc', 'invoicing'),
137
+	'SAR' => __('Saudi Riyal', 'invoicing'),
138
+	'SBD' => __('Solomon Islands Dollar', 'invoicing'),
139
+	'SCR' => __('Seychellois Rupee', 'invoicing'),
140
+	'SDG' => __('Sudanese Pound', 'invoicing'),
141
+	'SEK' => __('Swedish Krona', 'invoicing'),
142
+	'SGD' => __('Singapore Dollar', 'invoicing'),
143
+	'SHP' => __('Saint Helena Pound', 'invoicing'),
144
+	'SLL' => __('Sierra Leonean Leone', 'invoicing'),
145
+	'SOS' => __('Somali Shilling', 'invoicing'),
146
+	'SRD' => __('Surinamese Dollar', 'invoicing'),
147
+	'SSP' => __('South Sudanese Pound', 'invoicing'),
148
+	'STD' => __('Sao Tomean Dobra', 'invoicing'),
149
+	'SYP' => __('Syrian Pound', 'invoicing'),
150
+	'SZL' => __('Swazi Lilangeni', 'invoicing'),
151
+	'THB' => __('Thai Baht', 'invoicing'),
152
+	'TJS' => __('Tajikistani Somoni', 'invoicing'),
153
+	'TMT' => __('Turkmenistan Manat', 'invoicing'),
154
+	'TND' => __('Tunisian Dinar', 'invoicing'),
155
+	'TOP' => __('Tongan Pa&#x2bb;anga', 'invoicing'),
156
+	'TRY' => __('Turkish Lira', 'invoicing'),
157
+	'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'),
158
+	'TWD' => __('New Taiwan Dollar', 'invoicing'),
159
+	'TZS' => __('Tanzanian Shilling', 'invoicing'),
160
+	'UAH' => __('Ukrainian Hryvnia', 'invoicing'),
161
+	'UGX' => __('Ugandan Shilling', 'invoicing'),
162
+	'UYU' => __('Uruguayan Peso', 'invoicing'),
163
+	'UZS' => __('Uzbekistani Som', 'invoicing'),
164
+	'VEF' => __('Venezuelan Bol&iacute;var', 'invoicing'),
165
+	'VND' => __('Vietnamese Dong', 'invoicing'),
166
+	'VUV' => __('Vanuatu Vatu', 'invoicing'),
167
+	'WST' => __('Samoan Tala', 'invoicing'),
168
+	'XAF' => __('Central African CFA Franc', 'invoicing'),
169
+	'XCD' => __('East Caribbean Dollar', 'invoicing'),
170
+	'XOF' => __('West African CFA Franc', 'invoicing'),
171
+	'XPF' => __('CFP Franc', 'invoicing'),
172
+	'YER' => __('Yemeni Rial', 'invoicing'),
173
+	'ZAR' => __('South African Rand', 'invoicing'),
174
+	'ZMW' => __('Zambian Kwacha', 'invoicing'),
175 175
 );
Please login to merge, or discard this patch.
includes/api/class-wpinv-rest-items-controller.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -15,172 +15,172 @@
 block discarded – undo
15 15
 class WPInv_REST_Items_Controller extends GetPaid_REST_Posts_Controller {
16 16
 
17 17
     /**
18
-	 * Post type.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	protected $post_type = 'wpi_item';
18
+     * Post type.
19
+     *
20
+     * @var string
21
+     */
22
+    protected $post_type = 'wpi_item';
23 23
 	
24
-	/**
25
-	 * The base of this controller's route.
26
-	 *
27
-	 * @since 1.0.13
28
-	 * @var string
29
-	 */
30
-	protected $rest_base = 'items';
31
-
32
-	/** Contains this controller's class name.
33
-	 *
34
-	 * @var string
35
-	 */
36
-	public $crud_class = 'WPInv_Item';
37
-
38
-	/**
39
-	 * Registers the routes for the objects of the controller.
40
-	 *
41
-	 * @since 1.0.19
42
-	 *
43
-	 * @see register_rest_route()
44
-	 */
45
-	public function register_namespace_routes( $namespace ) {
46
-
47
-		parent::register_namespace_routes( $namespace );
48
-
49
-		register_rest_route(
50
-			$this->namespace,
51
-			'/' . $this->rest_base . '/item-types',
52
-			array(
53
-				array(
54
-					'methods'             => WP_REST_Server::READABLE,
55
-					'callback'            => array( $this, 'get_item_types' ),
56
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
57
-				),
58
-			)
59
-		);
60
-
61
-	}
62
-
63
-	/**
64
-	 * Handles rest requests for item types.
65
-	 *
66
-	 * @since 1.0.13
67
-	 * 
68
-	 * 
69
-	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
70
-	 */
71
-	public function get_item_types() {
72
-		return rest_ensure_response( wpinv_get_item_types() );
73
-	}
24
+    /**
25
+     * The base of this controller's route.
26
+     *
27
+     * @since 1.0.13
28
+     * @var string
29
+     */
30
+    protected $rest_base = 'items';
31
+
32
+    /** Contains this controller's class name.
33
+     *
34
+     * @var string
35
+     */
36
+    public $crud_class = 'WPInv_Item';
37
+
38
+    /**
39
+     * Registers the routes for the objects of the controller.
40
+     *
41
+     * @since 1.0.19
42
+     *
43
+     * @see register_rest_route()
44
+     */
45
+    public function register_namespace_routes( $namespace ) {
46
+
47
+        parent::register_namespace_routes( $namespace );
48
+
49
+        register_rest_route(
50
+            $this->namespace,
51
+            '/' . $this->rest_base . '/item-types',
52
+            array(
53
+                array(
54
+                    'methods'             => WP_REST_Server::READABLE,
55
+                    'callback'            => array( $this, 'get_item_types' ),
56
+                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
57
+                ),
58
+            )
59
+        );
60
+
61
+    }
62
+
63
+    /**
64
+     * Handles rest requests for item types.
65
+     *
66
+     * @since 1.0.13
67
+     * 
68
+     * 
69
+     * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
70
+     */
71
+    public function get_item_types() {
72
+        return rest_ensure_response( wpinv_get_item_types() );
73
+    }
74
+
75
+    /**
76
+     * Retrieves the query params for the items collection.
77
+     *
78
+     * @since 1.0.13
79
+     *
80
+     * @return array Collection parameters.
81
+     */
82
+    public function get_collection_params() {
83
+
84
+        $params = array_merge(
85
+
86
+            parent::get_collection_params(),
87
+
88
+            array(
89
+
90
+                // Item types
91
+                'type'                  => array(
92
+                    'description'       => __( 'Type of items to fetch.', 'invoicing' ),
93
+                    'type'              => array( 'array', 'string' ),
94
+                    'default'           => 'any',
95
+                    'validate_callback' => 'rest_validate_request_arg',
96
+                    'sanitize_callback' => 'wpinv_parse_list',
97
+                    'items'             => array(
98
+                        'enum'          => array_merge( array( 'any' ), wpinv_item_types() ),
99
+                        'type'          => 'string',
100
+                    ),
101
+                ),
102
+
103
+            )
104
+        );
105
+
106
+        // Filter collection parameters for the items controller.
107
+        return apply_filters( 'getpaid_rest_items_collection_params', $params, $this );
108
+
109
+    }
110
+
111
+    /**
112
+     * Determine the allowed query_vars for a get_items() response and
113
+     * prepare for WP_Query.
114
+     *
115
+     * @param array           $prepared_args Prepared arguments.
116
+     * @param WP_REST_Request $request Request object.
117
+     * @return array          $query_args
118
+     */
119
+    protected function prepare_items_query( $prepared_args = array(), $request = null ) {
120
+
121
+        $query_args = parent::prepare_items_query( $prepared_args );
122
+
123
+        // Retrieve items by type.
124
+        if ( ! in_array( 'any', $request['type'] ) ) {
125
+
126
+            if ( empty( $query_args['meta_query'] ) ) {
127
+                $query_args['meta_query'] = array();
128
+            }
129
+
130
+            $query_args['meta_query'][] = array(
131
+                'key'     => '_wpinv_type',
132
+                'value'   => implode( ',', $request['type'] ),
133
+                'compare' => 'IN',
134
+            );
135
+
136
+        }
137
+
138
+        return apply_filters( 'getpaid_rest_items_prepare_items_query', $query_args, $request, $this );
139
+
140
+    }
141
+
142
+    /**
143
+     * Retrieves a valid list of post statuses.
144
+     *
145
+     * @since 1.0.15
146
+     *
147
+     * @return array A list of registered item statuses.
148
+     */
149
+    public function get_post_statuses() {
150
+        return array( 'draft', 'pending', 'publish' );
151
+    }
74 152
 
75 153
     /**
76
-	 * Retrieves the query params for the items collection.
77
-	 *
78
-	 * @since 1.0.13
79
-	 *
80
-	 * @return array Collection parameters.
81
-	 */
82
-	public function get_collection_params() {
83
-
84
-		$params = array_merge(
85
-
86
-			parent::get_collection_params(),
87
-
88
-        	array(
89
-
90
-				// Item types
91
-				'type'                  => array(
92
-					'description'       => __( 'Type of items to fetch.', 'invoicing' ),
93
-					'type'              => array( 'array', 'string' ),
94
-					'default'           => 'any',
95
-					'validate_callback' => 'rest_validate_request_arg',
96
-					'sanitize_callback' => 'wpinv_parse_list',
97
-					'items'             => array(
98
-						'enum'          => array_merge( array( 'any' ), wpinv_item_types() ),
99
-						'type'          => 'string',
100
-					),
101
-				),
102
-
103
-			)
104
-		);
105
-
106
-		// Filter collection parameters for the items controller.
107
-		return apply_filters( 'getpaid_rest_items_collection_params', $params, $this );
108
-
109
-	}
110
-
111
-	/**
112
-	 * Determine the allowed query_vars for a get_items() response and
113
-	 * prepare for WP_Query.
114
-	 *
115
-	 * @param array           $prepared_args Prepared arguments.
116
-	 * @param WP_REST_Request $request Request object.
117
-	 * @return array          $query_args
118
-	 */
119
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
120
-
121
-		$query_args = parent::prepare_items_query( $prepared_args );
122
-
123
-		// Retrieve items by type.
124
-		if ( ! in_array( 'any', $request['type'] ) ) {
125
-
126
-			if ( empty( $query_args['meta_query'] ) ) {
127
-				$query_args['meta_query'] = array();
128
-			}
129
-
130
-			$query_args['meta_query'][] = array(
131
-				'key'     => '_wpinv_type',
132
-				'value'   => implode( ',', $request['type'] ),
133
-				'compare' => 'IN',
134
-			);
135
-
136
-		}
137
-
138
-		return apply_filters( 'getpaid_rest_items_prepare_items_query', $query_args, $request, $this );
139
-
140
-	}
141
-
142
-	/**
143
-	 * Retrieves a valid list of post statuses.
144
-	 *
145
-	 * @since 1.0.15
146
-	 *
147
-	 * @return array A list of registered item statuses.
148
-	 */
149
-	public function get_post_statuses() {
150
-		return array( 'draft', 'pending', 'publish' );
151
-	}
152
-
153
-	/**
154
-	 * Checks if a key should be included in a response.
155
-	 *
156
-	 * @since  1.0.19
157
-	 * @param  WPInv_Item   $item  Item object.
158
-	 * @param  string       $field_key The key to check for.
159
-	 * @return bool
160
-	 */
161
-	public function object_supports_field( $item, $field_key ) {
162
-
163
-		if ( 'minimum_price' == $field_key && ! $item->user_can_set_their_price() ) {
164
-			return false;
165
-		}
166
-
167
-		foreach( wpinv_parse_list( 'initial_price the_initial_price recurring_price the_recurring_price recurring_period recurring_interval recurring_limit is_free_trial trial_period trial_interval first_renewal_date' ) as $key ) {
168
-
169
-			if ( $key == $field_key && ! $item->is_recurring() ) {
170
-				return false;
171
-			}
172
-
173
-		}
174
-
175
-		foreach( wpinv_parse_list( 'trial_period trial_interval' ) as $key ) {
176
-
177
-			if ( $key == $field_key && ! $item->has_free_trial() ) {
178
-				return false;
179
-			}
180
-
181
-		}
154
+     * Checks if a key should be included in a response.
155
+     *
156
+     * @since  1.0.19
157
+     * @param  WPInv_Item   $item  Item object.
158
+     * @param  string       $field_key The key to check for.
159
+     * @return bool
160
+     */
161
+    public function object_supports_field( $item, $field_key ) {
162
+
163
+        if ( 'minimum_price' == $field_key && ! $item->user_can_set_their_price() ) {
164
+            return false;
165
+        }
166
+
167
+        foreach( wpinv_parse_list( 'initial_price the_initial_price recurring_price the_recurring_price recurring_period recurring_interval recurring_limit is_free_trial trial_period trial_interval first_renewal_date' ) as $key ) {
168
+
169
+            if ( $key == $field_key && ! $item->is_recurring() ) {
170
+                return false;
171
+            }
172
+
173
+        }
174
+
175
+        foreach( wpinv_parse_list( 'trial_period trial_interval' ) as $key ) {
176
+
177
+            if ( $key == $field_key && ! $item->has_free_trial() ) {
178
+                return false;
179
+            }
180
+
181
+        }
182 182
 
183
-		return parent::object_supports_field( $item, $field_key );
184
-	}
183
+        return parent::object_supports_field( $item, $field_key );
184
+    }
185 185
 
186 186
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @version 1.0.19
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * REST API items controller class.
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @see register_rest_route()
44 44
 	 */
45
-	public function register_namespace_routes( $namespace ) {
45
+	public function register_namespace_routes($namespace) {
46 46
 
47
-		parent::register_namespace_routes( $namespace );
47
+		parent::register_namespace_routes($namespace);
48 48
 
49 49
 		register_rest_route(
50 50
 			$this->namespace,
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 			array(
53 53
 				array(
54 54
 					'methods'             => WP_REST_Server::READABLE,
55
-					'callback'            => array( $this, 'get_item_types' ),
56
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
55
+					'callback'            => array($this, 'get_item_types'),
56
+					'permission_callback' => array($this, 'get_items_permissions_check'),
57 57
 				),
58 58
 			)
59 59
 		);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
70 70
 	 */
71 71
 	public function get_item_types() {
72
-		return rest_ensure_response( wpinv_get_item_types() );
72
+		return rest_ensure_response(wpinv_get_item_types());
73 73
 	}
74 74
 
75 75
     /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 
90 90
 				// Item types
91 91
 				'type'                  => array(
92
-					'description'       => __( 'Type of items to fetch.', 'invoicing' ),
93
-					'type'              => array( 'array', 'string' ),
92
+					'description'       => __('Type of items to fetch.', 'invoicing'),
93
+					'type'              => array('array', 'string'),
94 94
 					'default'           => 'any',
95 95
 					'validate_callback' => 'rest_validate_request_arg',
96 96
 					'sanitize_callback' => 'wpinv_parse_list',
97 97
 					'items'             => array(
98
-						'enum'          => array_merge( array( 'any' ), wpinv_item_types() ),
98
+						'enum'          => array_merge(array('any'), wpinv_item_types()),
99 99
 						'type'          => 'string',
100 100
 					),
101 101
 				),
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		);
105 105
 
106 106
 		// Filter collection parameters for the items controller.
107
-		return apply_filters( 'getpaid_rest_items_collection_params', $params, $this );
107
+		return apply_filters('getpaid_rest_items_collection_params', $params, $this);
108 108
 
109 109
 	}
110 110
 
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
 	 * @param WP_REST_Request $request Request object.
117 117
 	 * @return array          $query_args
118 118
 	 */
119
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
119
+	protected function prepare_items_query($prepared_args = array(), $request = null) {
120 120
 
121
-		$query_args = parent::prepare_items_query( $prepared_args );
121
+		$query_args = parent::prepare_items_query($prepared_args);
122 122
 
123 123
 		// Retrieve items by type.
124
-		if ( ! in_array( 'any', $request['type'] ) ) {
124
+		if (!in_array('any', $request['type'])) {
125 125
 
126
-			if ( empty( $query_args['meta_query'] ) ) {
126
+			if (empty($query_args['meta_query'])) {
127 127
 				$query_args['meta_query'] = array();
128 128
 			}
129 129
 
130 130
 			$query_args['meta_query'][] = array(
131 131
 				'key'     => '_wpinv_type',
132
-				'value'   => implode( ',', $request['type'] ),
132
+				'value'   => implode(',', $request['type']),
133 133
 				'compare' => 'IN',
134 134
 			);
135 135
 
136 136
 		}
137 137
 
138
-		return apply_filters( 'getpaid_rest_items_prepare_items_query', $query_args, $request, $this );
138
+		return apply_filters('getpaid_rest_items_prepare_items_query', $query_args, $request, $this);
139 139
 
140 140
 	}
141 141
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return array A list of registered item statuses.
148 148
 	 */
149 149
 	public function get_post_statuses() {
150
-		return array( 'draft', 'pending', 'publish' );
150
+		return array('draft', 'pending', 'publish');
151 151
 	}
152 152
 
153 153
 	/**
@@ -158,29 +158,29 @@  discard block
 block discarded – undo
158 158
 	 * @param  string       $field_key The key to check for.
159 159
 	 * @return bool
160 160
 	 */
161
-	public function object_supports_field( $item, $field_key ) {
161
+	public function object_supports_field($item, $field_key) {
162 162
 
163
-		if ( 'minimum_price' == $field_key && ! $item->user_can_set_their_price() ) {
163
+		if ('minimum_price' == $field_key && !$item->user_can_set_their_price()) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		foreach( wpinv_parse_list( 'initial_price the_initial_price recurring_price the_recurring_price recurring_period recurring_interval recurring_limit is_free_trial trial_period trial_interval first_renewal_date' ) as $key ) {
167
+		foreach (wpinv_parse_list('initial_price the_initial_price recurring_price the_recurring_price recurring_period recurring_interval recurring_limit is_free_trial trial_period trial_interval first_renewal_date') as $key) {
168 168
 
169
-			if ( $key == $field_key && ! $item->is_recurring() ) {
169
+			if ($key == $field_key && !$item->is_recurring()) {
170 170
 				return false;
171 171
 			}
172 172
 
173 173
 		}
174 174
 
175
-		foreach( wpinv_parse_list( 'trial_period trial_interval' ) as $key ) {
175
+		foreach (wpinv_parse_list('trial_period trial_interval') as $key) {
176 176
 
177
-			if ( $key == $field_key && ! $item->has_free_trial() ) {
177
+			if ($key == $field_key && !$item->has_free_trial()) {
178 178
 				return false;
179 179
 			}
180 180
 
181 181
 		}
182 182
 
183
-		return parent::object_supports_field( $item, $field_key );
183
+		return parent::object_supports_field($item, $field_key);
184 184
 	}
185 185
 
186 186
 }
Please login to merge, or discard this patch.
includes/api/class-wpinv-rest-discounts-controller.php 2 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -15,138 +15,138 @@
 block discarded – undo
15 15
 class WPInv_REST_Discounts_Controller extends GetPaid_REST_Posts_Controller {
16 16
 
17 17
     /**
18
-	 * Post type.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	protected $post_type = 'wpi_discount';
23
-
24
-	/**
25
-	 * The base of this controller's route.
26
-	 *
27
-	 * @since 1.0.13
28
-	 * @var string
29
-	 */
30
-	protected $rest_base = 'discounts';
31
-
32
-	/** Contains this controller's class name.
33
-	 *
34
-	 * @var string
35
-	 */
36
-	public $crud_class = 'WPInv_Discount';
37
-
38
-	/**
39
-	 * Registers the routes for the objects of the controller.
40
-	 *
41
-	 * @since 1.0.19
42
-	 *
43
-	 * @see register_rest_route()
44
-	 */
45
-	public function register_namespace_routes( $namespace ) {
46
-
47
-		parent::register_namespace_routes( $namespace );
48
-
49
-		register_rest_route(
50
-			$this->namespace,
51
-			'/' . $this->rest_base . '/discount-types',
52
-			array(
53
-				array(
54
-					'methods'             => WP_REST_Server::READABLE,
55
-					'callback'            => array( $this, 'get_discount_types' ),
56
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
57
-				),
58
-			)
59
-		);
60
-
61
-	}
62
-
63
-	/**
64
-	 * Handles rest requests for discount types.
65
-	 *
66
-	 * @since 1.0.13
67
-	 *
68
-	 *
69
-	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
70
-	 */
71
-	public function get_discount_types() {
72
-		return rest_ensure_response( wpinv_get_discount_types() );
73
-	}
18
+     * Post type.
19
+     *
20
+     * @var string
21
+     */
22
+    protected $post_type = 'wpi_discount';
74 23
 
75 24
     /**
76
-	 * Retrieves the query params for the discount collection.
77
-	 *
78
-	 * @since 1.0.13
79
-	 *
80
-	 * @return array Collection parameters.
81
-	 */
82
-	public function get_collection_params() {
83
-
84
-		$params = array_merge(
85
-
86
-			parent::get_collection_params(),
87
-
88
-        	array(
89
-
90
-				// Discount types
91
-				'type'                  => array(
92
-					'description'       => __( 'Type of discounts to fetch.', 'invoicing' ),
93
-					'type'              => array( 'array', 'string' ),
94
-					'default'           => 'any',
95
-					'validate_callback' => 'rest_validate_request_arg',
96
-					'sanitize_callback' => 'wpinv_parse_list',
97
-					'items'             => array(
98
-						'enum'          => array_merge( array( 'any' ), array_keys( wpinv_get_discount_types() ) ),
99
-						'type'          => 'string',
100
-					),
101
-				),
102
-
103
-			)
104
-		);
105
-
106
-		// Filter collection parameters for the discounts controller.
107
-		return apply_filters( 'getpaid_rest_discounts_collection_params', $params, $this );
108
-	}
109
-
110
-	/**
111
-	 * Determine the allowed query_vars for a get_items() response and
112
-	 * prepare for WP_Query.
113
-	 *
114
-	 * @param array           $prepared_args Prepared arguments.
115
-	 * @param WP_REST_Request $request Request object.
116
-	 * @return array          $query_args
117
-	 */
118
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
119
-
120
-		$query_args = parent::prepare_items_query( $prepared_args );
121
-
122
-		// Retrieve items by type.
123
-		if ( ! in_array( 'any', $request['type'] ) ) {
124
-
125
-			if ( empty( $query_args['meta_query'] ) ) {
126
-				$query_args['meta_query'] = array();
127
-			}
128
-
129
-			$query_args['meta_query'][] = array(
130
-				'key'     => '_wpi_discount_type',
131
-				'value'   => implode( ',', $request['type'] ),
132
-				'compare' => 'IN',
133
-			);
134
-
135
-		}
136
-
137
-		return apply_filters( 'getpaid_rest_discounts_prepare_items_query', $query_args, $request, $this );
138
-
139
-	}
140
-
141
-	/**
142
-	 * Retrieves a valid list of post statuses.
143
-	 *
144
-	 * @since 1.0.15
145
-	 *
146
-	 * @return array A list of registered item statuses.
147
-	 */
148
-	public function get_post_statuses() {
149
-		return array( 'publish', 'pending', 'draft', 'expired' );
150
-	}
25
+     * The base of this controller's route.
26
+     *
27
+     * @since 1.0.13
28
+     * @var string
29
+     */
30
+    protected $rest_base = 'discounts';
31
+
32
+    /** Contains this controller's class name.
33
+     *
34
+     * @var string
35
+     */
36
+    public $crud_class = 'WPInv_Discount';
37
+
38
+    /**
39
+     * Registers the routes for the objects of the controller.
40
+     *
41
+     * @since 1.0.19
42
+     *
43
+     * @see register_rest_route()
44
+     */
45
+    public function register_namespace_routes( $namespace ) {
46
+
47
+        parent::register_namespace_routes( $namespace );
48
+
49
+        register_rest_route(
50
+            $this->namespace,
51
+            '/' . $this->rest_base . '/discount-types',
52
+            array(
53
+                array(
54
+                    'methods'             => WP_REST_Server::READABLE,
55
+                    'callback'            => array( $this, 'get_discount_types' ),
56
+                    'permission_callback' => array( $this, 'get_items_permissions_check' ),
57
+                ),
58
+            )
59
+        );
60
+
61
+    }
62
+
63
+    /**
64
+     * Handles rest requests for discount types.
65
+     *
66
+     * @since 1.0.13
67
+     *
68
+     *
69
+     * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
70
+     */
71
+    public function get_discount_types() {
72
+        return rest_ensure_response( wpinv_get_discount_types() );
73
+    }
74
+
75
+    /**
76
+     * Retrieves the query params for the discount collection.
77
+     *
78
+     * @since 1.0.13
79
+     *
80
+     * @return array Collection parameters.
81
+     */
82
+    public function get_collection_params() {
83
+
84
+        $params = array_merge(
85
+
86
+            parent::get_collection_params(),
87
+
88
+            array(
89
+
90
+                // Discount types
91
+                'type'                  => array(
92
+                    'description'       => __( 'Type of discounts to fetch.', 'invoicing' ),
93
+                    'type'              => array( 'array', 'string' ),
94
+                    'default'           => 'any',
95
+                    'validate_callback' => 'rest_validate_request_arg',
96
+                    'sanitize_callback' => 'wpinv_parse_list',
97
+                    'items'             => array(
98
+                        'enum'          => array_merge( array( 'any' ), array_keys( wpinv_get_discount_types() ) ),
99
+                        'type'          => 'string',
100
+                    ),
101
+                ),
102
+
103
+            )
104
+        );
105
+
106
+        // Filter collection parameters for the discounts controller.
107
+        return apply_filters( 'getpaid_rest_discounts_collection_params', $params, $this );
108
+    }
109
+
110
+    /**
111
+     * Determine the allowed query_vars for a get_items() response and
112
+     * prepare for WP_Query.
113
+     *
114
+     * @param array           $prepared_args Prepared arguments.
115
+     * @param WP_REST_Request $request Request object.
116
+     * @return array          $query_args
117
+     */
118
+    protected function prepare_items_query( $prepared_args = array(), $request = null ) {
119
+
120
+        $query_args = parent::prepare_items_query( $prepared_args );
121
+
122
+        // Retrieve items by type.
123
+        if ( ! in_array( 'any', $request['type'] ) ) {
124
+
125
+            if ( empty( $query_args['meta_query'] ) ) {
126
+                $query_args['meta_query'] = array();
127
+            }
128
+
129
+            $query_args['meta_query'][] = array(
130
+                'key'     => '_wpi_discount_type',
131
+                'value'   => implode( ',', $request['type'] ),
132
+                'compare' => 'IN',
133
+            );
134
+
135
+        }
136
+
137
+        return apply_filters( 'getpaid_rest_discounts_prepare_items_query', $query_args, $request, $this );
138
+
139
+    }
140
+
141
+    /**
142
+     * Retrieves a valid list of post statuses.
143
+     *
144
+     * @since 1.0.15
145
+     *
146
+     * @return array A list of registered item statuses.
147
+     */
148
+    public function get_post_statuses() {
149
+        return array( 'publish', 'pending', 'draft', 'expired' );
150
+    }
151 151
 
152 152
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @version 1.0.19
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * REST API discounts controller class.
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @see register_rest_route()
44 44
 	 */
45
-	public function register_namespace_routes( $namespace ) {
45
+	public function register_namespace_routes($namespace) {
46 46
 
47
-		parent::register_namespace_routes( $namespace );
47
+		parent::register_namespace_routes($namespace);
48 48
 
49 49
 		register_rest_route(
50 50
 			$this->namespace,
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 			array(
53 53
 				array(
54 54
 					'methods'             => WP_REST_Server::READABLE,
55
-					'callback'            => array( $this, 'get_discount_types' ),
56
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
55
+					'callback'            => array($this, 'get_discount_types'),
56
+					'permission_callback' => array($this, 'get_items_permissions_check'),
57 57
 				),
58 58
 			)
59 59
 		);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
70 70
 	 */
71 71
 	public function get_discount_types() {
72
-		return rest_ensure_response( wpinv_get_discount_types() );
72
+		return rest_ensure_response(wpinv_get_discount_types());
73 73
 	}
74 74
 
75 75
     /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 
90 90
 				// Discount types
91 91
 				'type'                  => array(
92
-					'description'       => __( 'Type of discounts to fetch.', 'invoicing' ),
93
-					'type'              => array( 'array', 'string' ),
92
+					'description'       => __('Type of discounts to fetch.', 'invoicing'),
93
+					'type'              => array('array', 'string'),
94 94
 					'default'           => 'any',
95 95
 					'validate_callback' => 'rest_validate_request_arg',
96 96
 					'sanitize_callback' => 'wpinv_parse_list',
97 97
 					'items'             => array(
98
-						'enum'          => array_merge( array( 'any' ), array_keys( wpinv_get_discount_types() ) ),
98
+						'enum'          => array_merge(array('any'), array_keys(wpinv_get_discount_types())),
99 99
 						'type'          => 'string',
100 100
 					),
101 101
 				),
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		);
105 105
 
106 106
 		// Filter collection parameters for the discounts controller.
107
-		return apply_filters( 'getpaid_rest_discounts_collection_params', $params, $this );
107
+		return apply_filters('getpaid_rest_discounts_collection_params', $params, $this);
108 108
 	}
109 109
 
110 110
 	/**
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
 	 * @param WP_REST_Request $request Request object.
116 116
 	 * @return array          $query_args
117 117
 	 */
118
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
118
+	protected function prepare_items_query($prepared_args = array(), $request = null) {
119 119
 
120
-		$query_args = parent::prepare_items_query( $prepared_args );
120
+		$query_args = parent::prepare_items_query($prepared_args);
121 121
 
122 122
 		// Retrieve items by type.
123
-		if ( ! in_array( 'any', $request['type'] ) ) {
123
+		if (!in_array('any', $request['type'])) {
124 124
 
125
-			if ( empty( $query_args['meta_query'] ) ) {
125
+			if (empty($query_args['meta_query'])) {
126 126
 				$query_args['meta_query'] = array();
127 127
 			}
128 128
 
129 129
 			$query_args['meta_query'][] = array(
130 130
 				'key'     => '_wpi_discount_type',
131
-				'value'   => implode( ',', $request['type'] ),
131
+				'value'   => implode(',', $request['type']),
132 132
 				'compare' => 'IN',
133 133
 			);
134 134
 
135 135
 		}
136 136
 
137
-		return apply_filters( 'getpaid_rest_discounts_prepare_items_query', $query_args, $request, $this );
137
+		return apply_filters('getpaid_rest_discounts_prepare_items_query', $query_args, $request, $this);
138 138
 
139 139
 	}
140 140
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @return array A list of registered item statuses.
147 147
 	 */
148 148
 	public function get_post_statuses() {
149
-		return array( 'publish', 'pending', 'draft', 'expired' );
149
+		return array('publish', 'pending', 'draft', 'expired');
150 150
 	}
151 151
 
152 152
 }
Please login to merge, or discard this patch.
includes/data/discount-schema.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -13,168 +13,168 @@
 block discarded – undo
13 13
 
14 14
 return array(
15 15
 
16
-	'id'              => array(
17
-		'description' => __( 'Unique identifier for the discount.', 'invoicing' ),
18
-		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
20
-		'readonly'    => true,
21
-	),
22
-
23
-	'status'          => array(
24
-		'description' => __( 'A named status for the discount.', 'invoicing' ),
25
-		'type'        => 'string',
26
-		'enum'        => array( 'publish', 'pending', 'draft', 'expired' ),
27
-		'default'     => 'draft',
28
-		'context'     => array( 'view', 'edit', 'embed' ),
29
-	),
30
-
31
-	'version'         => array(
32
-		'description' => __( 'Plugin version when the discount was created.', 'invoicing' ),
33
-		'type'        => 'string',
34
-		'context'     => array( 'view', 'edit', 'embed' ),
35
-		'readonly'    => true,
36
-	),
37
-
38
-	'date_created'    => array(
39
-		'description' => __( "The date the discount was created, in the site's timezone.", 'invoicing' ),
40
-		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit', 'embed' ),
42
-	),
43
-
44
-	'date_created_gmt'    => array(
45
-		'description' => __( 'The GMT date the discount was created.', 'invoicing' ),
46
-		'type'        => 'string',
47
-		'context'     => array( 'view', 'edit', 'embed' ),
48
-		'readonly'    => true,
49
-	),
50
-
51
-	'date_modified'   => array(
52
-		'description' => __( "The date the discount was last modified, in the site's timezone.", 'invoicing' ),
53
-		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
55
-		'readonly'    => true,
56
-	),
57
-
58
-	'date_modified_gmt'    => array(
59
-		'description' => __( 'The GMT date the discount was last modified.', 'invoicing' ),
60
-		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
62
-		'readonly'    => true,
63
-	),
64
-
65
-	'name'			  => array(
66
-		'description' => __( 'The discount name.', 'invoicing' ),
67
-		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
69
-	),
70
-
71
-	'description'     => array(
72
-		'description' => __( 'A description of what the discount is all about.', 'invoicing' ),
73
-		'type'        => 'string',
74
-		'context'     => array( 'view', 'edit', 'embed' ),
75
-	),
76
-
77
-	'code'            => array(
78
-		'description' => __( 'The discount code.', 'invoicing' ),
79
-		'type'        => 'string',
80
-		'context'     => array( 'view', 'edit', 'embed' ),
81
-		'required'	  => true,
82
-	),
83
-
84
-	'type'            => array(
85
-		'description' => __( 'The type of discount.', 'invoicing' ),
86
-		'type'        => 'string',
87
-		'enum'        => array_keys( wpinv_get_discount_types() ),
88
-		'context'     => array( 'view', 'edit', 'embed' ),
89
-		'default'	  => 'percent',
90
-	),
91
-
92
-	'amount'        => array(
93
-		'description' => __( 'The discount value.', 'invoicing' ),
94
-		'type'        => 'number',
95
-		'context'     => array( 'view', 'edit', 'embed' ),
96
-		'required'	  => true,
97
-	),
98
-
99
-	'formatted_amount'        => array(
100
-		'description' => __( 'The formatted discount value.', 'invoicing' ),
101
-		'type'        => 'string',
102
-		'context'     => array( 'view', 'edit', 'embed' ),
103
-		'readonly'    => true,
104
-	),
105
-
106
-	'uses'            => array(
107
-		'description' => __( 'The number of times the discount has been used.', 'invoicing' ),
108
-		'type'        => 'integer',
109
-		'context'     => array( 'view', 'embed' ),
110
-		'readonly'    => true,
111
-	),
112
-
113
-	'max_uses'        => array(
114
-		'description' => __( 'The maximum number of times the discount can be used.', 'invoicing' ),
115
-		'type'        => 'integer',
116
-		'context'     => array( 'view', 'edit' ),
117
-	),
118
-
119
-	'usage'           => array(
120
-		'description' => __( "The discount's usage, i.e uses / max uses.", 'invoicing' ),
121
-		'type'        => 'string',
122
-		'context'     => array( 'view', 'embed' ),
123
-		'readonly'    => true,
124
-	),
125
-
126
-	'is_single_use'   => array(
127
-		'description' => __( 'Whether or not the discount can only be used once per user.', 'invoicing' ),
128
-		'type'        => 'boolean',
129
-		'context'     => array( 'view', 'edit' ),
130
-	),
131
-
132
-	'is_recurring'   => array(
133
-		'description' => __( 'Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing' ),
134
-		'type'        => 'boolean',
135
-		'context'     => array( 'view', 'edit' ),
136
-	),
137
-
138
-	'start_date'      => array(
139
-		'description' => __( 'The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing' ),
140
-		'type'        => 'string',
141
-		'context'     => array( 'view', 'edit' ),
142
-	),
143
-
144
-	'end_date'        => array(
145
-		'description' => __( 'The expiration date for the discount.', 'invoicing' ),
146
-		'type'        => 'string',
147
-		'context'     => array( 'view', 'edit' ),
148
-	),
149
-
150
-	'allowed_items'   => array(
151
-		'description' => __( 'Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing' ),
152
-		'type'        => 'array',
153
-		'context'     => array( 'view', 'edit' ),
154
-		'items'       => array(
155
-			'type'    => 'integer'
156
-		)
157
-	),
158
-
159
-	'excluded_items'  => array(
160
-		'description' => __( 'Items which are NOT allowed to use this discount.', 'invoicing' ),
161
-		'type'        => 'array',
162
-		'context'     => array( 'view', 'edit' ),
163
-		'items'       => array(
164
-			'type'    => 'integer'
165
-		)
166
-	),
16
+    'id'              => array(
17
+        'description' => __( 'Unique identifier for the discount.', 'invoicing' ),
18
+        'type'        => 'integer',
19
+        'context'     => array( 'view', 'edit', 'embed' ),
20
+        'readonly'    => true,
21
+    ),
22
+
23
+    'status'          => array(
24
+        'description' => __( 'A named status for the discount.', 'invoicing' ),
25
+        'type'        => 'string',
26
+        'enum'        => array( 'publish', 'pending', 'draft', 'expired' ),
27
+        'default'     => 'draft',
28
+        'context'     => array( 'view', 'edit', 'embed' ),
29
+    ),
30
+
31
+    'version'         => array(
32
+        'description' => __( 'Plugin version when the discount was created.', 'invoicing' ),
33
+        'type'        => 'string',
34
+        'context'     => array( 'view', 'edit', 'embed' ),
35
+        'readonly'    => true,
36
+    ),
37
+
38
+    'date_created'    => array(
39
+        'description' => __( "The date the discount was created, in the site's timezone.", 'invoicing' ),
40
+        'type'        => 'string',
41
+        'context'     => array( 'view', 'edit', 'embed' ),
42
+    ),
43
+
44
+    'date_created_gmt'    => array(
45
+        'description' => __( 'The GMT date the discount was created.', 'invoicing' ),
46
+        'type'        => 'string',
47
+        'context'     => array( 'view', 'edit', 'embed' ),
48
+        'readonly'    => true,
49
+    ),
50
+
51
+    'date_modified'   => array(
52
+        'description' => __( "The date the discount was last modified, in the site's timezone.", 'invoicing' ),
53
+        'type'        => 'string',
54
+        'context'     => array( 'view', 'edit', 'embed' ),
55
+        'readonly'    => true,
56
+    ),
57
+
58
+    'date_modified_gmt'    => array(
59
+        'description' => __( 'The GMT date the discount was last modified.', 'invoicing' ),
60
+        'type'        => 'string',
61
+        'context'     => array( 'view', 'edit', 'embed' ),
62
+        'readonly'    => true,
63
+    ),
64
+
65
+    'name'			  => array(
66
+        'description' => __( 'The discount name.', 'invoicing' ),
67
+        'type'        => 'string',
68
+        'context'     => array( 'view', 'edit', 'embed' ),
69
+    ),
70
+
71
+    'description'     => array(
72
+        'description' => __( 'A description of what the discount is all about.', 'invoicing' ),
73
+        'type'        => 'string',
74
+        'context'     => array( 'view', 'edit', 'embed' ),
75
+    ),
76
+
77
+    'code'            => array(
78
+        'description' => __( 'The discount code.', 'invoicing' ),
79
+        'type'        => 'string',
80
+        'context'     => array( 'view', 'edit', 'embed' ),
81
+        'required'	  => true,
82
+    ),
83
+
84
+    'type'            => array(
85
+        'description' => __( 'The type of discount.', 'invoicing' ),
86
+        'type'        => 'string',
87
+        'enum'        => array_keys( wpinv_get_discount_types() ),
88
+        'context'     => array( 'view', 'edit', 'embed' ),
89
+        'default'	  => 'percent',
90
+    ),
91
+
92
+    'amount'        => array(
93
+        'description' => __( 'The discount value.', 'invoicing' ),
94
+        'type'        => 'number',
95
+        'context'     => array( 'view', 'edit', 'embed' ),
96
+        'required'	  => true,
97
+    ),
98
+
99
+    'formatted_amount'        => array(
100
+        'description' => __( 'The formatted discount value.', 'invoicing' ),
101
+        'type'        => 'string',
102
+        'context'     => array( 'view', 'edit', 'embed' ),
103
+        'readonly'    => true,
104
+    ),
105
+
106
+    'uses'            => array(
107
+        'description' => __( 'The number of times the discount has been used.', 'invoicing' ),
108
+        'type'        => 'integer',
109
+        'context'     => array( 'view', 'embed' ),
110
+        'readonly'    => true,
111
+    ),
112
+
113
+    'max_uses'        => array(
114
+        'description' => __( 'The maximum number of times the discount can be used.', 'invoicing' ),
115
+        'type'        => 'integer',
116
+        'context'     => array( 'view', 'edit' ),
117
+    ),
118
+
119
+    'usage'           => array(
120
+        'description' => __( "The discount's usage, i.e uses / max uses.", 'invoicing' ),
121
+        'type'        => 'string',
122
+        'context'     => array( 'view', 'embed' ),
123
+        'readonly'    => true,
124
+    ),
125
+
126
+    'is_single_use'   => array(
127
+        'description' => __( 'Whether or not the discount can only be used once per user.', 'invoicing' ),
128
+        'type'        => 'boolean',
129
+        'context'     => array( 'view', 'edit' ),
130
+    ),
131
+
132
+    'is_recurring'   => array(
133
+        'description' => __( 'Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing' ),
134
+        'type'        => 'boolean',
135
+        'context'     => array( 'view', 'edit' ),
136
+    ),
137
+
138
+    'start_date'      => array(
139
+        'description' => __( 'The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing' ),
140
+        'type'        => 'string',
141
+        'context'     => array( 'view', 'edit' ),
142
+    ),
143
+
144
+    'end_date'        => array(
145
+        'description' => __( 'The expiration date for the discount.', 'invoicing' ),
146
+        'type'        => 'string',
147
+        'context'     => array( 'view', 'edit' ),
148
+    ),
149
+
150
+    'allowed_items'   => array(
151
+        'description' => __( 'Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing' ),
152
+        'type'        => 'array',
153
+        'context'     => array( 'view', 'edit' ),
154
+        'items'       => array(
155
+            'type'    => 'integer'
156
+        )
157
+    ),
158
+
159
+    'excluded_items'  => array(
160
+        'description' => __( 'Items which are NOT allowed to use this discount.', 'invoicing' ),
161
+        'type'        => 'array',
162
+        'context'     => array( 'view', 'edit' ),
163
+        'items'       => array(
164
+            'type'    => 'integer'
165
+        )
166
+    ),
167 167
 	
168
-	'minimum_total'   => array(
169
-		'description' => __( 'The minimum total needed to use this invoice.', 'invoicing' ),
170
-		'type'        => 'number',
171
-		'context'     => array( 'view', 'edit' ),
172
-	),
173
-
174
-	'maximum_total'   => array(
175
-		'description' => __( 'The maximum total needed to use this invoice.', 'invoicing' ),
176
-		'type'        => 'number',
177
-		'context'     => array( 'view', 'edit' ),
178
-	),
168
+    'minimum_total'   => array(
169
+        'description' => __( 'The minimum total needed to use this invoice.', 'invoicing' ),
170
+        'type'        => 'number',
171
+        'context'     => array( 'view', 'edit' ),
172
+    ),
173
+
174
+    'maximum_total'   => array(
175
+        'description' => __( 'The maximum total needed to use this invoice.', 'invoicing' ),
176
+        'type'        => 'number',
177
+        'context'     => array( 'view', 'edit' ),
178
+    ),
179 179
 
180 180
 );
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -9,172 +9,172 @@
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
 	'id'              => array(
17
-		'description' => __( 'Unique identifier for the discount.', 'invoicing' ),
17
+		'description' => __('Unique identifier for the discount.', 'invoicing'),
18 18
 		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
19
+		'context'     => array('view', 'edit', 'embed'),
20 20
 		'readonly'    => true,
21 21
 	),
22 22
 
23 23
 	'status'          => array(
24
-		'description' => __( 'A named status for the discount.', 'invoicing' ),
24
+		'description' => __('A named status for the discount.', 'invoicing'),
25 25
 		'type'        => 'string',
26
-		'enum'        => array( 'publish', 'pending', 'draft', 'expired' ),
26
+		'enum'        => array('publish', 'pending', 'draft', 'expired'),
27 27
 		'default'     => 'draft',
28
-		'context'     => array( 'view', 'edit', 'embed' ),
28
+		'context'     => array('view', 'edit', 'embed'),
29 29
 	),
30 30
 
31 31
 	'version'         => array(
32
-		'description' => __( 'Plugin version when the discount was created.', 'invoicing' ),
32
+		'description' => __('Plugin version when the discount was created.', 'invoicing'),
33 33
 		'type'        => 'string',
34
-		'context'     => array( 'view', 'edit', 'embed' ),
34
+		'context'     => array('view', 'edit', 'embed'),
35 35
 		'readonly'    => true,
36 36
 	),
37 37
 
38 38
 	'date_created'    => array(
39
-		'description' => __( "The date the discount was created, in the site's timezone.", 'invoicing' ),
39
+		'description' => __("The date the discount was created, in the site's timezone.", 'invoicing'),
40 40
 		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit', 'embed' ),
41
+		'context'     => array('view', 'edit', 'embed'),
42 42
 	),
43 43
 
44 44
 	'date_created_gmt'    => array(
45
-		'description' => __( 'The GMT date the discount was created.', 'invoicing' ),
45
+		'description' => __('The GMT date the discount was created.', 'invoicing'),
46 46
 		'type'        => 'string',
47
-		'context'     => array( 'view', 'edit', 'embed' ),
47
+		'context'     => array('view', 'edit', 'embed'),
48 48
 		'readonly'    => true,
49 49
 	),
50 50
 
51 51
 	'date_modified'   => array(
52
-		'description' => __( "The date the discount was last modified, in the site's timezone.", 'invoicing' ),
52
+		'description' => __("The date the discount was last modified, in the site's timezone.", 'invoicing'),
53 53
 		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
54
+		'context'     => array('view', 'edit', 'embed'),
55 55
 		'readonly'    => true,
56 56
 	),
57 57
 
58 58
 	'date_modified_gmt'    => array(
59
-		'description' => __( 'The GMT date the discount was last modified.', 'invoicing' ),
59
+		'description' => __('The GMT date the discount was last modified.', 'invoicing'),
60 60
 		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
61
+		'context'     => array('view', 'edit', 'embed'),
62 62
 		'readonly'    => true,
63 63
 	),
64 64
 
65 65
 	'name'			  => array(
66
-		'description' => __( 'The discount name.', 'invoicing' ),
66
+		'description' => __('The discount name.', 'invoicing'),
67 67
 		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
68
+		'context'     => array('view', 'edit', 'embed'),
69 69
 	),
70 70
 
71 71
 	'description'     => array(
72
-		'description' => __( 'A description of what the discount is all about.', 'invoicing' ),
72
+		'description' => __('A description of what the discount is all about.', 'invoicing'),
73 73
 		'type'        => 'string',
74
-		'context'     => array( 'view', 'edit', 'embed' ),
74
+		'context'     => array('view', 'edit', 'embed'),
75 75
 	),
76 76
 
77 77
 	'code'            => array(
78
-		'description' => __( 'The discount code.', 'invoicing' ),
78
+		'description' => __('The discount code.', 'invoicing'),
79 79
 		'type'        => 'string',
80
-		'context'     => array( 'view', 'edit', 'embed' ),
80
+		'context'     => array('view', 'edit', 'embed'),
81 81
 		'required'	  => true,
82 82
 	),
83 83
 
84 84
 	'type'            => array(
85
-		'description' => __( 'The type of discount.', 'invoicing' ),
85
+		'description' => __('The type of discount.', 'invoicing'),
86 86
 		'type'        => 'string',
87
-		'enum'        => array_keys( wpinv_get_discount_types() ),
88
-		'context'     => array( 'view', 'edit', 'embed' ),
87
+		'enum'        => array_keys(wpinv_get_discount_types()),
88
+		'context'     => array('view', 'edit', 'embed'),
89 89
 		'default'	  => 'percent',
90 90
 	),
91 91
 
92 92
 	'amount'        => array(
93
-		'description' => __( 'The discount value.', 'invoicing' ),
93
+		'description' => __('The discount value.', 'invoicing'),
94 94
 		'type'        => 'number',
95
-		'context'     => array( 'view', 'edit', 'embed' ),
95
+		'context'     => array('view', 'edit', 'embed'),
96 96
 		'required'	  => true,
97 97
 	),
98 98
 
99 99
 	'formatted_amount'        => array(
100
-		'description' => __( 'The formatted discount value.', 'invoicing' ),
100
+		'description' => __('The formatted discount value.', 'invoicing'),
101 101
 		'type'        => 'string',
102
-		'context'     => array( 'view', 'edit', 'embed' ),
102
+		'context'     => array('view', 'edit', 'embed'),
103 103
 		'readonly'    => true,
104 104
 	),
105 105
 
106 106
 	'uses'            => array(
107
-		'description' => __( 'The number of times the discount has been used.', 'invoicing' ),
107
+		'description' => __('The number of times the discount has been used.', 'invoicing'),
108 108
 		'type'        => 'integer',
109
-		'context'     => array( 'view', 'embed' ),
109
+		'context'     => array('view', 'embed'),
110 110
 		'readonly'    => true,
111 111
 	),
112 112
 
113 113
 	'max_uses'        => array(
114
-		'description' => __( 'The maximum number of times the discount can be used.', 'invoicing' ),
114
+		'description' => __('The maximum number of times the discount can be used.', 'invoicing'),
115 115
 		'type'        => 'integer',
116
-		'context'     => array( 'view', 'edit' ),
116
+		'context'     => array('view', 'edit'),
117 117
 	),
118 118
 
119 119
 	'usage'           => array(
120
-		'description' => __( "The discount's usage, i.e uses / max uses.", 'invoicing' ),
120
+		'description' => __("The discount's usage, i.e uses / max uses.", 'invoicing'),
121 121
 		'type'        => 'string',
122
-		'context'     => array( 'view', 'embed' ),
122
+		'context'     => array('view', 'embed'),
123 123
 		'readonly'    => true,
124 124
 	),
125 125
 
126 126
 	'is_single_use'   => array(
127
-		'description' => __( 'Whether or not the discount can only be used once per user.', 'invoicing' ),
127
+		'description' => __('Whether or not the discount can only be used once per user.', 'invoicing'),
128 128
 		'type'        => 'boolean',
129
-		'context'     => array( 'view', 'edit' ),
129
+		'context'     => array('view', 'edit'),
130 130
 	),
131 131
 
132 132
 	'is_recurring'   => array(
133
-		'description' => __( 'Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing' ),
133
+		'description' => __('Whether or not the discount applies to the initial payment only or all recurring payments.', 'invoicing'),
134 134
 		'type'        => 'boolean',
135
-		'context'     => array( 'view', 'edit' ),
135
+		'context'     => array('view', 'edit'),
136 136
 	),
137 137
 
138 138
 	'start_date'      => array(
139
-		'description' => __( 'The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing' ),
139
+		'description' => __('The start date for the discount in the format of yyyy-mm-dd hh:mm:ss. If provided, the discount can only be used after or on this date.', 'invoicing'),
140 140
 		'type'        => 'string',
141
-		'context'     => array( 'view', 'edit' ),
141
+		'context'     => array('view', 'edit'),
142 142
 	),
143 143
 
144 144
 	'end_date'        => array(
145
-		'description' => __( 'The expiration date for the discount.', 'invoicing' ),
145
+		'description' => __('The expiration date for the discount.', 'invoicing'),
146 146
 		'type'        => 'string',
147
-		'context'     => array( 'view', 'edit' ),
147
+		'context'     => array('view', 'edit'),
148 148
 	),
149 149
 
150 150
 	'allowed_items'   => array(
151
-		'description' => __( 'Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing' ),
151
+		'description' => __('Items which are allowed to use this discount. Leave blank to enable for all items.', 'invoicing'),
152 152
 		'type'        => 'array',
153
-		'context'     => array( 'view', 'edit' ),
153
+		'context'     => array('view', 'edit'),
154 154
 		'items'       => array(
155 155
 			'type'    => 'integer'
156 156
 		)
157 157
 	),
158 158
 
159 159
 	'excluded_items'  => array(
160
-		'description' => __( 'Items which are NOT allowed to use this discount.', 'invoicing' ),
160
+		'description' => __('Items which are NOT allowed to use this discount.', 'invoicing'),
161 161
 		'type'        => 'array',
162
-		'context'     => array( 'view', 'edit' ),
162
+		'context'     => array('view', 'edit'),
163 163
 		'items'       => array(
164 164
 			'type'    => 'integer'
165 165
 		)
166 166
 	),
167 167
 	
168 168
 	'minimum_total'   => array(
169
-		'description' => __( 'The minimum total needed to use this invoice.', 'invoicing' ),
169
+		'description' => __('The minimum total needed to use this invoice.', 'invoicing'),
170 170
 		'type'        => 'number',
171
-		'context'     => array( 'view', 'edit' ),
171
+		'context'     => array('view', 'edit'),
172 172
 	),
173 173
 
174 174
 	'maximum_total'   => array(
175
-		'description' => __( 'The maximum total needed to use this invoice.', 'invoicing' ),
175
+		'description' => __('The maximum total needed to use this invoice.', 'invoicing'),
176 176
 		'type'        => 'number',
177
-		'context'     => array( 'view', 'edit' ),
177
+		'context'     => array('view', 'edit'),
178 178
 	),
179 179
 
180 180
 );
Please login to merge, or discard this patch.
uninstall.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 global $wpdb;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3
+if (!defined('WP_UNINSTALL_PLUGIN')) {
4 4
 	exit;
5 5
 }
6 6
 
7 7
 global $wpdb;
8 8
 
9
-if ( get_option( 'wpinv_remove_data_on_invoice_unistall' ) ) {
9
+if (get_option('wpinv_remove_data_on_invoice_unistall')) {
10 10
 
11 11
     // Fetch settings.
12
-    $settings = get_option( 'wpinv_settings' );
12
+    $settings = get_option('wpinv_settings');
13 13
 
14 14
     // Delete pages.
15
-    $pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' );
16
-    foreach ( $pages as $page ) {
17
-        if ( is_array( $settings ) && ! empty( $settings[ $page ] ) ) {
18
-            wp_delete_post( $settings[ $page ], true );
15
+    $pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page');
16
+    foreach ($pages as $page) {
17
+        if (is_array($settings) && !empty($settings[$page])) {
18
+            wp_delete_post($settings[$page], true);
19 19
         }
20 20
     }
21 21
 
22 22
     // Delete options.
23
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv\_%';" );
23
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv\_%';");
24 24
 
25 25
     // Delete posts.
26 26
     $wpdb->query(
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
     );
50 50
 
51 51
     // Cleanup Cron Schedule
52
-    wp_clear_scheduled_hook( 'wp_session_garbage_collection' );
53
-    wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
54
-    wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
52
+    wp_clear_scheduled_hook('wp_session_garbage_collection');
53
+    wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
54
+    wp_clear_scheduled_hook('wpinv_register_schedule_event_daily');
55 55
 
56 56
     // Clear any cached data that has been removed
57 57
     wp_cache_flush();
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
         "{$wpdb->prefix}getpaid_invoice_items",
64 64
     );
65 65
 
66
-    foreach ( $tables as $table ) {
67
-        $wpdb->query( "DROP TABLE IF EXISTS {$table}" );
66
+    foreach ($tables as $table) {
67
+        $wpdb->query("DROP TABLE IF EXISTS {$table}");
68 68
     }
69 69
 
70 70
 }
Please login to merge, or discard this patch.
includes/api/class-getpaid-rest-controller.php 2 patches
Indentation   +542 added lines, -542 removed lines patch added patch discarded remove patch
@@ -21,570 +21,570 @@
 block discarded – undo
21 21
  */
22 22
 class GetPaid_REST_Controller extends WP_REST_Controller {
23 23
 
24
-	/**
24
+    /**
25 25
      * The namespaces of this controller's route.
26 26
      *
27 27
      * @since 1.0.19
28 28
      * @var array
29 29
      */
30
-	protected $namespaces;
30
+    protected $namespaces;
31 31
 
32
-	/**
32
+    /**
33 33
      * The official namespace of this controller's route.
34 34
      *
35 35
      * @since 1.0.19
36 36
      * @var string
37 37
      */
38
-	protected $namespace = 'getpaid/v1';
38
+    protected $namespace = 'getpaid/v1';
39 39
 
40
-	/**
40
+    /**
41 41
      * Cached results of get_item_schema.
42 42
      *
43 43
      * @since 1.0.19
44 44
      * @var array
45 45
      */
46
-	protected $schema;
46
+    protected $schema;
47 47
 
48 48
     /**
49
-	 * Constructor.
50
-	 *
51
-	 * @since 1.0.19
52
-	 *
53
-	 */
54
-	public function __construct() {
55
-
56
-		// Offer several namespaces for backwards compatibility.
57
-		$this->namespaces = apply_filters(
58
-			'getpaid_rest_api_namespaces',
59
-			array(
60
-				'getpaid/v1',
61
-				'invoicing/v1',
62
-				'wpi/v1'
63
-			)
64
-		);
65
-
66
-		// Register REST routes.
49
+     * Constructor.
50
+     *
51
+     * @since 1.0.19
52
+     *
53
+     */
54
+    public function __construct() {
55
+
56
+        // Offer several namespaces for backwards compatibility.
57
+        $this->namespaces = apply_filters(
58
+            'getpaid_rest_api_namespaces',
59
+            array(
60
+                'getpaid/v1',
61
+                'invoicing/v1',
62
+                'wpi/v1'
63
+            )
64
+        );
65
+
66
+        // Register REST routes.
67 67
         add_action( 'rest_api_init', array( $this, 'register_routes' ) );
68 68
 
69
-	}
70
-
71
-	/**
72
-	 * Registers routes for each namespace.
73
-	 *
74
-	 * @since 1.0.19
75
-	 *
76
-	 */
77
-	public function register_routes() {
78
-
79
-		foreach ( $this->namespaces as $namespace ) {
80
-			$this->register_namespace_routes( $namespace );
81
-		}
82
-
83
-	}
84
-
85
-	/**
86
-	 * Registers routes for a namespace.
87
-	 *
88
-	 * @since 1.0.19
89
-	 *
90
-	 * @param string $namespace
91
-	 */
92
-	public function register_namespace_routes( /** @scrutinizer ignore-unused */ $namespace ) {
93
-
94
-		getpaid_doing_it_wrong(
95
-			__CLASS__ . '::' .__METHOD__,
96
-			/* translators: %s: register_namespace_routes() */
97
-			sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ),
98
-			'1.0.19'
99
-		);
100
-
101
-	}
102
-
103
-	/**
104
-	 * Get normalized rest base.
105
-	 *
106
-	 * @return string
107
-	 */
108
-	protected function get_normalized_rest_base() {
109
-		return preg_replace( '/\(.*\)\//i', '', $this->rest_base );
110
-	}
111
-
112
-	/**
113
-	 * Fill batches.
114
-	 *
115
-	 * @param array array of request items.
116
-	 * @return array
117
-	 */
118
-	protected function fill_batch_keys( $items ) {
119
-
120
-		$items['create'] = empty( $items['create'] ) ? array() : $items['create'];
121
-		$items['update'] = empty( $items['update'] ) ? array() : $items['update'];
122
-		$items['delete'] = empty( $items['delete'] ) ? array() : wp_parse_id_list( $items['delete'] );
123
-		return $items;
124
-
125
-	}
126
-
127
-	/**
128
-	 * Check batch limit.
129
-	 *
130
-	 * @param array $items Request items.
131
-	 * @return bool|WP_Error
132
-	 */
133
-	protected function check_batch_limit( $items ) {
134
-		$limit = apply_filters( 'getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
135
-		$total = count( $items['create'] ) + count( $items['update'] ) + count( $items['delete'] );
136
-
137
-		if ( $total > $limit ) {
138
-			/* translators: %s: items limit */
139
-			return new WP_Error( 'getpaid_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'invoicing' ), $limit ), array( 'status' => 413 ) );
140
-		}
141
-
142
-		return true;
143
-	}
144
-
145
-	/**
146
-	 * Bulk create items.
147
-	 *
148
-	 * @param array $items Array of items to create.
149
-	 * @param WP_REST_Request $request Full details about the request.
150
-	 * @param WP_REST_Server $wp_rest_server
151
-	 * @return array()
152
-	 */
153
-	protected function batch_create_items( $items, $request, $wp_rest_server ) {
154
-
155
-		$query  = $request->get_query_params();
156
-		$create = array();
157
-
158
-		foreach ( $items as $item ) {
159
-			$_item = new WP_REST_Request( 'POST' );
160
-
161
-			// Default parameters.
162
-			$defaults = array();
163
-			$schema   = $this->get_public_item_schema();
164
-			foreach ( $schema['properties'] as $arg => $options ) {
165
-				if ( isset( $options['default'] ) ) {
166
-					$defaults[ $arg ] = $options['default'];
167
-				}
168
-			}
169
-			$_item->set_default_params( $defaults );
170
-
171
-			// Set request parameters.
172
-			$_item->set_body_params( $item );
173
-
174
-			// Set query (GET) parameters.
175
-			$_item->set_query_params( $query );
176
-
177
-			// Create the item.
178
-			$_response = $this->create_item( $_item );
179
-
180
-			// If an error occured...
181
-			if ( is_wp_error( $_response ) ) {
182
-
183
-				$create[]   = array(
184
-					'id'    => 0,
185
-					'error' => array(
186
-						'code'    => $_response->get_error_code(),
187
-						'message' => $_response->get_error_message(),
188
-						'data'    => $_response->get_error_data(),
189
-					),
190
-				);
191
-
192
-				continue;
193
-			}
194
-
195
-			$create[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
196
-
197
-		}
198
-
199
-		return $create;
69
+    }
70
+
71
+    /**
72
+     * Registers routes for each namespace.
73
+     *
74
+     * @since 1.0.19
75
+     *
76
+     */
77
+    public function register_routes() {
78
+
79
+        foreach ( $this->namespaces as $namespace ) {
80
+            $this->register_namespace_routes( $namespace );
81
+        }
82
+
83
+    }
84
+
85
+    /**
86
+     * Registers routes for a namespace.
87
+     *
88
+     * @since 1.0.19
89
+     *
90
+     * @param string $namespace
91
+     */
92
+    public function register_namespace_routes( /** @scrutinizer ignore-unused */ $namespace ) {
93
+
94
+        getpaid_doing_it_wrong(
95
+            __CLASS__ . '::' .__METHOD__,
96
+            /* translators: %s: register_namespace_routes() */
97
+            sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ),
98
+            '1.0.19'
99
+        );
100
+
101
+    }
102
+
103
+    /**
104
+     * Get normalized rest base.
105
+     *
106
+     * @return string
107
+     */
108
+    protected function get_normalized_rest_base() {
109
+        return preg_replace( '/\(.*\)\//i', '', $this->rest_base );
110
+    }
111
+
112
+    /**
113
+     * Fill batches.
114
+     *
115
+     * @param array array of request items.
116
+     * @return array
117
+     */
118
+    protected function fill_batch_keys( $items ) {
119
+
120
+        $items['create'] = empty( $items['create'] ) ? array() : $items['create'];
121
+        $items['update'] = empty( $items['update'] ) ? array() : $items['update'];
122
+        $items['delete'] = empty( $items['delete'] ) ? array() : wp_parse_id_list( $items['delete'] );
123
+        return $items;
124
+
125
+    }
126
+
127
+    /**
128
+     * Check batch limit.
129
+     *
130
+     * @param array $items Request items.
131
+     * @return bool|WP_Error
132
+     */
133
+    protected function check_batch_limit( $items ) {
134
+        $limit = apply_filters( 'getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
135
+        $total = count( $items['create'] ) + count( $items['update'] ) + count( $items['delete'] );
136
+
137
+        if ( $total > $limit ) {
138
+            /* translators: %s: items limit */
139
+            return new WP_Error( 'getpaid_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'invoicing' ), $limit ), array( 'status' => 413 ) );
140
+        }
141
+
142
+        return true;
143
+    }
144
+
145
+    /**
146
+     * Bulk create items.
147
+     *
148
+     * @param array $items Array of items to create.
149
+     * @param WP_REST_Request $request Full details about the request.
150
+     * @param WP_REST_Server $wp_rest_server
151
+     * @return array()
152
+     */
153
+    protected function batch_create_items( $items, $request, $wp_rest_server ) {
154
+
155
+        $query  = $request->get_query_params();
156
+        $create = array();
157
+
158
+        foreach ( $items as $item ) {
159
+            $_item = new WP_REST_Request( 'POST' );
160
+
161
+            // Default parameters.
162
+            $defaults = array();
163
+            $schema   = $this->get_public_item_schema();
164
+            foreach ( $schema['properties'] as $arg => $options ) {
165
+                if ( isset( $options['default'] ) ) {
166
+                    $defaults[ $arg ] = $options['default'];
167
+                }
168
+            }
169
+            $_item->set_default_params( $defaults );
170
+
171
+            // Set request parameters.
172
+            $_item->set_body_params( $item );
173
+
174
+            // Set query (GET) parameters.
175
+            $_item->set_query_params( $query );
176
+
177
+            // Create the item.
178
+            $_response = $this->create_item( $_item );
179
+
180
+            // If an error occured...
181
+            if ( is_wp_error( $_response ) ) {
182
+
183
+                $create[]   = array(
184
+                    'id'    => 0,
185
+                    'error' => array(
186
+                        'code'    => $_response->get_error_code(),
187
+                        'message' => $_response->get_error_message(),
188
+                        'data'    => $_response->get_error_data(),
189
+                    ),
190
+                );
191
+
192
+                continue;
193
+            }
194
+
195
+            $create[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
196
+
197
+        }
198
+
199
+        return $create;
200
+
201
+    }
202
+
203
+    /**
204
+     * Bulk update items.
205
+     *
206
+     * @param array $items Array of items to update.
207
+     * @param WP_REST_Request $request Full details about the request.
208
+     * @param WP_REST_Server $wp_rest_server
209
+     * @return array()
210
+     */
211
+    protected function batch_update_items( $items, $request, $wp_rest_server ) {
212
+
213
+        $query  = $request->get_query_params();
214
+        $update = array();
215
+
216
+        foreach ( $items as $item ) {
217
+
218
+            // Create a dummy request.
219
+            $_item = new WP_REST_Request( 'PUT' );
220
+
221
+            // Add body params.
222
+            $_item->set_body_params( $item );
223
+
224
+            // Set query (GET) parameters.
225
+            $_item->set_query_params( $query );
226
+
227
+            // Update the item.
228
+            $_response = $this->update_item( $_item );
229
+
230
+            // If an error occured...
231
+            if ( is_wp_error( $_response ) ) {
232
+
233
+                $update[] = array(
234
+                    'id'    => $item['id'],
235
+                    'error' => array(
236
+                        'code'    => $_response->get_error_code(),
237
+                        'message' => $_response->get_error_message(),
238
+                        'data'    => $_response->get_error_data(),
239
+                    ),
240
+                );
241
+
242
+                continue;
243
+
244
+            }
245
+
246
+            $update[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
247
+
248
+        }
249
+
250
+        return $update;
251
+
252
+    }
253
+
254
+    /**
255
+     * Bulk delete items.
256
+     *
257
+     * @param array $items Array of items to delete.
258
+     * @param WP_REST_Server $wp_rest_server
259
+     * @return array()
260
+     */
261
+    protected function batch_delete_items( $items, $wp_rest_server ) {
262
+
263
+        $delete = array();
264
+
265
+        foreach ( array_filter( $items ) as $id ) {
266
+
267
+            // Prepare the request.
268
+            $_item = new WP_REST_Request( 'DELETE' );
269
+            $_item->set_query_params(
270
+                array(
271
+                    'id'    => $id,
272
+                    'force' => true,
273
+                )
274
+            );
275
+
276
+            // Delete the item.
277
+            $_response = $this->delete_item( $_item );
278
+
279
+            if ( is_wp_error( $_response ) ) {
280
+
281
+                $delete[] = array(
282
+                    'id'    => $id,
283
+                    'error' => array(
284
+                        'code'    => $_response->get_error_code(),
285
+                        'message' => $_response->get_error_message(),
286
+                        'data'    => $_response->get_error_data(),
287
+                    ),
288
+                );
289
+
290
+                continue;
291
+            }
200 292
 
201
-	}
202
-
203
-	/**
204
-	 * Bulk update items.
205
-	 *
206
-	 * @param array $items Array of items to update.
207
-	 * @param WP_REST_Request $request Full details about the request.
208
-	 * @param WP_REST_Server $wp_rest_server
209
-	 * @return array()
210
-	 */
211
-	protected function batch_update_items( $items, $request, $wp_rest_server ) {
212
-
213
-		$query  = $request->get_query_params();
214
-		$update = array();
215
-
216
-		foreach ( $items as $item ) {
217
-
218
-			// Create a dummy request.
219
-			$_item = new WP_REST_Request( 'PUT' );
220
-
221
-			// Add body params.
222
-			$_item->set_body_params( $item );
223
-
224
-			// Set query (GET) parameters.
225
-			$_item->set_query_params( $query );
226
-
227
-			// Update the item.
228
-			$_response = $this->update_item( $_item );
229
-
230
-			// If an error occured...
231
-			if ( is_wp_error( $_response ) ) {
232
-
233
-				$update[] = array(
234
-					'id'    => $item['id'],
235
-					'error' => array(
236
-						'code'    => $_response->get_error_code(),
237
-						'message' => $_response->get_error_message(),
238
-						'data'    => $_response->get_error_data(),
239
-					),
240
-				);
241
-
242
-				continue;
243
-
244
-			}
245
-
246
-			$update[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
247
-
248
-		}
249
-
250
-		return $update;
251
-
252
-	}
293
+            $delete[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
253 294
 
254
-	/**
255
-	 * Bulk delete items.
256
-	 *
257
-	 * @param array $items Array of items to delete.
258
-	 * @param WP_REST_Server $wp_rest_server
259
-	 * @return array()
260
-	 */
261
-	protected function batch_delete_items( $items, $wp_rest_server ) {
262
-
263
-		$delete = array();
264
-
265
-		foreach ( array_filter( $items ) as $id ) {
266
-
267
-			// Prepare the request.
268
-			$_item = new WP_REST_Request( 'DELETE' );
269
-			$_item->set_query_params(
270
-				array(
271
-					'id'    => $id,
272
-					'force' => true,
273
-				)
274
-			);
275
-
276
-			// Delete the item.
277
-			$_response = $this->delete_item( $_item );
278
-
279
-			if ( is_wp_error( $_response ) ) {
280
-
281
-				$delete[] = array(
282
-					'id'    => $id,
283
-					'error' => array(
284
-						'code'    => $_response->get_error_code(),
285
-						'message' => $_response->get_error_message(),
286
-						'data'    => $_response->get_error_data(),
287
-					),
288
-				);
289
-
290
-				continue;
291
-			}
292
-
293
-			$delete[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
294
-
295
-		}
296
-
297
-		return $delete;
298
-
299
-	}
300
-
301
-	/**
302
-	 * Bulk create, update and delete items.
303
-	 *
304
-	 * @param WP_REST_Request $request Full details about the request.
305
-	 * @return WP_Error|array.
306
-	 */
307
-	public function batch_items( $request ) {
308
-		global $wp_rest_server;
309
-
310
-		// Prepare the batch items.
311
-		$items = $this->fill_batch_keys( array_filter( $request->get_params() ) );
312
-
313
-		// Ensure that the batch has not exceeded the limit to prevent abuse.
314
-		$limit = $this->check_batch_limit( $items );
315
-		if ( is_wp_error( $limit ) ) {
316
-			return $limit;
317
-		}
318
-
319
-		// Process the items.
320
-		return array(
321
-			'create' => $this->batch_create_items( $items['create'], $request, $wp_rest_server ),
322
-			'update' => $this->batch_update_items( $items['update'], $request, $wp_rest_server ),
323
-			'delete' => $this->batch_delete_items( $items['delete'], $wp_rest_server ),
324
-		);
325
-
326
-	}
327
-
328
-	/**
329
-	 * Add meta query.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param array $args       Query args.
333
-	 * @param array $meta_query Meta query.
334
-	 * @return array
335
-	 */
336
-	protected function add_meta_query( $args, $meta_query ) {
337
-		if ( empty( $args['meta_query'] ) ) {
338
-			$args['meta_query'] = array();
339
-		}
340
-
341
-		$args['meta_query'][] = $meta_query;
342
-
343
-		return $args['meta_query'];
344
-	}
345
-
346
-	/**
347
-	 * Get the batch schema, conforming to JSON Schema.
348
-	 *
349
-	 * @return array
350
-	 */
351
-	public function get_public_batch_schema() {
352
-
353
-		return array(
354
-			'$schema'    => 'http://json-schema.org/draft-04/schema#',
355
-			'title'      => 'batch',
356
-			'type'       => 'object',
357
-			'properties' => array(
358
-				'create' => array(
359
-					'description' => __( 'List of created resources.', 'invoicing' ),
360
-					'type'        => 'array',
361
-					'context'     => array( 'view', 'edit' ),
362
-					'items'       => array(
363
-						'type'    => 'object',
364
-					),
365
-				),
366
-				'update' => array(
367
-					'description' => __( 'List of updated resources.', 'invoicing' ),
368
-					'type'        => 'array',
369
-					'context'     => array( 'view', 'edit' ),
370
-					'items'       => array(
371
-						'type'    => 'object',
372
-					),
373
-				),
374
-				'delete' => array(
375
-					'description' => __( 'List of deleted resources.', 'invoicing' ),
376
-					'type'        => 'array',
377
-					'context'     => array( 'view', 'edit' ),
378
-					'items'       => array(
379
-						'type'    => 'integer',
380
-					),
381
-				),
382
-			),
383
-		);
384
-
385
-	}
386
-
387
-	/**
388
-	 * Returns the value of schema['properties']
389
-	 * 
390
-	 * i.e Schema fields.
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @return array
394
-	 */
395
-	protected function get_schema_properties() {
396
-
397
-		$schema     = $this->get_item_schema();
398
-		$properties = isset( $schema['properties'] ) ? $schema['properties'] : array();
399
-
400
-		// For back-compat, include any field with an empty schema
401
-		// because it won't be present in $this->get_item_schema().
402
-		foreach ( $this->get_additional_fields() as $field_name => $field_options ) {
403
-			if ( is_null( $field_options['schema'] ) ) {
404
-				$properties[ $field_name ] = $field_options;
405
-			}
406
-		}
407
-
408
-		return $properties;
409
-	}
410
-
411
-	/**
412
-	 * Filters fields by context.
413
-	 *
414
-	 * @param array $fields Array of fields
415
-	 * @param string|null context view, edit or embed
416
-	 * @since 1.0.19
417
-	 * @return array
418
-	 */
419
-	protected function filter_response_fields_by_context( $fields, $context ) {
420
-
421
-		if ( empty( $context ) ) {
422
-			return $fields;
423
-		}
424
-
425
-		foreach ( $fields as $name => $options ) {
426
-			if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) {
427
-				unset( $fields[ $name ] );
428
-			}
429
-		}
430
-
431
-		return $fields;
432
-
433
-	}
434
-
435
-	/**
436
-	 * Filters fields by an array of requested fields.
437
-	 *
438
-	 * @param array $fields Array of available fields
439
-	 * @param array $requested array of requested fields.
440
-	 * @since 1.0.19
441
-	 * @return array
442
-	 */
443
-	protected function filter_response_fields_by_array( $fields, $requested ) {
444
-
445
-		// Trim off any whitespace from the list array.
446
-		$requested = array_map( 'trim', $requested );
447
-
448
-		// Always persist 'id', because it can be needed for add_additional_fields_to_object().
449
-		if ( in_array( 'id', $fields, true ) ) {
450
-			$requested[] = 'id';
451
-		}
452
-
453
-		// Get rid of duplicate fields.
454
-		$requested = array_unique( $requested );
455
-
456
-		// Return the list of all included fields which are available.
457
-		return array_reduce(
458
-			$requested,
459
-			function( $response_fields, $field ) use ( $fields ) {
460
-
461
-				if ( in_array( $field, $fields, true ) ) {
462
-					$response_fields[] = $field;
463
-					return $response_fields;
464
-				}
465
-
466
-				// Check for nested fields if $field is not a direct match.
467
-				$nested_fields = explode( '.', $field );
468
-
469
-				// A nested field is included so long as its top-level property is
470
-				// present in the schema.
471
-				if ( in_array( $nested_fields[0], $fields, true ) ) {
472
-					$response_fields[] = $field;
473
-				}
474
-
475
-				return $response_fields;
476
-			},
477
-			array()
478
-		);
479
-
480
-	}
481
-
482
-	/**
483
-	 * Gets an array of fields to be included on the response.
484
-	 *
485
-	 * Included fields are based on item schema and `_fields=` request argument.
486
-	 * Copied from WordPress 5.3 to support old versions.
487
-	 *
488
-	 * @since 1.0.19
489
-	 * @param WP_REST_Request $request Full details about the request.
490
-	 * @return array Fields to be included in the response.
491
-	 */
492
-	public function get_fields_for_response( $request ) {
493
-
494
-		// Retrieve fields in the schema.
495
-		$properties = $this->get_schema_properties();
496
-
497
-		// Exclude fields that specify a different context than the request context.
498
-		$properties = $this->filter_response_fields_by_context( $properties, $request['context'] );
499
-
500
-		// We only need the field keys.
501
-		$fields = array_keys( $properties );
502
-
503
-		// Is the user filtering the response fields??
504
-		if ( empty( $request['_fields'] ) ) {
505
-			return $fields;
506
-		}
507
-
508
-		return $this->filter_response_fields_by_array( $fields, wpinv_parse_list( $request['_fields'] ) );
509
-
510
-	}
511
-
512
-	/**
513
-	 * Limits an object to the requested fields.
514
-	 *
515
-	 * Included fields are based on the `_fields` request argument.
516
-	 *
517
-	 * @since 1.0.19
518
-	 * @param array $data Fields to include in the response.
519
-	 * @param array $fields Requested fields.
520
-	 * @return array Fields to be included in the response.
521
-	 */
522
-	public function limit_object_to_requested_fields( $data, $fields, $prefix = '' ) {
523
-
524
-		// Is the user filtering the response fields??
525
-		if ( empty( $fields ) ) {
526
-			return $data;
527
-		}
528
-
529
-		foreach ( $data as $key => $value ) {
530
-
531
-			// Numeric arrays.
532
-			if ( is_numeric( $key ) && is_array( $value ) ) {
533
-				$data[ $key ] = $this->limit_object_to_requested_fields( $value, $fields, $prefix );
534
-				continue;
535
-			}
536
-
537
-			// Generate a new prefix.
538
-			$new_prefix = empty( $prefix ) ? $key : "$prefix.$key";
539
-
540
-			// Check if it was requested.
541
-			if ( ! empty( $key ) && ! $this->is_field_included( $new_prefix, $fields ) ) {
542
-				unset( $data[ $key ] );
543
-				continue;
544
-			}
545
-
546
-			if ( $key != 'meta_data' && is_array( $value ) ) {
547
-				$data[ $key ] = $this->limit_object_to_requested_fields( $value, $fields, $new_prefix );
548
-			}
549
-
550
-		}
551
-
552
-		return $data;
553
-	}
554
-
555
-	/**
556
-	 * Given an array of fields to include in a response, some of which may be
557
-	 * `nested.fields`, determine whether the provided field should be included
558
-	 * in the response body.
559
-	 *
560
-	 * Copied from WordPress 5.3 to support old versions.
561
-	 *
562
-	 * @since 1.0.19
563
-	 *
564
-	 * @param string $field  A field to test for inclusion in the response body.
565
-	 * @param array  $fields An array of string fields supported by the endpoint.
566
-	 * @return bool Whether to include the field or not.
567
-	 * @see rest_is_field_included()
568
-	 */
569
-	public function is_field_included( $field, $fields ) {
570
-		if ( in_array( $field, $fields, true ) ) {
571
-			return true;
572
-		}
573
-
574
-		foreach ( $fields as $accepted_field ) {
575
-			// Check to see if $field is the parent of any item in $fields.
576
-			// A field "parent" should be accepted if "parent.child" is accepted.
577
-			if ( strpos( $accepted_field, "$field." ) === 0 ) {
578
-				return true;
579
-			}
580
-			// Conversely, if "parent" is accepted, all "parent.child" fields
581
-			// should also be accepted.
582
-			if ( strpos( $field, "$accepted_field." ) === 0 ) {
583
-				return true;
584
-			}
585
-		}
586
-
587
-		return false;
588
-	}
295
+        }
296
+
297
+        return $delete;
298
+
299
+    }
300
+
301
+    /**
302
+     * Bulk create, update and delete items.
303
+     *
304
+     * @param WP_REST_Request $request Full details about the request.
305
+     * @return WP_Error|array.
306
+     */
307
+    public function batch_items( $request ) {
308
+        global $wp_rest_server;
309
+
310
+        // Prepare the batch items.
311
+        $items = $this->fill_batch_keys( array_filter( $request->get_params() ) );
312
+
313
+        // Ensure that the batch has not exceeded the limit to prevent abuse.
314
+        $limit = $this->check_batch_limit( $items );
315
+        if ( is_wp_error( $limit ) ) {
316
+            return $limit;
317
+        }
318
+
319
+        // Process the items.
320
+        return array(
321
+            'create' => $this->batch_create_items( $items['create'], $request, $wp_rest_server ),
322
+            'update' => $this->batch_update_items( $items['update'], $request, $wp_rest_server ),
323
+            'delete' => $this->batch_delete_items( $items['delete'], $wp_rest_server ),
324
+        );
325
+
326
+    }
327
+
328
+    /**
329
+     * Add meta query.
330
+     *
331
+     * @since 1.0.19
332
+     * @param array $args       Query args.
333
+     * @param array $meta_query Meta query.
334
+     * @return array
335
+     */
336
+    protected function add_meta_query( $args, $meta_query ) {
337
+        if ( empty( $args['meta_query'] ) ) {
338
+            $args['meta_query'] = array();
339
+        }
340
+
341
+        $args['meta_query'][] = $meta_query;
342
+
343
+        return $args['meta_query'];
344
+    }
345
+
346
+    /**
347
+     * Get the batch schema, conforming to JSON Schema.
348
+     *
349
+     * @return array
350
+     */
351
+    public function get_public_batch_schema() {
352
+
353
+        return array(
354
+            '$schema'    => 'http://json-schema.org/draft-04/schema#',
355
+            'title'      => 'batch',
356
+            'type'       => 'object',
357
+            'properties' => array(
358
+                'create' => array(
359
+                    'description' => __( 'List of created resources.', 'invoicing' ),
360
+                    'type'        => 'array',
361
+                    'context'     => array( 'view', 'edit' ),
362
+                    'items'       => array(
363
+                        'type'    => 'object',
364
+                    ),
365
+                ),
366
+                'update' => array(
367
+                    'description' => __( 'List of updated resources.', 'invoicing' ),
368
+                    'type'        => 'array',
369
+                    'context'     => array( 'view', 'edit' ),
370
+                    'items'       => array(
371
+                        'type'    => 'object',
372
+                    ),
373
+                ),
374
+                'delete' => array(
375
+                    'description' => __( 'List of deleted resources.', 'invoicing' ),
376
+                    'type'        => 'array',
377
+                    'context'     => array( 'view', 'edit' ),
378
+                    'items'       => array(
379
+                        'type'    => 'integer',
380
+                    ),
381
+                ),
382
+            ),
383
+        );
384
+
385
+    }
386
+
387
+    /**
388
+     * Returns the value of schema['properties']
389
+     * 
390
+     * i.e Schema fields.
391
+     *
392
+     * @since 1.0.19
393
+     * @return array
394
+     */
395
+    protected function get_schema_properties() {
396
+
397
+        $schema     = $this->get_item_schema();
398
+        $properties = isset( $schema['properties'] ) ? $schema['properties'] : array();
399
+
400
+        // For back-compat, include any field with an empty schema
401
+        // because it won't be present in $this->get_item_schema().
402
+        foreach ( $this->get_additional_fields() as $field_name => $field_options ) {
403
+            if ( is_null( $field_options['schema'] ) ) {
404
+                $properties[ $field_name ] = $field_options;
405
+            }
406
+        }
407
+
408
+        return $properties;
409
+    }
410
+
411
+    /**
412
+     * Filters fields by context.
413
+     *
414
+     * @param array $fields Array of fields
415
+     * @param string|null context view, edit or embed
416
+     * @since 1.0.19
417
+     * @return array
418
+     */
419
+    protected function filter_response_fields_by_context( $fields, $context ) {
420
+
421
+        if ( empty( $context ) ) {
422
+            return $fields;
423
+        }
424
+
425
+        foreach ( $fields as $name => $options ) {
426
+            if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) {
427
+                unset( $fields[ $name ] );
428
+            }
429
+        }
430
+
431
+        return $fields;
432
+
433
+    }
434
+
435
+    /**
436
+     * Filters fields by an array of requested fields.
437
+     *
438
+     * @param array $fields Array of available fields
439
+     * @param array $requested array of requested fields.
440
+     * @since 1.0.19
441
+     * @return array
442
+     */
443
+    protected function filter_response_fields_by_array( $fields, $requested ) {
444
+
445
+        // Trim off any whitespace from the list array.
446
+        $requested = array_map( 'trim', $requested );
447
+
448
+        // Always persist 'id', because it can be needed for add_additional_fields_to_object().
449
+        if ( in_array( 'id', $fields, true ) ) {
450
+            $requested[] = 'id';
451
+        }
452
+
453
+        // Get rid of duplicate fields.
454
+        $requested = array_unique( $requested );
455
+
456
+        // Return the list of all included fields which are available.
457
+        return array_reduce(
458
+            $requested,
459
+            function( $response_fields, $field ) use ( $fields ) {
460
+
461
+                if ( in_array( $field, $fields, true ) ) {
462
+                    $response_fields[] = $field;
463
+                    return $response_fields;
464
+                }
465
+
466
+                // Check for nested fields if $field is not a direct match.
467
+                $nested_fields = explode( '.', $field );
468
+
469
+                // A nested field is included so long as its top-level property is
470
+                // present in the schema.
471
+                if ( in_array( $nested_fields[0], $fields, true ) ) {
472
+                    $response_fields[] = $field;
473
+                }
474
+
475
+                return $response_fields;
476
+            },
477
+            array()
478
+        );
479
+
480
+    }
481
+
482
+    /**
483
+     * Gets an array of fields to be included on the response.
484
+     *
485
+     * Included fields are based on item schema and `_fields=` request argument.
486
+     * Copied from WordPress 5.3 to support old versions.
487
+     *
488
+     * @since 1.0.19
489
+     * @param WP_REST_Request $request Full details about the request.
490
+     * @return array Fields to be included in the response.
491
+     */
492
+    public function get_fields_for_response( $request ) {
493
+
494
+        // Retrieve fields in the schema.
495
+        $properties = $this->get_schema_properties();
496
+
497
+        // Exclude fields that specify a different context than the request context.
498
+        $properties = $this->filter_response_fields_by_context( $properties, $request['context'] );
499
+
500
+        // We only need the field keys.
501
+        $fields = array_keys( $properties );
502
+
503
+        // Is the user filtering the response fields??
504
+        if ( empty( $request['_fields'] ) ) {
505
+            return $fields;
506
+        }
507
+
508
+        return $this->filter_response_fields_by_array( $fields, wpinv_parse_list( $request['_fields'] ) );
509
+
510
+    }
511
+
512
+    /**
513
+     * Limits an object to the requested fields.
514
+     *
515
+     * Included fields are based on the `_fields` request argument.
516
+     *
517
+     * @since 1.0.19
518
+     * @param array $data Fields to include in the response.
519
+     * @param array $fields Requested fields.
520
+     * @return array Fields to be included in the response.
521
+     */
522
+    public function limit_object_to_requested_fields( $data, $fields, $prefix = '' ) {
523
+
524
+        // Is the user filtering the response fields??
525
+        if ( empty( $fields ) ) {
526
+            return $data;
527
+        }
528
+
529
+        foreach ( $data as $key => $value ) {
530
+
531
+            // Numeric arrays.
532
+            if ( is_numeric( $key ) && is_array( $value ) ) {
533
+                $data[ $key ] = $this->limit_object_to_requested_fields( $value, $fields, $prefix );
534
+                continue;
535
+            }
536
+
537
+            // Generate a new prefix.
538
+            $new_prefix = empty( $prefix ) ? $key : "$prefix.$key";
539
+
540
+            // Check if it was requested.
541
+            if ( ! empty( $key ) && ! $this->is_field_included( $new_prefix, $fields ) ) {
542
+                unset( $data[ $key ] );
543
+                continue;
544
+            }
545
+
546
+            if ( $key != 'meta_data' && is_array( $value ) ) {
547
+                $data[ $key ] = $this->limit_object_to_requested_fields( $value, $fields, $new_prefix );
548
+            }
549
+
550
+        }
551
+
552
+        return $data;
553
+    }
554
+
555
+    /**
556
+     * Given an array of fields to include in a response, some of which may be
557
+     * `nested.fields`, determine whether the provided field should be included
558
+     * in the response body.
559
+     *
560
+     * Copied from WordPress 5.3 to support old versions.
561
+     *
562
+     * @since 1.0.19
563
+     *
564
+     * @param string $field  A field to test for inclusion in the response body.
565
+     * @param array  $fields An array of string fields supported by the endpoint.
566
+     * @return bool Whether to include the field or not.
567
+     * @see rest_is_field_included()
568
+     */
569
+    public function is_field_included( $field, $fields ) {
570
+        if ( in_array( $field, $fields, true ) ) {
571
+            return true;
572
+        }
573
+
574
+        foreach ( $fields as $accepted_field ) {
575
+            // Check to see if $field is the parent of any item in $fields.
576
+            // A field "parent" should be accepted if "parent.child" is accepted.
577
+            if ( strpos( $accepted_field, "$field." ) === 0 ) {
578
+                return true;
579
+            }
580
+            // Conversely, if "parent" is accepted, all "parent.child" fields
581
+            // should also be accepted.
582
+            if ( strpos( $field, "$accepted_field." ) === 0 ) {
583
+                return true;
584
+            }
585
+        }
586
+
587
+        return false;
588
+    }
589 589
 
590 590
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * Core class to access posts via the REST API.
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		);
65 65
 
66 66
 		// Register REST routes.
67
-        add_action( 'rest_api_init', array( $this, 'register_routes' ) );
67
+        add_action('rest_api_init', array($this, 'register_routes'));
68 68
 
69 69
 	}
70 70
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function register_routes() {
78 78
 
79
-		foreach ( $this->namespaces as $namespace ) {
80
-			$this->register_namespace_routes( $namespace );
79
+		foreach ($this->namespaces as $namespace) {
80
+			$this->register_namespace_routes($namespace);
81 81
 		}
82 82
 
83 83
 	}
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @param string $namespace
91 91
 	 */
92
-	public function register_namespace_routes( /** @scrutinizer ignore-unused */ $namespace ) {
92
+	public function register_namespace_routes(/** @scrutinizer ignore-unused */ $namespace) {
93 93
 
94 94
 		getpaid_doing_it_wrong(
95
-			__CLASS__ . '::' .__METHOD__,
95
+			__CLASS__ . '::' . __METHOD__,
96 96
 			/* translators: %s: register_namespace_routes() */
97
-			sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ),
97
+			sprintf(__("Method '%s' must be overridden."), __METHOD__),
98 98
 			'1.0.19'
99 99
 		);
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return string
107 107
 	 */
108 108
 	protected function get_normalized_rest_base() {
109
-		return preg_replace( '/\(.*\)\//i', '', $this->rest_base );
109
+		return preg_replace('/\(.*\)\//i', '', $this->rest_base);
110 110
 	}
111 111
 
112 112
 	/**
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 	 * @param array array of request items.
116 116
 	 * @return array
117 117
 	 */
118
-	protected function fill_batch_keys( $items ) {
118
+	protected function fill_batch_keys($items) {
119 119
 
120
-		$items['create'] = empty( $items['create'] ) ? array() : $items['create'];
121
-		$items['update'] = empty( $items['update'] ) ? array() : $items['update'];
122
-		$items['delete'] = empty( $items['delete'] ) ? array() : wp_parse_id_list( $items['delete'] );
120
+		$items['create'] = empty($items['create']) ? array() : $items['create'];
121
+		$items['update'] = empty($items['update']) ? array() : $items['update'];
122
+		$items['delete'] = empty($items['delete']) ? array() : wp_parse_id_list($items['delete']);
123 123
 		return $items;
124 124
 
125 125
 	}
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	 * @param array $items Request items.
131 131
 	 * @return bool|WP_Error
132 132
 	 */
133
-	protected function check_batch_limit( $items ) {
134
-		$limit = apply_filters( 'getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
135
-		$total = count( $items['create'] ) + count( $items['update'] ) + count( $items['delete'] );
133
+	protected function check_batch_limit($items) {
134
+		$limit = apply_filters('getpaid_rest_batch_items_limit', 100, $this->get_normalized_rest_base());
135
+		$total = count($items['create']) + count($items['update']) + count($items['delete']);
136 136
 
137
-		if ( $total > $limit ) {
137
+		if ($total > $limit) {
138 138
 			/* translators: %s: items limit */
139
-			return new WP_Error( 'getpaid_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'invoicing' ), $limit ), array( 'status' => 413 ) );
139
+			return new WP_Error('getpaid_rest_request_entity_too_large', sprintf(__('Unable to accept more than %s items for this request.', 'invoicing'), $limit), array('status' => 413));
140 140
 		}
141 141
 
142 142
 		return true;
@@ -150,37 +150,37 @@  discard block
 block discarded – undo
150 150
 	 * @param WP_REST_Server $wp_rest_server
151 151
 	 * @return array()
152 152
 	 */
153
-	protected function batch_create_items( $items, $request, $wp_rest_server ) {
153
+	protected function batch_create_items($items, $request, $wp_rest_server) {
154 154
 
155 155
 		$query  = $request->get_query_params();
156 156
 		$create = array();
157 157
 
158
-		foreach ( $items as $item ) {
159
-			$_item = new WP_REST_Request( 'POST' );
158
+		foreach ($items as $item) {
159
+			$_item = new WP_REST_Request('POST');
160 160
 
161 161
 			// Default parameters.
162 162
 			$defaults = array();
163 163
 			$schema   = $this->get_public_item_schema();
164
-			foreach ( $schema['properties'] as $arg => $options ) {
165
-				if ( isset( $options['default'] ) ) {
166
-					$defaults[ $arg ] = $options['default'];
164
+			foreach ($schema['properties'] as $arg => $options) {
165
+				if (isset($options['default'])) {
166
+					$defaults[$arg] = $options['default'];
167 167
 				}
168 168
 			}
169
-			$_item->set_default_params( $defaults );
169
+			$_item->set_default_params($defaults);
170 170
 
171 171
 			// Set request parameters.
172
-			$_item->set_body_params( $item );
172
+			$_item->set_body_params($item);
173 173
 
174 174
 			// Set query (GET) parameters.
175
-			$_item->set_query_params( $query );
175
+			$_item->set_query_params($query);
176 176
 
177 177
 			// Create the item.
178
-			$_response = $this->create_item( $_item );
178
+			$_response = $this->create_item($_item);
179 179
 
180 180
 			// If an error occured...
181
-			if ( is_wp_error( $_response ) ) {
181
+			if (is_wp_error($_response)) {
182 182
 
183
-				$create[]   = array(
183
+				$create[] = array(
184 184
 					'id'    => 0,
185 185
 					'error' => array(
186 186
 						'code'    => $_response->get_error_code(),
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				continue;
193 193
 			}
194 194
 
195
-			$create[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
195
+			$create[] = $wp_rest_server->response_to_data(/** @scrutinizer ignore-type */ $_response, false);
196 196
 
197 197
 		}
198 198
 
@@ -208,27 +208,27 @@  discard block
 block discarded – undo
208 208
 	 * @param WP_REST_Server $wp_rest_server
209 209
 	 * @return array()
210 210
 	 */
211
-	protected function batch_update_items( $items, $request, $wp_rest_server ) {
211
+	protected function batch_update_items($items, $request, $wp_rest_server) {
212 212
 
213 213
 		$query  = $request->get_query_params();
214 214
 		$update = array();
215 215
 
216
-		foreach ( $items as $item ) {
216
+		foreach ($items as $item) {
217 217
 
218 218
 			// Create a dummy request.
219
-			$_item = new WP_REST_Request( 'PUT' );
219
+			$_item = new WP_REST_Request('PUT');
220 220
 
221 221
 			// Add body params.
222
-			$_item->set_body_params( $item );
222
+			$_item->set_body_params($item);
223 223
 
224 224
 			// Set query (GET) parameters.
225
-			$_item->set_query_params( $query );
225
+			$_item->set_query_params($query);
226 226
 
227 227
 			// Update the item.
228
-			$_response = $this->update_item( $_item );
228
+			$_response = $this->update_item($_item);
229 229
 
230 230
 			// If an error occured...
231
-			if ( is_wp_error( $_response ) ) {
231
+			if (is_wp_error($_response)) {
232 232
 
233 233
 				$update[] = array(
234 234
 					'id'    => $item['id'],
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 			}
245 245
 
246
-			$update[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
246
+			$update[] = $wp_rest_server->response_to_data(/** @scrutinizer ignore-type */ $_response, false);
247 247
 
248 248
 		}
249 249
 
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 	 * @param WP_REST_Server $wp_rest_server
259 259
 	 * @return array()
260 260
 	 */
261
-	protected function batch_delete_items( $items, $wp_rest_server ) {
261
+	protected function batch_delete_items($items, $wp_rest_server) {
262 262
 
263 263
 		$delete = array();
264 264
 
265
-		foreach ( array_filter( $items ) as $id ) {
265
+		foreach (array_filter($items) as $id) {
266 266
 
267 267
 			// Prepare the request.
268
-			$_item = new WP_REST_Request( 'DELETE' );
268
+			$_item = new WP_REST_Request('DELETE');
269 269
 			$_item->set_query_params(
270 270
 				array(
271 271
 					'id'    => $id,
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 			);
275 275
 
276 276
 			// Delete the item.
277
-			$_response = $this->delete_item( $_item );
277
+			$_response = $this->delete_item($_item);
278 278
 
279
-			if ( is_wp_error( $_response ) ) {
279
+			if (is_wp_error($_response)) {
280 280
 
281 281
 				$delete[] = array(
282 282
 					'id'    => $id,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 				continue;
291 291
 			}
292 292
 
293
-			$delete[] = $wp_rest_server->response_to_data( /** @scrutinizer ignore-type */ $_response, false );
293
+			$delete[] = $wp_rest_server->response_to_data(/** @scrutinizer ignore-type */ $_response, false);
294 294
 
295 295
 		}
296 296
 
@@ -304,23 +304,23 @@  discard block
 block discarded – undo
304 304
 	 * @param WP_REST_Request $request Full details about the request.
305 305
 	 * @return WP_Error|array.
306 306
 	 */
307
-	public function batch_items( $request ) {
307
+	public function batch_items($request) {
308 308
 		global $wp_rest_server;
309 309
 
310 310
 		// Prepare the batch items.
311
-		$items = $this->fill_batch_keys( array_filter( $request->get_params() ) );
311
+		$items = $this->fill_batch_keys(array_filter($request->get_params()));
312 312
 
313 313
 		// Ensure that the batch has not exceeded the limit to prevent abuse.
314
-		$limit = $this->check_batch_limit( $items );
315
-		if ( is_wp_error( $limit ) ) {
314
+		$limit = $this->check_batch_limit($items);
315
+		if (is_wp_error($limit)) {
316 316
 			return $limit;
317 317
 		}
318 318
 
319 319
 		// Process the items.
320 320
 		return array(
321
-			'create' => $this->batch_create_items( $items['create'], $request, $wp_rest_server ),
322
-			'update' => $this->batch_update_items( $items['update'], $request, $wp_rest_server ),
323
-			'delete' => $this->batch_delete_items( $items['delete'], $wp_rest_server ),
321
+			'create' => $this->batch_create_items($items['create'], $request, $wp_rest_server),
322
+			'update' => $this->batch_update_items($items['update'], $request, $wp_rest_server),
323
+			'delete' => $this->batch_delete_items($items['delete'], $wp_rest_server),
324 324
 		);
325 325
 
326 326
 	}
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 * @param array $meta_query Meta query.
334 334
 	 * @return array
335 335
 	 */
336
-	protected function add_meta_query( $args, $meta_query ) {
337
-		if ( empty( $args['meta_query'] ) ) {
336
+	protected function add_meta_query($args, $meta_query) {
337
+		if (empty($args['meta_query'])) {
338 338
 			$args['meta_query'] = array();
339 339
 		}
340 340
 
@@ -356,25 +356,25 @@  discard block
 block discarded – undo
356 356
 			'type'       => 'object',
357 357
 			'properties' => array(
358 358
 				'create' => array(
359
-					'description' => __( 'List of created resources.', 'invoicing' ),
359
+					'description' => __('List of created resources.', 'invoicing'),
360 360
 					'type'        => 'array',
361
-					'context'     => array( 'view', 'edit' ),
361
+					'context'     => array('view', 'edit'),
362 362
 					'items'       => array(
363 363
 						'type'    => 'object',
364 364
 					),
365 365
 				),
366 366
 				'update' => array(
367
-					'description' => __( 'List of updated resources.', 'invoicing' ),
367
+					'description' => __('List of updated resources.', 'invoicing'),
368 368
 					'type'        => 'array',
369
-					'context'     => array( 'view', 'edit' ),
369
+					'context'     => array('view', 'edit'),
370 370
 					'items'       => array(
371 371
 						'type'    => 'object',
372 372
 					),
373 373
 				),
374 374
 				'delete' => array(
375
-					'description' => __( 'List of deleted resources.', 'invoicing' ),
375
+					'description' => __('List of deleted resources.', 'invoicing'),
376 376
 					'type'        => 'array',
377
-					'context'     => array( 'view', 'edit' ),
377
+					'context'     => array('view', 'edit'),
378 378
 					'items'       => array(
379 379
 						'type'    => 'integer',
380 380
 					),
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 	protected function get_schema_properties() {
396 396
 
397 397
 		$schema     = $this->get_item_schema();
398
-		$properties = isset( $schema['properties'] ) ? $schema['properties'] : array();
398
+		$properties = isset($schema['properties']) ? $schema['properties'] : array();
399 399
 
400 400
 		// For back-compat, include any field with an empty schema
401 401
 		// because it won't be present in $this->get_item_schema().
402
-		foreach ( $this->get_additional_fields() as $field_name => $field_options ) {
403
-			if ( is_null( $field_options['schema'] ) ) {
404
-				$properties[ $field_name ] = $field_options;
402
+		foreach ($this->get_additional_fields() as $field_name => $field_options) {
403
+			if (is_null($field_options['schema'])) {
404
+				$properties[$field_name] = $field_options;
405 405
 			}
406 406
 		}
407 407
 
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	 * @since 1.0.19
417 417
 	 * @return array
418 418
 	 */
419
-	protected function filter_response_fields_by_context( $fields, $context ) {
419
+	protected function filter_response_fields_by_context($fields, $context) {
420 420
 
421
-		if ( empty( $context ) ) {
421
+		if (empty($context)) {
422 422
 			return $fields;
423 423
 		}
424 424
 
425
-		foreach ( $fields as $name => $options ) {
426
-			if ( ! empty( $options['context'] ) && ! in_array( $context, $options['context'], true ) ) {
427
-				unset( $fields[ $name ] );
425
+		foreach ($fields as $name => $options) {
426
+			if (!empty($options['context']) && !in_array($context, $options['context'], true)) {
427
+				unset($fields[$name]);
428 428
 			}
429 429
 		}
430 430
 
@@ -440,35 +440,35 @@  discard block
 block discarded – undo
440 440
 	 * @since 1.0.19
441 441
 	 * @return array
442 442
 	 */
443
-	protected function filter_response_fields_by_array( $fields, $requested ) {
443
+	protected function filter_response_fields_by_array($fields, $requested) {
444 444
 
445 445
 		// Trim off any whitespace from the list array.
446
-		$requested = array_map( 'trim', $requested );
446
+		$requested = array_map('trim', $requested);
447 447
 
448 448
 		// Always persist 'id', because it can be needed for add_additional_fields_to_object().
449
-		if ( in_array( 'id', $fields, true ) ) {
449
+		if (in_array('id', $fields, true)) {
450 450
 			$requested[] = 'id';
451 451
 		}
452 452
 
453 453
 		// Get rid of duplicate fields.
454
-		$requested = array_unique( $requested );
454
+		$requested = array_unique($requested);
455 455
 
456 456
 		// Return the list of all included fields which are available.
457 457
 		return array_reduce(
458 458
 			$requested,
459
-			function( $response_fields, $field ) use ( $fields ) {
459
+			function($response_fields, $field) use ($fields) {
460 460
 
461
-				if ( in_array( $field, $fields, true ) ) {
461
+				if (in_array($field, $fields, true)) {
462 462
 					$response_fields[] = $field;
463 463
 					return $response_fields;
464 464
 				}
465 465
 
466 466
 				// Check for nested fields if $field is not a direct match.
467
-				$nested_fields = explode( '.', $field );
467
+				$nested_fields = explode('.', $field);
468 468
 
469 469
 				// A nested field is included so long as its top-level property is
470 470
 				// present in the schema.
471
-				if ( in_array( $nested_fields[0], $fields, true ) ) {
471
+				if (in_array($nested_fields[0], $fields, true)) {
472 472
 					$response_fields[] = $field;
473 473
 				}
474 474
 
@@ -489,23 +489,23 @@  discard block
 block discarded – undo
489 489
 	 * @param WP_REST_Request $request Full details about the request.
490 490
 	 * @return array Fields to be included in the response.
491 491
 	 */
492
-	public function get_fields_for_response( $request ) {
492
+	public function get_fields_for_response($request) {
493 493
 
494 494
 		// Retrieve fields in the schema.
495 495
 		$properties = $this->get_schema_properties();
496 496
 
497 497
 		// Exclude fields that specify a different context than the request context.
498
-		$properties = $this->filter_response_fields_by_context( $properties, $request['context'] );
498
+		$properties = $this->filter_response_fields_by_context($properties, $request['context']);
499 499
 
500 500
 		// We only need the field keys.
501
-		$fields = array_keys( $properties );
501
+		$fields = array_keys($properties);
502 502
 
503 503
 		// Is the user filtering the response fields??
504
-		if ( empty( $request['_fields'] ) ) {
504
+		if (empty($request['_fields'])) {
505 505
 			return $fields;
506 506
 		}
507 507
 
508
-		return $this->filter_response_fields_by_array( $fields, wpinv_parse_list( $request['_fields'] ) );
508
+		return $this->filter_response_fields_by_array($fields, wpinv_parse_list($request['_fields']));
509 509
 
510 510
 	}
511 511
 
@@ -519,32 +519,32 @@  discard block
 block discarded – undo
519 519
 	 * @param array $fields Requested fields.
520 520
 	 * @return array Fields to be included in the response.
521 521
 	 */
522
-	public function limit_object_to_requested_fields( $data, $fields, $prefix = '' ) {
522
+	public function limit_object_to_requested_fields($data, $fields, $prefix = '') {
523 523
 
524 524
 		// Is the user filtering the response fields??
525
-		if ( empty( $fields ) ) {
525
+		if (empty($fields)) {
526 526
 			return $data;
527 527
 		}
528 528
 
529
-		foreach ( $data as $key => $value ) {
529
+		foreach ($data as $key => $value) {
530 530
 
531 531
 			// Numeric arrays.
532
-			if ( is_numeric( $key ) && is_array( $value ) ) {
533
-				$data[ $key ] = $this->limit_object_to_requested_fields( $value, $fields, $prefix );
532
+			if (is_numeric($key) && is_array($value)) {
533
+				$data[$key] = $this->limit_object_to_requested_fields($value, $fields, $prefix);
534 534
 				continue;
535 535
 			}
536 536
 
537 537
 			// Generate a new prefix.
538
-			$new_prefix = empty( $prefix ) ? $key : "$prefix.$key";
538
+			$new_prefix = empty($prefix) ? $key : "$prefix.$key";
539 539
 
540 540
 			// Check if it was requested.
541
-			if ( ! empty( $key ) && ! $this->is_field_included( $new_prefix, $fields ) ) {
542
-				unset( $data[ $key ] );
541
+			if (!empty($key) && !$this->is_field_included($new_prefix, $fields)) {
542
+				unset($data[$key]);
543 543
 				continue;
544 544
 			}
545 545
 
546
-			if ( $key != 'meta_data' && is_array( $value ) ) {
547
-				$data[ $key ] = $this->limit_object_to_requested_fields( $value, $fields, $new_prefix );
546
+			if ($key != 'meta_data' && is_array($value)) {
547
+				$data[$key] = $this->limit_object_to_requested_fields($value, $fields, $new_prefix);
548 548
 			}
549 549
 
550 550
 		}
@@ -566,20 +566,20 @@  discard block
 block discarded – undo
566 566
 	 * @return bool Whether to include the field or not.
567 567
 	 * @see rest_is_field_included()
568 568
 	 */
569
-	public function is_field_included( $field, $fields ) {
570
-		if ( in_array( $field, $fields, true ) ) {
569
+	public function is_field_included($field, $fields) {
570
+		if (in_array($field, $fields, true)) {
571 571
 			return true;
572 572
 		}
573 573
 
574
-		foreach ( $fields as $accepted_field ) {
574
+		foreach ($fields as $accepted_field) {
575 575
 			// Check to see if $field is the parent of any item in $fields.
576 576
 			// A field "parent" should be accepted if "parent.child" is accepted.
577
-			if ( strpos( $accepted_field, "$field." ) === 0 ) {
577
+			if (strpos($accepted_field, "$field.") === 0) {
578 578
 				return true;
579 579
 			}
580 580
 			// Conversely, if "parent" is accepted, all "parent.child" fields
581 581
 			// should also be accepted.
582
-			if ( strpos( $field, "$accepted_field." ) === 0 ) {
582
+			if (strpos($field, "$accepted_field.") === 0) {
583 583
 				return true;
584 584
 			}
585 585
 		}
Please login to merge, or discard this patch.