Passed
Push — master ( 2632ed...8bf7c9 )
by Brian
05:05
created
vendor/composer/platform_check.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 $issues = array();
6 6
 
7 7
 if (!(PHP_VERSION_ID >= 50600)) {
8
-    $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION  .  '.';
8
+    $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
9 9
 }
10 10
 
11 11
 if ($issues) {
Please login to merge, or discard this patch.
admin/meta-boxes/class-getpaid-meta-box-invoice-shipping-address.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit; // Exit if accessed directly
10
+    exit; // Exit if accessed directly
11 11
 }
12 12
 
13 13
 /**
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Meta_Box_Invoice_Shipping_Address {
17 17
 
18
-	/**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post
22
-	 */
23
-	public static function output( $post ) {
18
+    /**
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post
22
+     */
23
+    public static function output( $post ) {
24 24
 
25
-		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
25
+        // Retrieve shipping address.
26
+        $shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
27 27
 
28
-		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
30
-			return;
31
-		}
28
+        // Abort if it is invalid.
29
+        if ( ! is_array( $shipping_address ) ) {
30
+            return;
31
+        }
32 32
 
33
-		?>
33
+        ?>
34 34
 
35 35
 		<div class="bsui">
36 36
 
@@ -55,31 +55,31 @@  discard block
 block discarded – undo
55 55
 
56 56
 		<?php
57 57
 
58
-	}
58
+    }
59 59
 
