Passed
Push — master ( 0612be...57280a )
by Brian
05:11
created
includes/class-getpaid-subscription-notification-emails.php 2 patches
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -13,282 +13,282 @@
 block discarded – undo
13 13
 class GetPaid_Subscription_Notification_Emails {
14 14
 
15 15
     /**
16
-	 * The array of subscription email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $subscription_actions;
16
+     * The array of subscription email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $subscription_actions;
21 21
 
22 22
     /**
23
-	 * Class constructor
23
+     * Class constructor
24 24
      *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->subscription_actions = apply_filters(
29
-			'getpaid_notification_email_subscription_triggers',
30
-			array(
31
-				'getpaid_subscription_trialling' => 'subscription_trial',
32
-				'getpaid_subscription_cancelled' => 'subscription_cancelled',
33
-				'getpaid_subscription_expired'   => 'subscription_expired',
34
-				'getpaid_subscription_completed' => 'subscription_complete',
35
-				'getpaid_daily_maintenance'      => 'renewal_reminder',
36
-			)
37
-		);
38
-
39
-		$this->init_hooks();
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->subscription_actions = apply_filters(
29
+            'getpaid_notification_email_subscription_triggers',
30
+            array(
31
+                'getpaid_subscription_trialling' => 'subscription_trial',
32
+                'getpaid_subscription_cancelled' => 'subscription_cancelled',
33
+                'getpaid_subscription_expired'   => 'subscription_expired',
34
+                'getpaid_subscription_completed' => 'subscription_complete',
35
+                'getpaid_daily_maintenance'      => 'renewal_reminder',
36
+            )
37
+        );
38
+
39
+        $this->init_hooks();
40 40
 
41 41
     }
42 42
 
43 43
     /**
44
-	 * Registers email hooks.
45
-	 */
46
-	public function init_hooks() {
47
-
48
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
50
-
51
-			$email = new GetPaid_Notification_Email( $email_type );
52
-
53
-			if ( ! $email->is_active() ) {
54
-				continue;
55
-			}
56
-
57
-			if ( method_exists( $this, $email_type ) ) {
58
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
59
-				continue;
60
-			}
61
-
62
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
63
-
64
-		}
65
-
66
-	}
67
-
68
-	/**
69
-	 * Filters subscription merge tags.
70
-	 *
71
-	 * @param array $merge_tags
72
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73
-	 */
74
-	public function subscription_merge_tags( $merge_tags, $object ) {
75
-
76
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
77
-			$merge_tags = array_merge(
78
-				$merge_tags,
79
-				$this->get_subscription_merge_tags( $object )
80
-			);
81
-		}
82
-
83
-		return $merge_tags;
84
-
85
-	}
86
-
87
-	/**
88
-	 * Generates subscription merge tags.
89
-	 *
90
-	 * @param WPInv_Subscription $subscription
91
-	 * @return array
92
-	 */
93
-	public function get_subscription_merge_tags( $subscription ) {
94
-
95
-		// Abort if it does not exist.
96
-		if ( ! $subscription->get_id() ) {
97
-			return array();
98
-		}
99
-
100
-		$invoice    = $subscription->get_parent_invoice();
101
-		return array(
102
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
-			'{subscription_id}'               => absint( $subscription->get_id() ),
107
-			'{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
-			'{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
110
-			'{subscription_bill_times}'       => $subscription->get_bill_times(),
111
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
112
-		);
113
-
114
-	}
115
-
116
-	/**
117
-	 * Checks if we should send a notification for a subscription.
118
-	 *
119
-	 * @param WPInv_Invoice $invoice
120
-	 * @return bool
121
-	 */
122
-	public function should_send_notification( $invoice ) {
123
-		return 0 != $invoice->get_id();
124
-	}
125
-
126
-	/**
127
-	 * Returns notification recipients.
128
-	 *
129
-	 * @param WPInv_Invoice $invoice
130
-	 * @return array
131
-	 */
132
-	public function get_recipients( $invoice ) {
133
-		$recipients = array( $invoice->get_email() );
134
-
135
-		$cc = $invoice->get_email_cc();
136
-
137
-		if ( ! empty( $cc ) ) {
138
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
140
-		}
141
-
142
-		return $recipients;
143
-	}
144
-
145
-	/**
146
-	 * Helper function to send an email.
147
-	 *
148
-	 * @param WPInv_Subscription $subscription
149
-	 * @param GetPaid_Notification_Email $email
150
-	 * @param string $type
151
-	 * @param array $extra_args Extra template args.
152
-	 */
153
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
154
-
155
-		// Abort in case the parent invoice does not exist.
156
-		$invoice = $subscription->get_parent_invoice();
157
-		if ( ! $this->should_send_notification( $invoice ) ) {
158
-			return;
159
-		}
160
-
161
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
162
-
163
-		$recipients  = $this->get_recipients( $invoice );
164
-		$mailer      = new GetPaid_Notification_Email_Sender();
165
-		$merge_tags  = $email->get_merge_tags();
166
-		$content     = $email->get_content( $merge_tags, $extra_args );
167
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
168
-		$attachments = $email->get_attachments();
169
-
170
-		$result = $mailer->send(
171
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
172
-			$subject,
173
-			$content,
174
-			$attachments
175
-		);
176
-
177
-		// Maybe send a copy to the admin.
178
-		if ( $email->include_admin_bcc() ) {
179
-			$mailer->send(
180
-				wpinv_get_admin_email(),
181
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
182
-				$content,
183
-				$attachments
184
-			);
185
-		}
186
-
187
-		if ( ! $result ) {
188
-			$subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
189
-		}
190
-
191
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
192
-
193
-	}
44
+     * Registers email hooks.
45
+     */
46
+    public function init_hooks() {
47
+
48
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
+        foreach ( $this->subscription_actions as $hook => $email_type ) {
50
+
51
+            $email = new GetPaid_Notification_Email( $email_type );
52
+
53
+            if ( ! $email->is_active() ) {
54
+                continue;
55
+            }
56
+
57
+            if ( method_exists( $this, $email_type ) ) {
58
+                add_action( $hook, array( $this, $email_type ), 100, 2 );
59
+                continue;
60
+            }
61
+
62
+            do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
63
+
64
+        }
65
+
66
+    }
194 67
 
195 68
     /**
196
-	 * Sends a new trial notification.
197
-	 *
198
-	 * @param WPInv_Subscription $subscription
199
-	 */
200
-	public function subscription_trial( $subscription ) {
69
+     * Filters subscription merge tags.
70
+     *
71
+     * @param array $merge_tags
72
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73
+     */
74
+    public function subscription_merge_tags( $merge_tags, $object ) {
201 75
 
202
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
203
-		$this->send_email( $subscription, $email, __FUNCTION__ );
76
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
77
+            $merge_tags = array_merge(
78
+                $merge_tags,
79
+                $this->get_subscription_merge_tags( $object )
80
+            );
81
+        }
204 82
 
205
-	}
83
+        return $merge_tags;
206 84
 
207
-	/**
208
-	 * Sends a cancelled subscription notification.
209
-	 *
210
-	 * @param WPInv_Subscription $subscription
211
-	 */
212
-	public function subscription_cancelled( $subscription ) {
85
+    }
213 86
 
214
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
215
-		$this->send_email( $subscription, $email, __FUNCTION__ );
87
+    /**
88
+     * Generates subscription merge tags.
89
+     *
90
+     * @param WPInv_Subscription $subscription
91
+     * @return array
92
+     */
93
+    public function get_subscription_merge_tags( $subscription ) {
94
+
95
+        // Abort if it does not exist.
96
+        if ( ! $subscription->get_id() ) {
97
+            return array();
98
+        }
99
+
100
+        $invoice    = $subscription->get_parent_invoice();
101
+        return array(
102
+            '{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
+            '{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
+            '{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
+            '{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
+            '{subscription_id}'               => absint( $subscription->get_id() ),
107
+            '{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
+            '{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
+            '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
110
+            '{subscription_bill_times}'       => $subscription->get_bill_times(),
111
+            '{subscription_url}'              => esc_url( $subscription->get_view_url() ),
112
+        );
216 113
 
217
-	}
114
+    }
218 115
 
219
-	/**
220
-	 * Sends a subscription expired notification.
221
-	 *
222
-	 * @param WPInv_Subscription $subscription
223
-	 */
224
-	public function subscription_expired( $subscription ) {
116
+    /**
117
+     * Checks if we should send a notification for a subscription.
118
+     *
119
+     * @param WPInv_Invoice $invoice
120
+     * @return bool
121
+     */
122
+    public function should_send_notification( $invoice ) {
123
+        return 0 != $invoice->get_id();
124
+    }
225 125
 
226
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
227
-		$this->send_email( $subscription, $email, __FUNCTION__ );
126
+    /**
127
+     * Returns notification recipients.
128
+     *
129
+     * @param WPInv_Invoice $invoice
130
+     * @return array
131
+     */
132
+    public function get_recipients( $invoice ) {
133
+        $recipients = array( $invoice->get_email() );
228 134
 
229
-	}
135
+        $cc = $invoice->get_email_cc();
230 136
 
231
-	/**
232
-	 * Sends a completed subscription notification.
233
-	 *
234
-	 * @param WPInv_Subscription $subscription
235
-	 */
236
-	public function subscription_complete( $subscription ) {
137
+        if ( ! empty( $cc ) ) {
138
+            $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
+            $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
140
+        }
237 141
 
238
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
239
-		$this->send_email( $subscription, $email, __FUNCTION__ );
142
+        return $recipients;
143
+    }
240 144
 
241
-	}
145
+    /**
146
+     * Helper function to send an email.
147
+     *
148
+     * @param WPInv_Subscription $subscription
149
+     * @param GetPaid_Notification_Email $email
150
+     * @param string $type
151
+     * @param array $extra_args Extra template args.
152
+     */
153
+    public function send_email( $subscription, $email, $type, $extra_args = array() ) {
154
+
155
+        // Abort in case the parent invoice does not exist.
156
+        $invoice = $subscription->get_parent_invoice();
157
+        if ( ! $this->should_send_notification( $invoice ) ) {
158
+            return;
159
+        }
160
+
161
+        do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
162
+
163
+        $recipients  = $this->get_recipients( $invoice );
164
+        $mailer      = new GetPaid_Notification_Email_Sender();
165
+        $merge_tags  = $email->get_merge_tags();
166
+        $content     = $email->get_content( $merge_tags, $extra_args );
167
+        $subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
168
+        $attachments = $email->get_attachments();
169
+
170
+        $result = $mailer->send(
171
+            apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
172
+            $subject,
173
+            $content,
174
+            $attachments
175
+        );
176
+
177
+        // Maybe send a copy to the admin.
178
+        if ( $email->include_admin_bcc() ) {
179
+            $mailer->send(
180
+                wpinv_get_admin_email(),
181
+                $subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
182
+                $content,
183
+                $attachments
184
+            );
185
+        }
186
+
187
+        if ( ! $result ) {
188
+            $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
189
+        }
190
+
191
+        do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
242 192
 
243
-	/**
244
-	 * Sends a subscription renewal reminder notification.
245
-	 *
246
-	 */
247
-	public function renewal_reminder() {
193
+    }
248 194
 
249
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
195
+    /**
196
+     * Sends a new trial notification.
197
+     *
198
+     * @param WPInv_Subscription $subscription
199
+     */
200
+    public function subscription_trial( $subscription ) {
250 201
 
251
-		// Fetch reminder days.
252
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
202
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
203
+        $this->send_email( $subscription, $email, __FUNCTION__ );
253 204
 
254
-		// Abort if non is set.
255
-		if ( empty( $reminder_days ) ) {
256
-			return;
257
-		}
205
+    }
258 206
 
259
-		// Fetch matching subscriptions.
207
+    /**
208
+     * Sends a cancelled subscription notification.
209
+     *
210
+     * @param WPInv_Subscription $subscription
211
+     */
212
+    public function subscription_cancelled( $subscription ) {
213
+
214
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
215
+        $this->send_email( $subscription, $email, __FUNCTION__ );
216
+
217
+    }
218
+
219
+    /**
220
+     * Sends a subscription expired notification.
221
+     *
222
+     * @param WPInv_Subscription $subscription
223
+     */
224
+    public function subscription_expired( $subscription ) {
225
+
226
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
227
+        $this->send_email( $subscription, $email, __FUNCTION__ );
228
+
229
+    }
230
+
231
+    /**
232
+     * Sends a completed subscription notification.
233
+     *
234
+     * @param WPInv_Subscription $subscription
235
+     */
236
+    public function subscription_complete( $subscription ) {
237
+
238
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
239
+        $this->send_email( $subscription, $email, __FUNCTION__ );
240
+
241
+    }
242
+
243
+    /**
244
+     * Sends a subscription renewal reminder notification.
245
+     *
246
+     */
247
+    public function renewal_reminder() {
248
+
249
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
250
+
251
+        // Fetch reminder days.
252
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
253
+
254
+        // Abort if non is set.
255
+        if ( empty( $reminder_days ) ) {
256
+            return;
257
+        }
258
+
259
+        // Fetch matching subscriptions.
260 260
         $args  = array(
261 261
             'number'             => -1,
262
-			'count_total'        => false,
263
-			'status'             => 'trialling active',
262
+            'count_total'        => false,
263
+            'status'             => 'trialling active',
264 264
             'date_expires_query' => array(
265
-				'relation'  => 'OR'
265
+                'relation'  => 'OR'
266 266
             ),
267
-		);
267
+        );
268 268
 
269
-		foreach ( $reminder_days as $days ) {
270
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
269
+        foreach ( $reminder_days as $days ) {
270
+            $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
271 271
 
272
-			$args['date_expires_query'][] = array(
273
-				'year'  => $date['year'],
274
-				'month' => $date['month'],
275
-				'day'   => $date['day'],
276
-			);
272
+            $args['date_expires_query'][] = array(
273
+                'year'  => $date['year'],
274
+                'month' => $date['month'],
275
+                'day'   => $date['day'],
276
+            );
277 277
 
278
-		}
278
+        }
279 279
 
280
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
280
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
281 281
 
282 282
         foreach ( $subscriptions as $subscription ) {
283 283
 
284
-			// Skip packages.
285
-			if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) {
286
-				$email->object = $subscription;
287
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
288
-			}
284
+            // Skip packages.
285
+            if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) {
286
+                $email->object = $subscription;
287
+                $this->send_email( $subscription, $email, __FUNCTION__ );
288
+            }
289 289
 
