Passed
Push — master ( 55fff1...2692d4 )
by Brian
16:18
created
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public function getLocations()
37 37
     {
38 38
         if ($this->matchesCakeVersion('>=', '3.0.0')) {
39
-            $this->locations['plugin'] =  $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
39
+            $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
40 40
         }
41 41
         return $this->locations;
42 42
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     protected function matchesCakeVersion($matcher, $version)
52 52
     {
53 53
         $repositoryManager = $this->composer->getRepositoryManager();
54
-        if (! $repositoryManager) {
54
+        if (!$repositoryManager) {
55 55
             return false;
56 56
         }
57 57
 
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/OxidInstaller.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class OxidInstaller extends BaseInstaller
7 7
 {
8
-	const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
8
+    const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
9 9
 
10 10
     protected $locations = array(
11 11
         'module'    => 'modules/{$name}/',
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
         'out'    => 'out/{$name}/',
14 14
     );
15 15
 
16
-	/**
17
-	 * getInstallPath
18
-	 *
19
-	 * @param PackageInterface $package
20
-	 * @param string $frameworkType
21
-	 * @return string
22
-	 */
23
-	public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
-	{
25
-		$installPath = parent::getInstallPath($package, $frameworkType);
26
-		$type = $this->package->getType();
27
-		if ($type === 'oxid-module') {
28
-			$this->prepareVendorDirectory($installPath);
29
-		}
30
-		return $installPath;
31
-	}
16
+    /**
17
+     * getInstallPath
18
+     *
19
+     * @param PackageInterface $package
20
+     * @param string $frameworkType
21
+     * @return string
22
+     */
23
+    public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
+    {
25
+        $installPath = parent::getInstallPath($package, $frameworkType);
26
+        $type = $this->package->getType();
27
+        if ($type === 'oxid-module') {
28
+            $this->prepareVendorDirectory($installPath);
29
+        }
30
+        return $installPath;
31
+    }
32 32
 
33
-	/**
34
-	 * prepareVendorDirectory
35
-	 *
36
-	 * Makes sure there is a vendormetadata.php file inside
37
-	 * the vendor folder if there is a vendor folder.
38
-	 *
39
-	 * @param string $installPath
40
-	 * @return void
41
-	 */
42
-	protected function prepareVendorDirectory($installPath)
43
-	{
44
-		$matches = '';
45
-		$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
-		if (!$hasVendorDirectory) {
47
-			return;
48
-		}
33
+    /**
34
+     * prepareVendorDirectory
35
+     *
36
+     * Makes sure there is a vendormetadata.php file inside
37
+     * the vendor folder if there is a vendor folder.
38
+     *
39
+     * @param string $installPath
40
+     * @return void
41
+     */
42
+    protected function prepareVendorDirectory($installPath)
43
+    {
44
+        $matches = '';
45
+        $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
+        if (!$hasVendorDirectory) {
47
+            return;
48
+        }
49 49
 
50
-		$vendorDirectory = $matches['vendor'];
51
-		$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
-		if (!file_exists($vendorPath)) {
53
-			mkdir($vendorPath, 0755, true);
54
-		}
50
+        $vendorDirectory = $matches['vendor'];
51
+        $vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
+        if (!file_exists($vendorPath)) {
53
+            mkdir($vendorPath, 0755, true);
54
+        }
55 55
 
56
-		$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
-		touch($vendorMetaDataPath);
58
-	}
56
+        $vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
+        touch($vendorMetaDataPath);
58
+    }
59 59
 }
Please login to merge, or discard this patch.
templates/frontend-head.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 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
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-exception.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@
 block discarded – undo
14 14
  */
15 15
 class GetPaid_Payment_Exception extends Exception {
16 16
 
17
-	/**
18
-	 * Sanitized error code.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	protected $error_code;
17
+    /**
18
+     * Sanitized error code.
19
+     *
20
+     * @var string
21
+     */
22
+    protected $error_code;
23 23
 
24
-	/**
25
-	 * Error extra data.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $error_data;
24
+    /**
25
+     * Error extra data.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $error_data;
30 30
 
31
-	/**
32
-	 * Setup exception.
33
-	 *
34
-	 * @param string $code             Machine-readable error code, e.g `getpaid-discount-error`.
35
-	 * @param string $message          User-friendly translated error message, e.g. 'Discount is invalid'.
36
-	 * @param int    $http_status_code Proper HTTP status code to respond with, e.g. 400.
37
-	 * @param array  $data             Extra error data.
38
-	 */
39
-	public function __construct( $code, $message, $http_status_code = 400, $data = array() ) {
40
-		$this->error_code = $code;
41
-		$this->error_data = array_merge( array( 'status' => $http_status_code ), $data );
31
+    /**
32
+     * Setup exception.
33
+     *
34
+     * @param string $code             Machine-readable error code, e.g `getpaid-discount-error`.
35
+     * @param string $message          User-friendly translated error message, e.g. 'Discount is invalid'.
36
+     * @param int    $http_status_code Proper HTTP status code to respond with, e.g. 400.
37
+     * @param array  $data             Extra error data.
38
+     */
39
+    public function __construct( $code, $message, $http_status_code = 400, $data = array() ) {
40
+        $this->error_code = $code;
41
+        $this->error_data = array_merge( array( 'status' => $http_status_code ), $data );
42 42
 
43
-		parent::__construct( $message, $http_status_code );
44
-	}
43
+        parent::__construct( $message, $http_status_code );
44
+    }
45 45
 
46
-	/**
47
-	 * Returns the error code.
48
-	 *
49
-	 * @return string
50
-	 */
51
-	public function getErrorCode() {
52
-		return $this->error_code;
53
-	}
46
+    /**
47
+     * Returns the error code.
48
+     *
49
+     * @return string
50
+     */
51
+    public function getErrorCode() {
52
+        return $this->error_code;
53
+    }
54 54
 
55
-	/**
56
-	 * Returns error data.
57
-	 *
58
-	 * @return array
59
-	 */
60
-	public function getErrorData() {
61
-		return $this->error_data;
62
-	}
55
+    /**
56
+     * Returns error data.
57
+     *
58
+     * @return array
59
+     */
60
+    public function getErrorData() {
61
+        return $this->error_data;
62
+    }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since   2.2.2
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * Payment exception class.
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	 * @param int    $http_status_code Proper HTTP status code to respond with, e.g. 400.
37 37
 	 * @param array  $data             Extra error data.
38 38
 	 */
39
-	public function __construct( $code, $message, $http_status_code = 400, $data = array() ) {
39
+	public function __construct($code, $message, $http_status_code = 400, $data = array()) {
40 40
 		$this->error_code = $code;
41
-		$this->error_data = array_merge( array( 'status' => $http_status_code ), $data );
41
+		$this->error_data = array_merge(array('status' => $http_status_code), $data);
42 42
 
43
-		parent::__construct( $message, $http_status_code );
43
+		parent::__construct($message, $http_status_code);
44 44
 	}
45 45
 
46 46
 	/**
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 2 patches
Indentation   +15 added lines, -15 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
 /**
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 class GetPaid_Meta_Box_Payment_Form {
17 17
 
18 18
     /**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post
22
-	 */
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post
22
+     */
23 23
     public static function output( $post ) {
24 24
         ?>
25 25
         <style>
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
     }
103 103
 
104 104
     /**
105
-	 * Save meta box data.
106
-	 *
107
-	 * @param int $post_id
108
-	 */
109
-	public static function save( $post_id ) {
105
+     * Save meta box data.
106
+     *
107
+     * @param int $post_id
108
+     */
109
+    public static function save( $post_id ) {
110 110
 
111 111
         // Prepare the form.
112 112
         $form = new GetPaid_Payment_Form( $post_id );
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
     }
138 138
 
139 139
     /**
140
-	 * Converts an array fo form items to objects.
141
-	 *
142
-	 * @param array $items
143
-	 */
144
-	public static function item_to_objects( $items ) {
140
+     * Converts an array fo form items to objects.
141
+     *
142
+     * @param array $items
143
+     */
144
+    public static function item_to_objects( $items ) {
145 145
 
146 146
         $objects = array();
147 147
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 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,7 +20,7 @@  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
         <style>
26 26
             .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                 <div class="col-sm-4">
34 34
 
35 35
                     <!-- Builder tabs -->
36
-                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></button>
36
+                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e('Go Back', 'invoicing'); ?></button>
37 37
 
38 38
                     <!-- Builder tab content -->
39 39
                     <div class="mt-4">
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                         <!-- Available builder elements -->
42 42
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
43 43
                             <div class="wpinv-form-builder-add-field-types">
44
-                                <small class='form-text text-muted'><?php esc_html_e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
44
+                                <small class='form-text text-muted'><?php esc_html_e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
45 45
                                 <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
46 46
                                     <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
47 47
                                         <button class="button btn text-dark">
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
                         <!-- Edit an element -->
57 57
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;">
58 58
                             <div class="wpinv-form-builder-edit-field-wrapper">
59
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
60
-                                <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?>
59
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
60
+                                <?php do_action('getpaid_payment_form_edit_element_template', $post); ?>
61 61
                                 <div class='form-group mb-3'>
62
-                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ); ?></label>
62
+                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing'); ?></label>
63 63
                                     <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'>
64
-                                        <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
65
-                                        <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
66
-                                        <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
64
+                                        <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
65
+                                        <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
66
+                                        <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
67 67
                                     </select>
68 68
                                 </div>
69 69
                                 <div>
70
-                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e( 'Delete Element', 'invoicing' ); ?></button>
70
+                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e('Delete Element', 'invoicing'); ?></button>
71 71
                                 </div>
72 72
                             </div>
73 73
                         </div>
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 
77 77
                 </div>
78 78
                 <div class="col-sm-8 border-left">
79
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
80
-                    <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
79
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
80
+                    <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
81 81
 
82 82
                     <div class="container-fluid">
83 83
                         <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
84 84
                             <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element &&  active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element">
85 85
                                 <div class="wpinv-form-builder-element-preview-inner">
86 86
                                     <div class="wpinv-payment-form-field-preview-overlay"></div>
87
-                                    <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
87
+                                    <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
88 88
                                 </div>
89 89
                             </div>
90 90
                         </draggable>
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         </script>
104 104
         <?php
105 105
 
106
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
106
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
107 107
     }
108 108
 
109 109
     /**
@@ -111,33 +111,33 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param int $post_id
113 113
 	 */
114
-	public static function save( $post_id ) {
114
+	public static function save($post_id) {
115 115
 
116 116
         // Prepare the form.
117
-        $form = new GetPaid_Payment_Form( $post_id );
117
+        $form = new GetPaid_Payment_Form($post_id);
118 118
 
119 119
         // Fetch form items.
120
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
120
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
121 121
 
122 122
         // Ensure that we have an array...
123
-        if ( empty( $form_items ) ) {
123
+        if (empty($form_items)) {
124 124
             $form_items = array();
125 125
         }
126 126
 
127 127
         // Add it to the form.
128
-        $form->set_items( self::item_to_objects( wp_kses_post_deep( $form_items ) ) );
128
+        $form->set_items(self::item_to_objects(wp_kses_post_deep($form_items)));
129 129
 
130 130
         // Save form elements.
131
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
132
-        if ( empty( $form_elements ) ) {
131
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
132
+        if (empty($form_elements)) {
133 133
             $form_elements = array();
134 134
         }
135 135
 
136
-        $form->set_elements( wp_kses_post_deep( $form_elements ) );
136
+        $form->set_elements(wp_kses_post_deep($form_elements));
137 137
 
138 138
         // Persist data to the datastore.
139 139
         $form->save();
140
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
140
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
141 141
 
142 142
     }
143 143
 
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param array $items
148 148
 	 */
149
-	public static function item_to_objects( $items ) {
149
+	public static function item_to_objects($items) {
150 150
 
151 151
         $objects = array();
152 152
 
153
-        foreach ( $items as $item ) {
154
-            $_item = new GetPaid_Form_Item( $item['id'] );
155
-            $_item->set_allow_quantities( (bool) $item['allow_quantities'] );
156
-            $_item->set_is_required( (bool) $item['required'] );
153
+        foreach ($items as $item) {
154
+            $_item = new GetPaid_Form_Item($item['id']);
155
+            $_item->set_allow_quantities((bool) $item['allow_quantities']);
156
+            $_item->set_is_required((bool) $item['required']);
157 157
             $objects[] = $_item;
158 158
         }
159 159
 
Please login to merge, or discard this patch.
includes/deprecated-functions.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @deprecated
247 247
  */
248 248
 function wpinv_get_payment_key( $invoice = 0 ) {
249
-	$invoice = new WPInv_Invoice( $invoice );
249
+    $invoice = new WPInv_Invoice( $invoice );
250 250
     return $invoice->get_key();
251 251
 }
252 252
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @deprecated
425 425
  */
426 426
 function wpinv_get_checkout_session() {
427
-	return false;
427
+    return false;
428 428
 }
429 429
 
430 430
 /**
@@ -1273,5 +1273,5 @@  discard block
 block discarded – undo
1273 1273
  * @deprecated
1274 1274
  */
1275 1275
 function wpinv_get_subscription( $invoice ) {
1276
-	return wpinv_get_invoice_subscription( $invoice );
1276
+    return wpinv_get_invoice_subscription( $invoice );
1277 1277
 }
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * @deprecated
@@ -19,48 +19,48 @@  discard block
 block discarded – undo
19 19
  * @deprecated
20 20
  */
21 21
 function wpinv_get_invoice_cart() {
22
-    return wpinv_get_invoice( getpaid_get_current_invoice_id() );
22
+    return wpinv_get_invoice(getpaid_get_current_invoice_id());
23 23
 }
24 24
 
25 25
 /**
26 26
  * @deprecated
27 27
  */
28
-function wpinv_get_invoice_description( $invoice ) {
29
-    $invoice = new WPInv_Invoice( $invoice );
28
+function wpinv_get_invoice_description($invoice) {
29
+    $invoice = new WPInv_Invoice($invoice);
30 30
     return $invoice->get_description();
31 31
 }
32 32
 
33 33
 /**
34 34
  * @deprecated
35 35
  */
36
-function wpinv_get_invoice_currency_code( $invoice ) {
37
-    $invoice = new WPInv_Invoice( $invoice );
36
+function wpinv_get_invoice_currency_code($invoice) {
37
+    $invoice = new WPInv_Invoice($invoice);
38 38
     return $invoice->get_currency();
39 39
 }
40 40
 
41 41
 /**
42 42
  * @deprecated
43 43
  */
44
-function wpinv_get_payment_user_email( $invoice ) {
45
-    $invoice = new WPInv_Invoice( $invoice );
44
+function wpinv_get_payment_user_email($invoice) {
45
+    $invoice = new WPInv_Invoice($invoice);
46 46
     return $invoice->get_email();
47 47
 }
48 48
 
49 49
 /**
50 50
  * @deprecated
51 51
  */
52
-function wpinv_get_user_id( $invoice ) {
53
-    $invoice = new WPInv_Invoice( $invoice );
52
+function wpinv_get_user_id($invoice) {
53
+    $invoice = new WPInv_Invoice($invoice);
54 54
     return $invoice->get_user_id();
55 55
 }
56 56
 
57 57
 /**
58 58
  * @deprecated
59 59
  */
60
-function wpinv_get_invoice_status( $invoice, $return_label = false ) {
61
-    $invoice = new WPInv_Invoice( $invoice );
60
+function wpinv_get_invoice_status($invoice, $return_label = false) {
61
+    $invoice = new WPInv_Invoice($invoice);
62 62
 
63
-    if ( $return_label ) {
63
+    if ($return_label) {
64 64
         return $invoice->get_status_nicename();
65 65
     }
66 66
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 /**
71 71
  * @deprecated
72 72
  */
73
-function wpinv_get_payment_gateway( $invoice, $return_label = false ) {
74
-    $invoice = new WPInv_Invoice( $invoice );
73
+function wpinv_get_payment_gateway($invoice, $return_label = false) {
74
+    $invoice = new WPInv_Invoice($invoice);
75 75
 
76
-    if ( $return_label ) {
76
+    if ($return_label) {
77 77
         return $invoice->get_gateway_title();
78 78
     }
79 79
 
@@ -83,75 +83,75 @@  discard block
 block discarded – undo
83 83
 /**
84 84
  * @deprecated
85 85
  */
86
-function wpinv_get_payment_gateway_name( $invoice ) {
87
-    return wpinv_get_payment_gateway( $invoice, true );
86
+function wpinv_get_payment_gateway_name($invoice) {
87
+    return wpinv_get_payment_gateway($invoice, true);
88 88
 }
89 89
 
90 90
 /**
91 91
  * @deprecated
92 92
  */
93
-function wpinv_get_payment_transaction_id( $invoice ) {
94
-    $invoice = new WPInv_Invoice( $invoice );
93
+function wpinv_get_payment_transaction_id($invoice) {
94
+    $invoice = new WPInv_Invoice($invoice);
95 95
     return $invoice->get_transaction_id();
96 96
 }
97 97
 
98 98
 /**
99 99
  * @deprecated
100 100
  */
101
-function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) {
102
-    $invoice = new WPInv_Invoice( $invoice_id );
103
-    return $invoice->get_meta( $meta_key, $single );
101
+function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) {
102
+    $invoice = new WPInv_Invoice($invoice_id);
103
+    return $invoice->get_meta($meta_key, $single);
104 104
 }
105 105
 
106 106
 /**
107 107
  * @deprecated
108 108
  */
109
-function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) {
110
-    $invoice = new WPInv_Invoice( $invoice_id );
111
-    return $invoice->update_meta_data( $meta_key, $meta_value );
109
+function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') {
110
+    $invoice = new WPInv_Invoice($invoice_id);
111
+    return $invoice->update_meta_data($meta_key, $meta_value);
112 112
 }
113 113
 
114 114
 /**
115 115
  * @deprecated
116 116
  */
117
-function wpinv_get_items( $invoice = 0 ) {
118
-    $invoice = new WPInv_Invoice( $invoice );
117
+function wpinv_get_items($invoice = 0) {
118
+    $invoice = new WPInv_Invoice($invoice);
119 119
     return $invoice->get_items();
120 120
 }
121 121
 
122 122
 /**
123 123
  * @deprecated
124 124
  */
125
-function wpinv_get_fees( $invoice = 0 ) {
126
-    $invoice = new WPInv_Invoice( $invoice );
125
+function wpinv_get_fees($invoice = 0) {
126
+    $invoice = new WPInv_Invoice($invoice);
127 127
     return $invoice->get_fees();
128 128
 }
129 129
 
130 130
 /**
131 131
  * @deprecated
132 132
  */
133
-function wpinv_get_invoice_ip( $invoice ) {
134
-    $invoice = new WPInv_Invoice( $invoice );
133
+function wpinv_get_invoice_ip($invoice) {
134
+    $invoice = new WPInv_Invoice($invoice);
135 135
     return $invoice->get_ip();
136 136
 }
137 137
 
138 138
 /**
139 139
  * @deprecated
140 140
  */
141
-function wpinv_get_invoice_user_info( $invoice ) {
142
-    $invoice = new WPInv_Invoice( $invoice );
141
+function wpinv_get_invoice_user_info($invoice) {
142
+    $invoice = new WPInv_Invoice($invoice);
143 143
     return $invoice->get_user_info();
144 144
 }
145 145
 
146 146
 /**
147 147
  * @deprecated
148 148
  */
149
-function wpinv_subtotal( $invoice = 0, $currency = false ) {
150
-    $invoice  = new WPInv_Invoice( $invoice );
149
+function wpinv_subtotal($invoice = 0, $currency = false) {
150
+    $invoice  = new WPInv_Invoice($invoice);
151 151
     $subtotal = $invoice->get_subtotal();
152 152
 
153
-    if ( $currency ) {
154
-        return wpinv_price( $subtotal, $invoice->get_currency() );
153
+    if ($currency) {
154
+        return wpinv_price($subtotal, $invoice->get_currency());
155 155
     }
156 156
 
157 157
     return $subtotal;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 /**
161 161
  * @deprecated
162 162
  */
163
-function wpinv_tax( $invoice = 0, $currency = false ) {
164
-    $invoice  = new WPInv_Invoice( $invoice );
163
+function wpinv_tax($invoice = 0, $currency = false) {
164
+    $invoice  = new WPInv_Invoice($invoice);
165 165
     $tax      = $invoice->get_total_tax();
166 166
 
167
-    if ( $currency ) {
168
-        return wpinv_price( $tax, $invoice->get_currency() );
167
+    if ($currency) {
168
+        return wpinv_price($tax, $invoice->get_currency());
169 169
     }
170 170
 
171 171
     return $tax;
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 /**
175 175
  * @deprecated
176 176
  */
177
-function wpinv_discount( $invoice = 0, $currency = false ) {
178
-    $invoice  = new WPInv_Invoice( $invoice );
177
+function wpinv_discount($invoice = 0, $currency = false) {
178
+    $invoice  = new WPInv_Invoice($invoice);
179 179
     $discount = $invoice->get_total_discount();
180 180
 
181
-    if ( $currency ) {
182
-        return wpinv_price( $discount, $invoice->get_currency() );
181
+    if ($currency) {
182
+        return wpinv_price($discount, $invoice->get_currency());
183 183
     }
184 184
 
185 185
     return $discount;
@@ -188,20 +188,20 @@  discard block
 block discarded – undo
188 188
 /**
189 189
  * @deprecated
190 190
  */
191
-function wpinv_discount_code( $invoice = 0 ) {
192
-    $invoice = new WPInv_Invoice( $invoice );
191
+function wpinv_discount_code($invoice = 0) {
192
+    $invoice = new WPInv_Invoice($invoice);
193 193
     return $invoice->get_discount_code();
194 194
 }
195 195
 
196 196
 /**
197 197
  * @deprecated
198 198
  */
199
-function wpinv_payment_total( $invoice = 0, $currency = false ) {
200
-    $invoice  = new WPInv_Invoice( $invoice );
199
+function wpinv_payment_total($invoice = 0, $currency = false) {
200
+    $invoice = new WPInv_Invoice($invoice);
201 201
     $total = $invoice->get_total();
202 202
 
203
-    if ( $currency ) {
204
-        return wpinv_price( $total, $invoice->get_currency() );
203
+    if ($currency) {
204
+        return wpinv_price($total, $invoice->get_currency());
205 205
     }
206 206
 
207 207
     return $total;
@@ -210,51 +210,51 @@  discard block
 block discarded – undo
210 210
 /**
211 211
  * @deprecated
212 212
  */
213
-function wpinv_get_date_created( $invoice = 0, $format = '' ) {
214
-    $invoice = new WPInv_Invoice( $invoice );
213
+function wpinv_get_date_created($invoice = 0, $format = '') {
214
+    $invoice = new WPInv_Invoice($invoice);
215 215
 
216
-    $format         = ! empty( $format ) ? $format : get_option( 'date_format' );
216
+    $format         = !empty($format) ? $format : get_option('date_format');
217 217
     $date_created   = $invoice->get_created_date();
218 218
 
219
-    return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : '';
219
+    return empty($date_created) ? date_i18n($format, strtotime($date_created)) : '';
220 220
 }
221 221
 
222 222
 /**
223 223
  * @deprecated
224 224
  */
225
-function wpinv_get_invoice_date( $invoice = 0, $format = '' ) {
226
-    wpinv_get_date_created( $invoice, $format );
225
+function wpinv_get_invoice_date($invoice = 0, $format = '') {
226
+    wpinv_get_date_created($invoice, $format);
227 227
 }
228 228
 
229 229
 /**
230 230
  * @deprecated
231 231
  */
232
-function wpinv_get_invoice_vat_number( $invoice = 0 ) {
233
-    $invoice = new WPInv_Invoice( $invoice );
232
+function wpinv_get_invoice_vat_number($invoice = 0) {
233
+    $invoice = new WPInv_Invoice($invoice);
234 234
     return $invoice->get_vat_number();
235 235
 }
236 236
 
237 237
 /**
238 238
  * @deprecated
239 239
  */
240
-function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) {
241
-    $invoice = new WPInv_Invoice( $invoice );
242
-    return $invoice->add_note( $note, $user_type, $added_by_user, $system );
240
+function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) {
241
+    $invoice = new WPInv_Invoice($invoice);
242
+    return $invoice->add_note($note, $user_type, $added_by_user, $system);
243 243
 }
244 244
 
245 245
 /**
246 246
  * @deprecated
247 247
  */
248
-function wpinv_get_payment_key( $invoice = 0 ) {
249
-	$invoice = new WPInv_Invoice( $invoice );
248
+function wpinv_get_payment_key($invoice = 0) {
249
+	$invoice = new WPInv_Invoice($invoice);
250 250
     return $invoice->get_key();
251 251
 }
252 252
 
253 253
 /**
254 254
  * @deprecated
255 255
  */
256
-function wpinv_get_invoice_number( $invoice = 0 ) {
257
-    $invoice = new WPInv_Invoice( $invoice );
256
+function wpinv_get_invoice_number($invoice = 0) {
257
+    $invoice = new WPInv_Invoice($invoice);
258 258
     return $invoice->get_number();
259 259
 }
260 260
 
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 /**
402 402
  * @deprecated
403 403
  */
404
-function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) {
405
-    $invoice = new WPInv_Invoice( $invoice );
406
-    return $invoice->update_status( $new_status );
404
+function wpinv_update_payment_status($invoice, $new_status = 'publish') {
405
+    $invoice = new WPInv_Invoice($invoice);
406
+    return $invoice->update_status($new_status);
407 407
 }
408 408
 
409 409
 /**
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
 /**
457 457
  * @deprecated
458 458
  */
459
-function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) {
459
+function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') {
460 460
 
461 461
     // Fetch the invoice.
462
-    $invoice = new WPInv_Invoice( $invoice_id );
462
+    $invoice = new WPInv_Invoice($invoice_id);
463 463
 
464
-    if ( 0 == $invoice->get_id() ) {
464
+    if (0 == $invoice->get_id()) {
465 465
         return false;
466 466
     }
467 467
 
468 468
     // Prepare the transaction id.
469
-    if ( empty( $transaction_id ) ) {
469
+    if (empty($transaction_id)) {
470 470
         $transaction_id = $invoice_id;
471 471
     }
472 472
 
473 473
     // Set the transaction id;
474
-    $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) );
474
+    $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice));
475 475
 
476 476
     // Save the invoice.
477 477
     return $invoice->save();
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
  * @param WPInv_Invoice $invoice
485 485
  * @param string $gateway
486 486
  */
487
-function wpinv_send_to_gateway( $gateway, $invoice ) {
487
+function wpinv_send_to_gateway($gateway, $invoice) {
488 488
 
489 489
     $payment_data = array(
490 490
         'invoice_id'     => $invoice->get_id(),
491 491
         'items'          => $invoice->get_cart_details(),
492
-        'cart_discounts' => array( $invoice->get_discount_code() ),
492
+        'cart_discounts' => array($invoice->get_discount_code()),
493 493
         'fees'           => $invoice->get_total_fees(),
494 494
         'subtotal'       => $invoice->get_subtotal(),
495 495
         'discount'       => $invoice->get_total_discount(),
@@ -497,16 +497,16 @@  discard block
 block discarded – undo
497 497
         'price'          => $invoice->get_total(),
498 498
         'invoice_key'    => $invoice->get_key(),
499 499
         'user_email'     => $invoice->get_email(),
500
-        'date'           => gmdate( 'Y-m-d H:i:s', time() ),
500
+        'date'           => gmdate('Y-m-d H:i:s', time()),
501 501
         'user_info'      => $invoice->get_user_info(),
502
-        'post_data'      => wp_kses_post_deep( wp_unslash( $_POST ) ),
502
+        'post_data'      => wp_kses_post_deep(wp_unslash($_POST)),
503 503
         'cart_details'   => $invoice->get_cart_details(),
504 504
         'gateway'        => $gateway,
505 505
         'card_info'      => array(),
506
-        'gateway_nonce'  => wp_create_nonce( 'wpi-gateway' ),
506
+        'gateway_nonce'  => wp_create_nonce('wpi-gateway'),
507 507
     );
508 508
 
509
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
509
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
510 510
 }
511 511
 
512 512
 /**
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 /**
520 520
  * @deprecated
521 521
  */
522
-function wpinv_die( $message = '', $title = '', $status = 400 ) {
523
-    add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 );
524
-    add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 );
525
-    wp_die( esc_html( $message ), esc_html( $title ), array( 'response' => (int) $status ) );
522
+function wpinv_die($message = '', $title = '', $status = 400) {
523
+    add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3);
524
+    add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3);
525
+    wp_die(esc_html($message), esc_html($title), array('response' => (int) $status));
526 526
 }
527 527
 
528 528
 /**
@@ -640,14 +640,14 @@  discard block
 block discarded – undo
640 640
 /**
641 641
  * @deprecated
642 642
  */
643
-function wpinv_invoice_status_label( $status, $status_display = '' ) {
644
-    return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display );
643
+function wpinv_invoice_status_label($status, $status_display = '') {
644
+    return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display);
645 645
 }
646 646
 
647 647
 /**
648 648
  * @deprecated
649 649
  */
650
-function wpinv_clean_invoice_number( $number ) {
650
+function wpinv_clean_invoice_number($number) {
651 651
     return $number;
652 652
 }
653 653
 
@@ -852,12 +852,12 @@  discard block
 block discarded – undo
852 852
 /**
853 853
  * @deprecated
854 854
  */
855
-function wpinv_item_show_price( $item_id = 0, $echo = true ) {
855
+function wpinv_item_show_price($item_id = 0, $echo = true) {
856 856
 
857
-    if ( $echo ) {
858
-        echo wp_kses_post( wpinv_item_price( $item_id ) );
857
+    if ($echo) {
858
+        echo wp_kses_post(wpinv_item_price($item_id));
859 859
     } else {
860
-        return wpinv_item_price( $item_id );
860
+        return wpinv_item_price($item_id);
861 861
     }
862 862
 
863 863
 }
@@ -1272,6 +1272,6 @@  discard block
 block discarded – undo
1272 1272
  * @return WPInv_Subscription|bool
1273 1273
  * @deprecated
1274 1274
  */
1275
-function wpinv_get_subscription( $invoice ) {
1276
-	return wpinv_get_invoice_subscription( $invoice );
1275
+function wpinv_get_subscription($invoice) {
1276
+	return wpinv_get_invoice_subscription($invoice);
1277 1277
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-subscription.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 
8 8
 if ( ! defined( 'ABSPATH' ) ) {
9
-	exit; // Exit if accessed directly
9
+    exit; // Exit if accessed directly
10 10
 }
11 11
 
12 12
 /**
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 class GetPaid_Meta_Box_Invoice_Subscription {
16 16
 
17 17
     /**
18
-	 * Output the subscription metabox.
19
-	 *
20
-	 * @param WP_Post $post
21
-	 */
18
+     * Output the subscription metabox.
19
+     *
20
+     * @param WP_Post $post
21
+     */
22 22
     public static function output( $post ) {
23 23
 
24 24
         // Fetch the invoice.
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
     }
35 35
 
36 36
     /**
37
-	 * Output the subscription invoices.
38
-	 *
39
-	 * @param WP_Post $post
40
-	 */
37
+     * Output the subscription invoices.
38
+     *
39
+     * @param WP_Post $post
40
+     */
41 41
     public static function output_invoices( $post ) {
42 42
 
43 43
         // Fetch the invoice.
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     /**
56
-	 * Outputs related subscriptions.
57
-	 *
58
-	 * @param WP_Post $post
59
-	 */
56
+     * Outputs related subscriptions.
57
+     *
58
+     * @param WP_Post $post
59
+     */
60 60
     public static function output_related( $post ) {
61 61
 
62 62
         // Fetch the invoice.
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit; // Exit if accessed directly
10 10
 }
11 11
 
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param WP_Post $post
21 21
 	 */
22
-    public static function output( $post ) {
22
+    public static function output($post) {
23 23
 
24 24
         // Fetch the invoice.
25
-        $invoice = new WPInv_Invoice( $post );
25
+        $invoice = new WPInv_Invoice($post);
26 26
 
27 27
         // Fetch the subscription.
28
-        $subscription = getpaid_get_invoice_subscription( $invoice );
28
+        $subscription = getpaid_get_invoice_subscription($invoice);
29 29
 
30 30
         echo '<div class="bsui">';
31
-        getpaid_admin_subscription_details_metabox( /** @scrutinizer ignore-type */$subscription );
31
+        getpaid_admin_subscription_details_metabox(/** @scrutinizer ignore-type */$subscription);
32 32
         echo '</div>';
33 33
 
34 34
     }
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param WP_Post $post
40 40
 	 */
41
-    public static function output_invoices( $post ) {
41
+    public static function output_invoices($post) {
42 42
 
43 43
         // Fetch the invoice.
44
-        $invoice = new WPInv_Invoice( $post );
44
+        $invoice = new WPInv_Invoice($post);
45 45
 
46 46
         // Fetch the subscription.
47
-        $subscription = getpaid_get_invoice_subscription( $invoice );
47
+        $subscription = getpaid_get_invoice_subscription($invoice);
48 48
 
49 49
         echo '<div class="bsui">';
50
-        getpaid_admin_subscription_invoice_details_metabox( /** @scrutinizer ignore-type */$subscription, false );
50
+        getpaid_admin_subscription_invoice_details_metabox(/** @scrutinizer ignore-type */$subscription, false);
51 51
         echo '</div>';
52 52
 
53 53
     }
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @param WP_Post $post
59 59
 	 */
60
-    public static function output_related( $post ) {
60
+    public static function output_related($post) {
61 61
 
62 62
         // Fetch the invoice.
63
-        $invoice = new WPInv_Invoice( $post );
63
+        $invoice = new WPInv_Invoice($post);
64 64
 
65 65
         // Fetch the subscription.
66
-        $subscription = getpaid_get_invoice_subscription( $invoice );
66
+        $subscription = getpaid_get_invoice_subscription($invoice);
67 67
 
68 68
         echo '<div class="bsui">';
69
-        getpaid_admin_subscription_related_subscriptions_metabox( /** @scrutinizer ignore-type */$subscription, false );
69
+        getpaid_admin_subscription_related_subscriptions_metabox(/** @scrutinizer ignore-type */$subscription, false);
70 70
         echo '</div>';
71 71
 
72 72
     }
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-maxmind-geolocation.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -16,165 +16,165 @@
 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
-		return $license_key;
93
-	}
94
-
95
-	/**
96
-	 * Updates the database used for geolocation queries.
97
-	 *
98
-	 * @param string $tmp_database_path Temporary database path.
99
-	 */
100
-	public function update_database( $tmp_database_path = null ) {
101
-
102
-		// Allow us to easily interact with the filesystem.
103
-		require_once ABSPATH . 'wp-admin/includes/file.php';
104
-		WP_Filesystem();
105
-		global $wp_filesystem;
106
-
107
-		// Remove any existing archives to comply with the MaxMind TOS.
108
-		$target_database_path = $this->database_service->get_database_path();
109
-
110
-		// If there's no database path, we can't store the database.
111
-		if ( empty( $target_database_path ) ) {
112
-			return;
113
-		}
114
-
115
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
116
-			$wp_filesystem->delete( $target_database_path );
117
-		}
118
-
119
-		// We can't download a database if there's no license key configured.
120
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
121
-		if ( empty( $license_key ) ) {
122
-			return;
123
-		}
124
-
125
-		if ( empty( $tmp_database_path ) ) {
126
-			$tmp_database_path = $this->database_service->download_database( $license_key );
127
-		}
128
-
129
-		if ( is_wp_error( $tmp_database_path ) ) {
130
-			wpinv_error_log( $tmp_database_path->get_error_message() );
131
-			return;
132
-		}
133
-
134
-		// Move the new database into position.
135
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
136
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
137
-	}
138
-
139
-	/**
140
-	 * Performs a geolocation lookup against the MaxMind database for the given IP address.
141
-	 *
142
-	 * @param array  $data       Geolocation data.
143
-	 * @param string $ip_address The IP address to geolocate.
144
-	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
145
-	 */
146
-	public function get_geolocation( $data, $ip_address ) {
147
-
148
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
149
-			return $data;
150
-		}
151
-
152
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
153
-
154
-		return array(
155
-			'country'  => $country_code,
156
-			'state'    => '',
157
-			'city'     => '',
158
-			'postcode' => '',
159
-		);
160
-
161
-	}
162
-
163
-	/**
164
-	 * Fetches the prefix for the MaxMind database file.
165
-	 *
166
-	 * @return string
167
-	 */
168
-	private function get_database_prefix() {
169
-
170
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
171
-
172
-		if ( empty( $prefix ) ) {
173
-			$prefix = md5( uniqid( 'wpinv' ) );
174
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
175
-		}
176
-
177
-		return $prefix;
178
-	}
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
+        return $license_key;
93
+    }
94
+
95
+    /**
96
+     * Updates the database used for geolocation queries.
97
+     *
98
+     * @param string $tmp_database_path Temporary database path.
99
+     */
100
+    public function update_database( $tmp_database_path = null ) {
101
+
102
+        // Allow us to easily interact with the filesystem.
103
+        require_once ABSPATH . 'wp-admin/includes/file.php';
104
+        WP_Filesystem();
105
+        global $wp_filesystem;
106
+
107
+        // Remove any existing archives to comply with the MaxMind TOS.
108
+        $target_database_path = $this->database_service->get_database_path();
109
+
110
+        // If there's no database path, we can't store the database.
111
+        if ( empty( $target_database_path ) ) {
112
+            return;
113
+        }
114
+
115
+        if ( $wp_filesystem->exists( $target_database_path ) ) {
116
+            $wp_filesystem->delete( $target_database_path );
117
+        }
118
+
119
+        // We can't download a database if there's no license key configured.
120
+        $license_key = wpinv_get_option( 'maxmind_license_key' );
121
+        if ( empty( $license_key ) ) {
122
+            return;
123
+        }
124
+
125
+        if ( empty( $tmp_database_path ) ) {
126
+            $tmp_database_path = $this->database_service->download_database( $license_key );
127
+        }
128
+
129
+        if ( is_wp_error( $tmp_database_path ) ) {
130
+            wpinv_error_log( $tmp_database_path->get_error_message() );
131
+            return;
132
+        }
133
+
134
+        // Move the new database into position.
135
+        $wp_filesystem->move( $tmp_database_path, $target_database_path, true );
136
+        $wp_filesystem->delete( dirname( $tmp_database_path ) );
137
+    }
138
+
139
+    /**
140
+     * Performs a geolocation lookup against the MaxMind database for the given IP address.
141
+     *
142
+     * @param array  $data       Geolocation data.
143
+     * @param string $ip_address The IP address to geolocate.
144
+     * @return array Geolocation including country code, state, city and postcode based on an IP address.
145
+     */
146
+    public function get_geolocation( $data, $ip_address ) {
147
+
148
+        if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
149
+            return $data;
150
+        }
151
+
152
+        $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
153
+
154
+        return array(
155
+            'country'  => $country_code,
156
+            'state'    => '',
157
+            'city'     => '',
158
+            'postcode' => '',
159
+        );
160
+
161
+    }
162
+
163
+    /**
164
+     * Fetches the prefix for the MaxMind database file.
165
+     *
166
+     * @return string
167
+     */
168
+    private function get_database_prefix() {
169
+
170
+        $prefix = get_option( 'wpinv_maxmind_database_prefix' );
171
+
172
+        if ( empty( $prefix ) ) {
173
+            $prefix = md5( uniqid( 'wpinv' ) );
174
+            update_option( 'wpinv_maxmind_database_prefix', $prefix );
175
+        }
176
+
177
+        return $prefix;
178
+    }
179 179
 
180 180
 }
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
 		return $license_key;
93 93
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param string $tmp_database_path Temporary database path.
99 99
 	 */
100
-	public function update_database( $tmp_database_path = null ) {
100
+	public function update_database($tmp_database_path = null) {
101 101
 
102 102
 		// Allow us to easily interact with the filesystem.
103 103
 		require_once ABSPATH . 'wp-admin/includes/file.php';
@@ -108,32 +108,32 @@  discard block
 block discarded – undo
108 108
 		$target_database_path = $this->database_service->get_database_path();
109 109
 
110 110
 		// If there's no database path, we can't store the database.
111
-		if ( empty( $target_database_path ) ) {
111
+		if (empty($target_database_path)) {
112 112
 			return;
113 113
 		}
114 114
 
115
-		if ( $wp_filesystem->exists( $target_database_path ) ) {
116
-			$wp_filesystem->delete( $target_database_path );
115
+		if ($wp_filesystem->exists($target_database_path)) {
116
+			$wp_filesystem->delete($target_database_path);
117 117
 		}
118 118
 
119 119
 		// We can't download a database if there's no license key configured.
120
-		$license_key = wpinv_get_option( 'maxmind_license_key' );
121
-		if ( empty( $license_key ) ) {
120
+		$license_key = wpinv_get_option('maxmind_license_key');
121
+		if (empty($license_key)) {
122 122
 			return;
123 123
 		}
124 124
 
125
-		if ( empty( $tmp_database_path ) ) {
126
-			$tmp_database_path = $this->database_service->download_database( $license_key );
125
+		if (empty($tmp_database_path)) {
126
+			$tmp_database_path = $this->database_service->download_database($license_key);
127 127
 		}
128 128
 
129
-		if ( is_wp_error( $tmp_database_path ) ) {
130
-			wpinv_error_log( $tmp_database_path->get_error_message() );
129
+		if (is_wp_error($tmp_database_path)) {
130
+			wpinv_error_log($tmp_database_path->get_error_message());
131 131
 			return;
132 132
 		}
133 133
 
134 134
 		// Move the new database into position.
135
-		$wp_filesystem->move( $tmp_database_path, $target_database_path, true );
136
-		$wp_filesystem->delete( dirname( $tmp_database_path ) );
135
+		$wp_filesystem->move($tmp_database_path, $target_database_path, true);
136
+		$wp_filesystem->delete(dirname($tmp_database_path));
137 137
 	}
138 138
 
139 139
 	/**
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 	 * @param string $ip_address The IP address to geolocate.
144 144
 	 * @return array Geolocation including country code, state, city and postcode based on an IP address.
145 145
 	 */
146
-	public function get_geolocation( $data, $ip_address ) {
146
+	public function get_geolocation($data, $ip_address) {
147 147
 
148
-		if ( ! empty( $data['country'] ) || empty( $ip_address ) ) {
148
+		if (!empty($data['country']) || empty($ip_address)) {
149 149
 			return $data;
150 150
 		}
151 151
 
152
-		$country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address );
152
+		$country_code = $this->database_service->get_iso_country_code_for_ip($ip_address);
153 153
 
154 154
 		return array(
155 155
 			'country'  => $country_code,
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	private function get_database_prefix() {
169 169
 
170
-		$prefix = get_option( 'wpinv_maxmind_database_prefix' );
170
+		$prefix = get_option('wpinv_maxmind_database_prefix');
171 171
 
172
-		if ( empty( $prefix ) ) {
173
-			$prefix = md5( uniqid( 'wpinv' ) );
174
-			update_option( 'wpinv_maxmind_database_prefix', $prefix );
172
+		if (empty($prefix)) {
173
+			$prefix = md5(uniqid('wpinv'));
174
+			update_option('wpinv_maxmind_database_prefix', $prefix);
175 175
 		}
176 176
 
177 177
 		return $prefix;
Please login to merge, or discard this patch.
includes/admin/views/wizard-header.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
23
+                wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
+                wp_print_styles( 'select2' );
25 25
                 wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
26
+                wp_print_scripts( 'wpinv-admin-script' );
27 27
                 do_action( 'admin_print_styles' );
28 28
                 do_action( 'admin_head' );
29
-			?>
29
+            ?>
30 30
 			<style>
31 31
 				body, p{
32 32
 					font-size: 16px;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,9 +57,12 @@
 block discarded – undo
57 57
                         </li>
58 58
                     <?php endforeach; ?>
59 59
                 </ol>
60
-            <?php else : ?>
60
+            <?php else {
61
+    : ?>
61 62
                 <div class='mb-3'>&nbsp;</div>
62
-            <?php endif; ?>
63
+            <?php endif;
64
+}
65
+?>
63 66
 
64 67
             <div class="text-center pb-3 mt-5">
65 68
                 <a class=" text-decoration-none" href="https://wpgetpaid.com/">
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 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
 $aui_settings = AyeCode_UI_Settings::instance();
10 10
 $aui_settings->enqueue_scripts();
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
 		<head>
18 18
 			<meta name="viewport" content="width=device-width"/>
19 19
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
20
-			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
20
+			<title><?php esc_html_e('GetPaid &rsaquo; Setup Wizard', 'invoicing'); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
25
-                wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
27
-                do_action( 'admin_print_styles' );
28
-                do_action( 'admin_head' );
23
+				wp_enqueue_style('font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0');
24
+				wp_print_styles('select2');
25
+                wp_print_scripts('select2');
26
+				wp_print_scripts('wpinv-admin-script');
27
+                do_action('admin_print_styles');
28
+                do_action('admin_head');
29 29
 			?>
30 30
 			<style>
31 31
 				body, p{
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
                     font-weight: 500;
38 38
                     margin-bottom: .1rem;
39 39
                 }
40
-				<?php echo esc_html( $aui_settings::css_primary( '#009874', true ) ); ?>
40
+				<?php echo esc_html($aui_settings::css_primary('#009874', true)); ?>
41 41
 			</style>
42 42
 		</head>
43 43
 
44 44
         <body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;">
45 45
 
46
-            <?php if ( isset( $_REQUEST['step'] ) ) : ?>
46
+            <?php if (isset($_REQUEST['step'])) : ?>
47 47
                 <ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center">
48
-                    <?php foreach ( $steps as $step => $data ) : ?>
48
+                    <?php foreach ($steps as $step => $data) : ?>
49 49
                         <li class="list-group-item flex-fill rounded-0 
50 50
                         <?php
51 51
                             echo $step == $current ? 'active' : 'd-none d-md-block';
52
-                            echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? ' done' : '';
52
+                            echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? ' done' : '';
53 53
                         ?>
54 54
                         ">
55
-                            <i class="far fa-check-circle <?php echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? 'text-success' : ''; ?>"></i>
56
-                            <?php echo esc_html( $data['name'] ); ?>
55
+                            <i class="far fa-check-circle <?php echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? 'text-success' : ''; ?>"></i>
56
+                            <?php echo esc_html($data['name']); ?>
57 57
                         </li>
58 58
                     <?php endforeach; ?>
59 59
                 </ol>
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             <div class="text-center pb-3 mt-5">
65 65
                 <a class=" text-decoration-none" href="https://wpgetpaid.com/">
66 66
                     <span class="text-black-50">
67
-                        <img class="ml-n3x" src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png' ); ?>" />
67
+                        <img class="ml-n3x" src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'); ?>" />
68 68
                     </span>
69 69
                 </a>
70 70
             </div>
Please login to merge, or discard this patch.