60
-	/**
61
-	 * Prepares a value.
62
-	 *
63
-	 * @param array $address
64
-	 * @param string $key
65
-	 * @return string
66
-	 */
67
-	public static function prepare_for_display( $address, $key ) {
60
+    /**
61
+     * Prepares a value.
62
+     *
63
+     * @param array $address
64
+     * @param string $key
65
+     * @return string
66
+     */
67
+    public static function prepare_for_display( $address, $key ) {
68 68
 
69
-		// Prepare the value.
70
-		$value = $address[ $key ];
69
+        // Prepare the value.
70
+        $value = $address[ $key ];
71 71
 
72
-		if ( $key == 'country' ) {
73
-			$value = wpinv_country_name( $value );
74
-		}
72
+        if ( $key == 'country' ) {
73
+            $value = wpinv_country_name( $value );
74
+        }
75 75
 
76
-		if ( $key == 'state' ) {
77
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
-			$value = wpinv_state_name( $value, $country );
79
-		}
76
+        if ( $key == 'state' ) {
77
+            $country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
+            $value = wpinv_state_name( $value, $country );
79
+        }
80 80
 
81
-		return sanitize_text_field( $value );
81
+        return sanitize_text_field( $value );
82 82
 
83
-	}
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-	public static function output( $post ) {
23
+	public static function output($post) {
24 24
 
25 25
 		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
26
+		$shipping_address = get_post_meta($post->ID, 'shipping_address', true);
27 27
 
28 28
 		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
29
+		if (!is_array($shipping_address)) {
30 30
 			return;
31 31
 		}
32 32
 
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 
35 35
 		<div class="bsui">
36 36
 
37
-			<?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?>
37
+			<?php foreach (getpaid_user_address_fields() as $key => $label) : ?>
38 38
 
39
-					<?php if ( ! empty( $shipping_address[ $key ] ) ) : ?>
39
+					<?php if (!empty($shipping_address[$key])) : ?>
40 40
 
41 41
 						<div class="form-group form-row">
42 42
 							<div class="col">
43
-								<span style="font-weight: 600"><?php echo sanitize_text_field( $label ); ?>:</span>
43
+								<span style="font-weight: 600"><?php echo sanitize_text_field($label); ?>:</span>
44 44
 							</div>
45 45
 							<div class="col">
46
-								<?php echo self::prepare_for_display( $shipping_address, $key ); ?>
46
+								<?php echo self::prepare_for_display($shipping_address, $key); ?>
47 47
 							</div>
48 48
 						</div>
49 49
 
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 	 * @param string $key
65 65
 	 * @return string
66 66
 	 */
67
-	public static function prepare_for_display( $address, $key ) {
67
+	public static function prepare_for_display($address, $key) {
68 68
 
69 69
 		// Prepare the value.
70
-		$value = $address[ $key ];
70
+		$value = $address[$key];
71 71
 
72
-		if ( $key == 'country' ) {
73
-			$value = wpinv_country_name( $value );
72
+		if ($key == 'country') {
73
+			$value = wpinv_country_name($value);
74 74
 		}
75 75
 
76
-		if ( $key == 'state' ) {
77
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
78
-			$value = wpinv_state_name( $value, $country );
76
+		if ($key == 'state') {
77
+			$country = isset($address['country']) ? $address['country'] : wpinv_get_default_country();
78
+			$value = wpinv_state_name($value, $country);
79 79
 		}
80 80
 
81
-		return sanitize_text_field( $value );
81
+		return sanitize_text_field($value);
82 82
 
83 83
 	}
84 84
 
Please login to merge, or discard this patch.
includes/data/payment-form-elements.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@  discard block
 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
     array(
17 17
         'type'     => 'heading',
18
-        'name'     => __( 'Heading', 'invoicing' ),
18
+        'name'     => __('Heading', 'invoicing'),
19 19
         'defaults' => array(
20 20
             'level' => 'h2',
21
-            'text'  => __( 'Heading', 'invoicing' ),
21
+            'text'  => __('Heading', 'invoicing'),
22 22
         )
23 23
     ),
24 24
 
25 25
     array(
26 26
         'type' => 'paragraph',
27
-        'name' => __( 'Paragraph', 'invoicing' ),
27
+        'name' => __('Paragraph', 'invoicing'),
28 28
         'defaults'  => array(
29
-            'text'  => __( 'Paragraph text', 'invoicing' ),
29
+            'text'  => __('Paragraph text', 'invoicing'),
30 30
         )
31 31
     ),
32 32
 
33 33
     array( 
34 34
         'type' => 'alert',
35
-        'name' => __( 'Alert', 'invoicing' ),
35
+        'name' => __('Alert', 'invoicing'),
36 36
         'defaults'  => array(
37 37
             'value'        => '',
38 38
             'class'        => 'alert-warning',
39
-            'text'         => __( 'Alert', 'invoicing' ),
39
+            'text'         => __('Alert', 'invoicing'),
40 40
             'dismissible'  => false,
41 41
         )
42 42
     ),
43 43
 
44 44
     array( 
45 45
         'type' => 'separator',
46
-        'name' => __( 'Separator', 'invoicing' ),
46
+        'name' => __('Separator', 'invoicing'),
47 47
         'defaults'  => array(
48 48
             'value'        => '',
49 49
         ),
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
     array(
53 53
         'type' => 'text',
54
-        'name' => __( 'Text Input', 'invoicing' ),
54
+        'name' => __('Text Input', 'invoicing'),
55 55
         'defaults'  => array(
56
-            'placeholder'  => __( 'Enter some text', 'invoicing' ),
56
+            'placeholder'  => __('Enter some text', 'invoicing'),
57 57
             'value'        => '',
58
-            'label'        => __( 'Field Label', 'invoicing' ),
58
+            'label'        => __('Field Label', 'invoicing'),
59 59
             'description'  => '',
60 60
             'required'     => false,
61 61
         )
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
     array(
65 65
         'type' => 'textarea',
66
-        'name' => __( 'Textarea', 'invoicing' ),
66
+        'name' => __('Textarea', 'invoicing'),
67 67
         'defaults'         => array(
68
-            'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
68
+            'placeholder'  => __('Enter your text hear', 'invoicing'),
69 69
             'value'        => '',
70
-            'label'        => __( 'Textarea Label', 'invoicing' ),
70
+            'label'        => __('Textarea Label', 'invoicing'),
71 71
             'description'  => '',
72 72
             'required'     => false,
73 73
         )
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 
76 76
     array(
77 77
         'type' => 'select',
78
-        'name' => __( 'Dropdown', 'invoicing' ),
78
+        'name' => __('Dropdown', 'invoicing'),
79 79
         'defaults'         => array(
80
-            'placeholder'  => __( 'Select a value', 'invoicing' ),
80
+            'placeholder'  => __('Select a value', 'invoicing'),
81 81
             'value'        => '',
82
-            'label'        => __( 'Dropdown Label', 'invoicing' ),
82
+            'label'        => __('Dropdown Label', 'invoicing'),
83 83
             'description'  => '',
84 84
             'required'     => false,
85 85
             'options'      => array(
86
-                esc_attr__( 'Option One', 'invoicing' ),
87
-                esc_attr__( 'Option Two', 'invoicing' ),
88
-                esc_attr__( 'Option Three', 'invoicing' )
86
+                esc_attr__('Option One', 'invoicing'),
87
+                esc_attr__('Option Two', 'invoicing'),
88
+                esc_attr__('Option Three', 'invoicing')
89 89
             ),
90 90
         )
91 91
     ),
92 92
 
93 93
     array(
94 94
         'type' => 'checkbox',
95
-        'name' => __( 'Checkbox', 'invoicing' ),
95
+        'name' => __('Checkbox', 'invoicing'),
96 96
         'defaults'         => array(
97 97
             'value'        => '',
98
-            'label'        => __( 'Checkbox Label', 'invoicing' ),
98
+            'label'        => __('Checkbox Label', 'invoicing'),
99 99
             'description'  => '',
100 100
             'required'     => false,
101 101
         )
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 
104 104
     array( 
105 105
         'type' => 'radio',
106
-        'name' => __( 'Radio', 'invoicing' ),
106
+        'name' => __('Radio', 'invoicing'),
107 107
         'defaults'     => array(
108
-            'label'    => __( 'Select one choice', 'invoicing' ),
108
+            'label'    => __('Select one choice', 'invoicing'),
109 109
             'options'  => array(
110
-                esc_attr__( 'Choice One', 'invoicing' ),
111
-                esc_attr__( 'Choice Two', 'invoicing' ),
112
-                esc_attr__( 'Choice Three', 'invoicing' )
110
+                esc_attr__('Choice One', 'invoicing'),
111
+                esc_attr__('Choice Two', 'invoicing'),
112
+                esc_attr__('Choice Three', 'invoicing')
113 113
             ),
114 114
         )
115 115
     ),
116 116
 
117 117
     array( 
118 118
         'type' => 'date',
119
-        'name' => __( 'Date', 'invoicing' ),
119
+        'name' => __('Date', 'invoicing'),
120 120
         'defaults' => array(
121 121
             'value'        => '',
122
-            'label'        => __( 'Date', 'invoicing' ),
122
+            'label'        => __('Date', 'invoicing'),
123 123
             'description'  => '',
124 124
             'required'     => false,
125 125
         )
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 
128 128
     array( 
129 129
         'type' => 'time',
130
-        'name' => __( 'Time', 'invoicing' ),
130
+        'name' => __('Time', 'invoicing'),
131 131
         'defaults' => array(
132 132
             'value'        => '',
133
-            'label'        => __( 'Time', 'invoicing' ),
133
+            'label'        => __('Time', 'invoicing'),
134 134
             'description'  => '',
135 135
             'required'     => false,
136 136
         )
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
     array( 
140 140
         'type' => 'number',
141
-        'name' => __( 'Number', 'invoicing' ),
141
+        'name' => __('Number', 'invoicing'),
142 142
         'defaults' => array(
143 143
             'placeholder'  => '',
144 144
             'value'        => '',
145
-            'label'        => __( 'Number', 'invoicing' ),
145
+            'label'        => __('Number', 'invoicing'),
146 146
             'description'  => '',
147 147
             'required'     => false,
148 148
         )
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 
151 151
     array( 
152 152
         'type' => 'website',
153
-        'name' => __( 'Website', 'invoicing' ),
153
+        'name' => __('Website', 'invoicing'),
154 154
         'defaults' => array(
155 155
             'placeholder'  => 'http://example.com',
156 156
             'value'        => '',
157
-            'label'        => __( 'Website', 'invoicing' ),
157
+            'label'        => __('Website', 'invoicing'),
158 158
             'description'  => '',
159 159
             'required'     => false,
160 160
         )
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     array( 
164 164
         'type' => 'email',
165
-        'name' => __( 'Email', 'invoicing' ),
165
+        'name' => __('Email', 'invoicing'),
166 166
         'defaults'  => array(
167 167
             'placeholder'  => '[email protected]',
168 168
             'value'        => '',
169
-            'label'        => __( 'Email Address', 'invoicing' ),
169
+            'label'        => __('Email Address', 'invoicing'),
170 170
             'description'  => '',
171 171
             'required'     => false,
172 172
         )
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 
175 175
     array( 
176 176
         'type' => 'address',
177
-        'name' => __( 'Address', 'invoicing' ),
177
+        'name' => __('Address', 'invoicing'),
178 178
         'defaults'  => array(
179 179
 
180 180
             'address_type'            => 'billing',
181
-            'billing_address_title'   => __( 'Billing Address', 'invoicing' ),
182
-            'shipping_address_title'  => __( 'Shipping Address', 'invoicing' ),
183
-            'shipping_address_toggle' => __( 'Same billing & shipping address.', 'invoicing' ),
181
+            'billing_address_title'   => __('Billing Address', 'invoicing'),
182
+            'shipping_address_title'  => __('Shipping Address', 'invoicing'),
183
+            'shipping_address_toggle' => __('Same billing & shipping address.', 'invoicing'),
184 184
             'fields'                  => array(
185 185
                 array(
186 186
                     'placeholder'  => 'Jon',
187 187
                     'value'        => '',
188
-                    'label'        => __( 'First Name', 'invoicing' ),
188
+                    'label'        => __('First Name', 'invoicing'),
189 189
                     'description'  => '',
190 190
                     'required'     => false,
191 191
                     'visible'      => true,
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                 array(
197 197
                     'placeholder'  => 'Snow',
198 198
                     'value'        => '',
199
-                    'label'        => __( 'Last Name', 'invoicing' ),
199
+                    'label'        => __('Last Name', 'invoicing'),
200 200
                     'description'  => '',
201 201
                     'required'     => false,
202 202
                     'visible'      => true,
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                 array(
208 208
                     'placeholder'  => '',
209 209
                     'value'        => '',
210
-                    'label'        => __( 'Address', 'invoicing' ),
210
+                    'label'        => __('Address', 'invoicing'),
211 211
                     'description'  => '',
212 212
                     'required'     => false,
213 213
                     'visible'      => true,
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 array(
219 219
                     'placeholder'  => '',
220 220
                     'value'        => '',
221
-                    'label'        => __( 'City', 'invoicing' ),
221
+                    'label'        => __('City', 'invoicing'),
222 222
                     'description'  => '',
223 223
                     'required'     => false,
224 224
                     'visible'      => true,
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
                 ),
228 228
 
229 229
                 array(
230
-                    'placeholder'  => __( 'Select your country' ),
230
+                    'placeholder'  => __('Select your country'),
231 231
                     'value'        => '',
232
-                    'label'        => __( 'Country', 'invoicing' ),
232
+                    'label'        => __('Country', 'invoicing'),
233 233
                     'description'  => '',
234 234
                     'required'     => false,
235 235
                     'visible'      => true,
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
                 ),
239 239
 
240 240
                 array(
241
-                    'placeholder'  => __( 'Choose a state', 'invoicing' ),
241
+                    'placeholder'  => __('Choose a state', 'invoicing'),
242 242
                     'value'        => '',
243
-                    'label'        => __( 'State / Province', 'invoicing' ),
243
+                    'label'        => __('State / Province', 'invoicing'),
244 244
                     'description'  => '',
245 245
                     'required'     => false,
246 246
                     'visible'      => true,
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 array(
252 252
                     'placeholder'  => '',
253 253
                     'value'        => '',
254
-                    'label'        => __( 'ZIP / Postcode', 'invoicing' ),
254
+                    'label'        => __('ZIP / Postcode', 'invoicing'),
255 255
                     'description'  => '',
256 256
                     'required'     => false,
257 257
                     'visible'      => true,
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                 array(
263 263
                     'placeholder'  => '',
264 264
                     'value'        => '',
265
-                    'label'        => __( 'Phone', 'invoicing' ),
265
+                    'label'        => __('Phone', 'invoicing'),
266 266
                     'description'  => '',
267 267
                     'required'     => false,
268 268
                     'visible'      => true,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                 array(
274 274
                     'placeholder'  => '',
275 275
                     'value'        => '',
276
-                    'label'        => __( 'Company', 'invoicing' ),
276
+                    'label'        => __('Company', 'invoicing'),
277 277
                     'description'  => '',
278 278
                     'required'     => false,
279 279
                     'visible'      => false,
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                 array(
285 285
                     'placeholder'  => '',
286 286
                     'value'        => '',
287
-                    'label'        => __( 'VAT Number', 'invoicing' ),
287
+                    'label'        => __('VAT Number', 'invoicing'),
288 288
                     'description'  => '',
289 289
                     'required'     => false,
290 290
                     'visible'      => false,
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 
298 298
     array( 
299 299
         'type' => 'billing_email',
300
-        'name' => __( 'Billing Email', 'invoicing' ),
300
+        'name' => __('Billing Email', 'invoicing'),
301 301
         'defaults'  => array(
302 302
             'placeholder'  => '[email protected]',
303 303
             'value'        => '',
304
-            'label'        => __( 'Billing Email', 'invoicing' ),
304
+            'label'        => __('Billing Email', 'invoicing'),
305 305
             'description'  => '',
306 306
             'premade'      => true,
307 307
         )
@@ -309,18 +309,18 @@  discard block
 block discarded – undo
309 309
 
310 310
     array( 
311 311
         'type' => 'discount',
312
-        'name' => __( 'Discount Input', 'invoicing' ),
312
+        'name' => __('Discount Input', 'invoicing'),
313 313
         'defaults'  => array(
314 314
             'value'        => '',
315
-            'input_label'  => __( 'Coupon Code', 'invoicing' ),
316
-            'button_label' => __( 'Apply Coupon', 'invoicing' ),
317
-            'description'  => __( 'Have a discount code? Enter it above.', 'invoicing' ),
315
+            'input_label'  => __('Coupon Code', 'invoicing'),
316
+            'button_label' => __('Apply Coupon', 'invoicing'),
317
+            'description'  => __('Have a discount code? Enter it above.', 'invoicing'),
318 318
         )
319 319
     ),
320 320
 
321 321
     array( 
322 322
         'type' => 'items',
323
-        'name' => __( 'Items', 'invoicing' ),
323
+        'name' => __('Items', 'invoicing'),
324 324
         'defaults'  => array(
325 325
             'value'        => '',
326 326
             'items_type'   => 'total',
@@ -332,22 +332,22 @@  discard block
 block discarded – undo
332 332
 
333 333
     array( 
334 334
         'type' => 'price_input',
335
-        'name' => __( 'Price Input', 'invoicing' ),
335
+        'name' => __('Price Input', 'invoicing'),
336 336
         'defaults'  => array(
337 337
             'placeholder'  => wpinv_format_amount(0),
338 338
             'value'        => wpinv_format_amount(0),
339 339
             'minimum'      => wpinv_format_amount(0),
340
-            'label'        => __( 'Enter Amount', 'invoicing' ),
340
+            'label'        => __('Enter Amount', 'invoicing'),
341 341
             'description'  => '',
342 342
         )
343 343
     ),
344 344
 
345 345
     array( 
346 346
         'type' => 'price_select',
347
-        'name' => __( 'Price Select', 'invoicing' ),
347
+        'name' => __('Price Select', 'invoicing'),
348 348
         'defaults'  => array(
349 349
             'description'  => '',
350
-            'label'        => __( 'Select Amount', 'invoicing' ),
350
+            'label'        => __('Select Amount', 'invoicing'),
351 351
             'options'      => 'Option 1|10, Option 2|20',
352 352
             'placeholder'  => '',
353 353
             'select_type'  => 'select',
@@ -356,39 +356,39 @@  discard block
 block discarded – undo
356 356
 
357 357
     array( 
358 358
         'type'       => 'pay_button',
359
-        'name'       => __( 'Payment Button', 'invoicing' ),
359
+        'name'       => __('Payment Button', 'invoicing'),
360 360
         'defaults'   => array(
361 361
             'value'          => '',
362 362
             'class'          => 'btn-primary',
363
-            'label'          => __( 'Pay %price% »', 'invoicing' ),
364
-            'free'           => __( 'Continue »', 'invoicing' ),
365
-            'description'    => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
363
+            'label'          => __('Pay %price% »', 'invoicing'),
364
+            'free'           => __('Continue »', 'invoicing'),
365
+            'description'    => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
366 366
             'premade'        => true,
367 367
         )
368 368
     ),
369 369
 
370 370
     array(
371 371
         'type'       => 'gateway_select',
372
-        'name'       => __( 'Gateway Select', 'invoicing' ),
372
+        'name'       => __('Gateway Select', 'invoicing'),
373 373
         'defaults'   => array(
374
-            'text'    => __( 'Select Payment Method', 'invoicing' ),
374
+            'text'    => __('Select Payment Method', 'invoicing'),
375 375
             'premade' => true,
376 376
         )
377 377
     ),
378 378
 
379 379
     array( 
380 380
         'type'       => 'total_payable',
381
-        'name'       => __( 'Total Payable', 'invoicing' ),
381
+        'name'       => __('Total Payable', 'invoicing'),
382 382
         'defaults'   => array(
383
-            'text' => __( 'Total to pay:', 'invoicing' ),
383
+            'text' => __('Total to pay:', 'invoicing'),
384 384
         )
385 385
     ),
386 386
 
387 387
     array( 
388 388
         'type'       => 'ip_address',
389
-        'name'       => __( 'IP Address', 'invoicing' ),
389
+        'name'       => __('IP Address', 'invoicing'),
390 390
         'defaults'   => array(
391
-            'text' => __( 'Your IP address is:', 'invoicing' ),
391
+            'text' => __('Your IP address is:', 'invoicing'),
392 392
         )
393 393
     )
394 394
 );
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/address.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
                 <div class='form-group'>
33 33
                     <label class="d-block">
34
-                        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
34
+                        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
35 35
                         <input v-model='field.label' class='form-control' type="text"/>
36 36
                     </label>
37 37
                 </div>
38 38
 
39 39
                 <div class='form-group'>
40 40
                     <label class="d-block">
41
-                        <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span>
41
+                        <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span>
42 42
                         <input v-model='field.placeholder' class='form-control' type="text"/>
43 43
                     </label>
44 44
                 </div>
45 45
 
46 46
                 <div class='form-group'>
47 47
                     <label class="d-block">
48
-                        <span><?php esc_html_e( 'Width', 'invoicing' ) ?></span>
48
+                        <span><?php esc_html_e('Width', 'invoicing') ?></span>
49 49
                         <select class='form-control custom-select' v-model='field.grid_width'>
50
-                            <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
51
-                            <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
52
-                            <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
50
+                            <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
51
+                            <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
52
+                            <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
53 53
                         </select>
54 54
                     </label>
55 55
                 </div>
56 56
 
57 57
                 <div class='form-group'>
58 58
                     <label class="d-block">
59
-                        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
60
-                        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='field.description' class='form-control' rows='3'></textarea>
59
+                        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
60
+                        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='field.description' class='form-control' rows='3'></textarea>
61 61
                     </label>
62 62
                 </div>
63 63
 
64 64
                 <div class='form-group form-check'>
65 65
                     <input :id="active_form_element.id + '_edit_required' + index" v-model='field.required' type='checkbox' class='form-check-input' />
66
-                    <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e( 'Is required', 'invoicing' ); ?></label>
66
+                    <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e('Is required', 'invoicing'); ?></label>
67 67
                 </div>
68 68
 
69 69
                 <div class='form-group form-check'>
70 70
                     <input :id="active_form_element.id + '_edit_visible' + index" v-model='field.visible' type='checkbox' class='form-check-input' />
71
-                    <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e( 'Is visible', 'invoicing' ); ?></label>
71
+                    <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e('Is visible', 'invoicing'); ?></label>
72 72
                 </div>
73 73
 
74 74
             </div>
@@ -81,18 +81,18 @@  discard block
 block discarded – undo
81 81
 
82 82
 <div class='form-group'>
83 83
     <label class="d-block">
84
-        <span><?php esc_html_e( 'Address Type', 'invoicing' ) ?><span>
84
+        <span><?php esc_html_e('Address Type', 'invoicing') ?><span>
85 85
         <select class='form-control custom-select' v-model='active_form_element.address_type'>
86
-            <option value='billing'><?php esc_html_e( 'Billing', 'invoicing' ); ?></option>
87
-            <option value='shipping'><?php esc_html_e( 'Shipping', 'invoicing' ); ?></option>
88
-            <option value='both'><?php esc_html_e( 'Both', 'invoicing' ); ?></option>
86
+            <option value='billing'><?php esc_html_e('Billing', 'invoicing'); ?></option>
87
+            <option value='shipping'><?php esc_html_e('Shipping', 'invoicing'); ?></option>
88
+            <option value='both'><?php esc_html_e('Both', 'invoicing'); ?></option>
89 89
         </select>
90 90
     </label>
91 91
 </div>
92 92
 
93 93
 <div class='form-group' v-if="active_form_element.address_type == 'both'">
94 94
     <label class="d-block">
95
-        <span><?php esc_html_e( 'Shipping Address Toggle', 'invoicing' ) ?><span>
95
+        <span><?php esc_html_e('Shipping Address Toggle', 'invoicing') ?><span>
96 96
         <input type="text" class='form-control custom-select' v-model='active_form_element.shipping_address_toggle' >
97 97
     </label>
98 98
 </div>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/address.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='wpinv-address-wrapper row'>
15 15
 
16
-    <h4 v-if="form_element.address_type == 'both'" class="col-12 mb-3"><?php _e( 'Billing / Shipping Address', 'invoicing' ); ?></h4>
16
+    <h4 v-if="form_element.address_type == 'both'" class="col-12 mb-3"><?php _e('Billing / Shipping Address', 'invoicing'); ?></h4>
17 17
 
18 18
     <div class='form-group address-field-preview wpinv-payment-form-field-preview' v-for='(field, index) in visible_fields( form_element.fields )' :class='grid_class( field )' :key='field.name'>
19 19
         <label class="d-block w-100">
Please login to merge, or discard this patch.
includes/class-getpaid-notification-email-sender.php 2 patches
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Notification_Email_Sender {
14 14
 
15 15
     /**
16
-	 * Whether or not we should inline CSS into the email.
17
-	 */
18
-	public $inline_css = true;
16
+     * Whether or not we should inline CSS into the email.
17
+     */
18
+    public $inline_css = true;
19 19
 
20 20
     /**
21
-	 * The wp_mail() data.
22
-	 */
21
+     * The wp_mail() data.
22
+     */
23 23
     public $wp_mail_data = null;
24 24
 
25 25
     /**
26
-	 * Sends a new email.
26
+     * Sends a new email.
27 27
      * 
28 28
      * @param string|array $to The recipients email or an array of recipient emails.
29 29
      * @param string $subject The email's subject.
@@ -31,49 +31,49 @@  discard block
 block discarded – undo
31 31
      * @param array $attachments The email attachments.
32 32
      * 
33 33
      * @return bool
34
-	 */
35
-	public function send( $to, $subject, $email, $attachments = array() ) {
34
+     */
35
+    public function send( $to, $subject, $email, $attachments = array() ) {
36 36
 
37
-		/*
37
+        /*
38 38
 		 * Allow to filter data on per-email basis.
39 39
 		 */
40
-		$data = apply_filters(
41
-			'getpaid_email_data',
42
-			array(
43
-				'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
-				'subject'     => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ),
45
-				'email'       => apply_filters( 'wpinv_mail_content', $email ),
46
-				'headers'     => $this->get_headers(),
47
-				'attachments' => $attachments,
48
-			),
49
-			$this
50
-		);
40
+        $data = apply_filters(
41
+            'getpaid_email_data',
42
+            array(
43
+                'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
+                'subject'     => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ),
45
+                'email'       => apply_filters( 'wpinv_mail_content', $email ),
46
+                'headers'     => $this->get_headers(),
47
+                'attachments' => $attachments,
48
+            ),
49
+            $this
50
+        );
51 51
 
52 52
         // Remove slashes.
53 53
         $data               = (array) wp_unslash( $data );
54 54
 
55 55
         // Cache it.
56
-		$this->wp_mail_data = $data;
56
+        $this->wp_mail_data = $data;
57 57
 
58
-		// Attach our own hooks.
59
-		$this->before_sending();
58
+        // Attach our own hooks.
59
+        $this->before_sending();
60 60
 
61 61
         $result = false;
62 62
 
63 63
         foreach ( $this->wp_mail_data['to'] as $to ) {
64
-			$result = $this->_send( $to, $data );
64
+            $result = $this->_send( $to, $data );
65 65
         }
66 66
 
67
-		// Remove our hooks.
68
-		$this->after_sending();		
67
+        // Remove our hooks.
68
+        $this->after_sending();		
69 69
 
70
-		$this->wp_mail_data = null;
70
+        $this->wp_mail_data = null;
71 71
 
72
-		return $result;
73
-	}
72
+        return $result;
73
+    }
74 74
 
75
-	/**
76
-	 * Does the actual sending.
75
+    /**
76
+     * Does the actual sending.
77 77
      * 
78 78
      * @param string $to The recipient's email.
79 79
      * @param array $data The email's data.
@@ -81,81 +81,81 @@  discard block
 block discarded – undo
81 81
      * @param array $attachments The email attachments.
82 82
      * 
83 83
      * @return bool
84
-	 */
85
-	protected function _send( $to, $data ) {
86
-
87
-		// Prepare the sending function.
88
-		$sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
89
-
90
-		// Send the actual email.
91
-		$result = call_user_func(
92
-			$sending_function,
93
-			$to,
94
-			html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
95
-			$data['email'],
96
-			$data['headers'],
97
-			$data['attachments']
98
-		);
99
-
100
-		if ( ! $result ) {
101
-			$log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
-			wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
103
-		}
104
-
105
-		return $result;
106
-	}
84
+     */
85
+    protected function _send( $to, $data ) {
86
+
87
+        // Prepare the sending function.
88
+        $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
89
+
90
+        // Send the actual email.
91
+        $result = call_user_func(
92
+            $sending_function,
93
+            $to,
94
+            html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
95
+            $data['email'],
96
+            $data['headers'],
97
+            $data['attachments']
98
+        );
99
+
100
+        if ( ! $result ) {
101
+            $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
+            wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
103
+        }
104
+
105
+        return $result;
106
+    }
107 107
     
108 108
     /**
109
-	 * Retrieves email headers.
110
-	 */
111
-	public function get_headers() {
109
+     * Retrieves email headers.
110
+     */
111
+    public function get_headers() {
112 112
 
113
-		$name       = $this->get_from_name();
114
-		$reply_to   = $this->get_reply_to();
115
-		$headers    = array( "Reply-To:$name <$reply_to>" );
113
+        $name       = $this->get_from_name();
114
+        $reply_to   = $this->get_reply_to();
115
+        $headers    = array( "Reply-To:$name <$reply_to>" );
116 116
 
117
-		return apply_filters( 'getpaid_email_headers',  $headers, $this );
117
+        return apply_filters( 'getpaid_email_headers',  $headers, $this );
118 118
 
119
-	}
119
+    }
120 120
 
121 121
     /**
122
-	 * Fires before an email is sent
123
-	 *
124
-	 * @since 1.0.0
125
-	 */
126
-	public function before_sending() {
122
+     * Fires before an email is sent
123
+     *
124
+     * @since 1.0.0
125
+     */
126
+    public function before_sending() {
127 127
 
128 128
         do_action( 'getpaid_before_send_email', $this );
129
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
-		add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 );
129
+        add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
+        add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
+        add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
+        add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 );
133 133
 
134
-	}
134
+    }
135 135
 
136 136
     /**
137
-	 * Returns the from name.
138
-	 */
139
-	public function get_from_name() {
137
+     * Returns the from name.
138
+     */
139
+    public function get_from_name() {
140 140
 
141 141
         $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) );
142 142
 
143
-		if ( empty( $from_name ) ) {
144
-			$from_name =  get_bloginfo( 'name' );
143
+        if ( empty( $from_name ) ) {
144
+            $from_name =  get_bloginfo( 'name' );
145 145
         }
146 146
 
147
-		return wp_specialchars_decode( $from_name, ENT_QUOTES );
147
+        return wp_specialchars_decode( $from_name, ENT_QUOTES );
148 148
     }
149 149
 
150 150
     /**
151
-	 * Returns the from email.
152
-	 */
153
-	public function get_from_address() {
151
+     * Returns the from email.
152
+     */
153
+    public function get_from_address() {
154 154
 
155 155
         $from_address = wpinv_get_option( 'email_from', $this->default_from_address() );
156 156
 
157
-		if ( ! is_email( $from_address ) ) {
158
-			$from_address =  $this->default_from_address();
157
+        if ( ! is_email( $from_address ) ) {
158
+            $from_address =  $this->default_from_address();
159 159
         }
160 160
         
161 161
         return $from_address;
@@ -163,75 +163,75 @@  discard block
 block discarded – undo
163 163
     }
164 164
 
165 165
     /**
166
-	 * The default emails from address.
167
-	 * 
168
-	 * Defaults to wordpress@$sitename
169
-	 * Some hosts will block outgoing mail from this address if it doesn't exist,
170
-	 * but there's no easy alternative. Defaulting to admin_email might appear to be
171
-	 * another option, but some hosts may refuse to relay mail from an unknown domain.
172
-	 *
173
-	 */
174
-	public function default_from_address() {
175
-
176
-		// Get the site domain and get rid of www.
177
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
-			$sitename = substr( $sitename, 4 );
180
-		}
181
-
182
-		$from_email = 'wordpress@' . $sitename;
183
-
184
-		return apply_filters( 'getpaid_default_from_address', $from_email );
166
+     * The default emails from address.
167
+     * 
168
+     * Defaults to wordpress@$sitename
169
+     * Some hosts will block outgoing mail from this address if it doesn't exist,
170
+     * but there's no easy alternative. Defaulting to admin_email might appear to be
171
+     * another option, but some hosts may refuse to relay mail from an unknown domain.
172
+     *
173
+     */
174
+    public function default_from_address() {
175
+
176
+        // Get the site domain and get rid of www.
177
+        $sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
+        if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
+            $sitename = substr( $sitename, 4 );
180
+        }
181
+
182
+        $from_email = 'wordpress@' . $sitename;
183
+
184
+        return apply_filters( 'getpaid_default_from_address', $from_email );
185 185
 
186 186
     }
187 187
     
188 188
     /**
189
-	 * Get the email reply-to.
190
-	 *
191
-	 *
192
-	 * @return string The email reply-to address.
193
-	 */
194
-	public function get_reply_to() {
189
+     * Get the email reply-to.
190
+     *
191
+     *
192
+     * @return string The email reply-to address.
193
+     */
194
+    public function get_reply_to() {
195 195
 
196
-		$reply_to = wpinv_get_admin_email();
196
+        $reply_to = wpinv_get_admin_email();
197 197
 
198
-		if ( ! is_email( $reply_to ) ) {
199
-			$reply_to =  get_option( 'admin_email' );
200
-		}
198
+        if ( ! is_email( $reply_to ) ) {
199
+            $reply_to =  get_option( 'admin_email' );
200
+        }
201 201
 
202
-		return $reply_to;
202
+        return $reply_to;
203 203
     }
204 204
     
205 205
     /**
206
-	 * Get the email content type.
207
-	 *
208
-	 */
209
-	public function get_content_type() {
210
-		return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
206
+     * Get the email content type.
207
+     *
208
+     */
209
+    public function get_content_type() {
210
+        return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
211 211
     }
212 212
     
213 213
     /**
214
-	 * Ensures that our email messages are not messed up by template plugins.
215
-	 *
216
-	 * @return array wp_mail_data.
217
-	 */
218
-	public function ensure_email_content( $args ) {
219
-		$args['message'] = $this->wp_mail_data['email'];
220
-		return $args;
214
+     * Ensures that our email messages are not messed up by template plugins.
215
+     *
216
+     * @return array wp_mail_data.
217
+     */
218
+    public function ensure_email_content( $args ) {
219
+        $args['message'] = $this->wp_mail_data['email'];
220
+        return $args;
221 221
     }
222 222
     
223 223
     /**
224
-	 * A little house keeping after an email is sent.
225
-	 *
226
- 	 */
227
-	public function after_sending() {
224
+     * A little house keeping after an email is sent.
225
+     *
226
+     */
227
+    public function after_sending() {
228 228
 
229 229
         do_action( 'getpaid_after_send_email', $this->wp_mail_data );
230
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
-		remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
230
+        remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
+        remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
+        remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
+        remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
234 234
 
235
-	}
235
+    }
236 236
 
237 237
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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
  * This function is responsible for sending emails.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * 
33 33
      * @return bool
34 34
 	 */
35
-	public function send( $to, $subject, $email, $attachments = array() ) {
35
+	public function send($to, $subject, $email, $attachments = array()) {
36 36
 
37 37
 		/*
38 38
 		 * Allow to filter data on per-email basis.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 		$data = apply_filters(
41 41
 			'getpaid_email_data',
42 42
 			array(
43
-				'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
-				'subject'     => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ),
45
-				'email'       => apply_filters( 'wpinv_mail_content', $email ),
43
+				'to'          => array_filter(array_unique(wpinv_parse_list($to))),
44
+				'subject'     => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES),
45
+				'email'       => apply_filters('wpinv_mail_content', $email),
46 46
 				'headers'     => $this->get_headers(),
47 47
 				'attachments' => $attachments,
48 48
 			),
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		);
51 51
 
52 52
         // Remove slashes.
53
-        $data               = (array) wp_unslash( $data );
53
+        $data = (array) wp_unslash($data);
54 54
 
55 55
         // Cache it.
56 56
 		$this->wp_mail_data = $data;
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 
61 61
         $result = false;
62 62
 
63
-        foreach ( $this->wp_mail_data['to'] as $to ) {
64
-			$result = $this->_send( $to, $data );
63
+        foreach ($this->wp_mail_data['to'] as $to) {
64
+			$result = $this->_send($to, $data);
65 65
         }
66 66
 
67 67
 		// Remove our hooks.
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
      * 
83 83
      * @return bool
84 84
 	 */
85
-	protected function _send( $to, $data ) {
85
+	protected function _send($to, $data) {
86 86
 
87 87
 		// Prepare the sending function.
88
-		$sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
88
+		$sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail');
89 89
 
90 90
 		// Send the actual email.
91 91
 		$result = call_user_func(
92 92
 			$sending_function,
93 93
 			$to,
94
-			html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
94
+			html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')),
95 95
 			$data['email'],
96 96
 			$data['headers'],
97 97
 			$data['attachments']
98 98
 		);
99 99
 
100
-		if ( ! $result ) {
101
-			$log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
-			wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
100
+		if (!$result) {
101
+			$log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']);
102
+			wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__);
103 103
 		}
104 104
 
105 105
 		return $result;
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$name       = $this->get_from_name();
114 114
 		$reply_to   = $this->get_reply_to();
115
-		$headers    = array( "Reply-To:$name <$reply_to>" );
115
+		$headers    = array("Reply-To:$name <$reply_to>");
116 116
 
117
-		return apply_filters( 'getpaid_email_headers',  $headers, $this );
117
+		return apply_filters('getpaid_email_headers', $headers, $this);
118 118
 
119 119
 	}
120 120
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function before_sending() {
127 127
 
128
-        do_action( 'getpaid_before_send_email', $this );
129
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
-		add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 );
128
+        do_action('getpaid_before_send_email', $this);
129
+		add_filter('wp_mail_from', array($this, 'get_from_address'), 1000);
130
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000);
131
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000);
132
+		add_filter('wp_mail', array($this, 'ensure_email_content'), 1000);
133 133
 
134 134
 	}
135 135
 
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function get_from_name() {
140 140
 
141
-        $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) );
141
+        $from_name = wpinv_get_option('email_from_name', get_bloginfo('name'));
142 142
 
143
-		if ( empty( $from_name ) ) {
144
-			$from_name =  get_bloginfo( 'name' );
143
+		if (empty($from_name)) {
144
+			$from_name = get_bloginfo('name');
145 145
         }
146 146
 
147
-		return wp_specialchars_decode( $from_name, ENT_QUOTES );
147
+		return wp_specialchars_decode($from_name, ENT_QUOTES);
148 148
     }
149 149
 
150 150
     /**
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function get_from_address() {
154 154
 
155
-        $from_address = wpinv_get_option( 'email_from', $this->default_from_address() );
155
+        $from_address = wpinv_get_option('email_from', $this->default_from_address());
156 156
 
157
-		if ( ! is_email( $from_address ) ) {
158
-			$from_address =  $this->default_from_address();
157
+		if (!is_email($from_address)) {
158
+			$from_address = $this->default_from_address();
159 159
         }
160 160
         
161 161
         return $from_address;
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	public function default_from_address() {
175 175
 
176 176
 		// Get the site domain and get rid of www.
177
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
-			$sitename = substr( $sitename, 4 );
177
+		$sitename = strtolower($_SERVER['SERVER_NAME']);
178
+		if (substr($sitename, 0, 4) == 'www.') {
179
+			$sitename = substr($sitename, 4);
180 180
 		}
181 181
 
182 182
 		$from_email = 'wordpress@' . $sitename;
183 183
 
184
-		return apply_filters( 'getpaid_default_from_address', $from_email );
184
+		return apply_filters('getpaid_default_from_address', $from_email);
185 185
 
186 186
     }
187 187
     
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 
196 196
 		$reply_to = wpinv_get_admin_email();
197 197
 
198
-		if ( ! is_email( $reply_to ) ) {
199
-			$reply_to =  get_option( 'admin_email' );
198
+		if (!is_email($reply_to)) {
199
+			$reply_to = get_option('admin_email');
200 200
 		}
201 201
 
202 202
 		return $reply_to;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 */
209 209
 	public function get_content_type() {
210
-		return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
210
+		return apply_filters('getpaid_email_content_type', 'text/html', $this);
211 211
     }
212 212
     
213 213
     /**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array wp_mail_data.
217 217
 	 */
218
-	public function ensure_email_content( $args ) {
218
+	public function ensure_email_content($args) {
219 219
 		$args['message'] = $this->wp_mail_data['email'];
220 220
 		return $args;
221 221
     }
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
  	 */
227 227
 	public function after_sending() {
228 228
 
229
-        do_action( 'getpaid_after_send_email', $this->wp_mail_data );
230
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
-		remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
229
+        do_action('getpaid_after_send_email', $this->wp_mail_data);
230
+		remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000);
231
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000);
232
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000);
233
+		remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000000);
234 234
 
235 235
 	}
236 236
 
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-abstract-report.php 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -12,72 +12,72 @@  discard block
 block discarded – undo
12 12
  */
13 13
 abstract class GetPaid_Reports_Abstract_Report {
14 14
 
15
-	/**
16
-	 * @var array
17
-	 */
18
-	public $stats;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 */
24
-	public function __construct() {
25
-		$this->prepare_stats();
26
-	}
27
-
28
-	/**
29
-	 * Retrieves the current range.
30
-	 *
31
-	 */
32
-	public function get_range() {
33
-		$valid_ranges = $this->get_periods();
34
-
35
-		if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) {
36
-			return sanitize_key( $_GET['date_range'] );
37
-		}
38
-
39
-		return '7_days';
40
-	}
41
-
42
-	/**
43
-	 * Returns an array of date ranges.
44
-	 *
45
-	 * @return array
46
-	 */
47
-	public function get_periods() {
48
-
49
-		$periods = array(
15
+    /**
16
+     * @var array
17
+     */
18
+    public $stats;
19
+
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     */
24
+    public function __construct() {
25
+        $this->prepare_stats();
26
+    }
27
+
28
+    /**
29
+     * Retrieves the current range.
30
+     *
31
+     */
32
+    public function get_range() {
33
+        $valid_ranges = $this->get_periods();
34
+
35
+        if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) {
36
+            return sanitize_key( $_GET['date_range'] );
37
+        }
38
+
39
+        return '7_days';
40
+    }
41
+
42
+    /**
43
+     * Returns an array of date ranges.
44
+     *
45
+     * @return array
46
+     */
47
+    public function get_periods() {
48
+
49
+        $periods = array(
50 50
             'today'     => __( 'Today', 'invoicing' ),
51 51
             'yesterday' => __( 'Yesterday', 'invoicing' ),
52 52
             '7_days'    => __( 'Last 7 days', 'invoicing' ),
53
-			'30_days'   => __( 'Last 30 days', 'invoicing' ),
54
-			'60_days'   => __( 'Last 60 days', 'invoicing' ),
55
-			'90_days'   => __( 'Last 90 days', 'invoicing' ),
56
-			'180_days'  => __( 'Last 180 days', 'invoicing' ),
57
-			'360_days'  => __( 'Last 360 days', 'invoicing' ),
58
-		);
59
-
60
-		return apply_filters( 'getpaid_earning_periods', $periods );
61
-	}
62
-
63
-	/**
64
-	 * Retrieves the current range's sql.
65
-	 *
66
-	 */
67
-	public function get_range_sql( $range ) {
68
-
69
-		$date     = 'CAST(meta.completed_date AS DATE)';
53
+            '30_days'   => __( 'Last 30 days', 'invoicing' ),
54
+            '60_days'   => __( 'Last 60 days', 'invoicing' ),
55
+            '90_days'   => __( 'Last 90 days', 'invoicing' ),
56
+            '180_days'  => __( 'Last 180 days', 'invoicing' ),
57
+            '360_days'  => __( 'Last 360 days', 'invoicing' ),
58
+        );
59
+
60
+        return apply_filters( 'getpaid_earning_periods', $periods );
61
+    }
62
+
63
+    /**
64
+     * Retrieves the current range's sql.
65
+     *
66
+     */
67
+    public function get_range_sql( $range ) {
68
+
69
+        $date     = 'CAST(meta.completed_date AS DATE)';
70 70
         $datetime = 'meta.completed_date';
71 71
 
72 72
         // Prepare durations.
73 73
         $today                = current_time( 'Y-m-d' );
74
-		$yesterday            = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) );
75
-		$seven_days_ago       = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) );
76
-		$thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
77
-		$ninety_days_ago      = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) );
78
-		$sixty_days_ago       = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) );
79
-		$one_eighty_days_ago  = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) );
80
-		$three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) );
74
+        $yesterday            = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) );
75
+        $seven_days_ago       = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) );
76
+        $thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
77
+        $ninety_days_ago      = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) );
78
+        $sixty_days_ago       = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) );
79
+        $one_eighty_days_ago  = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) );
80
+        $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) );
81 81
 
82 82
         $ranges = array(
83 83
 
@@ -94,130 +94,130 @@  discard block
 block discarded – undo
94 94
             '7_days'       => array(
95 95
                 "DATE($datetime)",
96 96
                 "$date BETWEEN '$seven_days_ago' AND '$today'"
97
-			),
97
+            ),
98 98
 
99
-			'30_days'       => array(
99
+            '30_days'       => array(
100 100
                 "DATE($datetime)",
101 101
                 "$date BETWEEN '$thirty_days_ago' AND '$today'"
102
-			),
102
+            ),
103 103
 
104
-			'60_days'       => array(
104
+            '60_days'       => array(
105 105
                 "DATE($datetime)",
106 106
                 "$date BETWEEN '$sixty_days_ago' AND '$today'"
107
-			),
107
+            ),
108 108
 
109
-			'90_days'       => array(
109
+            '90_days'       => array(
110 110
                 "WEEK($datetime)",
111 111
                 "$date BETWEEN '$ninety_days_ago' AND '$today'"
112
-			),
112
+            ),
113 113
 
114
-			'180_days'       => array(
114
+            '180_days'       => array(
115 115
                 "WEEK($datetime)",
116 116
                 "$date BETWEEN '$one_eighty_days_ago' AND '$today'"
117
-			),
117
+            ),
118 118
 
119
-			'360_days'       => array(
119
+            '360_days'       => array(
120 120
                 "WEEK($datetime)",
121 121
                 "$date BETWEEN '$three_sixty_days_ago' AND '$today'"
122 122
             ),
123 123
 
124 124
         );
125 125
 
126
-		$sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ];
127
-		return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range );
128
-
129
-	}
130
-
131
-	/**
132
-	 * Retrieves the hours in a day
133
-	 *
134
-	 */
135
-	public function get_hours_in_a_day() {
136
-
137
-		return array(
138
-			'12AM' => __( '12 AM', 'invoicing'),
139
-			'1AM'  => __( '1 AM', 'invoicing'),
140
-			'2AM'  => __( '2 AM', 'invoicing'),
141
-			'3AM'  => __( '3 AM', 'invoicing'),
142
-			'4AM'  => __( '4 AM', 'invoicing'),
143
-			'5AM'  => __( '5 AM', 'invoicing'),
144
-			'6AM'  => __( '6 AM', 'invoicing'),
145
-			'7AM'  => __( '7 AM', 'invoicing'),
146
-			'8AM'  => __( '8 AM', 'invoicing'),
147
-			'9AM'  => __( '9 AM', 'invoicing'),
148
-			'10AM' => __( '10 AM', 'invoicing'),
149
-			'11AM' => __( '11 AM', 'invoicing'),
150
-			'12pm' => __( '12 PM', 'invoicing'),
151
-			'1PM'  => __( '1 PM', 'invoicing'),
152
-			'2PM'  => __( '2 PM', 'invoicing'),
153
-			'3PM'  => __( '3 PM', 'invoicing'),
154
-			'4PM'  => __( '4 PM', 'invoicing'),
155
-			'5PM'  => __( '5 PM', 'invoicing'),
156
-			'6PM'  => __( '6 PM', 'invoicing'),
157
-			'7PM'  => __( '7 PM', 'invoicing'),
158
-			'8PM'  => __( '8 PM', 'invoicing'),
159
-			'9PM'  => __( '9 PM', 'invoicing'),
160
-			'10PM' => __( '10 PM', 'invoicing'),
161
-			'11PM' => __( '11 PM', 'invoicing'),
162
-		);
163
-
164
-	}
165
-
166
-	/**
167
-	 * Retrieves the days in a period
168
-	 *
169
-	 */
170
-	public function get_days_in_period( $days ) {
171
-
172
-		$return = array();
173
-		$format = 'Y-m-d';
174
-
175
-		if ( $days < 8 ) {
176
-			$format = 'D';
177
-		}
178
-
179
-		if ( $days < 32 ) {
180
-			$format = 'M j';
181
-		}
182
-
183
-		while ( $days > 0 ) {
184
-
185
-			$key            = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
186
-			$label          = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) );
187
-			$return[ $key ] = $label;
188
-			$days--;
189
-
190
-		}
191
-
192
-		return $return;
193
-	}
194
-
195
-	/**
196
-	 * Retrieves the weeks in a period
197
-	 *
198
-	 */
199
-	public function get_weeks_in_period( $days ) {
200
-
201
-		$return = array();
202
-
203
-		while ( $days > 0 ) {
204
-
205
-			$key            = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) );
206
-			$label          = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
207
-			$return[ $key ] = $label;
208
-			$days--;
209
-
210
-		}
211
-
212
-		return $return;
213
-	}
214
-
215
-	/**
216
-	 * Displays the report card.
217
-	 *
218
-	 */
219
-	public function display() {
220
-		?>
126
+        $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ];
127
+        return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range );
128
+
129
+    }
130
+
131
+    /**
132
+     * Retrieves the hours in a day
133
+     *
134
+     */
135
+    public function get_hours_in_a_day() {
136
+
137
+        return array(
138
+            '12AM' => __( '12 AM', 'invoicing'),
139
+            '1AM'  => __( '1 AM', 'invoicing'),
140
+            '2AM'  => __( '2 AM', 'invoicing'),
141
+            '3AM'  => __( '3 AM', 'invoicing'),
142
+            '4AM'  => __( '4 AM', 'invoicing'),
143
+            '5AM'  => __( '5 AM', 'invoicing'),
144
+            '6AM'  => __( '6 AM', 'invoicing'),
145
+            '7AM'  => __( '7 AM', 'invoicing'),
146
+            '8AM'  => __( '8 AM', 'invoicing'),
147
+            '9AM'  => __( '9 AM', 'invoicing'),
148
+            '10AM' => __( '10 AM', 'invoicing'),
149
+            '11AM' => __( '11 AM', 'invoicing'),
150
+            '12pm' => __( '12 PM', 'invoicing'),
151
+            '1PM'  => __( '1 PM', 'invoicing'),
152
+            '2PM'  => __( '2 PM', 'invoicing'),
153
+            '3PM'  => __( '3 PM', 'invoicing'),
154
+            '4PM'  => __( '4 PM', 'invoicing'),
155
+            '5PM'  => __( '5 PM', 'invoicing'),
156
+            '6PM'  => __( '6 PM', 'invoicing'),
157
+            '7PM'  => __( '7 PM', 'invoicing'),
158
+            '8PM'  => __( '8 PM', 'invoicing'),
159
+            '9PM'  => __( '9 PM', 'invoicing'),
160
+            '10PM' => __( '10 PM', 'invoicing'),
161
+            '11PM' => __( '11 PM', 'invoicing'),
162
+        );
163
+
164
+    }
165
+
166
+    /**
167
+     * Retrieves the days in a period
168
+     *
169
+     */
170
+    public function get_days_in_period( $days ) {
171
+
172
+        $return = array();
173
+        $format = 'Y-m-d';
174
+
175
+        if ( $days < 8 ) {
176
+            $format = 'D';
177
+        }
178
+
179
+        if ( $days < 32 ) {
180
+            $format = 'M j';
181
+        }
182
+
183
+        while ( $days > 0 ) {
184
+
185
+            $key            = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
186
+            $label          = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) );
187
+            $return[ $key ] = $label;
188
+            $days--;
189
+
190
+        }
191
+
192
+        return $return;
193
+    }
194
+
195
+    /**
196
+     * Retrieves the weeks in a period
197
+     *
198
+     */
199
+    public function get_weeks_in_period( $days ) {
200
+
201
+        $return = array();
202
+
203
+        while ( $days > 0 ) {
204
+
205
+            $key            = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) );
206
+            $label          = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
207
+            $return[ $key ] = $label;
208
+            $days--;
209
+
210
+        }
211
+
212
+        return $return;
213
+    }
214
+
215
+    /**
216
+     * Displays the report card.
217
+     *
218
+     */
219
+    public function display() {
220
+        ?>
221 221
 
222 222
 			<div class="row">
223 223
 				<div class="col-12">
@@ -231,20 +231,20 @@  discard block
 block discarded – undo
231 231
 
232 232
 		<?php
233 233
 
234
-	}
235
-
236
-	/**
237
-	 * Prepares the report stats.
238
-	 *
239
-	 * Extend this in child classes.
240
-	 */
241
-	abstract public function prepare_stats();
242
-
243
-	/**
244
-	 * Displays the actual report.
245
-	 *
246
-	 * Extend this in child classes.
247
-	 */
248
-	abstract public function display_stats();
234
+    }
235
+
236
+    /**
237
+     * Prepares the report stats.
238
+     *
239
+     * Extend this in child classes.
240
+     */
241
+    abstract public function prepare_stats();
242
+
243
+    /**
244
+     * Displays the actual report.
245
+     *
246
+     * Extend this in child classes.
247
+     */
248
+    abstract public function display_stats();
249 249
 