290
-		}
290
+        }
291 291
 
292
-	}
292
+    }
293 293
 
294 294
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This class handles subscription notificaiton emails.
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function init_hooks() {
47 47
 
48
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
48
+		add_filter('getpaid_get_email_merge_tags', array($this, 'subscription_merge_tags'), 10, 2);
49
+		foreach ($this->subscription_actions as $hook => $email_type) {
50 50
 
51
-			$email = new GetPaid_Notification_Email( $email_type );
51
+			$email = new GetPaid_Notification_Email($email_type);
52 52
 
53
-			if ( ! $email->is_active() ) {
53
+			if (!$email->is_active()) {
54 54
 				continue;
55 55
 			}
56 56
 
57
-			if ( method_exists( $this, $email_type ) ) {
58
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
57
+			if (method_exists($this, $email_type)) {
58
+				add_action($hook, array($this, $email_type), 100, 2);
59 59
 				continue;
60 60
 			}
61 61
 
62
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
62
+			do_action('getpaid_subscription_notification_email_register_hook', $email_type, $hook);
63 63
 
64 64
 		}
65 65
 
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	 * @param array $merge_tags
72 72
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73 73
 	 */
74
-	public function subscription_merge_tags( $merge_tags, $object ) {
74
+	public function subscription_merge_tags($merge_tags, $object) {
75 75
 
76
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
76
+		if (is_a($object, 'WPInv_Subscription')) {
77 77
 			$merge_tags = array_merge(
78 78
 				$merge_tags,
79
-				$this->get_subscription_merge_tags( $object )
79
+				$this->get_subscription_merge_tags($object)
80 80
 			);
81 81
 		}
82 82
 
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
 	 * @param WPInv_Subscription $subscription
91 91
 	 * @return array
92 92
 	 */
93
-	public function get_subscription_merge_tags( $subscription ) {
93
+	public function get_subscription_merge_tags($subscription) {
94 94
 
95 95
 		// Abort if it does not exist.
96
-		if ( ! $subscription->get_id() ) {
96
+		if (!$subscription->get_id()) {
97 97
 			return array();
98 98
 		}
99 99
 
100
-		$invoice    = $subscription->get_parent_invoice();
100
+		$invoice = $subscription->get_parent_invoice();
101 101
 		return array(
102
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
-			'{subscription_id}'               => absint( $subscription->get_id() ),
107
-			'{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
108
-			'{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
109
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
102
+			'{subscription_renewal_date}'     => getpaid_format_date_value($subscription->get_next_renewal_date(), __('Never', 'invoicing')),
103
+			'{subscription_created}'          => getpaid_format_date_value($subscription->get_date_created()),
104
+			'{subscription_status}'           => sanitize_text_field($subscription->get_status_label()),
105
+			'{subscription_profile_id}'       => sanitize_text_field($subscription->get_profile_id()),
106
+			'{subscription_id}'               => absint($subscription->get_id()),
107
+			'{subscription_recurring_amount}' => sanitize_text_field(wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency())),
108
+			'{subscription_initial_amount}'   => sanitize_text_field(wpinv_price($subscription->get_initial_amount(), $invoice->get_currency())),
109
+			'{subscription_recurring_period}' => getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''),
110 110
 			'{subscription_bill_times}'       => $subscription->get_bill_times(),
111
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
111
+			'{subscription_url}'              => esc_url($subscription->get_view_url()),
112 112
 		);
113 113
 
114 114
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return bool
121 121
 	 */
122
-	public function should_send_notification( $invoice ) {
122
+	public function should_send_notification($invoice) {
123 123
 		return 0 != $invoice->get_id();
124 124
 	}
125 125
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 * @param WPInv_Invoice $invoice
130 130
 	 * @return array
131 131
 	 */
132
-	public function get_recipients( $invoice ) {
133
-		$recipients = array( $invoice->get_email() );
132
+	public function get_recipients($invoice) {
133
+		$recipients = array($invoice->get_email());
134 134
 
135 135
 		$cc = $invoice->get_email_cc();
136 136
 
137
-		if ( ! empty( $cc ) ) {
138
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
137
+		if (!empty($cc)) {
138
+			$cc = array_map('sanitize_email', wpinv_parse_list($cc));
139
+			$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
140 140
 		}
141 141
 
142 142
 		return $recipients;
@@ -150,45 +150,45 @@  discard block
 block discarded – undo
150 150
 	 * @param string $type
151 151
 	 * @param array $extra_args Extra template args.
152 152
 	 */
153
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
153
+	public function send_email($subscription, $email, $type, $extra_args = array()) {
154 154
 
155 155
 		// Abort in case the parent invoice does not exist.
156 156
 		$invoice = $subscription->get_parent_invoice();
157
-		if ( ! $this->should_send_notification( $invoice ) ) {
157
+		if (!$this->should_send_notification($invoice)) {
158 158
 			return;
159 159
 		}
160 160
 
161
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
161
+		do_action('getpaid_before_send_subscription_notification', $type, $subscription, $email);
162 162
 
163
-		$recipients  = $this->get_recipients( $invoice );
163
+		$recipients  = $this->get_recipients($invoice);
164 164
 		$mailer      = new GetPaid_Notification_Email_Sender();
165 165
 		$merge_tags  = $email->get_merge_tags();
166
-		$content     = $email->get_content( $merge_tags, $extra_args );
167
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
166
+		$content     = $email->get_content($merge_tags, $extra_args);
167
+		$subject     = $email->add_merge_tags($email->get_subject(), $merge_tags);
168 168
 		$attachments = $email->get_attachments();
169 169
 
170 170
 		$result = $mailer->send(
171
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
171
+			apply_filters('getpaid_subscription_email_recipients', wpinv_parse_list($recipients), $email),
172 172
 			$subject,
173 173
 			$content,
174 174
 			$attachments
175 175
 		);
176 176
 
177 177
 		// Maybe send a copy to the admin.
178
-		if ( $email->include_admin_bcc() ) {
178
+		if ($email->include_admin_bcc()) {
179 179
 			$mailer->send(
180 180
 				wpinv_get_admin_email(),
181
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
181
+				$subject . __(' - ADMIN BCC COPY', 'invoicing'),
182 182
 				$content,
183 183
 				$attachments
184 184
 			);
185 185
 		}
186 186
 
187
-		if ( ! $result ) {
188
-			$subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
187
+		if (!$result) {
188
+			$subscription->get_parent_invoice()->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true);
189 189
 		}
190 190
 
191
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
191
+		do_action('getpaid_after_send_subscription_notification', $type, $subscription, $email);
192 192
 
193 193
 	}
194 194
 
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @param WPInv_Subscription $subscription
199 199
 	 */
200
-	public function subscription_trial( $subscription ) {
200
+	public function subscription_trial($subscription) {
201 201
 
202
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
203
-		$this->send_email( $subscription, $email, __FUNCTION__ );
202
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
203
+		$this->send_email($subscription, $email, __FUNCTION__);
204 204
 
205 205
 	}
206 206
 
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @param WPInv_Subscription $subscription
211 211
 	 */
212
-	public function subscription_cancelled( $subscription ) {
212
+	public function subscription_cancelled($subscription) {
213 213
 
214
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
215
-		$this->send_email( $subscription, $email, __FUNCTION__ );
214
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
215
+		$this->send_email($subscription, $email, __FUNCTION__);
216 216
 
217 217
 	}
218 218
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param WPInv_Subscription $subscription
223 223
 	 */
224
-	public function subscription_expired( $subscription ) {
224
+	public function subscription_expired($subscription) {
225 225
 
226
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
227
-		$this->send_email( $subscription, $email, __FUNCTION__ );
226
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
227
+		$this->send_email($subscription, $email, __FUNCTION__);
228 228
 
229 229
 	}
230 230
 
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @param WPInv_Subscription $subscription
235 235
 	 */
236
-	public function subscription_complete( $subscription ) {
236
+	public function subscription_complete($subscription) {
237 237
 
238
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
239
-		$this->send_email( $subscription, $email, __FUNCTION__ );
238
+		$email = new GetPaid_Notification_Email(__FUNCTION__, $subscription);
239
+		$this->send_email($subscription, $email, __FUNCTION__);
240 240
 
241 241
 	}
242 242
 
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function renewal_reminder() {
248 248
 
249
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
249
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
250 250
 
251 251
 		// Fetch reminder days.
252
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
252
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
253 253
 
254 254
 		// Abort if non is set.
255
-		if ( empty( $reminder_days ) ) {
255
+		if (empty($reminder_days)) {
256 256
 			return;
257 257
 		}
258 258
 
259 259
 		// Fetch matching subscriptions.
260
-        $args  = array(
260
+        $args = array(
261 261
             'number'             => -1,
262 262
 			'count_total'        => false,
263 263
 			'status'             => 'trialling active',
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
             ),
267 267
 		);
268 268
 
269
-		foreach ( $reminder_days as $days ) {
270
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
269
+		foreach ($reminder_days as $days) {
270
+			$date = date_parse(date('Y-m-d', strtotime("+$days days", current_time('timestamp'))));
271 271
 
272 272
 			$args['date_expires_query'][] = array(
273 273
 				'year'  => $date['year'],
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
 
278 278
 		}
279 279
 
280
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
280
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
281 281
 
282
-        foreach ( $subscriptions as $subscription ) {
282
+        foreach ($subscriptions as $subscription) {
283 283
 
284 284
 			// Skip packages.
285
-			if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) {
285
+			if (get_post_meta($subscription->get_product_id(), '_wpinv_type', true) != 'package') {
286 286
 				$email->object = $subscription;
287
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
287
+            	$this->send_email($subscription, $email, __FUNCTION__);
288 288
 			}
289 289
 
290 290
 		}
Please login to merge, or discard this patch.
templates/emails/invoice-items.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
  * @var WPInv_Invoice $invoice
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$column_count = count( $columns );
13
+$column_count = count($columns);
14 14
 ?>
15 15
 
16
-<?php do_action( 'wpinv_before_email_items', $invoice ); ?>
16
+<?php do_action('wpinv_before_email_items', $invoice); ?>
17 17
 
18 18
 
19 19
 <div id="wpinv-email-items">
20 20
 
21 21
     <h3 class="invoice-items-title">
22
-        <?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), ucfirst( $invoice->get_invoice_quote_type() )); ?>
22
+        <?php echo sprintf(esc_html__('%s Items', 'invoicing'), ucfirst($invoice->get_invoice_quote_type())); ?>
23 23
     </h3>
24 24
 
25 25
     <table class="table table-bordered table-hover">
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
             <tr class="wpinv_cart_header_row">
30 30
 
31
-                <?php foreach ( $columns as $key => $label ) : ?>
32
-                    <th class="<?php echo 'name' == $key ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $key ); ?>">
33
-                        <?php echo sanitize_text_field( $label ); ?>
31
+                <?php foreach ($columns as $key => $label) : ?>
32
+                    <th class="<?php echo 'name' == $key ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($key); ?>">
33
+                        <?php echo sanitize_text_field($label); ?>
34 34
                     </th>
35 35
                 <?php endforeach; ?>
36 36
 
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
             <?php
44 44
 
45 45
                 // Display the item totals.
46
-                foreach ( $invoice->get_items() as $item ) {
47
-                    wpinv_get_template( 'emails/invoice-item.php', compact( 'invoice', 'item', 'columns' ) );
46
+                foreach ($invoice->get_items() as $item) {
47
+                    wpinv_get_template('emails/invoice-item.php', compact('invoice', 'item', 'columns'));
48 48
                 }
49 49
 
50 50
                 // Display the fee totals.
51
-                foreach ( $invoice->get_fees() as $fee ) {
52
-                    wpinv_get_template( 'emails/fee-item.php', compact( 'invoice', 'fee', 'columns' ) );
51
+                foreach ($invoice->get_fees() as $fee) {
52
+                    wpinv_get_template('emails/fee-item.php', compact('invoice', 'fee', 'columns'));
53 53
                 }
54 54
 
55 55
             ?>
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         </tbody>
58 58
 
59 59
         <tfoot>
60
-            <?php wpinv_get_template( 'emails/invoice-totals.php', compact( 'invoice', 'column_count' ) ); ?>
60
+            <?php wpinv_get_template('emails/invoice-totals.php', compact('invoice', 'column_count')); ?>
61 61
         </tfoot>
62 62
     
63 63
     </table>
Please login to merge, or discard this patch.
templates/emails/invoice-details.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,45 +8,45 @@  discard block
 block discarded – undo
8 8
  * @var WPInv_Invoice $invoice
9 9
  * @var array $columns
10 10
  */
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$meta_data = getpaid_get_invoice_meta( $invoice );
13
+$meta_data = getpaid_get_invoice_meta($invoice);
14 14
 
15
-if ( isset( $meta_data['status'] ) ) {
15
+if (isset($meta_data['status'])) {
16 16
     $meta_data['status']['value'] = $invoice->get_status_nicename();
17 17
 }
18 18
 
19
-do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin );
19
+do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin);
20 20
 
21 21
 ?>
22 22
 
23 23
 <div id="wpinv-email-details">
24 24
 
25 25
     <h3 class="invoice-details-title">
26
-        <?php echo sprintf( esc_html__( '%s Details', 'invoicing' ), ucfirst( $invoice->get_invoice_quote_type() )); ?>
26
+        <?php echo sprintf(esc_html__('%s Details', 'invoicing'), ucfirst($invoice->get_invoice_quote_type())); ?>
27 27
     </h3>
28 28
 
29 29
     <table class="table table-bordered table-sm">
30 30
 
31
-        <?php foreach ( $meta_data as $key => $data ) : ?>
31
+        <?php foreach ($meta_data as $key => $data) : ?>
32 32
 
33
-            <?php if ( ! empty( $data['value'] ) ) : ?>
33
+            <?php if (!empty($data['value'])) : ?>
34 34
 
35
-                <?php do_action( "getpaid_before_email_details_$key", $invoice, $data ); ?>
35
+                <?php do_action("getpaid_before_email_details_$key", $invoice, $data); ?>
36 36
 
37
-                <tr class="getpaid-email-details-<?php echo sanitize_html_class( $key ); ?>">
37
+                <tr class="getpaid-email-details-<?php echo sanitize_html_class($key); ?>">
38 38
 
39 39
                     <td class="getpaid-lable-td">
40
-                        <?php echo sanitize_text_field( $data['label'] ); ?>
40
+                        <?php echo sanitize_text_field($data['label']); ?>
41 41
                     </td>
42 42
 
43 43
                     <td class="getpaid-value-td">
44
-                        <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span>
44
+                        <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span>
45 45
                     </td>
46 46
 
47 47
                 </tr>
48 48
 
49
-                <?php do_action( "getpaid_after_email_details_$key", $invoice, $data ); ?>
49
+                <?php do_action("getpaid_after_email_details_$key", $invoice, $data); ?>
50 50
 
51 51
             <?php endif; ?>
52 52
 
@@ -56,4 +56,4 @@  discard block
 block discarded – undo
56 56
 
57 57
 </div>
58 58
 
59
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
59
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
Please login to merge, or discard this patch.
templates/invoice/header-right-actions.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @var WPInv_Invoice $invoice
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 ?>
14 14
 
@@ -21,43 +21,43 @@  discard block
 block discarded – undo
21 21
             $actions[] = sprintf(
22 22
                 '<a href="javascript:void(0)" class="btn btn-sm m-1 d-inline-block btn-secondary invoice-action-print d-none d-lg-inline-block" onclick="window.print();">%s</a>',
23 23
                 sprintf(
24
-                    __( 'Print %s', 'invoicing' ),
25
-                    ucfirst( $invoice->get_invoice_quote_type() )
24
+                    __('Print %s', 'invoicing'),
25
+                    ucfirst($invoice->get_invoice_quote_type())
26 26
                 )
27 27
             );
28 28
 
29
-            if ( is_user_logged_in() ) {
29
+            if (is_user_logged_in()) {
30 30
 
31 31
                 $actions[] = sprintf(
32 32
                     '<a href="%s" class="btn btn-sm btn-secondary m-1 d-inline-block invoice-action-history">%s</a>',
33
-                    esc_url( wpinv_get_history_page_uri( $invoice->get_post_type() ) ),
33
+                    esc_url(wpinv_get_history_page_uri($invoice->get_post_type())),
34 34
                     sprintf(
35
-                        __( '%s History', 'invoicing' ),
36
-                        ucfirst( $invoice->get_invoice_quote_type() )
35
+                        __('%s History', 'invoicing'),
36
+                        ucfirst($invoice->get_invoice_quote_type())
37 37
                     )
38 38
                 );
39 39
 
40 40
             }
41 41
 
42
-            if ( wpinv_current_user_can_manage_invoicing() ) {
42
+            if (wpinv_current_user_can_manage_invoicing()) {
43 43
 
44 44
                 $actions[] = sprintf(
45 45
                     '<a href="%s" class="btn btn-sm btn-secondary m-1 d-inline-block invoice-action-edit">%s</a>',
46
-                    esc_url( get_edit_post_link( $invoice->get_id() ) ),
46
+                    esc_url(get_edit_post_link($invoice->get_id())),
47 47
                     sprintf(
48
-                        __( 'Edit %s', 'invoicing' ),
49
-                        ucfirst( $invoice->get_invoice_quote_type() )
48
+                        __('Edit %s', 'invoicing'),
49
+                        ucfirst($invoice->get_invoice_quote_type())
50 50
                     )
51 51
                 );
52 52
 
53 53
             }
54 54
 
55
-            $actions = apply_filters( 'getpaid_invoice_header_right_actions_array', $actions, $invoice );
56
-            echo implode( '', $actions );
55
+            $actions = apply_filters('getpaid_invoice_header_right_actions_array', $actions, $invoice);
56
+            echo implode('', $actions);
57 57
 
58 58
         ?>
59 59
 
60
-        <?php do_action('wpinv_invoice_display_right_actions', $invoice ); ?>
60
+        <?php do_action('wpinv_invoice_display_right_actions', $invoice); ?>
61 61
     </div>
62 62
 
63 63
 <?php
Please login to merge, or discard this patch.
templates/invoice/invoice-type.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 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
 <h2 class="h3 text-dark">
14
-    <?php echo apply_filters( 'getpaid_invoice_type_label', ucfirst( $invoice->get_invoice_quote_type() ), $invoice ); ?>
14
+    <?php echo apply_filters('getpaid_invoice_type_label', ucfirst($invoice->get_invoice_quote_type()), $invoice); ?>
15 15
 </h2>
16 16
 
17 17
 <?php
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-subscription-data-store.php 2 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit;
8
+    exit;
9 9
 }
10 10
 
11 11
 /**
@@ -15,197 +15,197 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Subscription_Data_Store {
17 17
 
18
-	/**
19
-	 * A map of database fields to data types.
20
-	 *
21
-	 * @since 1.0.19
22
-	 * @var array
23
-	 */
24
-	protected $database_fields_to_data_type = array(
25
-		'id'                => '%d',
26
-		'customer_id'       => '%d',
27
-		'frequency'         => '%d',
28
-		'period'            => '%s',
29
-		'initial_amount'    => '%s',
30
-		'recurring_amount'  => '%s',
31
-		'bill_times'        => '%d',
32
-		'transaction_id'    => '%s',
33
-		'parent_payment_id' => '%d',
34
-		'product_id'        => '%d',
35
-		'created'           => '%s',
36
-		'expiration'        => '%s',
37
-		'trial_period'      => '%s',
38
-		'status'            => '%s',
39
-		'profile_id'        => '%s',
40
-	);
41
-
42
-	/*
18
+    /**
19
+     * A map of database fields to data types.
20
+     *
21
+     * @since 1.0.19
22
+     * @var array
23
+     */
24
+    protected $database_fields_to_data_type = array(
25
+        'id'                => '%d',
26
+        'customer_id'       => '%d',
27
+        'frequency'         => '%d',
28
+        'period'            => '%s',
29
+        'initial_amount'    => '%s',
30
+        'recurring_amount'  => '%s',
31
+        'bill_times'        => '%d',
32
+        'transaction_id'    => '%s',
33
+        'parent_payment_id' => '%d',
34
+        'product_id'        => '%d',
35
+        'created'           => '%s',
36
+        'expiration'        => '%s',
37
+        'trial_period'      => '%s',
38
+        'status'            => '%s',
39
+        'profile_id'        => '%s',
40
+    );
41
+
42
+    /*
43 43
 	|--------------------------------------------------------------------------
44 44
 	| CRUD Methods
45 45
 	|--------------------------------------------------------------------------
46 46
 	*/
47 47
 
48
-	/**
49
-	 * Method to create a new subscription in the database.
50
-	 *
51
-	 * @param WPInv_Subscription $subscription Subscription object.
52
-	 */
53
-	public function create( &$subscription ) {
54
-		global $wpdb;
55
-
56
-		$values  = array();
57
-		$formats = array();
58
-
59
-		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
61
-
62
-		foreach ( $fields as $key => $format ) {
63
-			$method       = "get_$key";
64
-			$values[$key] = $subscription->$method( 'edit' );
65
-			$formats[]    = $format;
66
-		}
67
-
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
69
-
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
72
-			$subscription->apply_changes();
73
-			$subscription->clear_cache();
74
-			update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
-			do_action( 'getpaid_new_subscription', $subscription );
76
-			return true;
77
-		}
78
-
79
-		return false;
80
-	}
81
-
82
-	/**
83
-	 * Method to read a subscription from the database.
84
-	 *
85
-	 * @param WPInv_Subscription $subscription Subscription object.
86
-	 *
87
-	 */
88
-	public function read( &$subscription ) {
89
-		global $wpdb;
90
-
91
-		$subscription->set_defaults();
92
-
93
-		if ( ! $subscription->get_id() ) {
94
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
-			$subscription->set_id( 0 );
96
-			return false;
97
-		}
98
-
99
-		// Maybe retrieve from the cache.
100
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
101
-
102
-		// If not found, retrieve from the db.
103
-		if ( false === $raw_subscription ) {
104
-
105
-			$raw_subscription = $wpdb->get_row(
106
-				$wpdb->prepare(
107
-					"SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d",
108
-					$subscription->get_id()
109
-				)
110
-			);
111
-
112
-			// Update the cache with our data
113
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
114
-
115
-		}
116
-
117
-		if ( ! $raw_subscription ) {
118
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
119
-			return false;
120
-		}
121
-
122
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
-			$method     = "set_$key";
124
-			$subscription->$method( $raw_subscription->$key );
125
-		}
126
-
127
-		$subscription->set_object_read( true );
128
-		do_action( 'getpaid_read_subscription', $subscription );
129
-
130
-	}
131
-
132
-	/**
133
-	 * Method to update a subscription in the database.
134
-	 *
135
-	 * @param WPInv_Subscription $subscription Subscription object.
136
-	 */
137
-	public function update( &$subscription ) {
138
-		global $wpdb;
139
-
140
-		$changes = $subscription->get_changes();
141
-		$values  = array();
142
-		$formats = array();
143
-
144
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
-			if ( array_key_exists( $key, $changes ) ) {
146
-				$method       = "get_$key";
147
-				$values[$key] = $subscription->$method( 'edit' );
148
-				$formats[]    = $format;
149
-			}
150
-		}
151
-
152
-		if ( empty( $values ) ) {
153
-			return;
154
-		}
155
-
156
-		$wpdb->update(
157
-			$wpdb->prefix . 'wpinv_subscriptions',
158
-			$values,
159
-			array(
160
-				'id' => $subscription->get_id(),
161
-			),
162
-			$formats,
163
-			'%d'
164
-		);
165
-
166
-		// Apply the changes.
167
-		$subscription->apply_changes();
168
-
169
-		// Delete cache.
170
-		$subscription->clear_cache();
171
-
172
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
173
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
174
-
175
-		// Fire a hook.
176
-		do_action( 'getpaid_update_subscription', $subscription );
177
-
178
-	}
179
-
180
-	/**
181
-	 * Method to delete a subscription from the database.
182
-	 *
183
-	 * @param WPInv_Subscription $subscription
184
-	 */
185
-	public function delete( &$subscription ) {
186
-		global $wpdb;
187
-
188
-		$wpdb->query(
189
-			$wpdb->prepare(
190
-				"DELETE FROM {$wpdb->prefix}wpinv_subscriptions
48
+    /**
49
+     * Method to create a new subscription in the database.
50
+     *
51
+     * @param WPInv_Subscription $subscription Subscription object.
52
+     */
53
+    public function create( &$subscription ) {
54
+        global $wpdb;
55
+
56
+        $values  = array();
57
+        $formats = array();
58
+
59
+        $fields = $this->database_fields_to_data_type;
60
+        unset( $fields['id'] );
61
+
62
+        foreach ( $fields as $key => $format ) {
63
+            $method       = "get_$key";
64
+            $values[$key] = $subscription->$method( 'edit' );
65
+            $formats[]    = $format;
66
+        }
67
+
68
+        $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
69
+
70
+        if ( $result ) {
71
+            $subscription->set_id( $wpdb->insert_id );
72
+            $subscription->apply_changes();
73
+            $subscription->clear_cache();
74
+            update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
+            do_action( 'getpaid_new_subscription', $subscription );
76
+            return true;
77
+        }
78
+
79
+        return false;
80
+    }
81
+
82
+    /**
83
+     * Method to read a subscription from the database.
84
+     *
85
+     * @param WPInv_Subscription $subscription Subscription object.
86
+     *
87
+     */
88
+    public function read( &$subscription ) {
89
+        global $wpdb;
90
+
91
+        $subscription->set_defaults();
92
+
93
+        if ( ! $subscription->get_id() ) {
94
+            $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
+            $subscription->set_id( 0 );
96
+            return false;
97
+        }
98
+
99
+        // Maybe retrieve from the cache.
100
+        $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
101
+
102
+        // If not found, retrieve from the db.
103
+        if ( false === $raw_subscription ) {
104
+
105
+            $raw_subscription = $wpdb->get_row(
106
+                $wpdb->prepare(
107
+                    "SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d",
108
+                    $subscription->get_id()
109
+                )
110
+            );
111
+
112
+            // Update the cache with our data
113
+            wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
114
+
115
+        }
116
+
117
+        if ( ! $raw_subscription ) {
118
+            $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
119
+            return false;
120
+        }
121
+
122
+        foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
+            $method     = "set_$key";
124
+            $subscription->$method( $raw_subscription->$key );
125
+        }
126
+
127
+        $subscription->set_object_read( true );
128
+        do_action( 'getpaid_read_subscription', $subscription );
129
+
130
+    }
131
+
132
+    /**
133
+     * Method to update a subscription in the database.
134
+     *
135
+     * @param WPInv_Subscription $subscription Subscription object.
136
+     */
137
+    public function update( &$subscription ) {
138
+        global $wpdb;
139
+
140
+        $changes = $subscription->get_changes();
141
+        $values  = array();
142
+        $formats = array();
143
+
144
+        foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
+            if ( array_key_exists( $key, $changes ) ) {
146
+                $method       = "get_$key";
147
+                $values[$key] = $subscription->$method( 'edit' );
148
+                $formats[]    = $format;
149
+            }
150
+        }
151
+
152
+        if ( empty( $values ) ) {
153
+            return;
154
+        }
155
+
156
+        $wpdb->update(
157
+            $wpdb->prefix . 'wpinv_subscriptions',
158
+            $values,
159
+            array(
160
+                'id' => $subscription->get_id(),
161
+            ),
162
+            $formats,
163
+            '%d'
164
+        );
165
+
166
+        // Apply the changes.
167
+        $subscription->apply_changes();
168
+
169
+        // Delete cache.
170
+        $subscription->clear_cache();
171
+
172
+        update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
173
+        update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
174
+
175
+        // Fire a hook.
176
+        do_action( 'getpaid_update_subscription', $subscription );
177
+
178
+    }
179
+
180
+    /**
181
+     * Method to delete a subscription from the database.
182
+     *
183
+     * @param WPInv_Subscription $subscription
184
+     */
185
+    public function delete( &$subscription ) {
186
+        global $wpdb;
187
+
188
+        $wpdb->query(
189
+            $wpdb->prepare(
190
+                "DELETE FROM {$wpdb->prefix}wpinv_subscriptions
191 191
 				WHERE id = %d",
192
-				$subscription->get_id()
193
-			)
194
-		);
192
+                $subscription->get_id()
193
+            )
194
+        );
195 195
 
196
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
197
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
196
+        delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
197
+        delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
198 198
 
199
-		// Delete cache.
200
-		$subscription->clear_cache();
199
+        // Delete cache.
200
+        $subscription->clear_cache();
201 201
 
202
-		// Fire a hook.
203
-		do_action( 'getpaid_delete_subscription', $subscription );
202
+        // Fire a hook.
203
+        do_action( 'getpaid_delete_subscription', $subscription );
204 204
 
205
-		$subscription->set_id( 0 );
206
-	}
205
+        $subscription->set_id( 0 );
206
+    }
207 207
 
208
-	/*
208
+    /*
209 209
 	|--------------------------------------------------------------------------
210 210
 	| Additional Methods
211 211
 	|--------------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Subscription_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Subscription $subscription Subscription object.
52 52
 	 */
53
-	public function create( &$subscription ) {
53
+	public function create(&$subscription) {
54 54
 		global $wpdb;
55 55
 
56 56
 		$values  = array();
57 57
 		$formats = array();
58 58
 
59 59
 		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
60
+		unset($fields['id']);
61 61
 
62
-		foreach ( $fields as $key => $format ) {
62
+		foreach ($fields as $key => $format) {
63 63
 			$method       = "get_$key";
64
-			$values[$key] = $subscription->$method( 'edit' );
64
+			$values[$key] = $subscription->$method('edit');
65 65
 			$formats[]    = $format;
66 66
 		}
67 67
 
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
68
+		$result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $values, $formats);
69 69
 
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
70
+		if ($result) {
71
+			$subscription->set_id($wpdb->insert_id);
72 72
 			$subscription->apply_changes();
73 73
 			$subscription->clear_cache();
74
-			update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
-			do_action( 'getpaid_new_subscription', $subscription );
74
+			update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id());
75
+			do_action('getpaid_new_subscription', $subscription);
76 76
 			return true;
77 77
 		}
78 78
 
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	 * @param WPInv_Subscription $subscription Subscription object.
86 86
 	 *
87 87
 	 */
88
-	public function read( &$subscription ) {
88
+	public function read(&$subscription) {
89 89
 		global $wpdb;
90 90
 
91 91
 		$subscription->set_defaults();
92 92
 
93
-		if ( ! $subscription->get_id() ) {
94
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
-			$subscription->set_id( 0 );
93
+		if (!$subscription->get_id()) {
94
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
95
+			$subscription->set_id(0);
96 96
 			return false;
97 97
 		}
98 98
 
99 99
 		// Maybe retrieve from the cache.
100
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
100
+		$raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions');
101 101
 
102 102
 		// If not found, retrieve from the db.
103
-		if ( false === $raw_subscription ) {
103
+		if (false === $raw_subscription) {
104 104
 
105 105
 			$raw_subscription = $wpdb->get_row(
106 106
 				$wpdb->prepare(
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 			);
111 111
 
112 112
 			// Update the cache with our data
113
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
113
+			wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions');
114 114
 
115 115
 		}
116 116
 
117
-		if ( ! $raw_subscription ) {
118
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
117
+		if (!$raw_subscription) {
118
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
119 119
 			return false;
120 120
 		}
121 121
 
122
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
-			$method     = "set_$key";
124
-			$subscription->$method( $raw_subscription->$key );
122
+		foreach (array_keys($this->database_fields_to_data_type) as $key) {
123
+			$method = "set_$key";
124
+			$subscription->$method($raw_subscription->$key);
125 125
 		}
126 126
 
127
-		$subscription->set_object_read( true );
128
-		do_action( 'getpaid_read_subscription', $subscription );
127
+		$subscription->set_object_read(true);
128
+		do_action('getpaid_read_subscription', $subscription);
129 129
 
130 130
 	}
131 131
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param WPInv_Subscription $subscription Subscription object.
136 136
 	 */
137
-	public function update( &$subscription ) {
137
+	public function update(&$subscription) {
138 138
 		global $wpdb;
139 139
 
140 140
 		$changes = $subscription->get_changes();
141 141
 		$values  = array();
142 142
 		$formats = array();
143 143
 
144
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
-			if ( array_key_exists( $key, $changes ) ) {
144
+		foreach ($this->database_fields_to_data_type as $key => $format) {
145
+			if (array_key_exists($key, $changes)) {
146 146
 				$method       = "get_$key";
147
-				$values[$key] = $subscription->$method( 'edit' );
147
+				$values[$key] = $subscription->$method('edit');
148 148
 				$formats[]    = $format;
149 149
 			}
150 150
 		}
151 151
 
152
-		if ( empty( $values ) ) {
152
+		if (empty($values)) {
153 153
 			return;
154 154
 		}
155 155
 
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 		// Delete cache.
170 170
 		$subscription->clear_cache();
171 171
 
172
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
173
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
172
+		update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id());
173
+		update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id());
174 174
 
175 175
 		// Fire a hook.
176
-		do_action( 'getpaid_update_subscription', $subscription );
176
+		do_action('getpaid_update_subscription', $subscription);
177 177
 
178 178
 	}
179 179
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @param WPInv_Subscription $subscription
184 184
 	 */
185
-	public function delete( &$subscription ) {
185
+	public function delete(&$subscription) {
186 186
 		global $wpdb;
187 187
 
188 188
 		$wpdb->query(
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
 			)
194 194
 		);
195 195
 
196
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
197
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
196
+		delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id');
197
+		delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id');
198 198
 
199 199
 		// Delete cache.
200 200
 		$subscription->clear_cache();
201 201
 
202 202
 		// Fire a hook.
203
-		do_action( 'getpaid_delete_subscription', $subscription );
203
+		do_action('getpaid_delete_subscription', $subscription);
204 204
 
205
-		$subscription->set_id( 0 );
205
+		$subscription->set_id(0);
206 206
 	}
207 207
 
208 208
 	/*
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+                    foreach( $tabs as $key => $label ) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
70
-						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
-						);
68
+                        $key   = sanitize_text_field( $key );
69
+                        $label = sanitize_text_field( $label );
70
+                        $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                        $url   = esc_url(
72
+                            add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
+                        );
74 74
 
75
-						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
75
+                        echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,77 +86,77 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
93
-			wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
94
-
95
-	}
96
-
97
-	/**
98
-	 * Retrieves reports page tabs.
99
-	 *
100
-	 * @return array
101
-	 */
102
-	public function get_tabs() {
103
-
104
-		$tabs = array(
105
-			'reports' => __( 'Reports', 'invoicing' ),
106
-			'export'  => __( 'Export', 'invoicing' ),
107
-		);
108
-
109
-		return apply_filters( 'getpaid_report_tabs', $tabs );
110
-	}
111
-
112
-	/**
113
-	 * Displays the reports tab.
114
-	 *
115
-	 */
116
-	public function display_reports_tab() {
117
-
118
-		$reports = new GetPaid_Reports_Report();
119
-		$reports->display();
120
-
121
-	}
122
-
123
-	/**
124
-	 * Displays the exports tab.
125
-	 *
126
-	 */
127
-	public function display_exports_tab() {
128
-
129
-		$exports = new GetPaid_Reports_Export();
130
-		$exports->display();
131
-
132
-	}
133
-
134
-	/**
135
-	 * Donwnloads a graph.
136
-	 *
137
-	 * @param array $args
138
-	 */
139
-	public function download_graph( $args ) {
140
-
141
-		if ( ! empty( $args['graph'] ) ) {
142
-			$downloader = new GetPaid_Graph_Downloader();
143
-			$downloader->download( $args['graph'] );
144
-		}
145
-
146
-	}
147
-
148
-	/**
149
-	 * Exports invoices.
150
-	 *
151
-	 * @param array $args
152
-	 */
153
-	public function export_invoices( $args ) {
154
-
155
-		if ( ! empty( $args['post_type'] ) ) {
156
-			$downloader = new GetPaid_Invoice_Exporter();
157
-			$downloader->export( $args['post_type'], $args );
158
-		}
159
-
160
-	}
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
93
+            wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
94
+
95
+    }
96
+
97
+    /**
98
+     * Retrieves reports page tabs.
99
+     *
100
+     * @return array
101
+     */
102
+    public function get_tabs() {
103
+
104
+        $tabs = array(
105
+            'reports' => __( 'Reports', 'invoicing' ),
106
+            'export'  => __( 'Export', 'invoicing' ),
107
+        );
108
+
109
+        return apply_filters( 'getpaid_report_tabs', $tabs );
110
+    }
111
+
112
+    /**
113
+     * Displays the reports tab.
114
+     *
115
+     */
116
+    public function display_reports_tab() {
117
+
118
+        $reports = new GetPaid_Reports_Report();
119
+        $reports->display();
120
+
121
+    }
122
+
123
+    /**
124
+     * Displays the exports tab.
125
+     *
126
+     */
127
+    public function display_exports_tab() {
128
+
129
+        $exports = new GetPaid_Reports_Export();
130
+        $exports->display();
131
+
132
+    }
133
+
134
+    /**
135
+     * Donwnloads a graph.
136
+     *
137
+     * @param array $args
138
+     */
139
+    public function download_graph( $args ) {
140
+
141
+        if ( ! empty( $args['graph'] ) ) {
142
+            $downloader = new GetPaid_Graph_Downloader();
143
+            $downloader->download( $args['graph'] );
144
+        }
145
+
146
+    }
147
+
148
+    /**
149
+     * Exports invoices.
150
+     *
151
+     * @param array $args
152
+     */
153
+    public function export_invoices( $args ) {
154
+
155
+        if ( ! empty( $args['post_type'] ) ) {
156
+            $downloader = new GetPaid_Invoice_Exporter();
157
+            $downloader->export( $args['post_type'], $args );
158
+        }
159
+
160
+    }
161 161
 
162 162
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 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 Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
68
+						$key   = sanitize_text_field($key);
69
+						$label = sanitize_text_field($label);
70 70
 						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+							add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
 						);
74 74
 
75 75
 						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
93
-			wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array('jquery'), '2.9.4', true);
93
+			wp_enqueue_style('chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4');
94 94
 
95 95
 	}
96 96
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	public function get_tabs() {
103 103
 
104 104
 		$tabs = array(
105
-			'reports' => __( 'Reports', 'invoicing' ),
106
-			'export'  => __( 'Export', 'invoicing' ),
105
+			'reports' => __('Reports', 'invoicing'),
106
+			'export'  => __('Export', 'invoicing'),
107 107
 		);
108 108
 
109
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
+		return apply_filters('getpaid_report_tabs', $tabs);
110 110
 	}
111 111
 
112 112
 	/**
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param array $args
138 138
 	 */
139
-	public function download_graph( $args ) {
139
+	public function download_graph($args) {
140 140
 
141
-		if ( ! empty( $args['graph'] ) ) {
141
+		if (!empty($args['graph'])) {
142 142
 			$downloader = new GetPaid_Graph_Downloader();
143
-			$downloader->download( $args['graph'] );
143
+			$downloader->download($args['graph']);
144 144
 		}
145 145
 
146 146
 	}
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param array $args
152 152
 	 */
153
-	public function export_invoices( $args ) {
153
+	public function export_invoices($args) {
154 154
 
155
-		if ( ! empty( $args['post_type'] ) ) {
155
+		if (!empty($args['post_type'])) {
156 156
 			$downloader = new GetPaid_Invoice_Exporter();
157
-			$downloader->export( $args['post_type'], $args );
157
+			$downloader->export($args['post_type'], $args);
158 158
 		}
159 159
 
160 160
 	}
Please login to merge, or discard this patch.
includes/class-getpaid-post-types.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -15,319 +15,319 @@
 block discarded – undo
15 15
 class GetPaid_Post_Types {
16 16
 
17 17
     /**
18
-	 * Hook in methods.
19
-	 */
20
-	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
-	}
18
+     * Hook in methods.
19
+     */
20
+    public function __construct() {
21
+        add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
+        add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
+        add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
+        add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
25
+    }
26 26
 
27
-	/**
28
-	 * Register core post types.
29
-	 */
30
-	public static function register_post_types() {
27
+    /**
28
+     * Register core post types.
29
+     */
30
+    public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
-			return;
34
-		}
32
+        if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
33
+            return;
34
+        }
35 35
 
36
-		// Fires before registering post types.
37
-		do_action( 'getpaid_register_post_types' );
36
+        // Fires before registering post types.
37
+        do_action( 'getpaid_register_post_types' );
38 38
 
39
-		// Register item post type.
40
-		register_post_type(
41
-			'wpi_item',
42
-			apply_filters(
43
-				'wpinv_register_post_type_invoice_item',
44
-				array(
45
-					'labels'             => array(
46
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
-						'new_item'           => __( 'New Item', 'invoicing' ),
53
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
-						'view_item'          => __( 'View Item', 'invoicing' ),
55
-						'all_items'          => __( 'Items', 'invoicing' ),
56
-						'search_items'       => __( 'Search items', 'invoicing' ),
57
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
-						'not_found'          => __( 'No items found.', 'invoicing' ),
59
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
60
-					),
61
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
62
-					'public'                => false,
63
-					'has_archive'           => false,
64
-					'_builtin'              => false,
65
-					'show_ui'               => true,
66
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67
-					'show_in_nav_menus'     => false,
68
-					'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
69
-					'rewrite'               => false,
70
-					'query_var'             => false,
71
-					'map_meta_cap'          => true,
72
-					'show_in_admin_bar'     => true,
73
-					'can_export'            => true,
74
-				)
75
-			)
76
-		);
39
+        // Register item post type.
40
+        register_post_type(
41
+            'wpi_item',
42
+            apply_filters(
43
+                'wpinv_register_post_type_invoice_item',
44
+                array(
45
+                    'labels'             => array(
46
+                        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
+                        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
+                        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
+                        'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
+                        'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
+                        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
+                        'new_item'           => __( 'New Item', 'invoicing' ),
53
+                        'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
+                        'view_item'          => __( 'View Item', 'invoicing' ),
55
+                        'all_items'          => __( 'Items', 'invoicing' ),
56
+                        'search_items'       => __( 'Search items', 'invoicing' ),
57
+                        'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
+                        'not_found'          => __( 'No items found.', 'invoicing' ),
59
+                        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
60
+                    ),
61
+                    'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
62
+                    'public'                => false,
63
+                    'has_archive'           => false,
64
+                    '_builtin'              => false,
65
+                    'show_ui'               => true,
66
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67
+                    'show_in_nav_menus'     => false,
68
+                    'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
69
+                    'rewrite'               => false,
70
+                    'query_var'             => false,
71
+                    'map_meta_cap'          => true,
72
+                    'show_in_admin_bar'     => true,
73
+                    'can_export'            => true,
74
+                )
75
+            )
76
+        );
77 77
 
78
-		// Register payment form post type.
79
-		register_post_type(
80
-			'wpi_payment_form',
81
-			apply_filters(
82
-				'wpinv_register_post_type_payment_form',
83
-				array(
84
-					'labels'             => array(
85
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
86
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
87
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
88
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
89
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
90
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
91
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
92
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
93
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
94
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
95
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
96
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
97
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
98
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
99
-					),
100
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
101
-					'public'             => false,
102
-					'show_ui'            => true,
103
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
104
-					'show_in_nav_menus'  => false,
105
-					'query_var'          => false,
106
-					'rewrite'            => true,
107
-					'map_meta_cap'       => true,
108
-					'has_archive'        => false,
109
-					'hierarchical'       => false,
110
-					'menu_position'      => null,
111
-					'supports'           => array( 'title' ),
112
-					'menu_icon'          => 'dashicons-media-form',
113
-				)
114
-			)
115
-		);
78
+        // Register payment form post type.
79
+        register_post_type(
80
+            'wpi_payment_form',
81
+            apply_filters(
82
+                'wpinv_register_post_type_payment_form',
83
+                array(
84
+                    'labels'             => array(
85
+                        'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
86
+                        'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
87
+                        'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
88
+                        'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
89
+                        'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
90
+                        'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
91
+                        'new_item'           => __( 'New Payment Form', 'invoicing' ),
92
+                        'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
93
+                        'view_item'          => __( 'View Payment Form', 'invoicing' ),
94
+                        'all_items'          => __( 'Payment Forms', 'invoicing' ),
95
+                        'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
96
+                        'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
97
+                        'not_found'          => __( 'No payment forms found.', 'invoicing' ),
98
+                        'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
99
+                    ),
100
+                    'description'        => __( 'Add new payment forms.', 'invoicing' ),
101
+                    'public'             => false,
102
+                    'show_ui'            => true,
103
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
104
+                    'show_in_nav_menus'  => false,
105
+                    'query_var'          => false,
106
+                    'rewrite'            => true,
107
+                    'map_meta_cap'       => true,
108
+                    'has_archive'        => false,
109
+                    'hierarchical'       => false,
110
+                    'menu_position'      => null,
111
+                    'supports'           => array( 'title' ),
112
+                    'menu_icon'          => 'dashicons-media-form',
113
+                )
114
+            )
115
+        );
116 116
 
117
-		// Register invoice post type.
118
-		register_post_type(
119
-			'wpi_invoice',
120
-			apply_filters(
121
-				'wpinv_register_post_type_invoice',
122
-				array(
123
-					'labels'                 => array(
124
-						'name'                  => __( 'Invoices', 'invoicing' ),
125
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
126
-						'all_items'             => __( 'Invoices', 'invoicing' ),
127
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
128
-						'add_new'               => __( 'Add New', 'invoicing' ),
129
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
130
-						'edit'                  => __( 'Edit', 'invoicing' ),
131
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
132
-						'new_item'              => __( 'New invoice', 'invoicing' ),
133
-						'view_item'             => __( 'View invoice', 'invoicing' ),
134
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
135
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
136
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
137
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
138
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
139
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
140
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
141
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
142
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
143
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
144
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
145
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
146
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
147
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
148
-					),
149
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
150
-					'public'                => true,
151
-					'has_archive'           => false,
152
-					'publicly_queryable'    => true,
153
-        			'exclude_from_search'   => true,
154
-        			'show_ui'               => true,
155
-					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
156
-					'show_in_nav_menus'     => false,
157
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
158
-					'rewrite'               => array(
159
-						'slug'              => 'invoice',
160
-						'with_front'        => false,
161
-					),
162
-					'query_var'             => false,
163
-					'map_meta_cap'          => true,
164
-					'show_in_admin_bar'     => true,
165
-					'can_export'            => true,
166
-					'hierarchical'          => false,
167
-					'menu_position'         => null,
168
-					'menu_icon'             => 'dashicons-media-spreadsheet',
169
-				)
170
-			)
171
-		);
117
+        // Register invoice post type.
118
+        register_post_type(
119
+            'wpi_invoice',
120
+            apply_filters(
121
+                'wpinv_register_post_type_invoice',
122
+                array(
123
+                    'labels'                 => array(
124
+                        'name'                  => __( 'Invoices', 'invoicing' ),
125
+                        'singular_name'         => __( 'Invoice', 'invoicing' ),
126
+                        'all_items'             => __( 'Invoices', 'invoicing' ),
127
+                        'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
128
+                        'add_new'               => __( 'Add New', 'invoicing' ),
129
+                        'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
130
+                        'edit'                  => __( 'Edit', 'invoicing' ),
131
+                        'edit_item'             => __( 'Edit invoice', 'invoicing' ),
132
+                        'new_item'              => __( 'New invoice', 'invoicing' ),
133
+                        'view_item'             => __( 'View invoice', 'invoicing' ),
134
+                        'view_items'            => __( 'View Invoices', 'invoicing' ),
135
+                        'search_items'          => __( 'Search invoices', 'invoicing' ),
136
+                        'not_found'             => __( 'No invoices found', 'invoicing' ),
137
+                        'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
138
+                        'parent'                => __( 'Parent invoice', 'invoicing' ),
139
+                        'featured_image'        => __( 'Invoice image', 'invoicing' ),
140
+                        'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
141
+                        'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
142
+                        'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
143
+                        'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
144
+                        'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
145
+                        'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
146
+                        'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
147
+                        'items_list'            => __( 'Invoices list', 'invoicing' ),
148
+                    ),
149
+                    'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
150
+                    'public'                => true,
151
+                    'has_archive'           => false,
152
+                    'publicly_queryable'    => true,
153
+                    'exclude_from_search'   => true,
154
+                    'show_ui'               => true,
155
+                    'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
156
+                    'show_in_nav_menus'     => false,
157
+                    'supports'              => array( 'title', 'author', 'excerpt'  ),
158
+                    'rewrite'               => array(
159
+                        'slug'              => 'invoice',
160
+                        'with_front'        => false,
161
+                    ),
162
+                    'query_var'             => false,
163
+                    'map_meta_cap'          => true,
164
+                    'show_in_admin_bar'     => true,
165
+                    'can_export'            => true,
166
+                    'hierarchical'          => false,
167
+                    'menu_position'         => null,
168
+                    'menu_icon'             => 'dashicons-media-spreadsheet',
169
+                )
170
+            )
171
+        );
172 172
 
173
-		// Register discount post type.
174
-		register_post_type(
175
-			'wpi_discount',
176
-			apply_filters(
177
-				'wpinv_register_post_type_discount',
178
-				array(
179
-					'labels'                 => array(
180
-						'name'                  => __( 'Discounts', 'invoicing' ),
181
-						'singular_name'         => __( 'Discount', 'invoicing' ),
182
-						'all_items'             => __( 'Discounts', 'invoicing' ),
183
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
184
-						'add_new'               => __( 'Add New', 'invoicing' ),
185
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
186
-						'edit'                  => __( 'Edit', 'invoicing' ),
187
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
188
-						'new_item'              => __( 'New discount', 'invoicing' ),
189
-						'view_item'             => __( 'View discount', 'invoicing' ),
190
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
191
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
192
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
193
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
194
-						'parent'                => __( 'Parent discount', 'invoicing' ),
195
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
196
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
197
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
198
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
199
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
200
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
201
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
202
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
203
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
204
-					),
205
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
206
-					'public'             => false,
207
-					'can_export'         => true,
208
-					'_builtin'           => false,
209
-					'publicly_queryable' => false,
210
-					'exclude_from_search'=> true,
211
-					'show_ui'            => true,
212
-					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
213
-					'query_var'          => false,
214
-					'rewrite'            => false,
215
-					'map_meta_cap'       => true,
216
-					'has_archive'        => false,
217
-					'hierarchical'       => false,
218
-					'supports'           => array( 'title', 'excerpt' ),
219
-					'show_in_nav_menus'  => false,
220
-					'show_in_admin_bar'  => true,
221
-					'menu_position'      => null,
222
-				)
223
-			)
224
-		);
173
+        // Register discount post type.
174
+        register_post_type(
175
+            'wpi_discount',
176
+            apply_filters(
177
+                'wpinv_register_post_type_discount',
178
+                array(
179
+                    'labels'                 => array(
180
+                        'name'                  => __( 'Discounts', 'invoicing' ),
181
+                        'singular_name'         => __( 'Discount', 'invoicing' ),
182
+                        'all_items'             => __( 'Discounts', 'invoicing' ),
183
+                        'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
184
+                        'add_new'               => __( 'Add New', 'invoicing' ),
185
+                        'add_new_item'          => __( 'Add new discount', 'invoicing' ),
186
+                        'edit'                  => __( 'Edit', 'invoicing' ),
187
+                        'edit_item'             => __( 'Edit discount', 'invoicing' ),
188
+                        'new_item'              => __( 'New discount', 'invoicing' ),
189
+                        'view_item'             => __( 'View discount', 'invoicing' ),
190
+                        'view_items'            => __( 'View Discounts', 'invoicing' ),
191
+                        'search_items'          => __( 'Search discounts', 'invoicing' ),
192
+                        'not_found'             => __( 'No discounts found', 'invoicing' ),
193
+                        'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
194
+                        'parent'                => __( 'Parent discount', 'invoicing' ),
195
+                        'featured_image'        => __( 'Discount image', 'invoicing' ),
196
+                        'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
197
+                        'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
198
+                        'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
199
+                        'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
200
+                        'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
201
+                        'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
202
+                        'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
203
+                        'items_list'            => __( 'Discounts list', 'invoicing' ),
204
+                    ),
205
+                    'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
206
+                    'public'             => false,
207
+                    'can_export'         => true,
208
+                    '_builtin'           => false,
209
+                    'publicly_queryable' => false,
210
+                    'exclude_from_search'=> true,
211
+                    'show_ui'            => true,
212
+                    'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
213
+                    'query_var'          => false,
214
+                    'rewrite'            => false,
215
+                    'map_meta_cap'       => true,
216
+                    'has_archive'        => false,
217
+                    'hierarchical'       => false,
218
+                    'supports'           => array( 'title', 'excerpt' ),
219
+                    'show_in_nav_menus'  => false,
220
+                    'show_in_admin_bar'  => true,
221
+                    'menu_position'      => null,
222
+                )
223
+            )
224
+        );
225 225
 
226
-		do_action( 'getpaid_after_register_post_types' );
227
-	}
226
+        do_action( 'getpaid_after_register_post_types' );
227
+    }
228 228
 
229
-	/**
230
-	 * Register our custom post statuses.
231
-	 */
232
-	public static function register_post_status() {
229
+    /**
230
+     * Register our custom post statuses.
231
+     */
232
+    public static function register_post_status() {
233 233
 
234
-		$invoice_statuses = apply_filters(
235
-			'getpaid_register_invoice_post_statuses',
236
-			array(
234
+        $invoice_statuses = apply_filters(
235
+            'getpaid_register_invoice_post_statuses',
236
+            array(
237 237
 
238
-				'wpi-pending' => array(
239
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
240
-        			'public'                    => true,
241
-        			'exclude_from_search'       => true,
242
-        			'show_in_admin_all_list'    => true,
243
-					'show_in_admin_status_list' => true,
244
-					/* translators: %s: number of invoices */
245
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
246
-				),
238
+                'wpi-pending' => array(
239
+                    'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
240
+                    'public'                    => true,
241
+                    'exclude_from_search'       => true,
242
+                    'show_in_admin_all_list'    => true,
243
+                    'show_in_admin_status_list' => true,
244
+                    /* translators: %s: number of invoices */
245
+                    'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
246
+                ),
247 247
 
248
-				'wpi-processing' => array(
249
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
250
-        			'public'                    => true,
251
-        			'exclude_from_search'       => true,
252
-        			'show_in_admin_all_list'    => true,
253
-					'show_in_admin_status_list' => true,
254
-					/* translators: %s: number of invoices */
255
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
256
-				),
248
+                'wpi-processing' => array(
249
+                    'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
250
+                    'public'                    => true,
251
+                    'exclude_from_search'       => true,
252
+                    'show_in_admin_all_list'    => true,
253
+                    'show_in_admin_status_list' => true,
254
+                    /* translators: %s: number of invoices */
255
+                    'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
256
+                ),
257 257
 
258
-				'wpi-onhold' => array(
259
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
260
-        			'public'                    => true,
261
-        			'exclude_from_search'       => true,
262
-        			'show_in_admin_all_list'    => true,
263
-					'show_in_admin_status_list' => true,
264
-					/* translators: %s: number of invoices */
265
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
266
-				),
258
+                'wpi-onhold' => array(
259
+                    'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
260
+                    'public'                    => true,
261
+                    'exclude_from_search'       => true,
262
+                    'show_in_admin_all_list'    => true,
263
+                    'show_in_admin_status_list' => true,
264
+                    /* translators: %s: number of invoices */
265
+                    'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
266
+                ),
267 267
 
268
-				'wpi-cancelled' => array(
269
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
270
-        			'public'                    => true,
271
-        			'exclude_from_search'       => true,
272
-        			'show_in_admin_all_list'    => true,
273
-					'show_in_admin_status_list' => true,
274
-					/* translators: %s: number of invoices */
275
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
276
-				),
268
+                'wpi-cancelled' => array(
269
+                    'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
270
+                    'public'                    => true,
271
+                    'exclude_from_search'       => true,
272
+                    'show_in_admin_all_list'    => true,
273
+                    'show_in_admin_status_list' => true,
274
+                    /* translators: %s: number of invoices */
275
+                    'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
276
+                ),
277 277
 
278
-				'wpi-refunded' => array(
279
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
280
-        			'public'                    => true,
281
-        			'exclude_from_search'       => true,
282
-        			'show_in_admin_all_list'    => true,
283
-					'show_in_admin_status_list' => true,
284
-					/* translators: %s: number of invoices */
285
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
286
-				),
278
+                'wpi-refunded' => array(
279
+                    'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
280
+                    'public'                    => true,
281
+                    'exclude_from_search'       => true,
282
+                    'show_in_admin_all_list'    => true,
283
+                    'show_in_admin_status_list' => true,
284
+                    /* translators: %s: number of invoices */
285
+                    'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
286
+                ),
287 287
 
288
-				'wpi-failed' => array(
289
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
290
-        			'public'                    => true,
291
-        			'exclude_from_search'       => true,
292
-        			'show_in_admin_all_list'    => true,
293
-					'show_in_admin_status_list' => true,
294
-					/* translators: %s: number of invoices */
295
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
296
-				),
288
+                'wpi-failed' => array(
289
+                    'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
290
+                    'public'                    => true,
291
+                    'exclude_from_search'       => true,
292
+                    'show_in_admin_all_list'    => true,
293
+                    'show_in_admin_status_list' => true,
294
+                    /* translators: %s: number of invoices */
295
+                    'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
296
+                ),
297 297
 
298
-				'wpi-renewal' => array(
299
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
300
-        			'public'                    => true,
301
-        			'exclude_from_search'       => true,
302
-        			'show_in_admin_all_list'    => true,
303
-					'show_in_admin_status_list' => true,
304
-					/* translators: %s: number of invoices */
305
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
306
-				)
307
-			)
308
-		);
298
+                'wpi-renewal' => array(
299
+                    'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
300
+                    'public'                    => true,
301
+                    'exclude_from_search'       => true,
302
+                    'show_in_admin_all_list'    => true,
303
+                    'show_in_admin_status_list' => true,
304
+                    /* translators: %s: number of invoices */
305
+                    'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
306
+                )
307
+            )
308
+        );
309 309
 
310
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
-			register_post_status( $invoice_statuse, $args );
312
-		}
313
-	}
310
+        foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
+            register_post_status( $invoice_statuse, $args );
312
+        }
313
+    }
314 314
 
315
-	/**
316
-	 * Flush rewrite rules.
317
-	 */
318
-	public static function flush_rewrite_rules() {
319
-		flush_rewrite_rules();
320
-	}
315
+    /**
316
+     * Flush rewrite rules.
317
+     */
318
+    public static function flush_rewrite_rules() {
319
+        flush_rewrite_rules();
320
+    }
321 321
 
322
-	/**
323
-	 * Flush rules to prevent 404.
324
-	 *
325
-	 */
326
-	public static function maybe_flush_rewrite_rules() {
327
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
-			self::flush_rewrite_rules();
330
-		}
331
-	}
322
+    /**
323
+     * Flush rules to prevent 404.
324
+     *
325
+     */
326
+    public static function maybe_flush_rewrite_rules() {
327
+        if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
+            update_option( 'getpaid_flushed_rewrite_rules', '1' );
329
+            self::flush_rewrite_rules();
330
+        }
331
+    }
332 332
 
333 333
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Post types Class
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	 * Hook in methods.
19 19
 	 */
20 20
 	public function __construct() {
21
-		add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 );
22
-		add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 );
23
-		add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
24
-		add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
21
+		add_action('init', array(__CLASS__, 'register_post_types'), 1);
22
+		add_action('init', array(__CLASS__, 'register_post_status'), 4);
23
+		add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules'));
24
+		add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules'));
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public static function register_post_types() {
31 31
 
32
-		if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) {
32
+		if (!is_blog_installed() || post_type_exists('wpi_item')) {
33 33
 			return;
34 34
 		}
35 35
 
36 36
 		// Fires before registering post types.
37
-		do_action( 'getpaid_register_post_types' );
37
+		do_action('getpaid_register_post_types');
38 38
 
39 39
 		// Register item post type.
40 40
 		register_post_type(
@@ -43,29 +43,29 @@  discard block
 block discarded – undo
43 43
 				'wpinv_register_post_type_invoice_item',
44 44
 				array(
45 45
 					'labels'             => array(
46
-						'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
47
-						'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
48
-						'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
49
-						'name_admin_bar'     => _x( 'Item', 'add new on admin bar', 'invoicing' ),
50
-						'add_new'            => _x( 'Add New', 'Item', 'invoicing' ),
51
-						'add_new_item'       => __( 'Add New Item', 'invoicing' ),
52
-						'new_item'           => __( 'New Item', 'invoicing' ),
53
-						'edit_item'          => __( 'Edit Item', 'invoicing' ),
54
-						'view_item'          => __( 'View Item', 'invoicing' ),
55
-						'all_items'          => __( 'Items', 'invoicing' ),
56
-						'search_items'       => __( 'Search items', 'invoicing' ),
57
-						'parent_item_colon'  => __( 'Parent item:', 'invoicing' ),
58
-						'not_found'          => __( 'No items found.', 'invoicing' ),
59
-						'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
46
+						'name'               => _x('Items', 'post type general name', 'invoicing'),
47
+						'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
48
+						'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
49
+						'name_admin_bar'     => _x('Item', 'add new on admin bar', 'invoicing'),
50
+						'add_new'            => _x('Add New', 'Item', 'invoicing'),
51
+						'add_new_item'       => __('Add New Item', 'invoicing'),
52
+						'new_item'           => __('New Item', 'invoicing'),
53
+						'edit_item'          => __('Edit Item', 'invoicing'),
54
+						'view_item'          => __('View Item', 'invoicing'),
55
+						'all_items'          => __('Items', 'invoicing'),
56
+						'search_items'       => __('Search items', 'invoicing'),
57
+						'parent_item_colon'  => __('Parent item:', 'invoicing'),
58
+						'not_found'          => __('No items found.', 'invoicing'),
59
+						'not_found_in_trash' => __('No items found in trash.', 'invoicing')
60 60
 					),
61
-					'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
61
+					'description'           => __('This is where you can add new invoice items.', 'invoicing'),
62 62
 					'public'                => false,
63 63
 					'has_archive'           => false,
64 64
 					'_builtin'              => false,
65 65
 					'show_ui'               => true,
66 66
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
67 67
 					'show_in_nav_menus'     => false,
68
-					'supports'              => array( 'title', 'excerpt', 'thumbnail' ),
68
+					'supports'              => array('title', 'excerpt', 'thumbnail'),
69 69
 					'rewrite'               => false,
70 70
 					'query_var'             => false,
71 71
 					'map_meta_cap'          => true,
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
 				'wpinv_register_post_type_payment_form',
83 83
 				array(
84 84
 					'labels'             => array(
85
-						'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
86
-						'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
87
-						'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
88
-						'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
89
-						'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
90
-						'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
91
-						'new_item'           => __( 'New Payment Form', 'invoicing' ),
92
-						'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
93
-						'view_item'          => __( 'View Payment Form', 'invoicing' ),
94
-						'all_items'          => __( 'Payment Forms', 'invoicing' ),
95
-						'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
96
-						'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
97
-						'not_found'          => __( 'No payment forms found.', 'invoicing' ),
98
-						'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
85
+						'name'               => _x('Payment Forms', 'post type general name', 'invoicing'),
86
+						'singular_name'      => _x('Payment Form', 'post type singular name', 'invoicing'),
87
+						'menu_name'          => _x('Payment Forms', 'admin menu', 'invoicing'),
88
+						'name_admin_bar'     => _x('Payment Form', 'add new on admin bar', 'invoicing'),
89
+						'add_new'            => _x('Add New', 'Payment Form', 'invoicing'),
90
+						'add_new_item'       => __('Add New Payment Form', 'invoicing'),
91
+						'new_item'           => __('New Payment Form', 'invoicing'),
92
+						'edit_item'          => __('Edit Payment Form', 'invoicing'),
93
+						'view_item'          => __('View Payment Form', 'invoicing'),
94
+						'all_items'          => __('Payment Forms', 'invoicing'),
95
+						'search_items'       => __('Search Payment Forms', 'invoicing'),
96
+						'parent_item_colon'  => __('Parent Payment Forms:', 'invoicing'),
97
+						'not_found'          => __('No payment forms found.', 'invoicing'),
98
+						'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing')
99 99
 					),
100
-					'description'        => __( 'Add new payment forms.', 'invoicing' ),
100
+					'description'        => __('Add new payment forms.', 'invoicing'),
101 101
 					'public'             => false,
102 102
 					'show_ui'            => true,
103 103
 					'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 					'has_archive'        => false,
109 109
 					'hierarchical'       => false,
110 110
 					'menu_position'      => null,
111
-					'supports'           => array( 'title' ),
111
+					'supports'           => array('title'),
112 112
 					'menu_icon'          => 'dashicons-media-form',
113 113
 				)
114 114
 			)
@@ -121,32 +121,32 @@  discard block
 block discarded – undo
121 121
 				'wpinv_register_post_type_invoice',
122 122
 				array(
123 123
 					'labels'                 => array(
124
-						'name'                  => __( 'Invoices', 'invoicing' ),
125
-						'singular_name'         => __( 'Invoice', 'invoicing' ),
126
-						'all_items'             => __( 'Invoices', 'invoicing' ),
127
-						'menu_name'             => _x( 'Invoices', 'Admin menu name', 'invoicing' ),
128
-						'add_new'               => __( 'Add New', 'invoicing' ),
129
-						'add_new_item'          => __( 'Add new invoice', 'invoicing' ),
130
-						'edit'                  => __( 'Edit', 'invoicing' ),
131
-						'edit_item'             => __( 'Edit invoice', 'invoicing' ),
132
-						'new_item'              => __( 'New invoice', 'invoicing' ),
133
-						'view_item'             => __( 'View invoice', 'invoicing' ),
134
-						'view_items'            => __( 'View Invoices', 'invoicing' ),
135
-						'search_items'          => __( 'Search invoices', 'invoicing' ),
136
-						'not_found'             => __( 'No invoices found', 'invoicing' ),
137
-						'not_found_in_trash'    => __( 'No invoices found in trash', 'invoicing' ),
138
-						'parent'                => __( 'Parent invoice', 'invoicing' ),
139
-						'featured_image'        => __( 'Invoice image', 'invoicing' ),
140
-						'set_featured_image'    => __( 'Set invoice image', 'invoicing' ),
141
-						'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ),
142
-						'use_featured_image'    => __( 'Use as invoice image', 'invoicing' ),
143
-						'insert_into_item'      => __( 'Insert into invoice', 'invoicing' ),
144
-						'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ),
145
-						'filter_items_list'     => __( 'Filter invoices', 'invoicing' ),
146
-						'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ),
147
-						'items_list'            => __( 'Invoices list', 'invoicing' ),
124
+						'name'                  => __('Invoices', 'invoicing'),
125
+						'singular_name'         => __('Invoice', 'invoicing'),
126
+						'all_items'             => __('Invoices', 'invoicing'),
127
+						'menu_name'             => _x('Invoices', 'Admin menu name', 'invoicing'),
128
+						'add_new'               => __('Add New', 'invoicing'),
129
+						'add_new_item'          => __('Add new invoice', 'invoicing'),
130
+						'edit'                  => __('Edit', 'invoicing'),
131
+						'edit_item'             => __('Edit invoice', 'invoicing'),
132
+						'new_item'              => __('New invoice', 'invoicing'),
133
+						'view_item'             => __('View invoice', 'invoicing'),
134
+						'view_items'            => __('View Invoices', 'invoicing'),
135
+						'search_items'          => __('Search invoices', 'invoicing'),
136
+						'not_found'             => __('No invoices found', 'invoicing'),
137
+						'not_found_in_trash'    => __('No invoices found in trash', 'invoicing'),
138
+						'parent'                => __('Parent invoice', 'invoicing'),
139
+						'featured_image'        => __('Invoice image', 'invoicing'),
140
+						'set_featured_image'    => __('Set invoice image', 'invoicing'),
141
+						'remove_featured_image' => __('Remove invoice image', 'invoicing'),
142
+						'use_featured_image'    => __('Use as invoice image', 'invoicing'),
143
+						'insert_into_item'      => __('Insert into invoice', 'invoicing'),
144
+						'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'),
145
+						'filter_items_list'     => __('Filter invoices', 'invoicing'),
146
+						'items_list_navigation' => __('Invoices navigation', 'invoicing'),
147
+						'items_list'            => __('Invoices list', 'invoicing'),
148 148
 					),
149
-					'description'           => __( 'This is where invoices are stored.', 'invoicing' ),
149
+					'description'           => __('This is where invoices are stored.', 'invoicing'),
150 150
 					'public'                => true,
151 151
 					'has_archive'           => false,
152 152
 					'publicly_queryable'    => true,
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         			'show_ui'               => true,
155 155
 					'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
156 156
 					'show_in_nav_menus'     => false,
157
-					'supports'              => array( 'title', 'author', 'excerpt'  ),
157
+					'supports'              => array('title', 'author', 'excerpt'),
158 158
 					'rewrite'               => array(
159 159
 						'slug'              => 'invoice',
160 160
 						'with_front'        => false,
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
 				'wpinv_register_post_type_discount',
178 178
 				array(
179 179
 					'labels'                 => array(
180
-						'name'                  => __( 'Discounts', 'invoicing' ),
181
-						'singular_name'         => __( 'Discount', 'invoicing' ),
182
-						'all_items'             => __( 'Discounts', 'invoicing' ),
183
-						'menu_name'             => _x( 'Discounts', 'Admin menu name', 'invoicing' ),
184
-						'add_new'               => __( 'Add New', 'invoicing' ),
185
-						'add_new_item'          => __( 'Add new discount', 'invoicing' ),
186
-						'edit'                  => __( 'Edit', 'invoicing' ),
187
-						'edit_item'             => __( 'Edit discount', 'invoicing' ),
188
-						'new_item'              => __( 'New discount', 'invoicing' ),
189
-						'view_item'             => __( 'View discount', 'invoicing' ),
190
-						'view_items'            => __( 'View Discounts', 'invoicing' ),
191
-						'search_items'          => __( 'Search discounts', 'invoicing' ),
192
-						'not_found'             => __( 'No discounts found', 'invoicing' ),
193
-						'not_found_in_trash'    => __( 'No discounts found in trash', 'invoicing' ),
194
-						'parent'                => __( 'Parent discount', 'invoicing' ),
195
-						'featured_image'        => __( 'Discount image', 'invoicing' ),
196
-						'set_featured_image'    => __( 'Set discount image', 'invoicing' ),
197
-						'remove_featured_image' => __( 'Remove discount image', 'invoicing' ),
198
-						'use_featured_image'    => __( 'Use as discount image', 'invoicing' ),
199
-						'insert_into_item'      => __( 'Insert into discount', 'invoicing' ),
200
-						'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ),
201
-						'filter_items_list'     => __( 'Filter discounts', 'invoicing' ),
202
-						'items_list_navigation' => __( 'Discount navigation', 'invoicing' ),
203
-						'items_list'            => __( 'Discounts list', 'invoicing' ),
180
+						'name'                  => __('Discounts', 'invoicing'),
181
+						'singular_name'         => __('Discount', 'invoicing'),
182
+						'all_items'             => __('Discounts', 'invoicing'),
183
+						'menu_name'             => _x('Discounts', 'Admin menu name', 'invoicing'),
184
+						'add_new'               => __('Add New', 'invoicing'),
185
+						'add_new_item'          => __('Add new discount', 'invoicing'),
186
+						'edit'                  => __('Edit', 'invoicing'),
187
+						'edit_item'             => __('Edit discount', 'invoicing'),
188
+						'new_item'              => __('New discount', 'invoicing'),
189
+						'view_item'             => __('View discount', 'invoicing'),
190
+						'view_items'            => __('View Discounts', 'invoicing'),
191
+						'search_items'          => __('Search discounts', 'invoicing'),
192
+						'not_found'             => __('No discounts found', 'invoicing'),
193
+						'not_found_in_trash'    => __('No discounts found in trash', 'invoicing'),
194
+						'parent'                => __('Parent discount', 'invoicing'),
195
+						'featured_image'        => __('Discount image', 'invoicing'),
196
+						'set_featured_image'    => __('Set discount image', 'invoicing'),
197
+						'remove_featured_image' => __('Remove discount image', 'invoicing'),
198
+						'use_featured_image'    => __('Use as discount image', 'invoicing'),
199
+						'insert_into_item'      => __('Insert into discount', 'invoicing'),
200
+						'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'),
201
+						'filter_items_list'     => __('Filter discounts', 'invoicing'),
202
+						'items_list_navigation' => __('Discount navigation', 'invoicing'),
203
+						'items_list'            => __('Discounts list', 'invoicing'),
204 204
 					),
205
-					'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
205
+					'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
206 206
 					'public'             => false,
207 207
 					'can_export'         => true,
208 208
 					'_builtin'           => false,
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 					'map_meta_cap'       => true,
216 216
 					'has_archive'        => false,
217 217
 					'hierarchical'       => false,
218
-					'supports'           => array( 'title', 'excerpt' ),
218
+					'supports'           => array('title', 'excerpt'),
219 219
 					'show_in_nav_menus'  => false,
220 220
 					'show_in_admin_bar'  => true,
221 221
 					'menu_position'      => null,
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			)
224 224
 		);
225 225
 
226
-		do_action( 'getpaid_after_register_post_types' );
226
+		do_action('getpaid_after_register_post_types');
227 227
 	}
228 228
 
229 229
 	/**
@@ -236,79 +236,79 @@  discard block
 block discarded – undo
236 236
 			array(
237 237
 
238 238
 				'wpi-pending' => array(
239
-					'label'                     => _x( 'Pending Payment', 'Invoice status', 'invoicing' ),
239
+					'label'                     => _x('Pending Payment', 'Invoice status', 'invoicing'),
240 240
         			'public'                    => true,
241 241
         			'exclude_from_search'       => true,
242 242
         			'show_in_admin_all_list'    => true,
243 243
 					'show_in_admin_status_list' => true,
244 244
 					/* translators: %s: number of invoices */
245
-        			'label_count'               => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' )
245
+        			'label_count'               => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing')
246 246
 				),
247 247
 
248 248
 				'wpi-processing' => array(
249
-					'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
249
+					'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
250 250
         			'public'                    => true,
251 251
         			'exclude_from_search'       => true,
252 252
         			'show_in_admin_all_list'    => true,
253 253
 					'show_in_admin_status_list' => true,
254 254
 					/* translators: %s: number of invoices */
255
-        			'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
255
+        			'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
256 256
 				),
257 257
 
258 258
 				'wpi-onhold' => array(
259
-					'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
259
+					'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
260 260
         			'public'                    => true,
261 261
         			'exclude_from_search'       => true,
262 262
         			'show_in_admin_all_list'    => true,
263 263
 					'show_in_admin_status_list' => true,
264 264
 					/* translators: %s: number of invoices */
265
-        			'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
265
+        			'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
266 266
 				),
267 267
 
268 268
 				'wpi-cancelled' => array(
269
-					'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
269
+					'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
270 270
         			'public'                    => true,
271 271
         			'exclude_from_search'       => true,
272 272
         			'show_in_admin_all_list'    => true,
273 273
 					'show_in_admin_status_list' => true,
274 274
 					/* translators: %s: number of invoices */
275
-        			'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
275
+        			'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
276 276
 				),
277 277
 
278 278
 				'wpi-refunded' => array(
279
-					'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
279
+					'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
280 280
         			'public'                    => true,
281 281
         			'exclude_from_search'       => true,
282 282
         			'show_in_admin_all_list'    => true,
283 283
 					'show_in_admin_status_list' => true,
284 284
 					/* translators: %s: number of invoices */
285
-        			'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
285
+        			'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
286 286
 				),
287 287
 
288 288
 				'wpi-failed' => array(
289
-					'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
289
+					'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
290 290
         			'public'                    => true,
291 291
         			'exclude_from_search'       => true,
292 292
         			'show_in_admin_all_list'    => true,
293 293
 					'show_in_admin_status_list' => true,
294 294
 					/* translators: %s: number of invoices */
295
-        			'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
295
+        			'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
296 296
 				),
297 297
 
298 298
 				'wpi-renewal' => array(
299
-					'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
299
+					'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
300 300
         			'public'                    => true,
301 301
         			'exclude_from_search'       => true,
302 302
         			'show_in_admin_all_list'    => true,
303 303
 					'show_in_admin_status_list' => true,
304 304
 					/* translators: %s: number of invoices */
305
-        			'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
305
+        			'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
306 306
 				)
307 307
 			)
308 308
 		);
309 309
 
310
-		foreach ( $invoice_statuses as $invoice_statuse => $args ) {
311
-			register_post_status( $invoice_statuse, $args );
310
+		foreach ($invoice_statuses as $invoice_statuse => $args) {
311
+			register_post_status($invoice_statuse, $args);
312 312
 		}
313 313
 	}
314 314
 
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 */
326 326
 	public static function maybe_flush_rewrite_rules() {
327
-		if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) {
328
-			update_option( 'getpaid_flushed_rewrite_rules', '1' );
327
+		if (!get_option('getpaid_flushed_rewrite_rules')) {
328
+			update_option('getpaid_flushed_rewrite_rules', '1');
329 329
 			self::flush_rewrite_rules();
330 330
 		}
331 331
 	}
Please login to merge, or discard this patch.
templates/emails/wpinv-email-footer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text', get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ) ) );
7
-$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : '';
6
+$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text', get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing')));
7
+$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : '';
8 8
 ?>
9 9
                                                             </div>
10 10
                                                         </td>
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text', get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ) ) );
7 8
 $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : '';
Please login to merge, or discard this patch.