Passed
Push — master ( 47b6fc...99ae46 )
by Brian
05:46 queued 20s
created
includes/payments/class-getpaid-payment-form-submission-items.php 1 patch
Spacing   +34 added lines, -34 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
  * Payment form submission itemss class
@@ -23,37 +23,37 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$data         = $submission->get_data();
29 29
 		$payment_form = $submission->get_payment_form();
30 30
 
31 31
 		// Prepare the selected items.
32 32
 		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
33
+		if (!empty($data['getpaid-items'])) {
34
+			$selected_items = wpinv_clean($data['getpaid-items']);
35 35
 		}
36 36
 
37 37
 		// (Maybe) set form items.
38
-		if ( isset( $data['getpaid-form-items'] ) ) {
38
+		if (isset($data['getpaid-form-items'])) {
39 39
 
40 40
 			// Confirm items key.
41
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
42
-			if ( ! isset( $data['getpaid-form-items-key'] ) || $data['getpaid-form-items-key'] !== md5( NONCE_KEY . AUTH_KEY . $form_items ) ) {
43
-				throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) );
41
+			$form_items = wpinv_clean($data['getpaid-form-items']);
42
+			if (!isset($data['getpaid-form-items-key']) || $data['getpaid-form-items-key'] !== md5(NONCE_KEY . AUTH_KEY . $form_items)) {
43
+				throw new Exception(__('We could not validate the form items. Please reload the page and try again.', 'invoicing'));
44 44
 			}
45 45
 
46
-			$items    = array();
46
+			$items = array();
47 47
             $item_ids = array();
48 48
 
49
-            foreach ( getpaid_convert_items_to_array( $form_items ) as $item_id => $qty ) {
50
-                if ( ! in_array( $item_id, $item_ids ) ) {
51
-                    $item = new GetPaid_Form_Item( $item_id );
52
-                    $item->set_quantity( $qty );
49
+            foreach (getpaid_convert_items_to_array($form_items) as $item_id => $qty) {
50
+                if (!in_array($item_id, $item_ids)) {
51
+                    $item = new GetPaid_Form_Item($item_id);
52
+                    $item->set_quantity($qty);
53 53
 
54
-                    if ( 0 == $qty ) {
55
-                        $item->set_allow_quantities( true );
56
-                        $item->set_is_required( false );
54
+                    if (0 == $qty) {
55
+                        $item->set_allow_quantities(true);
56
+                        $item->set_is_required(false);
57 57
                     }
58 58
 
59 59
                     $item_ids[] = $item->get_id();
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
                 }
62 62
             }
63 63
 
64
-            if ( ! $payment_form->is_default() ) {
64
+            if (!$payment_form->is_default()) {
65 65
 
66
-                foreach ( $payment_form->get_items() as $item ) {
67
-                    if ( ! in_array( $item->get_id(), $item_ids ) ) {
66
+                foreach ($payment_form->get_items() as $item) {
67
+                    if (!in_array($item->get_id(), $item_ids)) {
68 68
                         $item_ids[] = $item->get_id();
69 69
                         $items[]    = $item;
70 70
                     }
71 71
                 }
72 72
 }
73 73
 
74
-            $payment_form->set_items( $items );
74
+            $payment_form->set_items($items);
75 75
 
76 76
 		}
77 77
 
78 78
 		// Process each individual item.
79
-		foreach ( $payment_form->get_items() as $item ) {
80
-			$this->process_item( $item, $selected_items, $submission );
79
+		foreach ($payment_form->get_items() as $item) {
80
+			$this->process_item($item, $selected_items, $submission);
81 81
 		}
82 82
 
83 83
 	}
@@ -89,40 +89,40 @@  discard block
 block discarded – undo
89 89
 	 * @param array $selected_items
90 90
 	 * @param GetPaid_Payment_Form_Submission $submission
91 91
 	 */
92
-	public function process_item( $item, $selected_items, $submission ) {
92
+	public function process_item($item, $selected_items, $submission) {
93 93
 
94 94
 		// Abort if this is an optional item and it has not been selected.
95
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
95
+		if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
96 96
 			return;
97 97
 		}
98 98
 
99 99
 		// (maybe) let customers change the quantities and prices.
100
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
100
+		if (isset($selected_items[$item->get_id()])) {
101 101
 
102 102
 			// Maybe change the quantities.
103
-			if ( $item->allows_quantities() ) {
104
-				$item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
103
+			if ($item->allows_quantities()) {
104
+				$item->set_quantity((float) $selected_items[$item->get_id()]['quantity']);
105 105
 			}
106 106
 
107 107
 			// Maybe change the price.
108
-			if ( $item->user_can_set_their_price() ) {
109
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
108
+			if ($item->user_can_set_their_price()) {
109
+				$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
110 110
 
111
-				if ( $item->get_minimum_price() > $price ) {
112
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) );
111
+				if ($item->get_minimum_price() > $price) {
112
+					throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), getpaid_unstandardize_amount($item->get_minimum_price())));
113 113
 				}
114 114
 
115
-				$item->set_price( $price );
115
+				$item->set_price($price);
116 116
 
117 117
 			}
118 118
 }
119 119
 
120
-		if ( 0 == $item->get_quantity() ) {
120
+		if (0 == $item->get_quantity()) {
121 121
 			return;
122 122
 		}
123 123
 
124 124
 		// Save the item.
125
-		$this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission );
125
+		$this->items[] = apply_filters('getpaid_payment_form_submission_processed_item', $item, $submission);
126 126
 
127 127
 	}
128 128
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 1 patch
Spacing   +53 added lines, -53 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
  * Payment form submission taxes class
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param GetPaid_Payment_Form_Submission $submission
31 31
 	 */
32
-	public function __construct( $submission ) {
32
+	public function __construct($submission) {
33 33
 
34 34
 		// Validate VAT number.
35
-		$this->validate_vat( $submission );
35
+		$this->validate_vat($submission);
36 36
 
37
-		if ( $this->skip_taxes ) {
37
+		if ($this->skip_taxes) {
38 38
 			return;
39 39
 		}
40 40
 
41
-		foreach ( $submission->get_items() as $item ) {
42
-			$this->process_item_tax( $item, $submission );
41
+		foreach ($submission->get_items() as $item) {
42
+			$this->process_item_tax($item, $submission);
43 43
 		}
44 44
 
45 45
 		// Process any existing invoice taxes.
46
-		if ( $submission->has_invoice() ) {
47
-			$this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes );
46
+		if ($submission->has_invoice()) {
47
+			$this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes);
48 48
 		}
49 49
 
50 50
 	}
@@ -56,26 +56,26 @@  discard block
 block discarded – undo
56 56
 	 * @param GetPaid_Form_Item $item
57 57
 	 * @param GetPaid_Payment_Form_Submission $submission
58 58
 	 */
59
-	public function process_item_tax( $item, $submission ) {
59
+	public function process_item_tax($item, $submission) {
60 60
 
61
-		$rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
62
-		$rates    = getpaid_filter_item_tax_rates( $item, $rates );
63
-		$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
64
-		$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
61
+		$rates    = getpaid_get_item_tax_rates($item, $submission->country, $submission->state);
62
+		$rates    = getpaid_filter_item_tax_rates($item, $rates);
63
+		$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
64
+		$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
65 65
 
66
-		foreach ( $taxes as $name => $amount ) {
67
-			$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
68
-			$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
66
+		foreach ($taxes as $name => $amount) {
67
+			$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
68
+			$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
69 69
 
70
-			$item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] );
70
+			$item->item_tax += wpinv_sanitize_amount($tax['initial_tax']);
71 71
 
72
-			if ( ! isset( $this->taxes[ $name ] ) ) {
73
-				$this->taxes[ $name ] = $tax;
72
+			if (!isset($this->taxes[$name])) {
73
+				$this->taxes[$name] = $tax;
74 74
 				continue;
75 75
 			}
76 76
 
77
-			$this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
78
-			$this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
77
+			$this->taxes[$name]['initial_tax']   += $tax['initial_tax'];
78
+			$this->taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
79 79
 
80 80
 		}
81 81
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 	 * @since 1.0.19
89 89
 	 * @return bool
90 90
 	 */
91
-	public function has_digital_item( $submission ) {
91
+	public function has_digital_item($submission) {
92 92
 
93
-		foreach ( $submission->get_items() as $item ) {
93
+		foreach ($submission->get_items() as $item) {
94 94
 
95
-			if ( 'digital' == $item->get_vat_rule() ) {
95
+			if ('digital' == $item->get_vat_rule()) {
96 96
 				return true;
97 97
 			}
98 98
 }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return bool
108 108
 	 */
109 109
 	public static function is_eu_store() {
110
-		return self::is_eu_country( wpinv_get_default_country() );
110
+		return self::is_eu_country(wpinv_get_default_country());
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 * @since 1.0.19
118 118
 	 * @return bool
119 119
 	 */
120
-	public static function is_eu_country( $country ) {
121
-		return getpaid_is_eu_state( $country );
120
+	public static function is_eu_country($country) {
121
+		return getpaid_is_eu_state($country);
122 122
 	}
123 123
 
124 124
 	/**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @since 1.0.19
129 129
 	 * @return bool
130 130
 	 */
131
-	public static function is_eu_transaction( $customer_country ) {
132
-		return self::is_eu_country( $customer_country ) && self::is_eu_store();
131
+	public static function is_eu_transaction($customer_country) {
132
+		return self::is_eu_country($customer_country) && self::is_eu_store();
133 133
 	}
134 134
 
135 135
 	/**
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 	 * @since 1.0.19
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_vat_number( $submission ) {
142
+	public function get_vat_number($submission) {
143 143
 
144 144
 		// Retrieve from the posted number.
145
-		$vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
146
-		if ( ! is_null( $vat_number ) ) {
147
-			return wpinv_clean( $vat_number );
145
+		$vat_number = $submission->get_field('wpinv_vat_number', 'billing');
146
+		if (!is_null($vat_number)) {
147
+			return wpinv_clean($vat_number);
148 148
 		}
149 149
 
150 150
 		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
 	 * @since 1.0.19
158 158
 	 * @return string
159 159
 	 */
160
-	public function get_company( $submission ) {
160
+	public function get_company($submission) {
161 161
 
162 162
 		// Retrieve from the posted data.
163
-		$company = $submission->get_field( 'wpinv_company', 'billing' );
164
-		if ( ! empty( $company ) ) {
165
-			return wpinv_clean( $company );
163
+		$company = $submission->get_field('wpinv_company', 'billing');
164
+		if (!empty($company)) {
165
+			return wpinv_clean($company);
166 166
 		}
167 167
 
168 168
 		// Retrieve from the invoice.
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 * @since 1.0.19
178 178
 	 * @return string
179 179
 	 */
180
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
180
+	public function requires_vat($ip_in_eu, $country_in_eu) {
181 181
 
182
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
183
-		$prevent_b2c = ! empty( $prevent_b2c );
182
+		$prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase');
183
+		$prevent_b2c = !empty($prevent_b2c);
184 184
 		$is_eu       = $ip_in_eu || $country_in_eu;
185 185
 
186 186
 		return $prevent_b2c && $is_eu;
@@ -192,43 +192,43 @@  discard block
 block discarded – undo
192 192
 	 * @param GetPaid_Payment_Form_Submission $submission
193 193
 	 * @since 1.0.19
194 194
 	 */
195
-	public function validate_vat( $submission ) {
195
+	public function validate_vat($submission) {
196 196
 
197
-		$in_eu = $this->is_eu_transaction( $submission->country );
197
+		$in_eu = $this->is_eu_transaction($submission->country);
198 198
 
199 199
 		// Abort if we are not validating vat numbers.
200
-		if ( ! $in_eu ) {
200
+		if (!$in_eu) {
201 201
             return;
202 202
 		}
203 203
 
204 204
 		// Prepare variables.
205
-		$vat_number  = $this->get_vat_number( $submission );
205
+		$vat_number  = $this->get_vat_number($submission);
206 206
 		$ip_country  = getpaid_get_ip_country();
207
-        $is_eu       = $this->is_eu_country( $submission->country );
208
-        $is_ip_eu    = $this->is_eu_country( $ip_country );
207
+        $is_eu       = $this->is_eu_country($submission->country);
208
+        $is_ip_eu    = $this->is_eu_country($ip_country);
209 209
 
210 210
 		// Maybe abort early for initial fetches.
211
-		if ( $submission->is_initial_fetch() && empty( $vat_number ) ) {
211
+		if ($submission->is_initial_fetch() && empty($vat_number)) {
212 212
 			return;
213 213
 		}
214 214
 
215 215
 		// If we're preventing business to consumer purchases,
216
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
216
+		if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) {
217 217
 
218 218
 			// Ensure that a vat number has been specified.
219
-			throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) );
219
+			throw new GetPaid_Payment_Exception('.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing'));
220 220
 
221 221
 		}
222 222
 
223
-		if ( empty( $vat_number ) ) {
223
+		if (empty($vat_number)) {
224 224
 			return;
225 225
 		}
226 226
 
227
-		if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
228
-			throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) );
227
+		if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) {
228
+			throw new GetPaid_Payment_Exception('.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __('Your VAT number is invalid', 'invoicing'));
229 229
 		}
230 230
 
231
-		if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
231
+		if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
232 232
 			return;
233 233
 		}
234 234
 
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-abstract-report.php 1 patch
Spacing   +59 added lines, -59 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,34 +47,34 @@  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, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date' ) {
67
+	public function get_range_sql($range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date') {
68 68
 
69 69
         // Prepare durations.
70
-        $today                = current_time( 'Y-m-d' );
71
-		$yesterday            = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) );
72
-		$seven_days_ago       = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) );
73
-		$thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
74
-		$ninety_days_ago      = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) );
75
-		$sixty_days_ago       = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) );
76
-		$one_eighty_days_ago  = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) );
77
-		$three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) );
70
+        $today = current_time('Y-m-d');
71
+		$yesterday            = date('Y-m-d', strtotime('-1 day', current_time('timestamp')));
72
+		$seven_days_ago       = date('Y-m-d', strtotime('-7 days', current_time('timestamp')));
73
+		$thirty_days_ago      = date('Y-m-d', strtotime('-30 days', current_time('timestamp')));
74
+		$ninety_days_ago      = date('Y-m-d', strtotime('-90 days', current_time('timestamp')));
75
+		$sixty_days_ago       = date('Y-m-d', strtotime('-60 days', current_time('timestamp')));
76
+		$one_eighty_days_ago  = date('Y-m-d', strtotime('-180 days', current_time('timestamp')));
77
+		$three_sixty_days_ago = date('Y-m-d', strtotime('-360 days', current_time('timestamp')));
78 78
 
79 79
         $ranges = array(
80 80
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 
121 121
         );
122 122
 
123
-		$sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges['7_days'];
124
-		return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range );
123
+		$sql = isset($ranges[$range]) ? $ranges[$range] : $ranges['7_days'];
124
+		return apply_filters('getpaid_earning_graphs_get_range_sql', $sql, $range);
125 125
 
126 126
 	}
127 127
 
@@ -132,30 +132,30 @@  discard block
 block discarded – undo
132 132
 	public function get_hours_in_a_day() {
133 133
 
134 134
 		return array(
135
-			'12AM' => __( '12 AM', 'invoicing' ),
136
-			'1AM'  => __( '1 AM', 'invoicing' ),
137
-			'2AM'  => __( '2 AM', 'invoicing' ),
138
-			'3AM'  => __( '3 AM', 'invoicing' ),
139
-			'4AM'  => __( '4 AM', 'invoicing' ),
140
-			'5AM'  => __( '5 AM', 'invoicing' ),
141
-			'6AM'  => __( '6 AM', 'invoicing' ),
142
-			'7AM'  => __( '7 AM', 'invoicing' ),
143
-			'8AM'  => __( '8 AM', 'invoicing' ),
144
-			'9AM'  => __( '9 AM', 'invoicing' ),
145
-			'10AM' => __( '10 AM', 'invoicing' ),
146
-			'11AM' => __( '11 AM', 'invoicing' ),
147
-			'12pm' => __( '12 PM', 'invoicing' ),
148
-			'1PM'  => __( '1 PM', 'invoicing' ),
149
-			'2PM'  => __( '2 PM', 'invoicing' ),
150
-			'3PM'  => __( '3 PM', 'invoicing' ),
151
-			'4PM'  => __( '4 PM', 'invoicing' ),
152
-			'5PM'  => __( '5 PM', 'invoicing' ),
153
-			'6PM'  => __( '6 PM', 'invoicing' ),
154
-			'7PM'  => __( '7 PM', 'invoicing' ),
155
-			'8PM'  => __( '8 PM', 'invoicing' ),
156
-			'9PM'  => __( '9 PM', 'invoicing' ),
157
-			'10PM' => __( '10 PM', 'invoicing' ),
158
-			'11PM' => __( '11 PM', 'invoicing' ),
135
+			'12AM' => __('12 AM', 'invoicing'),
136
+			'1AM'  => __('1 AM', 'invoicing'),
137
+			'2AM'  => __('2 AM', 'invoicing'),
138
+			'3AM'  => __('3 AM', 'invoicing'),
139
+			'4AM'  => __('4 AM', 'invoicing'),
140
+			'5AM'  => __('5 AM', 'invoicing'),
141
+			'6AM'  => __('6 AM', 'invoicing'),
142
+			'7AM'  => __('7 AM', 'invoicing'),
143
+			'8AM'  => __('8 AM', 'invoicing'),
144
+			'9AM'  => __('9 AM', 'invoicing'),
145
+			'10AM' => __('10 AM', 'invoicing'),
146
+			'11AM' => __('11 AM', 'invoicing'),
147
+			'12pm' => __('12 PM', 'invoicing'),
148
+			'1PM'  => __('1 PM', 'invoicing'),
149
+			'2PM'  => __('2 PM', 'invoicing'),
150
+			'3PM'  => __('3 PM', 'invoicing'),
151
+			'4PM'  => __('4 PM', 'invoicing'),
152
+			'5PM'  => __('5 PM', 'invoicing'),
153
+			'6PM'  => __('6 PM', 'invoicing'),
154
+			'7PM'  => __('7 PM', 'invoicing'),
155
+			'8PM'  => __('8 PM', 'invoicing'),
156
+			'9PM'  => __('9 PM', 'invoicing'),
157
+			'10PM' => __('10 PM', 'invoicing'),
158
+			'11PM' => __('11 PM', 'invoicing'),
159 159
 		);
160 160
 
161 161
 	}
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
 	 * Retrieves the days in a period
165 165
 	 *
166 166
 	 */
167
-	public function get_days_in_period( $days ) {
167
+	public function get_days_in_period($days) {
168 168
 
169 169
 		$return = array();
170 170
 		$format = 'Y-m-d';
171 171
 
172
-		if ( $days < 8 ) {
172
+		if ($days < 8) {
173 173
 			$format = 'D';
174 174
 		}
175 175
 
176
-		if ( $days < 32 ) {
176
+		if ($days < 32) {
177 177
 			$format = 'M j';
178 178
 		}
179 179
 
180
-		while ( $days > 0 ) {
180
+		while ($days > 0) {
181 181
 
182
-			$key            = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
183
-			$label          = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) );
184
-			$return[ $key ] = $label;
182
+			$key            = date('Y-m-d', strtotime("-$days days", current_time('timestamp')));
183
+			$label          = date_i18n($format, strtotime("-$days days", current_time('timestamp')));
184
+			$return[$key] = $label;
185 185
 			$days--;
186 186
 
187 187
 		}
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
 	 * Retrieves the weeks in a period
194 194
 	 *
195 195
 	 */
196
-	public function get_weeks_in_period( $days ) {
196
+	public function get_weeks_in_period($days) {
197 197
 
198 198
 		$return = array();
199 199
 
200
-		while ( $days > 0 ) {
200
+		while ($days > 0) {
201 201
 
202
-			$key            = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) );
203
-			$label          = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
204
-			$return[ $key ] = $label;
202
+			$key            = date('W', strtotime("-$days days", current_time('timestamp')));
203
+			$label          = date_i18n('Y-m-d', strtotime("-$days days", current_time('timestamp')));
204
+			$return[$key] = $label;
205 205
 			$days--;
206 206
 
207 207
 		}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-report-items.php 1 patch
Spacing   +21 added lines, -21 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_Report_Items Class.
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	 * Retrieves the earning sql.
22 22
 	 *
23 23
 	 */
24
-	public function get_sql( $range ) {
24
+	public function get_sql($range) {
25 25
 		global $wpdb;
26 26
 
27 27
 		$table      = $wpdb->prefix . 'getpaid_invoices';
28 28
 		$table2     = $wpdb->prefix . 'getpaid_invoice_items';
29
-		$clauses    = $this->get_range_sql( $range );
29
+		$clauses    = $this->get_range_sql($range);
30 30
 
31 31
 		$sql        = "SELECT
32 32
 				item.item_name AS item_name,
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			ORDER BY total DESC
44 44
         ";
45 45
 
46
-		return apply_filters( 'getpaid_items_graphs_get_sql', $sql, $range );
46
+		return apply_filters('getpaid_items_graphs_get_sql', $sql, $range);
47 47
 
48 48
 	}
49 49
 
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function prepare_stats() {
55 55
 		global $wpdb;
56
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
57
-		$this->stats = $this->normalize_stats( $this->stats );
56
+		$this->stats = $wpdb->get_results($this->get_sql($this->get_range()));
57
+		$this->stats = $this->normalize_stats($this->stats);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Normalizes the report stats.
62 62
 	 *
63 63
 	 */
64
-	public function normalize_stats( $stats ) {
64
+	public function normalize_stats($stats) {
65 65
 		$normalized = array();
66 66
 		$others     = 0;
67 67
 		$did        = 0;
68 68
 
69
-		foreach ( $stats as $stat ) {
69
+		foreach ($stats as $stat) {
70 70
 
71
-			if ( $did > 4 ) {
71
+			if ($did > 4) {
72 72
 
73
-				$others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) );
73
+				$others += wpinv_round_amount(wpinv_sanitize_amount($stat->total));
74 74
 
75 75
 			} else {
76 76
 
77 77
 				$normalized[] = array(
78
-					'total'     => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ),
79
-					'item_name' => strip_tags( $stat->item_name ),
78
+					'total'     => wpinv_round_amount(wpinv_sanitize_amount($stat->total)),
79
+					'item_name' => strip_tags($stat->item_name),
80 80
 				);
81 81
 
82 82
 			}
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 			$did++;
85 85
 		}
86 86
 
87
-		if ( $others > 0 ) {
87
+		if ($others > 0) {
88 88
 
89 89
 			$normalized[] = array(
90
-				'total'     => wpinv_round_amount( wpinv_sanitize_amount( $others ) ),
91
-				'item_name' => esc_html__( 'Others', 'invoicing' ),
90
+				'total'     => wpinv_round_amount(wpinv_sanitize_amount($others)),
91
+				'item_name' => esc_html__('Others', 'invoicing'),
92 92
 			);
93 93
 
94 94
 		}
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function get_data() {
104 104
 
105
-		$data     = wp_list_pluck( $this->stats, 'total' );
106
-		$colors   = array( '#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3' );
105
+		$data     = wp_list_pluck($this->stats, 'total');
106
+		$colors   = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3');
107 107
 
108
-		shuffle( $colors );
108
+		shuffle($colors);
109 109
 
110 110
 		return array(
111 111
 			'data'            => $data,
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 */
121 121
 	public function get_labels() {
122
-		return wp_list_pluck( $this->stats, 'item_name' );
122
+		return wp_list_pluck($this->stats, 'item_name');
123 123
 	}
124 124
 
125 125
 	/**
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 						{
141 141
 							type: 'doughnut',
142 142
 							data: {
143
-								'labels': <?php echo wp_json_encode( wp_kses_post_deep( $this->get_labels() ) ); ?>,
144
-								'datasets': [ <?php echo wp_json_encode( wp_kses_post_deep( $this->get_data() ) ); ?> ]
143
+								'labels': <?php echo wp_json_encode(wp_kses_post_deep($this->get_labels())); ?>,
144
+								'datasets': [ <?php echo wp_json_encode(wp_kses_post_deep($this->get_data())); ?> ]
145 145
 							},
146 146
 							options: {
147 147
 								legend: {
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-report-earnings.php 1 patch
Spacing   +45 added lines, -45 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_Report_Earnings Class.
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 
21 21
 		$graphs = array(
22 22
 
23
-            'total'      => __( 'Earnings', 'invoicing' ),
24
-            'discount'   => __( 'Discount', 'invoicing' ),
25
-			'fees_total' => __( 'Fees', 'invoicing' ),
26
-			'tax'        => __( 'Tax', 'invoicing' ),
23
+            'total'      => __('Earnings', 'invoicing'),
24
+            'discount'   => __('Discount', 'invoicing'),
25
+			'fees_total' => __('Fees', 'invoicing'),
26
+			'tax'        => __('Tax', 'invoicing'),
27 27
 
28 28
 		);
29 29
 
30
-		return apply_filters( 'getpaid_earning_graphs', $graphs );
30
+		return apply_filters('getpaid_earning_graphs', $graphs);
31 31
 
32 32
 	}
33 33
 
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
 	 * Retrieves the earning sql.
36 36
 	 *
37 37
 	 */
38
-	public function get_sql( $range ) {
38
+	public function get_sql($range) {
39 39
 		global $wpdb;
40 40
 
41 41
 		$table      = $wpdb->prefix . 'getpaid_invoices';
42
-		$clauses    = $this->get_range_sql( $range );
43
-		$graphs     = array_keys( $this->get_graphs() );
42
+		$clauses    = $this->get_range_sql($range);
43
+		$graphs     = array_keys($this->get_graphs());
44 44
 		$graphs_sql = array();
45 45
 
46
-		foreach ( $graphs as $graph ) {
46
+		foreach ($graphs as $graph) {
47 47
 			$graphs_sql[] = "SUM( meta.$graph ) AS $graph";
48 48
 		}
49 49
 
50
-		$graphs_sql = implode( ', ', $graphs_sql );
50
+		$graphs_sql = implode(', ', $graphs_sql);
51 51
 		$sql        = "SELECT {$clauses[0]} AS completed_date, $graphs_sql
52 52
             FROM $wpdb->posts
53 53
             LEFT JOIN $table as meta ON meta.post_id = $wpdb->posts.ID
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             GROUP BY {$clauses[0]}
59 59
         ";
60 60
 
61
-		return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range );
61
+		return apply_filters('getpaid_earning_graphs_get_sql', $sql, $range);
62 62
 
63 63
 	}
64 64
 
@@ -68,68 +68,68 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function prepare_stats() {
70 70
 		global $wpdb;
71
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
71
+		$this->stats = $wpdb->get_results($this->get_sql($this->get_range()));
72 72
 	}
73 73
 
74 74
 	/**
75 75
 	 * Retrieves report labels.
76 76
 	 *
77 77
 	 */
78
-	public function get_labels( $range ) {
78
+	public function get_labels($range) {
79 79
 
80 80
 		$labels = array(
81 81
 			'today'     => $this->get_hours_in_a_day(),
82 82
 			'yesterday' => $this->get_hours_in_a_day(),
83
-			'7_days'    => $this->get_days_in_period( 7 ),
84
-			'30_days'   => $this->get_days_in_period( 30 ),
85
-			'60_days'   => $this->get_days_in_period( 60 ),
86
-			'90_days'   => $this->get_weeks_in_period( 90 ),
87
-			'180_days'  => $this->get_weeks_in_period( 180 ),
88
-			'360_days'  => $this->get_weeks_in_period( 360 ),
83
+			'7_days'    => $this->get_days_in_period(7),
84
+			'30_days'   => $this->get_days_in_period(30),
85
+			'60_days'   => $this->get_days_in_period(60),
86
+			'90_days'   => $this->get_weeks_in_period(90),
87
+			'180_days'  => $this->get_weeks_in_period(180),
88
+			'360_days'  => $this->get_weeks_in_period(360),
89 89
 		);
90 90
 
91
-		$label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels['7_days'];
92
-		return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range );
91
+		$label = isset($labels[$range]) ? $labels[$range] : $labels['7_days'];
92
+		return apply_filters('getpaid_earning_graphs_get_labels', $label, $range);
93 93
 	}
94 94
 
95 95
 	/**
96 96
 	 * Retrieves report datasets.
97 97
 	 *
98 98
 	 */
99
-	public function get_datasets( $labels ) {
99
+	public function get_datasets($labels) {
100 100
 
101 101
 		$datasets = array();
102 102
 
103
-		foreach ( $this->get_graphs() as $key => $label ) {
104
-			$datasets[ $key ] = array(
103
+		foreach ($this->get_graphs() as $key => $label) {
104
+			$datasets[$key] = array(
105 105
 				'label' => $label,
106
-				'data'  => $this->get_data( $key, $labels ),
106
+				'data'  => $this->get_data($key, $labels),
107 107
 			);
108 108
 		}
109 109
 
110
-		return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $labels );
110
+		return apply_filters('getpaid_earning_graphs_get_datasets', $datasets, $labels);
111 111
 	}
112 112
 
113 113
 	/**
114 114
 	 * Retrieves report data.
115 115
 	 *
116 116
 	 */
117
-	public function get_data( $key, $labels ) {
117
+	public function get_data($key, $labels) {
118 118
 
119
-		$data     = wp_list_pluck( $this->stats, $key, 'completed_date' );
119
+		$data     = wp_list_pluck($this->stats, $key, 'completed_date');
120 120
 		$prepared = array();
121 121
 
122
-		foreach ( $labels as $label ) {
122
+		foreach ($labels as $label) {
123 123
 
124 124
 			$value = 0;
125
-			if ( isset( $data[ $label ] ) ) {
126
-				$value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) );
125
+			if (isset($data[$label])) {
126
+				$value = wpinv_round_amount(wpinv_sanitize_amount($data[$label]));
127 127
 			}
128 128
 
129 129
 			$prepared[] = $value;
130 130
 		}
131 131
 
132
-		return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels );
132
+		return apply_filters('getpaid_earning_graphs_get_data', $prepared, $key, $labels);
133 133
 
134 134
 	}
135 135
 
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function display() {
141 141
 
142
-		$labels     = $this->get_labels( $this->get_range() );
142
+		$labels     = $this->get_labels($this->get_range());
143 143
 		$chart_data = array(
144
-			'labels'   => array_values( $labels ),
145
-			'datasets' => $this->get_datasets( array_keys( $labels ) ),
144
+			'labels'   => array_values($labels),
145
+			'datasets' => $this->get_datasets(array_keys($labels)),
146 146
 		);
147 147
 
148 148
 		?>
149 149
 
150
-			<?php foreach ( $chart_data['datasets'] as $key => $dataset ) : ?>
150
+			<?php foreach ($chart_data['datasets'] as $key => $dataset) : ?>
151 151
 				<div class="row mb-4">
152 152
 					<div class="col-12">
153 153
 						<div class="card m-0 p-0" style="max-width:100%">
154 154
 							<div class="card-header d-flex align-items-center">
155
-								<strong class="flex-grow-1"><?php echo esc_html( $dataset['label'] ); ?></strong>
155
+								<strong class="flex-grow-1"><?php echo esc_html($dataset['label']); ?></strong>
156 156
 								<?php $this->display_range_selector(); ?>
157 157
 							</div>
158 158
 							<div class="card-body">
159
-								<?php $this->display_graph( $key, $dataset, $chart_data['labels'] ); ?>
159
+								<?php $this->display_graph($key, $dataset, $chart_data['labels']); ?>
160 160
 							</div>
161 161
 						</div>
162 162
 					</div>
@@ -171,26 +171,26 @@  discard block
 block discarded – undo
171 171
 	 * Displays the actual report.
172 172
 	 *
173 173
 	 */
174
-	public function display_graph( $key, $dataset, $labels ) {
174
+	public function display_graph($key, $dataset, $labels) {
175 175
 
176 176
 		?>
177 177
 
178
-		<canvas id="getpaid-chartjs-earnings-<?php echo esc_attr( $key ); ?>"></canvas>
178
+		<canvas id="getpaid-chartjs-earnings-<?php echo esc_attr($key); ?>"></canvas>
179 179
 
180 180
 		<script>
181 181
 			window.addEventListener( 'DOMContentLoaded', function() {
182 182
 
183
-				var ctx = document.getElementById( 'getpaid-chartjs-earnings-<?php echo esc_attr( $key ); ?>' ).getContext('2d');
183
+				var ctx = document.getElementById( 'getpaid-chartjs-earnings-<?php echo esc_attr($key); ?>' ).getContext('2d');
184 184
 				new Chart(
185 185
 					ctx,
186 186
 					{
187 187
 						type: 'line',
188 188
 						data: {
189
-							'labels': <?php echo wp_json_encode( wpinv_clean( $labels ) ); ?>,
189
+							'labels': <?php echo wp_json_encode(wpinv_clean($labels)); ?>,
190 190
 							'datasets': [
191 191
 								{
192
-									label: '<?php echo esc_attr( $dataset['label'] ); ?>',
193
-									data: <?php echo wp_json_encode( wpinv_clean( $dataset['data'] ) ); ?>,
192
+									label: '<?php echo esc_attr($dataset['label']); ?>',
193
+									data: <?php echo wp_json_encode(wpinv_clean($dataset['data'])); ?>,
194 194
 									backgroundColor: 'rgba(54, 162, 235, 0.1)',
195 195
 									borderColor: 'rgb(54, 162, 235)',
196 196
 									borderWidth: 4,
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-report-discounts.php 1 patch
Spacing   +21 added lines, -21 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_Report_Discounts Class.
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	 * Retrieves the discounts sql.
22 22
 	 *
23 23
 	 */
24
-	public function get_sql( $range ) {
24
+	public function get_sql($range) {
25 25
 		global $wpdb;
26 26
 
27 27
 		$table      = $wpdb->prefix . 'getpaid_invoices';
28
-		$clauses    = $this->get_range_sql( $range );
28
+		$clauses    = $this->get_range_sql($range);
29 29
 
30 30
 		$sql        = "SELECT
31 31
 				meta.discount_code AS discount_code,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			ORDER BY total DESC
42 42
         ";
43 43
 
44
-		return apply_filters( 'getpaid_discounts_graphs_get_sql', $sql, $range );
44
+		return apply_filters('getpaid_discounts_graphs_get_sql', $sql, $range);
45 45
 
46 46
 	}
47 47
 
@@ -51,30 +51,30 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function prepare_stats() {
53 53
 		global $wpdb;
54
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
55
-		$this->stats = $this->normalize_stats( $this->stats );
54
+		$this->stats = $wpdb->get_results($this->get_sql($this->get_range()));
55
+		$this->stats = $this->normalize_stats($this->stats);
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * Normalizes the report stats.
60 60
 	 *
61 61
 	 */
62
-	public function normalize_stats( $stats ) {
62
+	public function normalize_stats($stats) {
63 63
 		$normalized = array();
64 64
 		$others     = 0;
65 65
 		$did        = 0;
66 66
 
67
-		foreach ( $stats as $stat ) {
67
+		foreach ($stats as $stat) {
68 68
 
69
-			if ( $did > 4 ) {
69
+			if ($did > 4) {
70 70
 
71
-				$others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) );
71
+				$others += wpinv_round_amount(wpinv_sanitize_amount($stat->total));
72 72
 
73 73
 			} else {
74 74
 
75 75
 				$normalized[] = array(
76
-					'total'         => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ),
77
-					'discount_code' => strip_tags( $stat->discount_code ),
76
+					'total'         => wpinv_round_amount(wpinv_sanitize_amount($stat->total)),
77
+					'discount_code' => strip_tags($stat->discount_code),
78 78
 				);
79 79
 
80 80
 			}
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 			$did++;
83 83
 		}
84 84
 
85
-		if ( $others > 0 ) {
85
+		if ($others > 0) {
86 86
 
87 87
 			$normalized[] = array(
88
-				'total'         => wpinv_round_amount( wpinv_sanitize_amount( $others ) ),
89
-				'discount_code' => esc_html__( 'Others', 'invoicing' ),
88
+				'total'         => wpinv_round_amount(wpinv_sanitize_amount($others)),
89
+				'discount_code' => esc_html__('Others', 'invoicing'),
90 90
 			);
91 91
 
92 92
 		}
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function get_data() {
102 102
 
103
-		$data     = wp_list_pluck( $this->stats, 'total' );
104
-		$colors   = array( '#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3' );
103
+		$data     = wp_list_pluck($this->stats, 'total');
104
+		$colors   = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3');
105 105
 
106
-		shuffle( $colors );
106
+		shuffle($colors);
107 107
 
108 108
 		return array(
109 109
 			'data'            => $data,
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 */
119 119
 	public function get_labels() {
120
-		return wp_list_pluck( $this->stats, 'discount_code' );
120
+		return wp_list_pluck($this->stats, 'discount_code');
121 121
 	}
122 122
 
123 123
 	/**
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 						{
139 139
 							type: 'doughnut',
140 140
 							data: {
141
-								'labels': <?php echo wp_json_encode( wpinv_clean( $this->get_labels() ) ); ?>,
142
-								'datasets': [ <?php echo wp_json_encode( wpinv_clean( $this->get_data() ) ); ?> ]
141
+								'labels': <?php echo wp_json_encode(wpinv_clean($this->get_labels())); ?>,
142
+								'datasets': [ <?php echo wp_json_encode(wpinv_clean($this->get_data())); ?> ]
143 143
 							},
144 144
 							options: {
145 145
 								legend: {
Please login to merge, or discard this patch.
includes/reports/class-getpaid-invoice-exporter.php 1 patch
Spacing   +36 added lines, -36 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_Invoice_Exporter Class.
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	 * @param array $args Args to search for.
20 20
 	 * @return array
21 21
 	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
22
+	public function get_invoice_query_args($post_type, $args) {
23 23
 
24 24
 		$query_args = array(
25 25
 			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
26
+			'post_status'            => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)),
27 27
 			'posts_per_page'         => -1,
28 28
 			'no_found_rows'          => true,
29 29
 			'update_post_term_cache' => false,
30 30
 			'fields'                 => 'ids',
31 31
 		);
32 32
 
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
33
+		if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) {
34
+			$query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status']));
35 35
 		}
36 36
 
37 37
 		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
38
+		if (!empty($args['to_date'])) {
39
+			$date_query['before'] = wpinv_clean($args['to_date']);
40 40
 		}
41 41
 
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
42
+		if (!empty($args['from_date'])) {
43
+			$date_query['after'] = wpinv_clean($args['from_date']);
44 44
 		}
45 45
 
46
-		if ( ! empty( $date_query ) ) {
46
+		if (!empty($date_query)) {
47 47
 			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
48
+			$query_args['date_query'] = array($date_query);
49 49
 		}
50 50
 
51 51
 		return $query_args;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @param array $query_args WP_Query args.
58 58
 	 * @return WPInv_Invoice[]
59 59
 	 */
60
-	public function get_invoices( $query_args ) {
60
+	public function get_invoices($query_args) {
61 61
 
62 62
 		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
63
+		$invoices = new WP_Query($query_args);
64 64
 
65 65
 		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
66
+		return array_map('wpinv_get_invoice', $invoices->posts);
67 67
 
68 68
 	}
69 69
 
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * Handles the actual download.
72 72
 	 *
73 73
 	 */
74
-	public function export( $post_type, $args ) {
74
+	public function export($post_type, $args) {
75 75
 
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
76
+		$invoices  = $this->get_invoices($this->get_invoice_query_args($post_type, $args));
77 77
 		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
78
+		$headers   = $this->get_export_fields($post_type);
79
+		$file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type)));
80 80
 
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} elseif ( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
81
+		if ('csv' == $file_type) {
82
+			$this->download_csv($invoices, $stream, $headers);
83
+		} elseif ('xml' == $file_type) {
84
+			$this->download_xml($invoices, $stream, $headers);
85 85
 		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
86
+			$this->download_json($invoices, $stream, $headers);
87 87
 		}
88 88
 
89
-		fclose( $stream );
89
+		fclose($stream);
90 90
 		exit;
91 91
 	}
92 92
 
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
 	 * @since       1.0.19
99 99
 	 * @return array
100 100
 	 */
101
-	public function prepare_row( $invoice, $fields ) {
101
+	public function prepare_row($invoice, $fields) {
102 102
 
103 103
 		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
104
+		$amount_fields = $this->get_amount_fields($invoice->get_post_type());
105 105
 
106
-		foreach ( $fields as $field ) {
106
+		foreach ($fields as $field) {
107 107
 
108 108
 			$value  = '';
109 109
 			$method = "get_$field";
110 110
 
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
111
+			if (method_exists($invoice, $method)) {
112
+				$value = $invoice->$method();
113 113
 			}
114 114
 
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
115
+			if (in_array($field, $amount_fields)) {
116
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
117 117
 			}
118 118
 
119
-			$prepared[ $field ] = wpinv_clean( $value );
119
+			$prepared[$field] = wpinv_clean($value);
120 120
 
121 121
 		}
122 122
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @since       1.0.19
131 131
 	 * @return array
132 132
 	 */
133
-	public function get_export_fields( $post_type ) {
133
+	public function get_export_fields($post_type) {
134 134
 
135 135
 		$fields = array(
136 136
 			'id',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 			'created_via',
181 181
     	);
182 182
 
183
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
183
+		return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type);
184 184
 	}
185 185
 
186 186
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.19
191 191
 	 * @return array
192 192
 	 */
193
-	public function get_amount_fields( $post_type ) {
193
+	public function get_amount_fields($post_type) {
194 194
 
195 195
 		$fields = array(
196 196
 			'subtotal',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			'total_fees',
200 200
     	);
201 201
 
202
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
202
+		return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type);
203 203
 	}
204 204
 
205 205
 }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-subscription-exporter.php 1 patch
Spacing   +33 added lines, -33 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_Subscription_Exporter Class.
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @param array $args Args to search for.
19 19
 	 * @return array
20 20
 	 */
21
-	public function get_subscription_query_args( $args ) {
21
+	public function get_subscription_query_args($args) {
22 22
 
23 23
 		$query_args = array(
24 24
 			'status'      => 'all',
@@ -27,22 +27,22 @@  discard block
 block discarded – undo
27 27
 			'fields'      => 'all',
28 28
 		);
29 29
 
30
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) {
31
-			$query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
30
+		if (!empty($args['status']) && in_array($args['status'], array_keys(getpaid_get_subscription_statuses()), true)) {
31
+			$query_args['status'] = wpinv_clean(wpinv_parse_list($args['status']));
32 32
 		}
33 33
 
34 34
 		$date_query = array();
35
-		if ( ! empty( $args['to_date'] ) ) {
36
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
35
+		if (!empty($args['to_date'])) {
36
+			$date_query['before'] = wpinv_clean($args['to_date']);
37 37
 		}
38 38
 
39
-		if ( ! empty( $args['from_date'] ) ) {
40
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
39
+		if (!empty($args['from_date'])) {
40
+			$date_query['after'] = wpinv_clean($args['from_date']);
41 41
 		}
42 42
 
43
-		if ( ! empty( $date_query ) ) {
43
+		if (!empty($date_query)) {
44 44
 			$date_query['inclusive']          = true;
45
-			$query_args['date_created_query'] = array( $date_query );
45
+			$query_args['date_created_query'] = array($date_query);
46 46
 		}
47 47
 
48 48
 		return $query_args;
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 	 * @param array $query_args GetPaid_Subscriptions_Query args.
55 55
 	 * @return WPInv_Subscription[]
56 56
 	 */
57
-	public function get_subscriptions( $query_args ) {
57
+	public function get_subscriptions($query_args) {
58 58
 
59 59
 		// Get subscriptions.
60
-		$subscriptions = new GetPaid_Subscriptions_Query( $query_args );
60
+		$subscriptions = new GetPaid_Subscriptions_Query($query_args);
61 61
 
62 62
 		// Prepare the results.
63 63
 		return $subscriptions->get_results();
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 	 * Handles the actual download.
69 69
 	 *
70 70
 	 */
71
-	public function export( $post_type, $args ) {
71
+	public function export($post_type, $args) {
72 72
 
73
-		$subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) );
73
+		$subscriptions = $this->get_subscriptions($this->get_subscription_query_args($args));
74 74
 		$stream        = $this->prepare_output();
75 75
 		$headers       = $this->get_export_fields();
76
-		$file_type     = $this->prepare_file_type( 'subscriptions' );
76
+		$file_type     = $this->prepare_file_type('subscriptions');
77 77
 
78
-		if ( 'csv' == $file_type ) {
79
-			$this->download_csv( $subscriptions, $stream, $headers );
80
-		} elseif ( 'xml' == $file_type ) {
81
-			$this->download_xml( $subscriptions, $stream, $headers );
78
+		if ('csv' == $file_type) {
79
+			$this->download_csv($subscriptions, $stream, $headers);
80
+		} elseif ('xml' == $file_type) {
81
+			$this->download_xml($subscriptions, $stream, $headers);
82 82
 		} else {
83
-			$this->download_json( $subscriptions, $stream, $headers );
83
+			$this->download_json($subscriptions, $stream, $headers);
84 84
 		}
85 85
 
86
-		fclose( $stream );
86
+		fclose($stream);
87 87
 		exit;
88 88
 	}
89 89
 
@@ -95,31 +95,31 @@  discard block
 block discarded – undo
95 95
 	 * @since       1.0.19
96 96
 	 * @return array
97 97
 	 */
98
-	public function prepare_row( $subscription, $fields ) {
98
+	public function prepare_row($subscription, $fields) {
99 99
 
100 100
 		$prepared      = array();
101 101
 		$amount_fields = $this->get_amount_fields();
102 102
 		$invoice       = $subscription->get_parent_payment();
103 103
 
104
-		foreach ( $fields as $field ) {
104
+		foreach ($fields as $field) {
105 105
 
106 106
 			$value  = '';
107 107
 			$method = "get_$field";
108 108
 
109
-			if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) {
109
+			if (0 === stripos($field, 'customer') || 'currency' === $field) {
110 110
 
111
-				if ( method_exists( $invoice, $method ) ) {
112
-					$value  = $invoice->$method();
111
+				if (method_exists($invoice, $method)) {
112
+					$value = $invoice->$method();
113 113
 				}
114
-} elseif ( method_exists( $subscription, $method ) ) {
115
-				$value  = $subscription->$method();
114
+} elseif (method_exists($subscription, $method)) {
115
+				$value = $subscription->$method();
116 116
 			}
117 117
 
118
-			if ( in_array( $field, $amount_fields ) ) {
119
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
118
+			if (in_array($field, $amount_fields)) {
119
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
120 120
 			}
121 121
 
122
-			$prepared[ $field ] = wpinv_clean( $value );
122
+			$prepared[$field] = wpinv_clean($value);
123 123
 
124 124
 		}
125 125
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
     	);
167 167
 
168
-		return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields );
168
+		return apply_filters('getpaid_subscription_exporter_get_fields', $fields);
169 169
 	}
170 170
 
171 171
 	/**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			'recurring_amount',
182 182
     	);
183 183
 
184
-		return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields );
184
+		return apply_filters('getpaid_subscription_exporter_get_amount_fields', $fields);
185 185
 	}
186 186
 
187 187
 }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-report-gateways.php 1 patch
Spacing   +21 added lines, -21 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_Report_Items Class.
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	 * Retrieves the earning sql.
22 22
 	 *
23 23
 	 */
24
-	public function get_sql( $range ) {
24
+	public function get_sql($range) {
25 25
 		global $wpdb;
26 26
 
27 27
 		$table      = $wpdb->prefix . 'getpaid_invoices';
28
-		$clauses    = $this->get_range_sql( $range );
28
+		$clauses    = $this->get_range_sql($range);
29 29
 
30 30
 		$sql        = "SELECT
31 31
 				meta.gateway AS gateway,
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			ORDER BY total DESC
41 41
         ";
42 42
 
43
-		return apply_filters( 'getpaid_gateways_graphs_get_sql', $sql, $range );
43
+		return apply_filters('getpaid_gateways_graphs_get_sql', $sql, $range);
44 44
 
45 45
 	}
46 46
 
@@ -50,30 +50,30 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function prepare_stats() {
52 52
 		global $wpdb;
53
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
54
-		$this->stats = $this->normalize_stats( $this->stats );
53
+		$this->stats = $wpdb->get_results($this->get_sql($this->get_range()));
54
+		$this->stats = $this->normalize_stats($this->stats);
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * Normalizes the report stats.
59 59
 	 *
60 60
 	 */
61
-	public function normalize_stats( $stats ) {
61
+	public function normalize_stats($stats) {
62 62
 		$normalized = array();
63 63
 		$others     = 0;
64 64
 		$did        = 0;
65 65
 
66
-		foreach ( $stats as $stat ) {
66
+		foreach ($stats as $stat) {
67 67
 
68
-			if ( $did > 4 ) {
68
+			if ($did > 4) {
69 69
 
70
-				$others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) );
70
+				$others += wpinv_round_amount(wpinv_sanitize_amount($stat->total));
71 71
 
72 72
 			} else {
73 73
 
74 74
 				$normalized[] = array(
75
-					'total'   => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ),
76
-					'gateway' => strip_tags( wpinv_get_gateway_admin_label( $stat->gateway ) ),
75
+					'total'   => wpinv_round_amount(wpinv_sanitize_amount($stat->total)),
76
+					'gateway' => strip_tags(wpinv_get_gateway_admin_label($stat->gateway)),
77 77
 				);
78 78
 
79 79
 			}
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 			$did++;
82 82
 		}
83 83
 
84
-		if ( $others > 0 ) {
84
+		if ($others > 0) {
85 85
 
86 86
 			$normalized[] = array(
87
-				'total'   => wpinv_round_amount( wpinv_sanitize_amount( $others ) ),
88
-				'gateway' => esc_html__( 'Others', 'invoicing' ),
87
+				'total'   => wpinv_round_amount(wpinv_sanitize_amount($others)),
88
+				'gateway' => esc_html__('Others', 'invoicing'),
89 89
 			);
90 90
 
91 91
 		}
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function get_data() {
101 101
 
102
-		$data     = wp_list_pluck( $this->stats, 'total' );
103
-		$colors   = array( '#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3' );
102
+		$data     = wp_list_pluck($this->stats, 'total');
103
+		$colors   = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3');
104 104
 
105
-		shuffle( $colors );
105
+		shuffle($colors);
106 106
 
107 107
 		return array(
108 108
 			'data'            => $data,
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 */
118 118
 	public function get_labels() {
119
-		return wp_list_pluck( $this->stats, 'gateway' );
119
+		return wp_list_pluck($this->stats, 'gateway');
120 120
 	}
121 121
 
122 122
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 						{
138 138
 							type: 'doughnut',
139 139
 							data: {
140
-								'labels': <?php echo wp_json_encode( wp_kses_post_deep( $this->get_labels() ) ); ?>,
141
-								'datasets': [ <?php echo wp_json_encode( wp_kses_post_deep( $this->get_data() ) ); ?> ]
140
+								'labels': <?php echo wp_json_encode(wp_kses_post_deep($this->get_labels())); ?>,
141
+								'datasets': [ <?php echo wp_json_encode(wp_kses_post_deep($this->get_data())); ?> ]
142 142
 							},
143 143
 							options: {
144 144
 								legend: {
Please login to merge, or discard this patch.