250 250
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Abstract_Report Class.
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	public function get_range() {
33 33
 		$valid_ranges = $this->get_periods();
34 34
 
35
-		if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) {
36
-			return sanitize_key( $_GET['date_range'] );
35
+		if (isset($_GET['date_range']) && array_key_exists($_GET['date_range'], $valid_ranges)) {
36
+			return sanitize_key($_GET['date_range']);
37 37
 		}
38 38
 
39 39
 		return '7_days';
@@ -47,37 +47,37 @@  discard block
 block discarded – undo
47 47
 	public function get_periods() {
48 48
 
49 49
 		$periods = array(
50
-            'today'     => __( 'Today', 'invoicing' ),
51
-            'yesterday' => __( 'Yesterday', 'invoicing' ),
52
-            '7_days'    => __( 'Last 7 days', 'invoicing' ),
53
-			'30_days'   => __( 'Last 30 days', 'invoicing' ),
54
-			'60_days'   => __( 'Last 60 days', 'invoicing' ),
55
-			'90_days'   => __( 'Last 90 days', 'invoicing' ),
56
-			'180_days'  => __( 'Last 180 days', 'invoicing' ),
57
-			'360_days'  => __( 'Last 360 days', 'invoicing' ),
50
+            'today'     => __('Today', 'invoicing'),
51
+            'yesterday' => __('Yesterday', 'invoicing'),
52
+            '7_days'    => __('Last 7 days', 'invoicing'),
53
+			'30_days'   => __('Last 30 days', 'invoicing'),
54
+			'60_days'   => __('Last 60 days', 'invoicing'),
55
+			'90_days'   => __('Last 90 days', 'invoicing'),
56
+			'180_days'  => __('Last 180 days', 'invoicing'),
57
+			'360_days'  => __('Last 360 days', 'invoicing'),
58 58
 		);
59 59
 
60
-		return apply_filters( 'getpaid_earning_periods', $periods );
60
+		return apply_filters('getpaid_earning_periods', $periods);
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 * Retrieves the current range's sql.
65 65
 	 *
66 66
 	 */
67
-	public function get_range_sql( $range ) {
67
+	public function get_range_sql($range) {
68 68
 
69
-		$date     = 'CAST(meta.completed_date AS DATE)';
69
+		$date = 'CAST(meta.completed_date AS DATE)';
70 70
         $datetime = 'meta.completed_date';
71 71
 
72 72
         // Prepare durations.
73
-        $today                = current_time( 'Y-m-d' );
74
-		$yesterday            = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) );
75
-		$seven_days_ago       = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) );
76
-		$thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
77
-		$ninety_days_ago      = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) );
78
-		$sixty_days_ago       = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) );
79
-		$one_eighty_days_ago  = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) );
80
-		$three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) );
73
+        $today = current_time('Y-m-d');
74
+		$yesterday            = date('Y-m-d', strtotime('-1 day', current_time('timestamp')));
75
+		$seven_days_ago       = date('Y-m-d', strtotime('-7 days', current_time('timestamp')));
76
+		$thirty_days_ago      = date('Y-m-d', strtotime('-30 days', current_time('timestamp')));
77
+		$ninety_days_ago      = date('Y-m-d', strtotime('-90 days', current_time('timestamp')));
78
+		$sixty_days_ago       = date('Y-m-d', strtotime('-60 days', current_time('timestamp')));
79
+		$one_eighty_days_ago  = date('Y-m-d', strtotime('-180 days', current_time('timestamp')));
80
+		$three_sixty_days_ago = date('Y-m-d', strtotime('-360 days', current_time('timestamp')));
81 81
 
82 82
         $ranges = array(
83 83
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 
124 124
         );
125 125
 
126
-		$sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ];
127
-		return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range );
126
+		$sql = isset($ranges[$range]) ? $ranges[$range] : $ranges['7_days'];
127
+		return apply_filters('getpaid_earning_graphs_get_range_sql', $sql, $range);
128 128
 
129 129
 	}
130 130
 
@@ -135,30 +135,30 @@  discard block
 block discarded – undo
135 135
 	public function get_hours_in_a_day() {
136 136
 
137 137
 		return array(
138
-			'12AM' => __( '12 AM', 'invoicing'),
139
-			'1AM'  => __( '1 AM', 'invoicing'),
140
-			'2AM'  => __( '2 AM', 'invoicing'),
141
-			'3AM'  => __( '3 AM', 'invoicing'),
142
-			'4AM'  => __( '4 AM', 'invoicing'),
143
-			'5AM'  => __( '5 AM', 'invoicing'),
144
-			'6AM'  => __( '6 AM', 'invoicing'),
145
-			'7AM'  => __( '7 AM', 'invoicing'),
146
-			'8AM'  => __( '8 AM', 'invoicing'),
147
-			'9AM'  => __( '9 AM', 'invoicing'),
148
-			'10AM' => __( '10 AM', 'invoicing'),
149
-			'11AM' => __( '11 AM', 'invoicing'),
150
-			'12pm' => __( '12 PM', 'invoicing'),
151
-			'1PM'  => __( '1 PM', 'invoicing'),
152
-			'2PM'  => __( '2 PM', 'invoicing'),
153
-			'3PM'  => __( '3 PM', 'invoicing'),
154
-			'4PM'  => __( '4 PM', 'invoicing'),
155
-			'5PM'  => __( '5 PM', 'invoicing'),
156
-			'6PM'  => __( '6 PM', 'invoicing'),
157
-			'7PM'  => __( '7 PM', 'invoicing'),
158
-			'8PM'  => __( '8 PM', 'invoicing'),
159
-			'9PM'  => __( '9 PM', 'invoicing'),
160
-			'10PM' => __( '10 PM', 'invoicing'),
161
-			'11PM' => __( '11 PM', 'invoicing'),
138
+			'12AM' => __('12 AM', 'invoicing'),
139
+			'1AM'  => __('1 AM', 'invoicing'),
140
+			'2AM'  => __('2 AM', 'invoicing'),
141
+			'3AM'  => __('3 AM', 'invoicing'),
142
+			'4AM'  => __('4 AM', 'invoicing'),
143
+			'5AM'  => __('5 AM', 'invoicing'),
144
+			'6AM'  => __('6 AM', 'invoicing'),
145
+			'7AM'  => __('7 AM', 'invoicing'),
146
+			'8AM'  => __('8 AM', 'invoicing'),
147
+			'9AM'  => __('9 AM', 'invoicing'),
148
+			'10AM' => __('10 AM', 'invoicing'),
149
+			'11AM' => __('11 AM', 'invoicing'),
150
+			'12pm' => __('12 PM', 'invoicing'),
151
+			'1PM'  => __('1 PM', 'invoicing'),
152
+			'2PM'  => __('2 PM', 'invoicing'),
153
+			'3PM'  => __('3 PM', 'invoicing'),
154
+			'4PM'  => __('4 PM', 'invoicing'),
155
+			'5PM'  => __('5 PM', 'invoicing'),
156
+			'6PM'  => __('6 PM', 'invoicing'),
157
+			'7PM'  => __('7 PM', 'invoicing'),
158
+			'8PM'  => __('8 PM', 'invoicing'),
159
+			'9PM'  => __('9 PM', 'invoicing'),
160
+			'10PM' => __('10 PM', 'invoicing'),
161
+			'11PM' => __('11 PM', 'invoicing'),
162 162
 		);
163 163
 
164 164
 	}
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 	 * Retrieves the days in a period
168 168
 	 *
169 169
 	 */
170
-	public function get_days_in_period( $days ) {
170
+	public function get_days_in_period($days) {
171 171
 
172 172
 		$return = array();
173 173
 		$format = 'Y-m-d';
174 174
 
175
-		if ( $days < 8 ) {
175
+		if ($days < 8) {
176 176
 			$format = 'D';
177 177
 		}
178 178
 
179
-		if ( $days < 32 ) {
179
+		if ($days < 32) {
180 180
 			$format = 'M j';
181 181
 		}
182 182
 
183
-		while ( $days > 0 ) {
183
+		while ($days > 0) {
184 184
 
185
-			$key            = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
186
-			$label          = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) );
187
-			$return[ $key ] = $label;
185
+			$key            = date('Y-m-d', strtotime("-$days days", current_time('timestamp')));
186
+			$label          = date_i18n($format, strtotime("-$days days", current_time('timestamp')));
187
+			$return[$key] = $label;
188 188
 			$days--;
189 189
 
190 190
 		}
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
 	 * Retrieves the weeks in a period
197 197
 	 *
198 198
 	 */
199
-	public function get_weeks_in_period( $days ) {
199
+	public function get_weeks_in_period($days) {
200 200
 
201 201
 		$return = array();
202 202
 
203
-		while ( $days > 0 ) {
203
+		while ($days > 0) {
204 204
 
205
-			$key            = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) );
206
-			$label          = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
207
-			$return[ $key ] = $label;
205
+			$key            = date('W', strtotime("-$days days", current_time('timestamp')));
206
+			$label          = date_i18n('Y-m-d', strtotime("-$days days", current_time('timestamp')));
207
+			$return[$key] = $label;
208 208
 			$days--;
209 209
 
210 210
 		}
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-database-service.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -13,154 +13,154 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_MaxMind_Database_Service {
15 15
 
16
-	/**
17
-	 * The name of the MaxMind database to utilize.
18
-	 */
19
-	const DATABASE = 'GeoLite2-Country';
20
-
21
-	/**
22
-	 * The extension for the MaxMind database.
23
-	 */
24
-	const DATABASE_EXTENSION = '.mmdb';
25
-
26
-	/**
27
-	 * A prefix for the MaxMind database filename.
28
-	 *
29
-	 * @var string
30
-	 */
31
-	private $database_prefix;
32
-
33
-	/**
34
-	 * Class constructor.
35
-	 *
36
-	 * @param string|null $database_prefix A prefix for the MaxMind database filename.
37
-	 */
38
-	public function __construct( $database_prefix ) {
39
-		$this->database_prefix = $database_prefix;
40
-	}
41
-
42
-	/**
43
-	 * Fetches the path that the database should be stored.
44
-	 *
45
-	 * @return string The local database path.
46
-	 */
47
-	public function get_database_path() {
48
-		$uploads_dir = wp_upload_dir();
49
-
50
-		$database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
-		if ( ! empty( $this->database_prefix ) ) {
52
-			$database_path .= $this->database_prefix . '-';
53
-		}
54
-		$database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55
-
56
-		// Filter the geolocation database storage path.
57
-		return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
58
-	}
59
-
60
-	/**
61
-	 * Fetches the database from the MaxMind service.
62
-	 *
63
-	 * @param string $license_key The license key to be used when downloading the database.
64
-	 * @return string|WP_Error The path to the database file or an error if invalid.
65
-	 */
66
-	public function download_database( $license_key ) {
67
-
68
-		$download_uri = add_query_arg(
69
-			array(
70
-				'edition_id'  => self::DATABASE,
71
-				'license_key' => urlencode( wpinv_clean( $license_key ) ),
72
-				'suffix'      => 'tar.gz',
73
-			),
74
-			'https://download.maxmind.com/app/geoip_download'
75
-		);
76
-
77
-		// Needed for the download_url call right below.
78
-		require_once ABSPATH . 'wp-admin/includes/file.php';
79
-
80
-		$tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
81
-
82
-		if ( is_wp_error( $tmp_archive_path ) ) {
83
-			// Transform the error into something more informative.
84
-			$error_data = $tmp_archive_path->get_error_data();
85
-			if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
86
-				return new WP_Error(
87
-					'getpaid_maxmind_geolocation_database_license_key',
88
-					__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
89
-				);
90
-			}
91
-
92
-			return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
93
-		}
94
-
95
-		// Extract the database from the archive.
96
-		return $this->extract_downloaded_database( $tmp_archive_path );
97
-
98
-	}
99
-
100
-	/**
101
-	 * Extracts the downloaded database.
102
-	 *
103
-	 * @param string $tmp_archive_path The database archive path.
104
-	 * @return string|WP_Error The path to the database file or an error if invalid.
105
-	 */
106
-	protected function extract_downloaded_database( $tmp_archive_path ) {
107
-
108
-		// Extract the database from the archive.
109
-		$tmp_database_path = '';
110
-
111
-		try {
112
-
113
-			$file              = new PharData( $tmp_archive_path );
114
-			$tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
115
-
116
-			$file->extractTo(
117
-				dirname( $tmp_archive_path ),
118
-				trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
119
-				true
120
-			);
121
-
122
-		} catch ( Exception $exception ) {
123
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
124
-		} finally {
125
-			// Remove the archive since we only care about a single file in it.
126
-			unlink( $tmp_archive_path );
127
-		}
128
-
129
-		return $tmp_database_path;
130
-	}
131
-
132
-	/**
133
-	 * Fetches the ISO country code associated with an IP address.
134
-	 *
135
-	 * @param string $ip_address The IP address to find the country code for.
136
-	 * @return string The country code for the IP address, or empty if not found.
137
-	 */
138
-	public function get_iso_country_code_for_ip( $ip_address ) {
139
-		$country_code = '';
140
-
141
-		if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
142
-			return $country_code;
143
-		}
144
-
145
-		$database_path = $this->get_database_path();
146
-		if ( ! file_exists( $database_path ) ) {
147
-			return $country_code;
148
-		}
149
-
150
-		try {
151
-			$reader = new MaxMind\Db\Reader( $database_path );
152
-			$data   = $reader->get( $ip_address );
153
-
154
-			if ( isset( $data['country']['iso_code'] ) ) {
155
-				$country_code = $data['country']['iso_code'];
156
-			}
157
-
158
-			$reader->close();
159
-		} catch ( Exception $e ) {
160
-			wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
161
-		}
162
-
163
-		return $country_code;
164
-	}
16
+    /**
17
+     * The name of the MaxMind database to utilize.
18
+     */
19
+    const DATABASE = 'GeoLite2-Country';
20
+
21
+    /**
22
+     * The extension for the MaxMind database.
23
+     */
24
+    const DATABASE_EXTENSION = '.mmdb';
25
+
26
+    /**
27
+     * A prefix for the MaxMind database filename.
28
+     *
29
+     * @var string
30
+     */
31
+    private $database_prefix;
32
+
33
+    /**
34
+     * Class constructor.
35
+     *
36
+     * @param string|null $database_prefix A prefix for the MaxMind database filename.
37
+     */
38
+    public function __construct( $database_prefix ) {
39
+        $this->database_prefix = $database_prefix;
40
+    }
41
+
42
+    /**
43
+     * Fetches the path that the database should be stored.
44
+     *
45
+     * @return string The local database path.
46
+     */
47
+    public function get_database_path() {
48
+        $uploads_dir = wp_upload_dir();
49
+
50
+        $database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
+        if ( ! empty( $this->database_prefix ) ) {
52
+            $database_path .= $this->database_prefix . '-';
53
+        }
54
+        $database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55
+
56
+        // Filter the geolocation database storage path.
57
+        return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
58
+    }
59
+
60
+    /**
61
+     * Fetches the database from the MaxMind service.
62
+     *
63
+     * @param string $license_key The license key to be used when downloading the database.
64
+     * @return string|WP_Error The path to the database file or an error if invalid.
65
+     */
66
+    public function download_database( $license_key ) {
67
+
68
+        $download_uri = add_query_arg(
69
+            array(
70
+                'edition_id'  => self::DATABASE,
71
+                'license_key' => urlencode( wpinv_clean( $license_key ) ),
72
+                'suffix'      => 'tar.gz',
73
+            ),
74
+            'https://download.maxmind.com/app/geoip_download'
75
+        );
76
+
77
+        // Needed for the download_url call right below.
78
+        require_once ABSPATH . 'wp-admin/includes/file.php';
79
+
80
+        $tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
81
+
82
+        if ( is_wp_error( $tmp_archive_path ) ) {
83
+            // Transform the error into something more informative.
84
+            $error_data = $tmp_archive_path->get_error_data();
85
+            if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
86
+                return new WP_Error(
87
+                    'getpaid_maxmind_geolocation_database_license_key',
88
+                    __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
89
+                );
90
+            }
91
+
92
+            return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
93
+        }
94
+
95
+        // Extract the database from the archive.
96
+        return $this->extract_downloaded_database( $tmp_archive_path );
97
+
98
+    }
99
+
100
+    /**
101
+     * Extracts the downloaded database.
102
+     *
103
+     * @param string $tmp_archive_path The database archive path.
104
+     * @return string|WP_Error The path to the database file or an error if invalid.
105
+     */
106
+    protected function extract_downloaded_database( $tmp_archive_path ) {
107
+
108
+        // Extract the database from the archive.
109
+        $tmp_database_path = '';
110
+
111
+        try {
112
+
113
+            $file              = new PharData( $tmp_archive_path );
114
+            $tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
115
+
116
+            $file->extractTo(
117
+                dirname( $tmp_archive_path ),
118
+                trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
119
+                true
120
+            );
121
+
122
+        } catch ( Exception $exception ) {
123
+            return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
124
+        } finally {
125
+            // Remove the archive since we only care about a single file in it.
126
+            unlink( $tmp_archive_path );
127
+        }
128
+
129
+        return $tmp_database_path;
130
+    }
131
+
132
+    /**
133
+     * Fetches the ISO country code associated with an IP address.
134
+     *
135
+     * @param string $ip_address The IP address to find the country code for.
136
+     * @return string The country code for the IP address, or empty if not found.
137
+     */
138
+    public function get_iso_country_code_for_ip( $ip_address ) {
139
+        $country_code = '';
140
+
141
+        if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
142
+            return $country_code;
143
+        }
144
+
145
+        $database_path = $this->get_database_path();
146
+        if ( ! file_exists( $database_path ) ) {
147
+            return $country_code;
148
+        }
149
+
150
+        try {
151
+            $reader = new MaxMind\Db\Reader( $database_path );
152
+            $data   = $reader->get( $ip_address );
153
+
154
+            if ( isset( $data['country']['iso_code'] ) ) {
155
+                $country_code = $data['country']['iso_code'];
156
+            }
157
+
158
+            $reader->close();
159
+        } catch ( Exception $e ) {
160
+            wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
161
+        }
162
+
163
+        return $country_code;
164
+    }
165 165
 
166 166
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 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
  * The service class responsible for interacting with MaxMind databases.
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string|null $database_prefix A prefix for the MaxMind database filename.
37 37
 	 */
38
-	public function __construct( $database_prefix ) {
38
+	public function __construct($database_prefix) {
39 39
 		$this->database_prefix = $database_prefix;
40 40
 	}
41 41
 
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	public function get_database_path() {
48 48
 		$uploads_dir = wp_upload_dir();
49 49
 
50
-		$database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/';
51
-		if ( ! empty( $this->database_prefix ) ) {
50
+		$database_path = trailingslashit($uploads_dir['basedir']) . 'invoicing/';
51
+		if (!empty($this->database_prefix)) {
52 52
 			$database_path .= $this->database_prefix . '-';
53 53
 		}
54 54
 		$database_path .= self::DATABASE . self::DATABASE_EXTENSION;
55 55
 
56 56
 		// Filter the geolocation database storage path.
57
-		return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path );
57
+		return apply_filters('getpaid_maxmind_geolocation_database_path', $database_path);
58 58
 	}
59 59
 
60 60
 	/**
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 	 * @param string $license_key The license key to be used when downloading the database.
64 64
 	 * @return string|WP_Error The path to the database file or an error if invalid.
65 65
 	 */
66
-	public function download_database( $license_key ) {
66
+	public function download_database($license_key) {
67 67
 
68 68
 		$download_uri = add_query_arg(
69 69
 			array(
70 70
 				'edition_id'  => self::DATABASE,
71
-				'license_key' => urlencode( wpinv_clean( $license_key ) ),
71
+				'license_key' => urlencode(wpinv_clean($license_key)),
72 72
 				'suffix'      => 'tar.gz',
73 73
 			),
74 74
 			'https://download.maxmind.com/app/geoip_download'
@@ -77,23 +77,23 @@  discard block
 block discarded – undo
77 77
 		// Needed for the download_url call right below.
78 78
 		require_once ABSPATH . 'wp-admin/includes/file.php';
79 79
 
80
-		$tmp_archive_path = download_url( esc_url_raw( $download_uri ) );
80
+		$tmp_archive_path = download_url(esc_url_raw($download_uri));
81 81
 
82
-		if ( is_wp_error( $tmp_archive_path ) ) {
82
+		if (is_wp_error($tmp_archive_path)) {
83 83
 			// Transform the error into something more informative.
84 84
 			$error_data = $tmp_archive_path->get_error_data();
85
-			if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) {
85
+			if (isset($error_data['code']) && $error_data['code'] == 401) {
86 86
 				return new WP_Error(
87 87
 					'getpaid_maxmind_geolocation_database_license_key',
88
-					__( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' )
88
+					__('The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing')
89 89
 				);
90 90
 			}
91 91
 
92
-			return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) );
92
+			return new WP_Error('getpaid_maxmind_geolocation_database_download', __('Failed to download the MaxMind database.', 'invoicing'));
93 93
 		}
94 94
 
95 95
 		// Extract the database from the archive.
96
-		return $this->extract_downloaded_database( $tmp_archive_path );
96
+		return $this->extract_downloaded_database($tmp_archive_path);
97 97
 
98 98
 	}
99 99
 
@@ -103,27 +103,27 @@  discard block
 block discarded – undo
103 103
 	 * @param string $tmp_archive_path The database archive path.
104 104
 	 * @return string|WP_Error The path to the database file or an error if invalid.
105 105
 	 */
106
-	protected function extract_downloaded_database( $tmp_archive_path ) {
106
+	protected function extract_downloaded_database($tmp_archive_path) {
107 107
 
108 108
 		// Extract the database from the archive.
109 109
 		$tmp_database_path = '';
110 110
 
111 111
 		try {
112 112
 
113
-			$file              = new PharData( $tmp_archive_path );
114
-			$tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION;
113
+			$file              = new PharData($tmp_archive_path);
114
+			$tmp_database_path = trailingslashit(dirname($tmp_archive_path)) . trailingslashit($file->current()->getFilename()) . self::DATABASE . self::DATABASE_EXTENSION;
115 115
 
116 116
 			$file->extractTo(
117
-				dirname( $tmp_archive_path ),
118
-				trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION,
117
+				dirname($tmp_archive_path),
118
+				trailingslashit($file->current()->getFilename()) . self::DATABASE . self::DATABASE_EXTENSION,
119 119
 				true
120 120
 			);
121 121
 
122
-		} catch ( Exception $exception ) {
123
-			return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() );
122
+		} catch (Exception $exception) {
123
+			return new WP_Error('invoicing_maxmind_geolocation_database_archive', $exception->getMessage());
124 124
 		} finally {
125 125
 			// Remove the archive since we only care about a single file in it.
126
-			unlink( $tmp_archive_path );
126
+			unlink($tmp_archive_path);
127 127
 		}
128 128
 
129 129
 		return $tmp_database_path;
@@ -135,29 +135,29 @@  discard block
 block discarded – undo
135 135
 	 * @param string $ip_address The IP address to find the country code for.
136 136
 	 * @return string The country code for the IP address, or empty if not found.
137 137
 	 */
138
-	public function get_iso_country_code_for_ip( $ip_address ) {
138
+	public function get_iso_country_code_for_ip($ip_address) {
139 139
 		$country_code = '';
140 140
 
141
-		if ( ! class_exists( 'MaxMind\Db\Reader' ) ) {
141
+		if (!class_exists('MaxMind\Db\Reader')) {
142 142
 			return $country_code;
143 143
 		}
144 144
 
145 145
 		$database_path = $this->get_database_path();
146
-		if ( ! file_exists( $database_path ) ) {
146
+		if (!file_exists($database_path)) {
147 147
 			return $country_code;
148 148
 		}
149 149
 
150 150
 		try {
151
-			$reader = new MaxMind\Db\Reader( $database_path );
152
-			$data   = $reader->get( $ip_address );
151
+			$reader = new MaxMind\Db\Reader($database_path);
152
+			$data   = $reader->get($ip_address);
153 153
 
154
-			if ( isset( $data['country']['iso_code'] ) ) {
154
+			if (isset($data['country']['iso_code'])) {
155 155
 				$country_code = $data['country']['iso_code'];
156 156
 			}
157 157
 
158 158
 			$reader->close();
159
-		} catch ( Exception $e ) {
160
-			wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' );
159
+		} catch (Exception $e) {
160
+			wpinv_error_log($e->getMessage(), 'SOURCE: MaxMind GeoLocation');
161 161
 		}
162 162
 
163 163
 		return $country_code;
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-geolocation.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -16,164 +16,164 @@
 block discarded – undo
16 16
  */
17 17
 class GetPaid_MaxMind_Geolocation {
18 18
 
19
-	/**
20
-	 * The service responsible for interacting with the MaxMind database.
21
-	 *
22
-	 * @var GetPaid_MaxMind_Database_Service
23
-	 */
24
-	private $database_service;
25
-
26
-	/**
27
-	 * Initialize the integration.
28
-	 */
29
-	public function __construct() {
30
-
31
-		/**
32
-		 * Supports overriding the database service to be used.
33
-		 *
34
-		 * @since 1.0.19
35
-		 * @return mixed|null The geolocation database service.
36
-		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
-		}
41
-
42
-		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
-
45
-		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
-
48
-		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Get database service.
55
-	 *
56
-	 * @return GetPaid_MaxMind_Database_Service|null
57
-	 */
58
-	public function get_database_service() {
59
-		return $this->database_service;
60
-	}
61
-
62
-	/**
63
-	 * Checks to make sure that the license key is valid.
64
-	 *
65
-	 * @param string $license_key The new license key.
66
-	 * @return string
67
-	 */
68
-	public function handle_key_updates( $license_key ) {
69
-
70
-		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
72
-
73
-		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
75
-			return $license_key;
76
-		}
77
-
78
-		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
-			return $license_key;
81
-		}
82
-
83
-		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
-			return $license_key;
88
-		}
89
-
90
-		$this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path );
91
-
92
-	}
93
-
94
-	/**
95
-	 * Updates the database used for geolocation queries.
96
-	 *
97
-	 * @param string $tmp_database_path Temporary database path.
98
-	 */
99
-	public function update_database( $tmp_database_path = null ) {
100
-
101
-		// Allow us to easily interact with the filesystem.
102
-		require_once ABSPATH . 'wp-admin/includes/file.php';
103
-		WP_Filesystem();
104
-		global $wp_filesystem;
105
-
106
-		// Remove any existing archives to comply with the MaxMind TOS.
107
-		$target_database_path = $this->database_service->get_database_path();
108
-
109
-		// If there's no database path, we can't store the database.
110
-		if ( empty( $target_database_path ) ) {
111
-			return;
112
-		}
113
-
114
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
115
-			$wp_filesystem->delete( $target_database_path );
116
-		}
117
-
118
-		// We can't download a database if there's no license key configured.
119
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
120
-		if ( empty( $license_key ) ) {
121
-			return;
122
-		}
123
-
124
-		if ( empty( $tmp_database_path ) ) {
125
-			$tmp_database_path = $this->database_service->download_database( $license_key );
126
-		}
127
-
128
-		if ( is_wp_error( $tmp_database_path ) ) {
129
-			wpinv_error_log( $tmp_database_path->get_error_message() );
130
-			return;
131
-		}
132
-
133
-		// Move the new database into position.
134
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
136
-	}
137
-
138
-	/**
139
-	 * Performs a geolocation lookup against the MaxMind database for the given IP address.
140
-	 *
141
-	 * @param array  $data       Geolocation data.
142
-	 * @param string $ip_address The IP address to geolocate.
143
-	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
144
-	 */
145
-	public function get_geolocation( $data, $ip_address ) {
146
-
147
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
-			return $data;
149
-		}
150
-
151
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
-
153
-		return array(
154
-			'country'  => $country_code,
155
-			'state'    => '',
156
-			'city'     => '',
157
-			'postcode' => '',
158
-		);
159
-
160
-	}
161
-
162
-	/**
163
-	 * Fetches the prefix for the MaxMind database file.
164
-	 *
165
-	 * @return string
166
-	 */
167
-	private function get_database_prefix() {
168
-
169
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
-
171
-		if ( empty( $prefix ) ) {
172
-			$prefix = md5( uniqid( 'wpinv' ) );
173
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
174
-		}
175
-
176
-		return $prefix;
177
-	}
19
+    /**
20
+     * The service responsible for interacting with the MaxMind database.
21
+     *
22
+     * @var GetPaid_MaxMind_Database_Service
23
+     */
24
+    private $database_service;
25
+
26
+    /**
27
+     * Initialize the integration.
28
+     */
29
+    public function __construct() {
30
+
31
+        /**
32
+         * Supports overriding the database service to be used.
33
+         *
34
+         * @since 1.0.19
35
+         * @return mixed|null The geolocation database service.
36
+         */
37
+        $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
+        if ( null === $this->database_service ) {
39
+            $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
40
+        }
41
+
42
+        // Bind to the scheduled updater action.
43
+        add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
44
+
45
+        // Bind to the geolocation filter for MaxMind database lookups.
46
+        add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
47
+
48
+        // Handle maxmind key updates.
49
+        add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
50
+
51
+    }
52
+
53
+    /**
54
+     * Get database service.
55
+     *
56
+     * @return GetPaid_MaxMind_Database_Service|null
57
+     */
58
+    public function get_database_service() {
59
+        return $this->database_service;
60
+    }
61
+
62
+    /**
63
+     * Checks to make sure that the license key is valid.
64
+     *
65
+     * @param string $license_key The new license key.
66
+     * @return string
67
+     */
68
+    public function handle_key_updates( $license_key ) {
69
+
70
+        // Trim whitespaces and strip slashes.
71
+        $license_key = trim( $license_key );
72
+
73
+        // Abort if the license key is empty or unchanged.
74
+        if ( empty( $license_key ) ) {
75
+            return $license_key;
76
+        }
77
+
78
+        // Abort if a database exists and the license key is unchaged.
79
+        if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
80
+            return $license_key;
81
+        }
82
+
83
+        // Check the license key by attempting to download the Geolocation database.
84
+        $tmp_database_path = $this->database_service->download_database( $license_key );
85
+        if ( is_wp_error( $tmp_database_path ) ) {
86
+            getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
87
+            return $license_key;
88
+        }
89
+
90
+        $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path );
91
+
92
+    }
93
+
94
+    /**
95
+     * Updates the database used for geolocation queries.
96
+     *
97
+     * @param string $tmp_database_path Temporary database path.
98
+     */
99
+    public function update_database( $tmp_database_path = null ) {
100
+
101
+        // Allow us to easily interact with the filesystem.
102
+        require_once ABSPATH . 'wp-admin/includes/file.php';
103
+        WP_Filesystem();
104
+        global $wp_filesystem;
105
+
106
+        // Remove any existing archives to comply with the MaxMind TOS.
107
+        $target_database_path = $this->database_service->get_database_path();
108
+
109
+        // If there's no database path, we can't store the database.
110
+        if ( empty( $target_database_path ) ) {
111
+            return;
112
+        }
113
+
114
+        if ( $wp_filesystem->exists( $target_database_path ) ) {
115
+            $wp_filesystem->delete( $target_database_path );
116
+        }
117
+
118
+        // We can't download a database if there's no license key configured.
119
+        $license_key = wpinv_get_option( 'maxmind_license_key' );
120
+        if ( empty( $license_key ) ) {
121
+            return;
122
+        }
123
+
124
+        if ( empty( $tmp_database_path ) ) {
125
+            $tmp_database_path = $this->database_service->download_database( $license_key );
126
+        }
127
+
128
+        if ( is_wp_error( $tmp_database_path ) ) {
129
+            wpinv_error_log( $tmp_database_path->get_error_message() );
130
+            return;
131
+        }
132
+
133
+        // Move the new database into position.
134
+        $wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
+        $wp_filesystem->delete( dirname( $tmp_database_path ) );
136
+    }
137
+
138
+    /**
139
+     * Performs a geolocation lookup against the MaxMind database for the given IP address.
140
+     *
141
+     * @param array  $data       Geolocation data.
142
+     * @param string $ip_address The IP address to geolocate.
143
+     * @return array Geolocation including country code, state, city and postcode based on an IP address.
144
+     */
145
+    public function get_geolocation( $data, $ip_address ) {
146
+
147
+        if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
+            return $data;
149
+        }
150
+
151
+        $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
+
153
+        return array(
154
+            'country'  => $country_code,
155
+            'state'    => '',
156
+            'city'     => '',
157
+            'postcode' => '',
158
+        );
159
+
160
+    }
161
+
162
+    /**
163
+     * Fetches the prefix for the MaxMind database file.
164
+     *
165
+     * @return string
166
+     */
167
+    private function get_database_prefix() {
168
+
169
+        $prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
+
171
+        if ( empty( $prefix ) ) {
172
+            $prefix = md5( uniqid( 'wpinv' ) );
173
+            update_option( 'wpinv_maxmind_database_prefix', $prefix );
174
+        }
175
+
176
+        return $prefix;
177
+    }
178 178
 
179 179
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * Uses MaxMind for Geolocation
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		 * @since 1.0.19
35 35
 		 * @return mixed|null The geolocation database service.
36 36
 		 */
37
-		$this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null );
38
-		if ( null === $this->database_service ) {
39
-			$this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() );
37
+		$this->database_service = apply_filters('getpaid_maxmind_geolocation_database_service', null);
38
+		if (null === $this->database_service) {
39
+			$this->database_service = new GetPaid_MaxMind_Database_Service($this->get_database_prefix());
40 40
 		}
41 41
 
42 42
 		// Bind to the scheduled updater action.
43
-		add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) );
43
+		add_action('getpaid_update_geoip_databases', array($this, 'update_database'));
44 44
 
45 45
 		// Bind to the geolocation filter for MaxMind database lookups.
46
-		add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );
46
+		add_filter('getpaid_get_geolocation', array($this, 'get_geolocation'), 10, 2);
47 47
 
48 48
 		// Handle maxmind key updates.
49
-		add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) );
49
+		add_filter('wpinv_settings_sanitize_maxmind_license_key', array($this, 'handle_key_updates'));
50 50
 
51 51
 	}
52 52
 
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
 	 * @param string $license_key The new license key.
66 66
 	 * @return string
67 67
 	 */
68
-	public function handle_key_updates( $license_key ) {
68
+	public function handle_key_updates($license_key) {
69 69
 
70 70
 		// Trim whitespaces and strip slashes.
71
-		$license_key = trim( $license_key );
71
+		$license_key = trim($license_key);
72 72
 
73 73
 		// Abort if the license key is empty or unchanged.
74
-		if ( empty( $license_key ) ) {
74
+		if (empty($license_key)) {
75 75
 			return $license_key;
76 76
 		}
77 77
 
78 78
 		// Abort if a database exists and the license key is unchaged.
79
-		if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) {
79
+		if (file_exists($this->database_service->get_database_path() && $license_key == wpinv_get_option('maxmind_license_key'))) {
80 80
 			return $license_key;
81 81
 		}
82 82
 
83 83
 		// Check the license key by attempting to download the Geolocation database.
84
-		$tmp_database_path = $this->database_service->download_database( $license_key );
85
-		if ( is_wp_error( $tmp_database_path ) ) {
86
-			getpaid_admin()->show_error( $tmp_database_path->get_error_message() );
84
+		$tmp_database_path = $this->database_service->download_database($license_key);
85
+		if (is_wp_error($tmp_database_path)) {
86
+			getpaid_admin()->show_error($tmp_database_path->get_error_message());
87 87
 			return $license_key;
88 88
 		}
89 89
 
90
-		$this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path );
90
+		$this->update_database(/** @scrutinizer ignore-type */ $tmp_database_path);
91 91
 
92 92
 	}
93 93
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param string $tmp_database_path Temporary database path.
98 98
 	 */
99
-	public function update_database( $tmp_database_path = null ) {
99
+	public function update_database($tmp_database_path = null) {
100 100
 
101 101
 		// Allow us to easily interact with the filesystem.
102 102
 		require_once ABSPATH . 'wp-admin/includes/file.php';
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
 		$target_database_path = $this->database_service->get_database_path();
108 108
 
109 109
 		// If there's no database path, we can't store the database.
110
-		if ( empty( $target_database_path ) ) {
110
+		if (empty($target_database_path)) {
111 111
 			return;
112 112
 		}
113 113
 
114
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
115
-			$wp_filesystem->delete( $target_database_path );
114
+		if ($wp_filesystem->exists($target_database_path)) {
115
+			$wp_filesystem->delete($target_database_path);
116 116
 		}
117 117
 
118 118
 		// We can't download a database if there's no license key configured.
119
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
120
-		if ( empty( $license_key ) ) {
119
+		$license_key = wpinv_get_option('maxmind_license_key');
120
+		if (empty($license_key)) {
121 121
 			return;
122 122
 		}
123 123
 
124
-		if ( empty( $tmp_database_path ) ) {
125
-			$tmp_database_path = $this->database_service->download_database( $license_key );
124
+		if (empty($tmp_database_path)) {
125
+			$tmp_database_path = $this->database_service->download_database($license_key);
126 126
 		}
127 127
 
128
-		if ( is_wp_error( $tmp_database_path ) ) {
129
-			wpinv_error_log( $tmp_database_path->get_error_message() );
128
+		if (is_wp_error($tmp_database_path)) {
129
+			wpinv_error_log($tmp_database_path->get_error_message());
130 130
 			return;
131 131
 		}
132 132
 
133 133
 		// Move the new database into position.
134
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
135
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
134
+		$wp_filesystem->move($tmp_database_path, $target_database_path, true);
135
+		$wp_filesystem->delete(dirname($tmp_database_path));
136 136
 	}
137 137
 
138 138
 	/**
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 	 * @param string $ip_address The IP address to geolocate.
143 143
 	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
144 144
 	 */
145
-	public function get_geolocation( $data, $ip_address ) {
145
+	public function get_geolocation($data, $ip_address) {
146 146
 
147
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
147
+		if (!empty($data['country']) || empty($ip_address)) {
148 148
 			return $data;
149 149
 		}
150 150
 
151
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
151
+		$country_code = $this->database_service->get_iso_country_code_for_ip($ip_address);
152 152
 
153 153
 		return array(
154 154
 			'country'  => $country_code,
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	private function get_database_prefix() {
168 168
 
169
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
169
+		$prefix = get_option('wpinv_maxmind_database_prefix');
170 170
 
171
-		if ( empty( $prefix ) ) {
172
-			$prefix = md5( uniqid( 'wpinv' ) );
173
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
171
+		if (empty($prefix)) {
172
+			$prefix = md5(uniqid('wpinv'));
173
+			update_option('wpinv_maxmind_database_prefix', $prefix);
174 174
 		}
175 175
 
176 176
 		return $prefix;
Please login to merge, or discard this patch.